From 9727f123b9a2a37c682e363897fc299f59628789 Mon Sep 17 00:00:00 2001 From: Tanguy Leroux Date: Mon, 29 Aug 2016 12:07:22 +0200 Subject: [PATCH] Rename Netty TCP transports thread factories from http_* to transport_* Netty3/4 TcpTransport implementations are creating thread factories with a "http_server" thread prefix whereas it should start with "transport_server" and let the "http_server" prefix for the HttpServerTransport implementations. --- .../java/org/elasticsearch/http/HttpServerTransport.java | 3 +++ .../java/org/elasticsearch/transport/TcpTransport.java | 4 ++-- .../main/java/org/elasticsearch/transport/Transports.java | 7 +++++-- .../http/netty3/Netty3HttpServerTransport.java | 8 ++++---- .../elasticsearch/transport/netty3/Netty3Transport.java | 4 ++-- .../http/netty4/Netty4HttpServerTransport.java | 4 ++-- .../elasticsearch/transport/netty4/Netty4Transport.java | 2 +- 7 files changed, 19 insertions(+), 13 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/http/HttpServerTransport.java b/core/src/main/java/org/elasticsearch/http/HttpServerTransport.java index 0ec57e2bfc2..4dc4a888d8a 100644 --- a/core/src/main/java/org/elasticsearch/http/HttpServerTransport.java +++ b/core/src/main/java/org/elasticsearch/http/HttpServerTransport.java @@ -24,6 +24,9 @@ import org.elasticsearch.common.transport.BoundTransportAddress; public interface HttpServerTransport extends LifecycleComponent { + String HTTP_SERVER_WORKER_THREAD_NAME_PREFIX = "http_server_worker"; + String HTTP_SERVER_BOSS_THREAD_NAME_PREFIX = "http_server_boss"; + BoundTransportAddress boundAddress(); HttpInfo info(); diff --git a/core/src/main/java/org/elasticsearch/transport/TcpTransport.java b/core/src/main/java/org/elasticsearch/transport/TcpTransport.java index d567e838138..505890f2ead 100644 --- a/core/src/main/java/org/elasticsearch/transport/TcpTransport.java +++ b/core/src/main/java/org/elasticsearch/transport/TcpTransport.java @@ -106,8 +106,8 @@ import static org.elasticsearch.common.util.concurrent.ConcurrentCollections.new public abstract class TcpTransport extends AbstractLifecycleComponent implements Transport { - public static final String HTTP_SERVER_WORKER_THREAD_NAME_PREFIX = "http_server_worker"; - public static final String HTTP_SERVER_BOSS_THREAD_NAME_PREFIX = "http_server_boss"; + public static final String TRANSPORT_SERVER_WORKER_THREAD_NAME_PREFIX = "transport_server_worker"; + public static final String TRANSPORT_SERVER_BOSS_THREAD_NAME_PREFIX = "transport_server_boss"; public static final String TRANSPORT_CLIENT_WORKER_THREAD_NAME_PREFIX = "transport_client_worker"; public static final String TRANSPORT_CLIENT_BOSS_THREAD_NAME_PREFIX = "transport_client_boss"; diff --git a/core/src/main/java/org/elasticsearch/transport/Transports.java b/core/src/main/java/org/elasticsearch/transport/Transports.java index 15bf2c833f6..9b4dc4d5a6a 100644 --- a/core/src/main/java/org/elasticsearch/transport/Transports.java +++ b/core/src/main/java/org/elasticsearch/transport/Transports.java @@ -19,6 +19,7 @@ package org.elasticsearch.transport; +import org.elasticsearch.http.HttpServerTransport; import org.elasticsearch.transport.local.LocalTransport; import java.util.Arrays; @@ -38,8 +39,10 @@ public enum Transports { final String threadName = t.getName(); for (String s : Arrays.asList( LocalTransport.LOCAL_TRANSPORT_THREAD_NAME_PREFIX, - TcpTransport.HTTP_SERVER_BOSS_THREAD_NAME_PREFIX, - TcpTransport.HTTP_SERVER_WORKER_THREAD_NAME_PREFIX, + HttpServerTransport.HTTP_SERVER_BOSS_THREAD_NAME_PREFIX, + HttpServerTransport.HTTP_SERVER_WORKER_THREAD_NAME_PREFIX, + TcpTransport.TRANSPORT_SERVER_BOSS_THREAD_NAME_PREFIX, + TcpTransport.TRANSPORT_SERVER_WORKER_THREAD_NAME_PREFIX, TcpTransport.TRANSPORT_CLIENT_WORKER_THREAD_NAME_PREFIX, TcpTransport.TRANSPORT_CLIENT_BOSS_THREAD_NAME_PREFIX, TEST_MOCK_TRANSPORT_THREAD_PREFIX)) { diff --git a/modules/transport-netty3/src/main/java/org/elasticsearch/http/netty3/Netty3HttpServerTransport.java b/modules/transport-netty3/src/main/java/org/elasticsearch/http/netty3/Netty3HttpServerTransport.java index b7934da00e9..d12636de5cb 100644 --- a/modules/transport-netty3/src/main/java/org/elasticsearch/http/netty3/Netty3HttpServerTransport.java +++ b/modules/transport-netty3/src/main/java/org/elasticsearch/http/netty3/Netty3HttpServerTransport.java @@ -285,13 +285,13 @@ public class Netty3HttpServerTransport extends AbstractLifecycleComponent implem this.serverOpenChannels = new Netty3OpenChannelsHandler(logger); if (blockingServer) { serverBootstrap = new ServerBootstrap(new OioServerSocketChannelFactory( - Executors.newCachedThreadPool(daemonThreadFactory(settings, "http_server_boss")), - Executors.newCachedThreadPool(daemonThreadFactory(settings, "http_server_worker")) + Executors.newCachedThreadPool(daemonThreadFactory(settings, HTTP_SERVER_BOSS_THREAD_NAME_PREFIX)), + Executors.newCachedThreadPool(daemonThreadFactory(settings, HTTP_SERVER_WORKER_THREAD_NAME_PREFIX)) )); } else { serverBootstrap = new ServerBootstrap(new NioServerSocketChannelFactory( - Executors.newCachedThreadPool(daemonThreadFactory(settings, "http_server_boss")), - Executors.newCachedThreadPool(daemonThreadFactory(settings, "http_server_worker")), + Executors.newCachedThreadPool(daemonThreadFactory(settings, HTTP_SERVER_BOSS_THREAD_NAME_PREFIX)), + Executors.newCachedThreadPool(daemonThreadFactory(settings, HTTP_SERVER_WORKER_THREAD_NAME_PREFIX)), workerCount)); } serverBootstrap.setPipelineFactory(configureServerChannelPipelineFactory()); diff --git a/modules/transport-netty3/src/main/java/org/elasticsearch/transport/netty3/Netty3Transport.java b/modules/transport-netty3/src/main/java/org/elasticsearch/transport/netty3/Netty3Transport.java index f5f32044eb7..71a9ca25d4d 100644 --- a/modules/transport-netty3/src/main/java/org/elasticsearch/transport/netty3/Netty3Transport.java +++ b/modules/transport-netty3/src/main/java/org/elasticsearch/transport/netty3/Netty3Transport.java @@ -286,8 +286,8 @@ public class Netty3Transport extends TcpTransport { receivePredictorMax); } - final ThreadFactory bossFactory = daemonThreadFactory(this.settings, HTTP_SERVER_BOSS_THREAD_NAME_PREFIX, name); - final ThreadFactory workerFactory = daemonThreadFactory(this.settings, HTTP_SERVER_WORKER_THREAD_NAME_PREFIX, name); + final ThreadFactory bossFactory = daemonThreadFactory(this.settings, TRANSPORT_SERVER_BOSS_THREAD_NAME_PREFIX, name); + final ThreadFactory workerFactory = daemonThreadFactory(this.settings, TRANSPORT_SERVER_WORKER_THREAD_NAME_PREFIX, name); final ServerBootstrap serverBootstrap; if (blockingServer) { serverBootstrap = new ServerBootstrap(new OioServerSocketChannelFactory( diff --git a/modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/Netty4HttpServerTransport.java b/modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/Netty4HttpServerTransport.java index 68727db27c1..1a6e8ae60bf 100644 --- a/modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/Netty4HttpServerTransport.java +++ b/modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/Netty4HttpServerTransport.java @@ -290,10 +290,10 @@ public class Netty4HttpServerTransport extends AbstractLifecycleComponent implem serverBootstrap = new ServerBootstrap(); if (blockingServer) { - serverBootstrap.group(new OioEventLoopGroup(workerCount, daemonThreadFactory(settings, "http_server_worker"))); + serverBootstrap.group(new OioEventLoopGroup(workerCount, daemonThreadFactory(settings, HTTP_SERVER_WORKER_THREAD_NAME_PREFIX))); serverBootstrap.channel(OioServerSocketChannel.class); } else { - serverBootstrap.group(new NioEventLoopGroup(workerCount, daemonThreadFactory(settings, "http_server_worker"))); + serverBootstrap.group(new NioEventLoopGroup(workerCount, daemonThreadFactory(settings, HTTP_SERVER_WORKER_THREAD_NAME_PREFIX))); serverBootstrap.channel(NioServerSocketChannel.class); } diff --git a/modules/transport-netty4/src/main/java/org/elasticsearch/transport/netty4/Netty4Transport.java b/modules/transport-netty4/src/main/java/org/elasticsearch/transport/netty4/Netty4Transport.java index d7631acd6b7..9de5a31dbe6 100644 --- a/modules/transport-netty4/src/main/java/org/elasticsearch/transport/netty4/Netty4Transport.java +++ b/modules/transport-netty4/src/main/java/org/elasticsearch/transport/netty4/Netty4Transport.java @@ -272,7 +272,7 @@ public class Netty4Transport extends TcpTransport { connectionsPerNodePing, receivePredictorMin, receivePredictorMax); } - final ThreadFactory workerFactory = daemonThreadFactory(this.settings, HTTP_SERVER_WORKER_THREAD_NAME_PREFIX, name); + final ThreadFactory workerFactory = daemonThreadFactory(this.settings, TRANSPORT_SERVER_WORKER_THREAD_NAME_PREFIX, name); final ServerBootstrap serverBootstrap = new ServerBootstrap();