Search in sources :

Example 11 with NioDatagramChannelFactory

use of org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory in project pinpoint by naver.

the class NettyUdpReceiverTest method createUdpServer.

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;
}
Also used : NioDatagramChannelFactory(org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory) DatagramChannelFactory(org.jboss.netty.channel.socket.DatagramChannelFactory) NioDatagramChannelFactory(org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory) IOException(java.io.IOException) ConnectionlessBootstrap(org.jboss.netty.bootstrap.ConnectionlessBootstrap)

Aggregations

NioDatagramChannelFactory (org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory)11 ConnectionlessBootstrap (org.jboss.netty.bootstrap.ConnectionlessBootstrap)10 ChannelPipeline (org.jboss.netty.channel.ChannelPipeline)4 ChannelPipelineFactory (org.jboss.netty.channel.ChannelPipelineFactory)4 FixedReceiveBufferSizePredictorFactory (org.jboss.netty.channel.FixedReceiveBufferSizePredictorFactory)4 InetSocketAddress (java.net.InetSocketAddress)3 DatagramChannelFactory (org.jboss.netty.channel.socket.DatagramChannelFactory)3 IOException (java.io.IOException)2 NioDatagramWorkerPool (org.jboss.netty.channel.socket.nio.NioDatagramWorkerPool)2 StringDecoder (org.jboss.netty.handler.codec.string.StringDecoder)2 ServerPipelineFactory (com.jcumulus.server.rtmfp.ServerPipelineFactory)1 Sessions (com.jcumulus.server.rtmfp.Sessions)1 ParseException (java.text.ParseException)1 Map (java.util.Map)1 ServerBootstrap (org.jboss.netty.bootstrap.ServerBootstrap)1 ChannelFactory (org.jboss.netty.channel.ChannelFactory)1 FixedReceiveBufferSizePredictor (org.jboss.netty.channel.FixedReceiveBufferSizePredictor)1 NioServerSocketChannelFactory (org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory)1 OrderedMemoryAwareThreadPoolExecutor (org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor)1 IpV4Subnet (org.jboss.netty.handler.ipfilter.IpV4Subnet)1