Skip to content

Commit e7fcb28

Browse files
authored
Merge pull request alibaba#689 from Black-Mamba24/master
[ISSUE alibaba#556]Fix useEpollNativeSelector=true Broker Start Exception
2 parents 306dcbb + 0767a9d commit e7fcb28

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

remoting/src/main/java/org/apache/rocketmq/remoting/netty/NettyRemotingServer.java

+17-8
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,16 @@ public Thread newThread(Runnable r) {
107107
}
108108
});
109109

110-
this.eventLoopGroupBoss = new NioEventLoopGroup(1, new ThreadFactory() {
111-
private AtomicInteger threadIndex = new AtomicInteger(0);
110+
if (useEpoll()) {
111+
this.eventLoopGroupBoss = new EpollEventLoopGroup(1, new ThreadFactory() {
112+
private AtomicInteger threadIndex = new AtomicInteger(0);
112113

113-
@Override
114-
public Thread newThread(Runnable r) {
115-
return new Thread(r, String.format("NettyBoss_%d", this.threadIndex.incrementAndGet()));
116-
}
117-
});
114+
@Override
115+
public Thread newThread(Runnable r) {
116+
return new Thread(r, String.format("NettyEPOLLBoss_%d", this.threadIndex.incrementAndGet()));
117+
}
118+
});
118119

119-
if (useEpoll()) {
120120
this.eventLoopGroupSelector = new EpollEventLoopGroup(nettyServerConfig.getServerSelectorThreads(), new ThreadFactory() {
121121
private AtomicInteger threadIndex = new AtomicInteger(0);
122122
private int threadTotal = nettyServerConfig.getServerSelectorThreads();
@@ -127,6 +127,15 @@ public Thread newThread(Runnable r) {
127127
}
128128
});
129129
} else {
130+
this.eventLoopGroupBoss = new NioEventLoopGroup(1, new ThreadFactory() {
131+
private AtomicInteger threadIndex = new AtomicInteger(0);
132+
133+
@Override
134+
public Thread newThread(Runnable r) {
135+
return new Thread(r, String.format("NettyNIOBoss_%d", this.threadIndex.incrementAndGet()));
136+
}
137+
});
138+
130139
this.eventLoopGroupSelector = new NioEventLoopGroup(nettyServerConfig.getServerSelectorThreads(), new ThreadFactory() {
131140
private AtomicInteger threadIndex = new AtomicInteger(0);
132141
private int threadTotal = nettyServerConfig.getServerSelectorThreads();

0 commit comments

Comments
 (0)