Skip to content

Commit 433b189

Browse files
committed
provide the timer for netty
this helps to control the thread name of the thread it created
1 parent c56cc6e commit 433b189

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main/java/org/elasticsearch/transport/netty/NettyTransport.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@
5151
import org.jboss.netty.channel.*;
5252
import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
5353
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
54+
import org.jboss.netty.channel.socket.nio.NioWorkerPool;
5455
import org.jboss.netty.channel.socket.oio.OioClientSocketChannelFactory;
5556
import org.jboss.netty.channel.socket.oio.OioServerSocketChannelFactory;
57+
import org.jboss.netty.util.HashedWheelTimer;
5658

5759
import java.io.IOException;
5860
import java.net.InetAddress;
@@ -93,6 +95,7 @@ public class NettyTransport extends AbstractLifecycleComponent<Transport> implem
9395
private final NetworkService networkService;
9496

9597
final int workerCount;
98+
final int bossCount;
9699

97100
final boolean blockingServer;
98101

@@ -172,6 +175,7 @@ public NettyTransport(Settings settings, ThreadPool threadPool, NetworkService n
172175
}
173176

174177
this.workerCount = componentSettings.getAsInt("worker_count", Runtime.getRuntime().availableProcessors() * 2);
178+
this.bossCount = componentSettings.getAsInt("boss_count", 1);
175179
this.blockingServer = settings.getAsBoolean("transport.tcp.blocking_server", settings.getAsBoolean(TCP_BLOCKING_SERVER, settings.getAsBoolean(TCP_BLOCKING, false)));
176180
this.blockingClient = settings.getAsBoolean("transport.tcp.blocking_client", settings.getAsBoolean(TCP_BLOCKING_CLIENT, settings.getAsBoolean(TCP_BLOCKING, false)));
177181
this.port = componentSettings.get("port", settings.get("transport.tcp.port", "9300-9400"));
@@ -235,8 +239,9 @@ protected void doStart() throws ElasticSearchException {
235239
} else {
236240
clientBootstrap = new ClientBootstrap(new NioClientSocketChannelFactory(
237241
Executors.newCachedThreadPool(daemonThreadFactory(settings, "transport_client_boss")),
238-
Executors.newCachedThreadPool(daemonThreadFactory(settings, "transport_client_worker")),
239-
workerCount));
242+
bossCount,
243+
new NioWorkerPool(Executors.newCachedThreadPool(daemonThreadFactory(settings, "transport_client_worker")), workerCount),
244+
new HashedWheelTimer(daemonThreadFactory(settings, "transport_client_timer"))));
240245
}
241246
ChannelPipelineFactory clientPipelineFactory = new ChannelPipelineFactory() {
242247
@Override

0 commit comments

Comments
 (0)