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();
}
Aggregations