Java 类org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory 实例源码

项目:hadoop    文件:SimpleUdpServer.java   
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);
}
项目:aliyun-oss-hadoop-fs    文件:SimpleUdpServer.java   
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);
}
项目:big-c    文件:SimpleUdpServer.java   
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);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:SimpleUdpServer.java   
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);
}
项目:hadoop-plus    文件:SimpleUdpServer.java   
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);
}
项目:hops    文件:SimpleUdpServer.java   
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);
}
项目:hadoop-TCP    文件:SimpleUdpServer.java   
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);
}
项目:pinpoint    文件:NettyUdpReceiverTest.java   
private ConnectionlessBootstrap createUdpServer() {
        DatagramChannelFactory udpFactory = new NioDatagramChannelFactory(Executors.newCachedThreadPool(), 4);
        ChannelPipelineFactory pipelineFactory = new ChannelPipelineFactory() {
            @Override
            public ChannelPipeline getPipeline() throws Exception {
                ChannelPipeline pipeline = Channels.pipeline();
                pipeline.addLast("test", new SimpleChannelHandler() {
                    @Override
                    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
                        String name = Thread.currentThread().getName();
                        logger.debug("sleep:{}", name);
                        Thread.sleep(10000);
//                        if (!name.equals("New I/O worker #1")) {
                            logger.debug("messageReceived thread-{} message:", Thread.currentThread().getName());
//                        }
                    }
                });
                return pipeline;
            }
        };
        ConnectionlessBootstrap udpBootstrap = new ConnectionlessBootstrap(udpFactory);
        udpBootstrap.setPipelineFactory(pipelineFactory);
        return udpBootstrap;
    }
