当前位置: 首页>>代码示例>>Java>>正文


Java ConnectionlessBootstrap.setOption方法代码示例

本文整理汇总了Java中org.jboss.netty.bootstrap.ConnectionlessBootstrap.setOption方法的典型用法代码示例。如果您正苦于以下问题:Java ConnectionlessBootstrap.setOption方法的具体用法?Java ConnectionlessBootstrap.setOption怎么用?Java ConnectionlessBootstrap.setOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jboss.netty.bootstrap.ConnectionlessBootstrap的用法示例。


在下文中一共展示了ConnectionlessBootstrap.setOption方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import org.jboss.netty.bootstrap.ConnectionlessBootstrap; //导入方法依赖的package包/类
public void run() {
  // Configure the client.
  DatagramChannelFactory f = new NioDatagramChannelFactory(
      Executors.newCachedThreadPool(), workerCount);

  server = new ConnectionlessBootstrap(f);
  server.setPipeline(Channels.pipeline(RpcUtil.STAGE_RPC_MESSAGE_PARSER,
      rpcProgram, RpcUtil.STAGE_RPC_UDP_RESPONSE));

  server.setOption("broadcast", "false");
  server.setOption("sendBufferSize", SEND_BUFFER_SIZE);
  server.setOption("receiveBufferSize", RECEIVE_BUFFER_SIZE);

  // Listen to the UDP port
  ch = server.bind(new InetSocketAddress(port));
  InetSocketAddress socketAddr = (InetSocketAddress) ch.getLocalAddress();
  boundPort = socketAddr.getPort();

  LOG.info("Started listening to UDP requests at port " + boundPort + " for "
      + rpcProgram + " with workerCount " + workerCount);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:SimpleUdpServer.java

示例2: run

import org.jboss.netty.bootstrap.ConnectionlessBootstrap; //导入方法依赖的package包/类
public void run() {
  // Configure the client.
  DatagramChannelFactory f = new NioDatagramChannelFactory(
      Executors.newCachedThreadPool(), workerCount);

  ConnectionlessBootstrap b = new ConnectionlessBootstrap(f);
  b.setPipeline(Channels.pipeline(
          RpcUtil.STAGE_RPC_MESSAGE_PARSER, rpcProgram,
          RpcUtil.STAGE_RPC_UDP_RESPONSE));

  b.setOption("broadcast", "false");
  b.setOption("sendBufferSize", SEND_BUFFER_SIZE);
  b.setOption("receiveBufferSize", RECEIVE_BUFFER_SIZE);
  
  // Listen to the UDP port
  Channel ch = b.bind(new InetSocketAddress(port));
  InetSocketAddress socketAddr = (InetSocketAddress) ch.getLocalAddress();
  boundPort = socketAddr.getPort();
  
  LOG.info("Started listening to UDP requests at port " + boundPort + " for "
      + rpcProgram + " with workerCount " + workerCount);
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:23,代码来源:SimpleUdpServer.java

示例3: run

import org.jboss.netty.bootstrap.ConnectionlessBootstrap; //导入方法依赖的package包/类
public void run() {
  // Configure the client.
  DatagramChannelFactory f = new NioDatagramChannelFactory(
      Executors.newCachedThreadPool(), workerCount);

  ConnectionlessBootstrap b = new ConnectionlessBootstrap(f);
  ChannelPipeline p = b.getPipeline();
  p.addLast("handler", new SimpleUdpServerHandler(rpcProgram));

  b.setOption("broadcast", "false");
  b.setOption("sendBufferSize", SEND_BUFFER_SIZE);
  b.setOption("receiveBufferSize", RECEIVE_BUFFER_SIZE);
  
  // Listen to the UDP port
  b.bind(new InetSocketAddress(port));

  LOG.info("Started listening to UDP requests at port " + port + " for "
      + rpcProgram + " with workerCount " + workerCount);
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:20,代码来源:SimpleUdpServer.java

示例4: run

import org.jboss.netty.bootstrap.ConnectionlessBootstrap; //导入方法依赖的package包/类
public void run() {
  // Configure the client.
  DatagramChannelFactory f = new NioDatagramChannelFactory(
      Executors.newCachedThreadPool(), workerCount);

  ConnectionlessBootstrap b = new ConnectionlessBootstrap(f);
  b.setPipeline(Channels.pipeline(
          RpcUtil.STAGE_RPC_MESSAGE_PARSER, rpcProgram,
          RpcUtil.STAGE_RPC_UDP_RESPONSE));

  b.setOption("broadcast", "false");
  b.setOption("sendBufferSize", SEND_BUFFER_SIZE);
  b.setOption("receiveBufferSize", RECEIVE_BUFFER_SIZE);
  
  // Listen to the UDP port
  b.bind(new InetSocketAddress(port));

  LOG.info("Started listening to UDP requests at port " + port + " for "
      + rpcProgram + " with workerCount " + workerCount);
}
 
开发者ID:chendave,项目名称:hadoop-TCP,代码行数:21,代码来源:SimpleUdpServer.java

示例5: start

import org.jboss.netty.bootstrap.ConnectionlessBootstrap; //导入方法依赖的package包/类
@Override
public void start() {
  // setup Netty server
  ConnectionlessBootstrap serverBootstrap = new ConnectionlessBootstrap(
      new OioDatagramChannelFactory(Executors.newCachedThreadPool()));
  final syslogHandler handler = new syslogHandler();
  handler.setFormater(formaterProp);
  handler.setKeepFields(keepFields);
  serverBootstrap.setOption("receiveBufferSizePredictorFactory",
      new AdaptiveReceiveBufferSizePredictorFactory(DEFAULT_MIN_SIZE,
          DEFAULT_INITIAL_SIZE, maxsize));
  serverBootstrap.setPipelineFactory(new ChannelPipelineFactory() {
    @Override
    public ChannelPipeline getPipeline() {
      return Channels.pipeline(handler);
    }
  });

  if (host == null) {
    nettyChannel = serverBootstrap.bind(new InetSocketAddress(port));
  } else {
    nettyChannel = serverBootstrap.bind(new InetSocketAddress(host, port));
  }

  sourceCounter.start();
  super.start();
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:28,代码来源:SyslogUDPSource.java

示例6: configBootstrap

import org.jboss.netty.bootstrap.ConnectionlessBootstrap; //导入方法依赖的package包/类
private void configBootstrap(ConnectionlessBootstrap bootstrap) {
    if (ServerConfigure.containsKey(NaviDefine.BACKLOG)) {
        bootstrap.setOption(NaviDefine.BACKLOG, ServerConfigure.get(NaviDefine.BACKLOG));
    }

    if (ServerConfigure.containsKey(NaviDefine.REUSEADDRESS)) {
        bootstrap.setOption(NaviDefine.REUSEADDRESS, Boolean.valueOf(ServerConfigure.get(NaviDefine.REUSEADDRESS)));
    }

    if (ServerConfigure.containsKey(NaviDefine.CHILD_KEEPALIVE)) {
        bootstrap.setOption(NaviDefine.CHILD_KEEPALIVE, Boolean.valueOf(ServerConfigure.get(NaviDefine.CHILD_KEEPALIVE)));
    }

    if (ServerConfigure.containsKey(NaviDefine.CHILD_TCPNODELAY)) {
        bootstrap.setOption(NaviDefine.CHILD_TCPNODELAY, Boolean.valueOf(ServerConfigure.get(NaviDefine.CHILD_TCPNODELAY)));
    }
    if (ServerConfigure.containsKey(ServerConfigure.CHILD_SENDBUFFERSIZE)) {
        bootstrap.setOption(ServerConfigure.CHILD_SENDBUFFERSIZE, Integer.valueOf(ServerConfigure.get(ServerConfigure.CHILD_SENDBUFFERSIZE)));
    }
    if (ServerConfigure.containsKey(ServerConfigure.CHILD_RECEIVEBUFFERSIZE)) {
        bootstrap.setOption(ServerConfigure.CHILD_RECEIVEBUFFERSIZE, Integer.valueOf(ServerConfigure.get(ServerConfigure.CHILD_RECEIVEBUFFERSIZE)));
    }
    if (ServerConfigure.containsKey(ServerConfigure.WRITEBUFFERHIGHWATERMARK)) {
        bootstrap.setOption(ServerConfigure.WRITEBUFFERHIGHWATERMARK, Integer.valueOf(ServerConfigure.get(ServerConfigure.WRITEBUFFERHIGHWATERMARK)));
    }
    if (ServerConfigure.containsKey(ServerConfigure.WRITEBUFFERLOWWARTERMARK)) {
        bootstrap.setOption(ServerConfigure.WRITEBUFFERLOWWARTERMARK, Integer.valueOf(ServerConfigure.get(ServerConfigure.WRITEBUFFERLOWWARTERMARK)));
    }
}
 
开发者ID:sunguangran,项目名称:navi,代码行数:30,代码来源:ANaviPacketServer.java

示例7: startServerBootstrap

import org.jboss.netty.bootstrap.ConnectionlessBootstrap; //导入方法依赖的package包/类
protected void startServerBootstrap() throws Exception {
    // create non-shared worker pool
    int count = configuration.getWorkerCount() > 0 ? configuration.getWorkerCount() : NettyHelper.DEFAULT_IO_THREADS;
    workerPool = new NioDatagramWorkerPool(Executors.newCachedThreadPool(), count);

    datagramChannelFactory = new NioDatagramChannelFactory(workerPool);

    connectionlessBootstrap = new ConnectionlessBootstrap(datagramChannelFactory);
    connectionlessBootstrap.setOption("child.keepAlive", configuration.isKeepAlive());
    connectionlessBootstrap.setOption("child.tcpNoDelay", configuration.isTcpNoDelay());
    connectionlessBootstrap.setOption("reuseAddress", configuration.isReuseAddress());
    connectionlessBootstrap.setOption("child.reuseAddress", configuration.isReuseAddress());
    connectionlessBootstrap.setOption("child.connectTimeoutMillis", configuration.getConnectTimeout());
    connectionlessBootstrap.setOption("child.broadcast", configuration.isBroadcast());
    connectionlessBootstrap.setOption("sendBufferSize", configuration.getSendBufferSize());
    connectionlessBootstrap.setOption("receiveBufferSize", configuration.getReceiveBufferSize());
    // only set this if user has specified
    if (configuration.getReceiveBufferSizePredictor() > 0) {
        connectionlessBootstrap.setOption("receiveBufferSizePredictorFactory",
                new FixedReceiveBufferSizePredictorFactory(configuration.getReceiveBufferSizePredictor()));
    }
    if (configuration.getBacklog() > 0) {
        connectionlessBootstrap.setOption("backlog", configuration.getBacklog());
    }

    // set any additional netty options
    if (configuration.getOptions() != null) {
        for (Map.Entry<String, Object> entry : configuration.getOptions().entrySet()) {
            connectionlessBootstrap.setOption(entry.getKey(), entry.getValue());
        }
    }

    LOG.debug("Created ConnectionlessBootstrap {} with options: {}", connectionlessBootstrap, connectionlessBootstrap.getOptions());

    // set the pipeline factory, which creates the pipeline for each newly created channels
    connectionlessBootstrap.setPipelineFactory(pipelineFactory);

    InetSocketAddress hostAddress = new InetSocketAddress(configuration.getHost(), configuration.getPort());
    IpV4Subnet multicastSubnet = new IpV4Subnet(MULTICAST_SUBNET);

    if (multicastSubnet.contains(configuration.getHost())) {
        datagramChannel = (DatagramChannel)connectionlessBootstrap.bind(hostAddress);
        String networkInterface = configuration.getNetworkInterface() == null ? LOOPBACK_INTERFACE : configuration.getNetworkInterface();
        multicastNetworkInterface = NetworkInterface.getByName(networkInterface);
        ObjectHelper.notNull(multicastNetworkInterface, "No network interface found for '" + networkInterface + "'.");
        LOG.info("ConnectionlessBootstrap joining {}:{} using network interface: {}", new Object[]{configuration.getHost(), configuration.getPort(), multicastNetworkInterface.getName()});
        datagramChannel.joinGroup(hostAddress, multicastNetworkInterface).syncUninterruptibly();
        allChannels.add(datagramChannel);
    } else {
        LOG.info("ConnectionlessBootstrap binding to {}:{}", configuration.getHost(), configuration.getPort());
        channel = connectionlessBootstrap.bind(hostAddress);
        allChannels.add(channel);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:55,代码来源:SingleUDPNettyServerBootstrapFactory.java

示例8: doStart

import org.jboss.netty.bootstrap.ConnectionlessBootstrap; //导入方法依赖的package包/类
public void doStart()
{
    Log.info("RayoComponent initialize " + jid);

    XMPPServer server = XMPPServer.getInstance();

    server.getIQDiscoInfoHandler().addServerFeature(RAYO_CORE);
    rayoProvider = new RayoProvider();
    rayoProvider.setValidator(new Validator());

    server.getIQDiscoInfoHandler().addServerFeature(RAYO_RECORD);
    recordProvider = new RecordProvider();
    recordProvider.setValidator(new Validator());

    server.getIQDiscoInfoHandler().addServerFeature(RAYO_SAY);
    sayProvider = new SayProvider();
    sayProvider.setValidator(new Validator());

    server.getIQDiscoInfoHandler().addServerFeature(RAYO_HANDSET);
    handsetProvider = new HandsetProvider();
    handsetProvider.setValidator(new Validator());

    createIQHandlers();

    try{
        Log.info("Starting jCumulus.....");

        sessions = new Sessions();
        ExecutorService executorservice = Executors.newCachedThreadPool();
        NioDatagramChannelFactory niodatagramchannelfactory = new NioDatagramChannelFactory(executorservice);
        bootstrap = new ConnectionlessBootstrap(niodatagramchannelfactory);
        OrderedMemoryAwareThreadPoolExecutor orderedmemoryawarethreadpoolexecutor = new OrderedMemoryAwareThreadPoolExecutor(10, 0x100000L, 0x40000000L, 100L, TimeUnit.MILLISECONDS, Executors.defaultThreadFactory());

        bootstrap.setPipelineFactory(new ServerPipelineFactory(sessions, orderedmemoryawarethreadpoolexecutor));
        bootstrap.setOption("reuseAddress", Boolean.valueOf(true));
        bootstrap.setOption("sendBufferSize", Integer.valueOf(1215));
        bootstrap.setOption("receiveBufferSize", Integer.valueOf(2048));
        bootstrap.setOption("receiveBufferSizePredictorFactory", new FixedReceiveBufferSizePredictorFactory(2048));

        InetSocketAddress inetsocketaddress = new InetSocketAddress(JiveGlobals.getIntProperty("voicebridge.rtmfp.port", 1935));

        Log.info("Listening on " + inetsocketaddress.getPort() + " port");

        channel = bootstrap.bind(inetsocketaddress);

    } catch (Exception e) {
        Log.error("jCumulus startup failure");
        e.printStackTrace();
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:51,代码来源:RayoComponent.java

示例9: doStart

import org.jboss.netty.bootstrap.ConnectionlessBootstrap; //导入方法依赖的package包/类
public void doStart()
   {
	Log.info("RayoComponent initialize " + jid);

	XMPPServer server = XMPPServer.getInstance();

	server.getIQDiscoInfoHandler().addServerFeature(RAYO_CORE);
      	rayoProvider = new RayoProvider();
       rayoProvider.setValidator(new Validator());

	server.getIQDiscoInfoHandler().addServerFeature(RAYO_RECORD);
       recordProvider = new RecordProvider();
       recordProvider.setValidator(new Validator());

	server.getIQDiscoInfoHandler().addServerFeature(RAYO_SAY);
       sayProvider = new SayProvider();
       sayProvider.setValidator(new Validator());

	server.getIQDiscoInfoHandler().addServerFeature(RAYO_HANDSET);
       handsetProvider = new HandsetProvider();
       handsetProvider.setValidator(new Validator());

	createIQHandlers();

	try{
		Log.info("Starting jCumulus.....");

		sessions = new Sessions();
		ExecutorService executorservice = Executors.newCachedThreadPool();
		NioDatagramChannelFactory niodatagramchannelfactory = new NioDatagramChannelFactory(executorservice);
		bootstrap = new ConnectionlessBootstrap(niodatagramchannelfactory);
		OrderedMemoryAwareThreadPoolExecutor orderedmemoryawarethreadpoolexecutor = new OrderedMemoryAwareThreadPoolExecutor(10, 0x100000L, 0x40000000L, 100L, TimeUnit.MILLISECONDS, Executors.defaultThreadFactory());

		bootstrap.setPipelineFactory(new ServerPipelineFactory(sessions, orderedmemoryawarethreadpoolexecutor));
		bootstrap.setOption("reuseAddress", Boolean.valueOf(true));
		bootstrap.setOption("sendBufferSize", Integer.valueOf(1215));
		bootstrap.setOption("receiveBufferSize", Integer.valueOf(2048));
		bootstrap.setOption("receiveBufferSizePredictorFactory", new FixedReceiveBufferSizePredictorFactory(2048));

		InetSocketAddress inetsocketaddress = new InetSocketAddress(JiveGlobals.getIntProperty("voicebridge.rtmfp.port", 1935));

		Log.info("Listening on " + inetsocketaddress.getPort() + " port");

		channel = bootstrap.bind(inetsocketaddress);

	} catch (Exception e) {
		Log.error("jCumulus startup failure");
		e.printStackTrace();
	}
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:51,代码来源:RayoComponent.java


注:本文中的org.jboss.netty.bootstrap.ConnectionlessBootstrap.setOption方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。