Search in sources :

Example 11 with ConnectionlessBootstrap

use of org.jboss.netty.bootstrap.ConnectionlessBootstrap in project pinpoint by naver.

the class NettyUdpReceiverTest method server.

/*
    * netty io thread is single-threaded even for udp.
    * this is for running multiple workers.
    * */
@Test
public void server() throws IOException, InterruptedException {
    final ConnectionlessBootstrap udpServer = createUdpServer();
    Thread thread = new Thread(new Runnable() {

        @Override
        public void run() {
            udpServer.bind(new InetSocketAddress("127.0.0.1", PORT));
            try {
                logger.debug("server-await");
                latch.await();
            } catch (InterruptedException ignored) {
            }
            logger.debug("server-shutdown");
            udpServer.shutdown();
        }
    });
    thread.start();
    Thread.sleep(1000);
    logger.debug("start--------");
    //        ExecutorService executorService = Executors.newFixedThreadPool(10);
    //        for (int i =0; i< 10; i++) {
    //            executorService.execute(new Runnable() {
    //                @Override
    //                public void run() {
    //                    try {
    start();
    //                    } catch (IOException e) {
    //                        e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
    //                    }
    //                }
    //            });
    //        }
    //        executorService.awaitTermination(120, TimeUnit.SECONDS) ;
    latch.countDown();
}
Also used : InetSocketAddress(java.net.InetSocketAddress) ConnectionlessBootstrap(org.jboss.netty.bootstrap.ConnectionlessBootstrap) Test(org.junit.Test)

Aggregations

ConnectionlessBootstrap (org.jboss.netty.bootstrap.ConnectionlessBootstrap)11 NioDatagramChannelFactory (org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory)8 InetSocketAddress (java.net.InetSocketAddress)4 ChannelPipeline (org.jboss.netty.channel.ChannelPipeline)3 ChannelPipelineFactory (org.jboss.netty.channel.ChannelPipelineFactory)3 FixedReceiveBufferSizePredictorFactory (org.jboss.netty.channel.FixedReceiveBufferSizePredictorFactory)3 Map (java.util.Map)2 ServerBootstrap (org.jboss.netty.bootstrap.ServerBootstrap)2 DatagramChannelFactory (org.jboss.netty.channel.socket.DatagramChannelFactory)2 StringDecoder (org.jboss.netty.handler.codec.string.StringDecoder)2 ServerPipelineFactory (com.jcumulus.server.rtmfp.ServerPipelineFactory)1 Sessions (com.jcumulus.server.rtmfp.Sessions)1 IOException (java.io.IOException)1 ParseException (java.text.ParseException)1 Callable (java.util.concurrent.Callable)1 MisfireException (org.graylog2.plugin.inputs.MisfireException)1 ClientBootstrap (org.jboss.netty.bootstrap.ClientBootstrap)1 Channel (org.jboss.netty.channel.Channel)1 ChannelFuture (org.jboss.netty.channel.ChannelFuture)1 ChannelHandler (org.jboss.netty.channel.ChannelHandler)1