项目:hardfs    文件:SimpleUdpServer.java   
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);
}
项目:hadoop-on-lustre2    文件:SimpleUdpServer.java   
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);
}
项目:hadoop    文件:Portmap.java   
void start(final int idleTimeMilliSeconds, final SocketAddress tcpAddress,
    final SocketAddress udpAddress) {

  tcpServer = new ServerBootstrap(new NioServerSocketChannelFactory(
      Executors.newCachedThreadPool(), Executors.newCachedThreadPool()));
  tcpServer.setPipelineFactory(new ChannelPipelineFactory() {
    private final HashedWheelTimer timer = new HashedWheelTimer();
    private final IdleStateHandler idleStateHandler = new IdleStateHandler(
        timer, 0, 0, idleTimeMilliSeconds, TimeUnit.MILLISECONDS);

    @Override
    public ChannelPipeline getPipeline() throws Exception {
      return Channels.pipeline(RpcUtil.constructRpcFrameDecoder(),
          RpcUtil.STAGE_RPC_MESSAGE_PARSER, idleStateHandler, handler,
          RpcUtil.STAGE_RPC_TCP_RESPONSE);
    }
  });

  udpServer = new ConnectionlessBootstrap(new NioDatagramChannelFactory(
      Executors.newCachedThreadPool()));

  udpServer.setPipeline(Channels.pipeline(RpcUtil.STAGE_RPC_MESSAGE_PARSER,
      handler, RpcUtil.STAGE_RPC_UDP_RESPONSE));

  tcpChannel = tcpServer.bind(tcpAddress);
  udpChannel = udpServer.bind(udpAddress);
  allChannels.add(tcpChannel);
  allChannels.add(udpChannel);

  LOG.info("Portmap server started at tcp://" + tcpChannel.getLocalAddress()
      + ", udp://" + udpChannel.getLocalAddress());
}
项目:aliyun-oss-hadoop-fs    文件:Portmap.java   
void start(final int idleTimeMilliSeconds, final SocketAddress tcpAddress,
    final SocketAddress udpAddress) {

  tcpServer = new ServerBootstrap(new NioServerSocketChannelFactory(
      Executors.newCachedThreadPool(), Executors.newCachedThreadPool()));
  tcpServer.setPipelineFactory(new ChannelPipelineFactory() {
    private final HashedWheelTimer timer = new HashedWheelTimer();
    private final IdleStateHandler idleStateHandler = new IdleStateHandler(
        timer, 0, 0, idleTimeMilliSeconds, TimeUnit.MILLISECONDS);

    @Override
    public ChannelPipeline getPipeline() throws Exception {
      return Channels.pipeline(RpcUtil.constructRpcFrameDecoder(),
          RpcUtil.STAGE_RPC_MESSAGE_PARSER, idleStateHandler, handler,
          RpcUtil.STAGE_RPC_TCP_RESPONSE);
    }
  });

  udpServer = new ConnectionlessBootstrap(new NioDatagramChannelFactory(
      Executors.newCachedThreadPool()));

  udpServer.setPipeline(Channels.pipeline(RpcUtil.STAGE_RPC_MESSAGE_PARSER,
      handler, RpcUtil.STAGE_RPC_UDP_RESPONSE));

  tcpChannel = tcpServer.bind(tcpAddress);
  udpChannel = udpServer.bind(udpAddress);
  allChannels.add(tcpChannel);
  allChannels.add(udpChannel);

  LOG.info("Portmap server started at tcp://" + tcpChannel.getLocalAddress()
      + ", udp://" + udpChannel.getLocalAddress());
}
项目:big-c    文件:Portmap.java   
void start(final int idleTimeMilliSeconds, final SocketAddress tcpAddress,
    final SocketAddress udpAddress) {

  tcpServer = new ServerBootstrap(new NioServerSocketChannelFactory(
      Executors.newCachedThreadPool(), Executors.newCachedThreadPool()));
  tcpServer.setPipelineFactory(new ChannelPipelineFactory() {
    private final HashedWheelTimer timer = new HashedWheelTimer();
    private final IdleStateHandler idleStateHandler = new IdleStateHandler(
        timer, 0, 0, idleTimeMilliSeconds, TimeUnit.MILLISECONDS);

    @Override
    public ChannelPipeline getPipeline() throws Exception {
      return Channels.pipeline(RpcUtil.constructRpcFrameDecoder(),
          RpcUtil.STAGE_RPC_MESSAGE_PARSER, idleStateHandler, handler,
          RpcUtil.STAGE_RPC_TCP_RESPONSE);
    }
  });

  udpServer = new ConnectionlessBootstrap(new NioDatagramChannelFactory(
      Executors.newCachedThreadPool()));

  udpServer.setPipeline(Channels.pipeline(RpcUtil.STAGE_RPC_MESSAGE_PARSER,
      handler, RpcUtil.STAGE_RPC_UDP_RESPONSE));

  tcpChannel = tcpServer.bind(tcpAddress);
  udpChannel = udpServer.bind(udpAddress);
  allChannels.add(tcpChannel);
  allChannels.add(udpChannel);

  LOG.info("Portmap server started at tcp://" + tcpChannel.getLocalAddress()
      + ", udp://" + udpChannel.getLocalAddress());
}
项目:Camel    文件:NettyUdpConnectionlessSendTest.java   
public void createNettyUdpReceiver() {
    bootstrap = new ConnectionlessBootstrap(new NioDatagramChannelFactory());
    bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
        @Override
        public ChannelPipeline getPipeline() throws Exception {
            ChannelPipeline channelPipeline = Channels.pipeline();
            channelPipeline.addLast("StringDecoder", new StringDecoder(CharsetUtil.UTF_8));
            channelPipeline.addLast("ContentHandler", new ContentHandler());
            return channelPipeline;
        }
    });

}
项目:Camel    文件:NettyUdpConnectedSendTest.java   
public void createNettyUdpReceiver() {
    bootstrap = new ConnectionlessBootstrap(new NioDatagramChannelFactory());
    bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
        @Override
        public ChannelPipeline getPipeline() throws Exception {
            ChannelPipeline channelPipeline = Channels.pipeline();
            channelPipeline.addLast("StringDecoder", new StringDecoder(CharsetUtil.UTF_8));
            channelPipeline.addLast("ContentHandler", new ContentHandler());
            return channelPipeline;
        }
    });
}
项目:hadoop-2.6.0-cdh5.4.3    文件:Portmap.java   
void start(final int idleTimeMilliSeconds, final SocketAddress tcpAddress,
    final SocketAddress udpAddress) {

  tcpServer = new ServerBootstrap(new NioServerSocketChannelFactory(
      Executors.newCachedThreadPool(), Executors.newCachedThreadPool()));
  tcpServer.setPipelineFactory(new ChannelPipelineFactory() {
    private final HashedWheelTimer timer = new HashedWheelTimer();
    private final IdleStateHandler idleStateHandler = new IdleStateHandler(
        timer, 0, 0, idleTimeMilliSeconds, TimeUnit.MILLISECONDS);

    @Override
    public ChannelPipeline getPipeline() throws Exception {
      return Channels.pipeline(RpcUtil.constructRpcFrameDecoder(),
          RpcUtil.STAGE_RPC_MESSAGE_PARSER, idleStateHandler, handler,
          RpcUtil.STAGE_RPC_TCP_RESPONSE);
    }
  });

  udpServer = new ConnectionlessBootstrap(new NioDatagramChannelFactory(
      Executors.newCachedThreadPool()));

  udpServer.setPipeline(Channels.pipeline(RpcUtil.STAGE_RPC_MESSAGE_PARSER,
      handler, RpcUtil.STAGE_RPC_UDP_RESPONSE));

  tcpChannel = tcpServer.bind(tcpAddress);
  udpChannel = udpServer.bind(udpAddress);
  allChannels.add(tcpChannel);
  allChannels.add(udpChannel);

  LOG.info("Portmap server started at tcp://" + tcpChannel.getLocalAddress()
      + ", udp://" + udpChannel.getLocalAddress());
}
项目:parallec    文件:TcpUdpSshPingResourceStore.java   
/**
 * Initialize; cached threadpool is safe as it is releasing resources automatically if idle
 */
