use of io.netty.channel.socket.nio.NioSocketChannel in project rest.li by linkedin.
the class HttpNettyServer method start.
@Override
public void start() {
_eventExecutors = new DefaultEventExecutorGroup(_threadPoolSize);
_bossGroup = new NioEventLoopGroup(1, new NamedThreadFactory("R2 Nio Boss"));
_workerGroup = new NioEventLoopGroup(0, new NamedThreadFactory("R2 Nio Worker"));
ServerBootstrap bootstrap = new ServerBootstrap().group(_bossGroup, _workerGroup).channel(NioServerSocketChannel.class).childHandler(new ChannelInitializer<NioSocketChannel>() {
@Override
protected void initChannel(NioSocketChannel ch) throws Exception {
ch.pipeline().addLast("decoder", new HttpRequestDecoder());
ch.pipeline().addLast("aggregator", new HttpObjectAggregator(1048576));
ch.pipeline().addLast("encoder", new HttpResponseEncoder());
ch.pipeline().addLast("rapi", new RAPServerCodec());
ch.pipeline().addLast(_eventExecutors, "handler", _restOverStream ? new StreamHandler() : new RestHandler());
}
});
bootstrap.bind(new InetSocketAddress(_port));
}
Aggregations