/**
* 初始化
*
* @param pThreadCount parent thread count.
* @param cThreadCount worker thread count.
* @param options netty network options。
*/
public void initialize(int pThreadCount, int cThreadCount,
Map<ChannelOption<Object>, Object> options) {
this.bootstrap = new ServerBootstrap();
if (Epoll.isAvailable()) {
this.parentGroup = new EpollEventLoopGroup(pThreadCount);
this.childGroup = new EpollEventLoopGroup(cThreadCount);
this.bootstrap.group(parentGroup, childGroup).channel(EpollServerSocketChannel.class);
} else {
this.parentGroup = new NioEventLoopGroup(pThreadCount);
this.childGroup = new NioEventLoopGroup(cThreadCount);
this.bootstrap.group(parentGroup, childGroup).channel(NioServerSocketChannel.class);
}
// handlers
this.prepender = new LengthFieldPrepender(this.lengthFieldLength, false);
bootstrap.childHandler(new ChannelInitializer() {
@Override
protected void initChannel(Channel ch) throws Exception {
ServerContext.this.initChannel(ch);
}
});
//
this.defaultOptions();
if (!options.isEmpty()) {
for (Map.Entry<ChannelOption<Object>, Object> entry : options.entrySet()) {
bootstrap.childOption(entry.getKey(), entry.getValue());
}
}
}
ServerContext.java 文件源码
java
阅读 24
收藏 0
点赞 0
评论 0
项目:Okra-Ax
作者:
评论列表
文章目录