org.jboss.netty.channel.socket.DatagramChannelFactory Java Examples

The following examples show how to use org.jboss.netty.channel.socket.DatagramChannelFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SimpleUdpServer.java    From hadoop with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #2
Source File: SimpleUdpServer.java    From big-c with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #3
Source File: NettyUdpReceiverTest.java    From pinpoint with Apache License 2.0 6 votes vote down vote up
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;
    }
 
Example #4
Source File: UdpMeta.java    From parallec with Apache License 2.0 5 votes vote down vote up
public UdpMeta(String command, int udpPort, int udpIdleTimeoutSec,
        DatagramChannelFactory channelFactory) {
    super();
    this.command = command;
    this.udpPort = udpPort;
    this.udpIdleTimeoutSec = udpIdleTimeoutSec;
    this.channelFactory = channelFactory;
    
}
 
Example #5
Source File: TcpUdpSshPingResourceStore.java    From parallec with Apache License 2.0 4 votes vote down vote up
public DatagramChannelFactory getDatagramChannelFactory() {
    return datagramChannelFactory;
}
 
Example #6
Source File: TcpUdpSshPingResourceStore.java    From parallec with Apache License 2.0 4 votes vote down vote up
public void setDatagramChannelFactory(DatagramChannelFactory datagramChannelFactory) {
    this.datagramChannelFactory = datagramChannelFactory;
}
 
Example #7
Source File: UdpMeta.java    From parallec with Apache License 2.0 4 votes vote down vote up
public void setChannelFactory(DatagramChannelFactory channelFactory) {
    this.channelFactory = channelFactory;
}