提交 0767a9d5 编写于 作者: B Black-Mamba24

修复issue556 EpollEventLoopGroup启动失败的bug

上级 d434a3af
...@@ -108,16 +108,16 @@ public class NettyRemotingServer extends NettyRemotingAbstract implements Remoti ...@@ -108,16 +108,16 @@ public class NettyRemotingServer extends NettyRemotingAbstract implements Remoti
} }
}); });
this.eventLoopGroupBoss = new NioEventLoopGroup(1, new ThreadFactory() { if (useEpoll()) {
this.eventLoopGroupBoss = new EpollEventLoopGroup(1, new ThreadFactory() {
private AtomicInteger threadIndex = new AtomicInteger(0); private AtomicInteger threadIndex = new AtomicInteger(0);
@Override @Override
public Thread newThread(Runnable r) { public Thread newThread(Runnable r) {
return new Thread(r, String.format("NettyBoss_%d", this.threadIndex.incrementAndGet())); return new Thread(r, String.format("NettyEPOLLBoss_%d", this.threadIndex.incrementAndGet()));
} }
}); });
if (useEpoll()) {
this.eventLoopGroupSelector = new EpollEventLoopGroup(nettyServerConfig.getServerSelectorThreads(), new ThreadFactory() { this.eventLoopGroupSelector = new EpollEventLoopGroup(nettyServerConfig.getServerSelectorThreads(), new ThreadFactory() {
private AtomicInteger threadIndex = new AtomicInteger(0); private AtomicInteger threadIndex = new AtomicInteger(0);
private int threadTotal = nettyServerConfig.getServerSelectorThreads(); private int threadTotal = nettyServerConfig.getServerSelectorThreads();
...@@ -128,6 +128,15 @@ public class NettyRemotingServer extends NettyRemotingAbstract implements Remoti ...@@ -128,6 +128,15 @@ public class NettyRemotingServer extends NettyRemotingAbstract implements Remoti
} }
}); });
} else { } else {
this.eventLoopGroupBoss = new NioEventLoopGroup(1, new ThreadFactory() {
private AtomicInteger threadIndex = new AtomicInteger(0);
@Override
public Thread newThread(Runnable r) {
return new Thread(r, String.format("NettyNIOBoss_%d", this.threadIndex.incrementAndGet()));
}
});
this.eventLoopGroupSelector = new NioEventLoopGroup(nettyServerConfig.getServerSelectorThreads(), new ThreadFactory() { this.eventLoopGroupSelector = new NioEventLoopGroup(nettyServerConfig.getServerSelectorThreads(), new ThreadFactory() {
private AtomicInteger threadIndex = new AtomicInteger(0); private AtomicInteger threadIndex = new AtomicInteger(0);
private int threadTotal = nettyServerConfig.getServerSelectorThreads(); private int threadTotal = nettyServerConfig.getServerSelectorThreads();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册