public synchronized void init() {
    channelFactory = new NioClientSocketChannelFactory(
            Executors.newCachedThreadPool(),
            Executors.newCachedThreadPool());

    datagramChannelFactory = new NioDatagramChannelFactory(
            Executors.newCachedThreadPool());

    timer = new HashedWheelTimer();
}
项目:hops    文件:Portmap.java   
void start(final int idleTimeMilliSeconds, final SocketAddress tcpAddress,
    final SocketAddress udpAddress) {

  tcpServer = new ServerBootstrap(new NioServerSocketChannelFactory(
      Executors.newCachedThreadPool(), Executors.newCachedThreadPool()));
  tcpServer.setPipelineFactory(new ChannelPipelineFactory() {
    private final HashedWheelTimer timer = new HashedWheelTimer();
    private final IdleStateHandler idleStateHandler = new IdleStateHandler(
        timer, 0, 0, idleTimeMilliSeconds, TimeUnit.MILLISECONDS);

    @Override
    public ChannelPipeline getPipeline() throws Exception {
      return Channels.pipeline(RpcUtil.constructRpcFrameDecoder(),
          RpcUtil.STAGE_RPC_MESSAGE_PARSER, idleStateHandler, handler,
          RpcUtil.STAGE_RPC_TCP_RESPONSE);
    }
  });

  udpServer = new ConnectionlessBootstrap(new NioDatagramChannelFactory(
      Executors.newCachedThreadPool()));

  udpServer.setPipeline(Channels.pipeline(RpcUtil.STAGE_RPC_MESSAGE_PARSER,
      handler, RpcUtil.STAGE_RPC_UDP_RESPONSE));

  tcpChannel = tcpServer.bind(tcpAddress);
  udpChannel = udpServer.bind(udpAddress);
  allChannels.add(tcpChannel);
  allChannels.add(udpChannel);

  LOG.info("Portmap server started at tcp://" + tcpChannel.getLocalAddress()
      + ", udp://" + udpChannel.getLocalAddress());
}
项目:hadoop-on-lustre2    文件:Portmap.java   
void start(final int idleTimeMilliSeconds, final SocketAddress tcpAddress,
    final SocketAddress udpAddress) {

  tcpServer = new ServerBootstrap(new NioServerSocketChannelFactory(
      Executors.newCachedThreadPool(), Executors.newCachedThreadPool()));
  tcpServer.setPipelineFactory(new ChannelPipelineFactory() {
    private final HashedWheelTimer timer = new HashedWheelTimer();
    private final IdleStateHandler idleStateHandler = new IdleStateHandler(
        timer, 0, 0, idleTimeMilliSeconds, TimeUnit.MILLISECONDS);

    @Override
    public ChannelPipeline getPipeline() throws Exception {
      return Channels.pipeline(RpcUtil.constructRpcFrameDecoder(),
          RpcUtil.STAGE_RPC_MESSAGE_PARSER, idleStateHandler, handler,
          RpcUtil.STAGE_RPC_TCP_RESPONSE);
    }
  });

  udpServer = new ConnectionlessBootstrap(new NioDatagramChannelFactory(
      Executors.newCachedThreadPool()));

  udpServer.setPipeline(Channels.pipeline(RpcUtil.STAGE_RPC_MESSAGE_PARSER,
      handler, RpcUtil.STAGE_RPC_UDP_RESPONSE));

  tcpChannel = tcpServer.bind(tcpAddress);
  udpChannel = udpServer.bind(udpAddress);
  allChannels.add(tcpChannel);
  allChannels.add(udpChannel);

  LOG.info("Portmap server started at tcp://" + tcpChannel.getLocalAddress()
      + ", udp://" + udpChannel.getLocalAddress());
}
项目:Camel    文件:SingleUDPNettyServerBootstrapFactory.java   
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);
    }
}
项目:Openfire    文件:RayoComponent.java   
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();
    }
}
项目:dhcp    文件:ClientSimulatorV4.java   
/**
   * Start sending DHCPv4 DISCOVERs.
   */
  public void start()
  {
    DatagramChannelFactory factory = 
        new NioDatagramChannelFactory(Executors.newCachedThreadPool());

    server = new InetSocketAddress(serverAddr, serverPort);
    client = new InetSocketAddress(clientPort);

ChannelPipeline pipeline = Channels.pipeline();
      pipeline.addLast("logger", new LoggingHandler());
      pipeline.addLast("encoder", new DhcpV4ChannelEncoder());
      pipeline.addLast("decoder", new DhcpV4ChannelDecoder(client, false));
      pipeline.addLast("executor", new ExecutionHandler(
            new OrderedMemoryAwareThreadPoolExecutor(16, 1048576, 1048576)));
      pipeline.addLast("handler", this);

      channel = factory.newChannel(pipeline);
    channel.bind(client);

    for (int i=1; i<=numRequests; i++) {
        executor.execute(new ClientMachine(i));
    }

    synchronized (syncDone) {
        long ms = timeout * 1000;
        try {
            log.info("Waiting total of " + timeout + " milliseconds for completion");
            syncDone.wait(ms);
        }
        catch (InterruptedException ex) {
            log.error("Interrupted", ex);
        }
}

log.info("Complete: discoversSent=" + discoversSent +
        " offersReceived=" + offersReceived +
        " requestsSent=" + requestsSent +
        " acksReceived=" + acksReceived +
        " releasesSent=" + releasesSent +
        " elapsedTime=" + (endTime - startTime) + "ms");

    log.info("Shutting down executor...");
    executor.shutdownNow();
    log.info("Closing channel...");
    channel.close();
    log.info("Done.");
    if ((discoversSent.get() == offersReceived.get()) &&
            (requestsSent.get() == acksReceived.get()) &&
            (releasesSent.get() == numRequests)) {

        System.exit(0);
    }
    else {
        System.exit(1);
    }
  }
项目:openfire    文件:RayoComponent.java   
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();
    }
}