use of org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory in project NabAlive by jcheype.
the class HttpServer method start.
public void start() {
// Timer timer = new HashedWheelTimer();
System.out.println("Runtime.getRuntime().availableProcessors(): " + Runtime.getRuntime().availableProcessors());
// ExecutorService bossExec = new OrderedMemoryAwareThreadPoolExecutor(2, 400000000, 2000000000, 60, TimeUnit.SECONDS);
// ExecutorService ioExec = new OrderedMemoryAwareThreadPoolExecutor(Runtime.getRuntime().availableProcessors() + 1, 400000000, 2000000000, 60, TimeUnit.SECONDS);
//
// bootstrap = new ServerBootstrap(
// new NioServerSocketChannelFactory(bossExec, ioExec, Runtime.getRuntime().availableProcessors() + 1));
// Configure the server.
bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool()));
bootstrap.setOption("child.tcpNoDelay", true);
bootstrap.setOption("child.keepAlive", true);
bootstrap.setOption("receiveBufferSize", 128 * 1024);
bootstrap.setOption("sendBufferSize", 128 * 1024);
bootstrap.setOption("reuseAddress", true);
bootstrap.setOption("backlog", 16384);
final HttpApiServerHandler httpApiServerHandler = new HttpApiServerHandler(restHandler);
// Set up the event pipeline factory.
bootstrap.setPipelineFactory(new HttpApiServerPipelineFactory(httpApiServerHandler));
// Bind and start to accept incoming connections.
Channel c = bootstrap.bind(new InetSocketAddress(port));
cg.add(c);
}
Aggregations