From 5f586477a7777c165a0b70082f3c8e956f5f6713 Mon Sep 17 00:00:00 2001 From: Tim Brooks Date: Wed, 12 Dec 2018 10:19:04 -0700 Subject: [PATCH 1/7] WIP --- .../transport/netty4/Netty4Transport.java | 11 +- .../Netty4SizeHeaderFrameDecoderTests.java | 6 +- .../transport/netty4/Netty4TransportIT.java | 6 +- .../netty4/NettyTransportMultiPortTests.java | 9 +- .../netty4/SimpleNetty4TransportTests.java | 9 +- .../classic/AzureUnicastHostsProvider.java | 2 +- .../AzureDiscoveryClusterFormationTests.java | 4 +- .../discovery/ec2/Ec2NetworkTests.java | 2 +- .../gce/GceUnicastHostsProvider.java | 2 +- .../discovery/gce/GceNetworkTests.java | 2 +- .../transport/nio/NioTransportIT.java | 6 +- .../nio/SimpleNioTransportTests.java | 9 +- .../org/elasticsearch/bootstrap/Security.java | 3 +- .../client/transport/TransportClient.java | 6 +- .../common/network/NetworkService.java | 5 +- .../common/settings/ClusterSettings.java | 68 ++++---- .../http/AbstractHttpServerTransport.java | 4 +- .../elasticsearch/plugins/PluginsService.java | 4 +- .../transport/ConnectionProfile.java | 18 +-- .../transport/RemoteClusterConnection.java | 4 +- .../transport/RemoteClusterService.java | 4 +- .../elasticsearch/transport/TcpTransport.java | 96 +++--------- .../elasticsearch/transport/Transport.java | 4 - .../transport/TransportService.java | 39 +---- .../transport/TransportSettings.java | 146 ++++++++++++++++++ .../transport/TransportClientTests.java | 4 +- .../common/settings/ScopedSettingsTests.java | 6 +- .../discovery/AbstractDisruptionTestCase.java | 4 +- .../discovery/ZenFaultDetectionTests.java | 3 +- .../zen/PublishClusterStateActionTests.java | 5 +- .../discovery/zen/UnicastZenPingTests.java | 14 +- .../transport/ConnectionProfileTests.java | 8 +- .../transport/PublishPortTests.java | 4 +- .../transport/RemoteClusterServiceTests.java | 4 +- .../test/InternalTestCluster.java | 15 +- .../test/transport/MockTransportService.java | 12 +- .../AbstractSimpleTransportTestCase.java | 28 ++-- .../transport/MockTcpTransport.java | 12 +- .../test/test/InternalTestClusterTests.java | 4 +- .../nio/SimpleMockNioTransportTests.java | 4 +- .../netty4/SecurityNetty4Transport.java | 6 +- .../esnative/tool/CommandLineHttpClient.java | 2 +- .../security/transport/filter/IPFilter.java | 6 +- .../transport/nio/SecurityNioTransport.java | 6 +- ...stractSimpleSecurityTransportTestCase.java | 5 +- .../transport/ServerTransportFilterTests.java | 4 +- .../netty4/IPHostnameVerificationTests.java | 4 +- ...pleSecurityNetty4ServerTransportTests.java | 6 +- .../nio/SimpleSecurityNioTransportTests.java | 6 +- 49 files changed, 352 insertions(+), 289 deletions(-) create mode 100644 server/src/main/java/org/elasticsearch/transport/TransportSettings.java 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 8e8a8abcc377f..4823bbbc3d7ff 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 @@ -56,6 +56,7 @@ import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TcpTransport; +import org.elasticsearch.transport.TransportSettings; import java.io.IOException; import java.net.InetSocketAddress; @@ -149,22 +150,22 @@ private Bootstrap createClientBootstrap(NioEventLoopGroup eventLoopGroup) { bootstrap.group(eventLoopGroup); bootstrap.channel(NioSocketChannel.class); - bootstrap.option(ChannelOption.TCP_NODELAY, TCP_NO_DELAY.get(settings)); - bootstrap.option(ChannelOption.SO_KEEPALIVE, TCP_KEEP_ALIVE.get(settings)); + bootstrap.option(ChannelOption.TCP_NODELAY, TransportSettings.TCP_NO_DELAY.get(settings)); + bootstrap.option(ChannelOption.SO_KEEPALIVE, TransportSettings.TCP_KEEP_ALIVE.get(settings)); - final ByteSizeValue tcpSendBufferSize = TCP_SEND_BUFFER_SIZE.get(settings); + final ByteSizeValue tcpSendBufferSize = TransportSettings.TCP_SEND_BUFFER_SIZE.get(settings); if (tcpSendBufferSize.getBytes() > 0) { bootstrap.option(ChannelOption.SO_SNDBUF, Math.toIntExact(tcpSendBufferSize.getBytes())); } - final ByteSizeValue tcpReceiveBufferSize = TCP_RECEIVE_BUFFER_SIZE.get(settings); + final ByteSizeValue tcpReceiveBufferSize = TransportSettings.TCP_RECEIVE_BUFFER_SIZE.get(settings); if (tcpReceiveBufferSize.getBytes() > 0) { bootstrap.option(ChannelOption.SO_RCVBUF, Math.toIntExact(tcpReceiveBufferSize.getBytes())); } bootstrap.option(ChannelOption.RCVBUF_ALLOCATOR, recvByteBufAllocator); - final boolean reuseAddress = TCP_REUSE_ADDRESS.get(settings); + final boolean reuseAddress = TransportSettings.TCP_REUSE_ADDRESS.get(settings); bootstrap.option(ChannelOption.SO_REUSEADDR, reuseAddress); return bootstrap; diff --git a/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/Netty4SizeHeaderFrameDecoderTests.java b/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/Netty4SizeHeaderFrameDecoderTests.java index f467a8ad8f3bf..0e90559bd51b0 100644 --- a/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/Netty4SizeHeaderFrameDecoderTests.java +++ b/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/Netty4SizeHeaderFrameDecoderTests.java @@ -30,7 +30,7 @@ import org.elasticsearch.mocksocket.MockSocket; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.transport.TcpTransport; +import org.elasticsearch.transport.TransportSettings; import org.junit.After; import org.junit.Before; @@ -51,8 +51,8 @@ public class Netty4SizeHeaderFrameDecoderTests extends ESTestCase { private final Settings settings = Settings.builder() .put("node.name", "NettySizeHeaderFrameDecoderTests") - .put(TcpTransport.BIND_HOST.getKey(), "127.0.0.1") - .put(TcpTransport.PORT.getKey(), "0") + .put(TransportSettings.BIND_HOST.getKey(), "127.0.0.1") + .put(TransportSettings.PORT.getKey(), "0") .build(); private ThreadPool threadPool; diff --git a/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/Netty4TransportIT.java b/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/Netty4TransportIT.java index ae0109a83b0d9..28d32f50bfc69 100644 --- a/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/Netty4TransportIT.java +++ b/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/Netty4TransportIT.java @@ -37,8 +37,8 @@ import org.elasticsearch.test.ESIntegTestCase.Scope; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TcpChannel; -import org.elasticsearch.transport.TcpTransport; import org.elasticsearch.transport.Transport; +import org.elasticsearch.transport.TransportSettings; import java.io.IOException; import java.net.InetSocketAddress; @@ -80,7 +80,7 @@ public void testThatConnectionFailsAsIntended() throws Exception { fail("Expected exception, but didn't happen"); } catch (ElasticsearchException e) { assertThat(e.getMessage(), containsString("MY MESSAGE")); - assertThat(channelProfileName, is(TcpTransport.DEFAULT_PROFILE)); + assertThat(channelProfileName, is(TransportSettings.DEFAULT_PROFILE)); } } @@ -116,7 +116,7 @@ protected String handleRequest(TcpChannel channel, String profileName, InetSocketAddress remoteAddress, byte status) throws IOException { String action = super.handleRequest(channel, profileName, stream, requestId, messageLengthBytes, version, remoteAddress, status); - channelProfileName = TcpTransport.DEFAULT_PROFILE; + channelProfileName = TransportSettings.DEFAULT_PROFILE; return action; } diff --git a/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/NettyTransportMultiPortTests.java b/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/NettyTransportMultiPortTests.java index ecb720173f726..5d3e897202cbc 100644 --- a/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/NettyTransportMultiPortTests.java +++ b/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/NettyTransportMultiPortTests.java @@ -31,6 +31,7 @@ import org.elasticsearch.threadpool.TestThreadPool; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TcpTransport; +import org.elasticsearch.transport.TransportSettings; import org.junit.Before; import java.util.Collections; @@ -53,7 +54,7 @@ public void setup() { public void testThatNettyCanBindToMultiplePorts() throws Exception { Settings settings = Settings.builder() .put("network.host", host) - .put(TcpTransport.PORT.getKey(), 22) // will not actually bind to this + .put(TransportSettings.PORT.getKey(), 22) // will not actually bind to this .put("transport.profiles.default.port", 0) .put("transport.profiles.client1.port", 0) .build(); @@ -70,7 +71,7 @@ public void testThatNettyCanBindToMultiplePorts() throws Exception { public void testThatDefaultProfileInheritsFromStandardSettings() throws Exception { Settings settings = Settings.builder() .put("network.host", host) - .put(TcpTransport.PORT.getKey(), 0) + .put(TransportSettings.PORT.getKey(), 0) .put("transport.profiles.client1.port", 0) .build(); @@ -87,7 +88,7 @@ public void testThatProfileWithoutPortSettingsFails() throws Exception { Settings settings = Settings.builder() .put("network.host", host) - .put(TcpTransport.PORT.getKey(), 0) + .put(TransportSettings.PORT.getKey(), 0) .put("transport.profiles.client1.whatever", "foo") .build(); @@ -103,7 +104,7 @@ public void testThatProfileWithoutPortSettingsFails() throws Exception { public void testThatDefaultProfilePortOverridesGeneralConfiguration() throws Exception { Settings settings = Settings.builder() .put("network.host", host) - .put(TcpTransport.PORT.getKey(), 22) // will not actually bind to this + .put(TransportSettings.PORT.getKey(), 22) // will not actually bind to this .put("transport.profiles.default.port", 0) .build(); diff --git a/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/SimpleNetty4TransportTests.java b/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/SimpleNetty4TransportTests.java index 5c3279eaf159c..b60f720bae14f 100644 --- a/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/SimpleNetty4TransportTests.java +++ b/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/SimpleNetty4TransportTests.java @@ -37,9 +37,8 @@ import org.elasticsearch.transport.ConnectTransportException; import org.elasticsearch.transport.ConnectionProfile; import org.elasticsearch.transport.TcpChannel; -import org.elasticsearch.transport.TcpTransport; import org.elasticsearch.transport.Transport; -import org.elasticsearch.transport.TransportService; +import org.elasticsearch.transport.TransportSettings; import java.net.InetAddress; import java.net.UnknownHostException; @@ -75,7 +74,7 @@ public void executeHandshake(DiscoveryNode node, TcpChannel channel, ConnectionP @Override protected MockTransportService build(Settings settings, Version version, ClusterSettings clusterSettings, boolean doHandshake) { - settings = Settings.builder().put(settings).put(TcpTransport.PORT.getKey(), "0").build(); + settings = Settings.builder().put(settings).put(TransportSettings.PORT.getKey(), "0").build(); MockTransportService transportService = nettyFromThreadPool(settings, threadPool, version, clusterSettings, doHandshake); transportService.start(); return transportService; @@ -97,8 +96,8 @@ public void testBindUnavailableAddress() { int port = serviceA.boundAddress().publishAddress().getPort(); Settings settings = Settings.builder() .put(Node.NODE_NAME_SETTING.getKey(), "foobar") - .put(TransportService.TRACE_LOG_INCLUDE_SETTING.getKey(), "") - .put(TransportService.TRACE_LOG_EXCLUDE_SETTING.getKey(), "NOTHING") + .put(TransportSettings.TRACE_LOG_INCLUDE_SETTING.getKey(), "") + .put(TransportSettings.TRACE_LOG_EXCLUDE_SETTING.getKey(), "NOTHING") .put("transport.tcp.port", port) .build(); ClusterSettings clusterSettings = new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); diff --git a/plugins/discovery-azure-classic/src/main/java/org/elasticsearch/discovery/azure/classic/AzureUnicastHostsProvider.java b/plugins/discovery-azure-classic/src/main/java/org/elasticsearch/discovery/azure/classic/AzureUnicastHostsProvider.java index 2d46ec0986296..576bdc7b2426a 100644 --- a/plugins/discovery-azure-classic/src/main/java/org/elasticsearch/discovery/azure/classic/AzureUnicastHostsProvider.java +++ b/plugins/discovery-azure-classic/src/main/java/org/elasticsearch/discovery/azure/classic/AzureUnicastHostsProvider.java @@ -166,7 +166,7 @@ public List buildDynamicHosts(HostsResolver hostsResolver) { InetAddress ipAddress = null; try { ipAddress = networkService.resolvePublishHostAddresses( - NetworkService.GLOBAL_NETWORK_PUBLISHHOST_SETTING.get(settings).toArray(Strings.EMPTY_ARRAY)); + NetworkService.GLOBAL_NETWORK_PUBLISH_HOST_SETTING.get(settings).toArray(Strings.EMPTY_ARRAY)); logger.trace("ip of current node: [{}]", ipAddress); } catch (IOException e) { // We can't find the publish host address... Hmmm. Too bad :-( diff --git a/plugins/discovery-azure-classic/src/test/java/org/elasticsearch/discovery/azure/classic/AzureDiscoveryClusterFormationTests.java b/plugins/discovery-azure-classic/src/test/java/org/elasticsearch/discovery/azure/classic/AzureDiscoveryClusterFormationTests.java index 35c2e7336a7d6..a833d196ed502 100644 --- a/plugins/discovery-azure-classic/src/test/java/org/elasticsearch/discovery/azure/classic/AzureDiscoveryClusterFormationTests.java +++ b/plugins/discovery-azure-classic/src/test/java/org/elasticsearch/discovery/azure/classic/AzureDiscoveryClusterFormationTests.java @@ -37,7 +37,7 @@ import org.elasticsearch.plugin.discovery.azure.classic.AzureDiscoveryPlugin; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESIntegTestCase; -import org.elasticsearch.transport.TcpTransport; +import org.elasticsearch.transport.TransportSettings; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.ClassRule; @@ -118,7 +118,7 @@ protected Settings nodeSettings(int nodeOrdinal) { return Settings.builder().put(super.nodeSettings(nodeOrdinal)) .put(DiscoveryModule.DISCOVERY_HOSTS_PROVIDER_SETTING.getKey(), AzureDiscoveryPlugin.AZURE) .put(Environment.PATH_LOGS_SETTING.getKey(), resolve) - .put(TcpTransport.PORT.getKey(), 0) + .put(TransportSettings.PORT.getKey(), 0) .put(Node.WRITE_PORTS_FILE_SETTING.getKey(), "true") .put(AzureComputeService.Management.ENDPOINT_SETTING.getKey(), "https://" + InetAddress.getLoopbackAddress().getHostAddress() + ":" + httpsServer.getAddress().getPort()) diff --git a/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2NetworkTests.java b/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2NetworkTests.java index dedf56b836eb3..9e7f2429b08b6 100644 --- a/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2NetworkTests.java +++ b/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2NetworkTests.java @@ -164,7 +164,7 @@ private InetAddress[] resolveEc2(String host, InetAddress ... expected) throws I NetworkService networkService = new NetworkService(Collections.singletonList(new Ec2NameResolver())); InetAddress[] addresses = networkService.resolveBindHostAddresses( - NetworkService.GLOBAL_NETWORK_BINDHOST_SETTING.get(nodeSettings).toArray(Strings.EMPTY_ARRAY)); + NetworkService.GLOBAL_NETWORK_BIND_HOST_SETTING.get(nodeSettings).toArray(Strings.EMPTY_ARRAY)); if (expected == null) { fail("We should get an IOException, resolved addressed:" + Arrays.toString(addresses)); } diff --git a/plugins/discovery-gce/src/main/java/org/elasticsearch/discovery/gce/GceUnicastHostsProvider.java b/plugins/discovery-gce/src/main/java/org/elasticsearch/discovery/gce/GceUnicastHostsProvider.java index a593faabcf622..4b733dd6823ef 100644 --- a/plugins/discovery-gce/src/main/java/org/elasticsearch/discovery/gce/GceUnicastHostsProvider.java +++ b/plugins/discovery-gce/src/main/java/org/elasticsearch/discovery/gce/GceUnicastHostsProvider.java @@ -120,7 +120,7 @@ public List buildDynamicHosts(HostsResolver hostsResolver) { String ipAddress = null; try { InetAddress inetAddress = networkService.resolvePublishHostAddresses( - NetworkService.GLOBAL_NETWORK_PUBLISHHOST_SETTING.get(settings).toArray(Strings.EMPTY_ARRAY)); + NetworkService.GLOBAL_NETWORK_PUBLISH_HOST_SETTING.get(settings).toArray(Strings.EMPTY_ARRAY)); if (inetAddress != null) { ipAddress = NetworkAddress.format(inetAddress); } diff --git a/plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/GceNetworkTests.java b/plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/GceNetworkTests.java index 94f2959917d5b..c72173dd20a17 100644 --- a/plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/GceNetworkTests.java +++ b/plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/GceNetworkTests.java @@ -110,7 +110,7 @@ private void resolveGce(String gceNetworkSetting, InetAddress[] expected) throws NetworkService networkService = new NetworkService(Collections.singletonList(new GceNameResolver(mock))); try { InetAddress[] addresses = networkService.resolveBindHostAddresses( - NetworkService.GLOBAL_NETWORK_BINDHOST_SETTING.get(nodeSettings).toArray(Strings.EMPTY_ARRAY)); + NetworkService.GLOBAL_NETWORK_BIND_HOST_SETTING.get(nodeSettings).toArray(Strings.EMPTY_ARRAY)); if (expected == null) { fail("We should get a IllegalArgumentException when setting network.host: _gce:doesnotexist_"); } diff --git a/plugins/transport-nio/src/test/java/org/elasticsearch/transport/nio/NioTransportIT.java b/plugins/transport-nio/src/test/java/org/elasticsearch/transport/nio/NioTransportIT.java index c6452e0be91e3..61f07aa016207 100644 --- a/plugins/transport-nio/src/test/java/org/elasticsearch/transport/nio/NioTransportIT.java +++ b/plugins/transport-nio/src/test/java/org/elasticsearch/transport/nio/NioTransportIT.java @@ -37,8 +37,8 @@ import org.elasticsearch.test.ESIntegTestCase.Scope; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TcpChannel; -import org.elasticsearch.transport.TcpTransport; import org.elasticsearch.transport.Transport; +import org.elasticsearch.transport.TransportSettings; import java.io.IOException; import java.net.InetSocketAddress; @@ -80,7 +80,7 @@ public void testThatConnectionFailsAsIntended() throws Exception { fail("Expected exception, but didn't happen"); } catch (ElasticsearchException e) { assertThat(e.getMessage(), containsString("MY MESSAGE")); - assertThat(channelProfileName, is(TcpTransport.DEFAULT_PROFILE)); + assertThat(channelProfileName, is(TransportSettings.DEFAULT_PROFILE)); } } @@ -112,7 +112,7 @@ protected String handleRequest(TcpChannel channel, String profileName, InetSocketAddress remoteAddress, byte status) throws IOException { String action = super.handleRequest(channel, profileName, stream, requestId, messageLengthBytes, version, remoteAddress, status); - channelProfileName = TcpTransport.DEFAULT_PROFILE; + channelProfileName = TransportSettings.DEFAULT_PROFILE; return action; } diff --git a/plugins/transport-nio/src/test/java/org/elasticsearch/transport/nio/SimpleNioTransportTests.java b/plugins/transport-nio/src/test/java/org/elasticsearch/transport/nio/SimpleNioTransportTests.java index 9dd3bc3b9570b..a762ec169b8bc 100644 --- a/plugins/transport-nio/src/test/java/org/elasticsearch/transport/nio/SimpleNioTransportTests.java +++ b/plugins/transport-nio/src/test/java/org/elasticsearch/transport/nio/SimpleNioTransportTests.java @@ -37,9 +37,8 @@ import org.elasticsearch.transport.ConnectTransportException; import org.elasticsearch.transport.ConnectionProfile; import org.elasticsearch.transport.TcpChannel; -import org.elasticsearch.transport.TcpTransport; import org.elasticsearch.transport.Transport; -import org.elasticsearch.transport.TransportService; +import org.elasticsearch.transport.TransportSettings; import java.io.IOException; import java.net.InetAddress; @@ -79,7 +78,7 @@ public void executeHandshake(DiscoveryNode node, TcpChannel channel, ConnectionP @Override protected MockTransportService build(Settings settings, Version version, ClusterSettings clusterSettings, boolean doHandshake) { settings = Settings.builder().put(settings) - .put(TcpTransport.PORT.getKey(), "0") + .put(TransportSettings.PORT.getKey(), "0") .build(); MockTransportService transportService = nioFromThreadPool(settings, threadPool, version, clusterSettings, doHandshake); transportService.start(); @@ -104,8 +103,8 @@ public void testBindUnavailableAddress() { int port = serviceA.boundAddress().publishAddress().getPort(); Settings settings = Settings.builder() .put(Node.NODE_NAME_SETTING.getKey(), "foobar") - .put(TransportService.TRACE_LOG_INCLUDE_SETTING.getKey(), "") - .put(TransportService.TRACE_LOG_EXCLUDE_SETTING.getKey(), "NOTHING") + .put(TransportSettings.TRACE_LOG_INCLUDE_SETTING.getKey(), "") + .put(TransportSettings.TRACE_LOG_EXCLUDE_SETTING.getKey(), "NOTHING") .put("transport.tcp.port", port) .build(); ClusterSettings clusterSettings = new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); diff --git a/server/src/main/java/org/elasticsearch/bootstrap/Security.java b/server/src/main/java/org/elasticsearch/bootstrap/Security.java index 734b15d509877..2a537186f6af8 100644 --- a/server/src/main/java/org/elasticsearch/bootstrap/Security.java +++ b/server/src/main/java/org/elasticsearch/bootstrap/Security.java @@ -29,6 +29,7 @@ import org.elasticsearch.plugins.PluginsService; import org.elasticsearch.secure_sm.SecureSM; import org.elasticsearch.transport.TcpTransport; +import org.elasticsearch.transport.TransportSettings; import java.io.IOException; import java.net.SocketPermission; @@ -368,7 +369,7 @@ private static void addSocketPermissionForTransportProfiles(final Permissions po * @param settings the {@link Settings} instance to read the transport settings from */ private static void addSocketPermissionForTransport(final Permissions policy, final Settings settings) { - final String transportRange = TcpTransport.PORT.get(settings); + final String transportRange = TransportSettings.PORT.get(settings); addSocketPermissionForPortRange(policy, transportRange); } diff --git a/server/src/main/java/org/elasticsearch/client/transport/TransportClient.java b/server/src/main/java/org/elasticsearch/client/transport/TransportClient.java index 8450fe8d714ef..b5720c023f095 100644 --- a/server/src/main/java/org/elasticsearch/client/transport/TransportClient.java +++ b/server/src/main/java/org/elasticsearch/client/transport/TransportClient.java @@ -57,9 +57,9 @@ import org.elasticsearch.search.SearchModule; import org.elasticsearch.threadpool.ExecutorBuilder; import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.transport.TcpTransport; import org.elasticsearch.transport.Transport; import org.elasticsearch.transport.TransportService; +import org.elasticsearch.transport.TransportSettings; import java.io.Closeable; import java.util.ArrayList; @@ -102,7 +102,7 @@ public abstract class TransportClient extends AbstractClient { private static PluginsService newPluginService(final Settings settings, Collection> plugins) { final Settings.Builder settingsBuilder = Settings.builder() - .put(TcpTransport.PING_SCHEDULE.getKey(), "5s") // enable by default the transport schedule ping interval + .put(TransportSettings.PING_SCHEDULE.getKey(), "5s") // enable by default the transport schedule ping interval .put(InternalSettingsPreparer.prepareSettings(settings)) .put(NetworkService.NETWORK_SERVER.getKey(), false) .put(CLIENT_TYPE_SETTING_S.getKey(), CLIENT_TYPE); @@ -136,7 +136,7 @@ private static ClientTemplate buildTemplate(Settings providedSettings, Settings Settings.builder() .put(defaultSettings) .put(pluginsService.updatedSettings()) - .put(TcpTransport.FEATURE_PREFIX + "." + TRANSPORT_CLIENT_FEATURE, true) + .put(TransportSettings.FEATURE_PREFIX + "." + TRANSPORT_CLIENT_FEATURE, true) .build(); final List resourcesToClose = new ArrayList<>(); final ThreadPool threadPool = new ThreadPool(settings); diff --git a/server/src/main/java/org/elasticsearch/common/network/NetworkService.java b/server/src/main/java/org/elasticsearch/common/network/NetworkService.java index de4aee289d336..a1a6d2896f1e9 100644 --- a/server/src/main/java/org/elasticsearch/common/network/NetworkService.java +++ b/server/src/main/java/org/elasticsearch/common/network/NetworkService.java @@ -41,9 +41,9 @@ public final class NetworkService { public static final String DEFAULT_NETWORK_HOST = "_local_"; public static final Setting> GLOBAL_NETWORK_HOST_SETTING = Setting.listSetting("network.host", Collections.emptyList(), Function.identity(), Property.NodeScope); - public static final Setting> GLOBAL_NETWORK_BINDHOST_SETTING = + public static final Setting> GLOBAL_NETWORK_BIND_HOST_SETTING = Setting.listSetting("network.bind_host", GLOBAL_NETWORK_HOST_SETTING, Function.identity(), Property.NodeScope); - public static final Setting> GLOBAL_NETWORK_PUBLISHHOST_SETTING = + public static final Setting> GLOBAL_NETWORK_PUBLISH_HOST_SETTING = Setting.listSetting("network.publish_host", GLOBAL_NETWORK_HOST_SETTING, Function.identity(), Property.NodeScope); public static final Setting NETWORK_SERVER = Setting.boolSetting("network.server", true, Property.NodeScope); @@ -57,6 +57,7 @@ public final class NetworkService { Setting.byteSizeSetting("network.tcp.send_buffer_size", new ByteSizeValue(-1), Property.NodeScope); public static final Setting TCP_RECEIVE_BUFFER_SIZE = Setting.byteSizeSetting("network.tcp.receive_buffer_size", new ByteSizeValue(-1), Property.NodeScope); + // TODO: Deprecate in 7.0 public static final Setting TCP_CONNECT_TIMEOUT = Setting.timeSetting("network.tcp.connect_timeout", new TimeValue(30, TimeUnit.SECONDS), Property.NodeScope); diff --git a/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java b/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java index f150650948dc2..54a5a647b25b8 100644 --- a/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java +++ b/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java @@ -104,9 +104,7 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.RemoteClusterAware; import org.elasticsearch.transport.RemoteClusterService; -import org.elasticsearch.transport.TcpTransport; -import org.elasticsearch.transport.Transport; -import org.elasticsearch.transport.TransportService; +import org.elasticsearch.transport.TransportSettings; import org.elasticsearch.watcher.ResourceWatcherService; import java.util.Arrays; @@ -307,44 +305,44 @@ public void apply(Settings value, Settings current, Settings previous) { RemoteClusterService.SEARCH_ENABLE_REMOTE_CLUSTERS, RemoteClusterService.REMOTE_CLUSTER_PING_SCHEDULE, RemoteClusterService.REMOTE_CLUSTER_COMPRESS, - TransportService.TRACE_LOG_EXCLUDE_SETTING, - TransportService.TRACE_LOG_INCLUDE_SETTING, + TransportSettings.TRACE_LOG_EXCLUDE_SETTING, + TransportSettings.TRACE_LOG_INCLUDE_SETTING, TransportCloseIndexAction.CLUSTER_INDICES_CLOSE_ENABLE_SETTING, ShardsLimitAllocationDecider.CLUSTER_TOTAL_SHARDS_PER_NODE_SETTING, NodeConnectionsService.CLUSTER_NODE_RECONNECT_INTERVAL_SETTING, HierarchyCircuitBreakerService.FIELDDATA_CIRCUIT_BREAKER_TYPE_SETTING, HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_TYPE_SETTING, - Transport.TRANSPORT_TCP_COMPRESS, - TcpTransport.HOST, - TcpTransport.PUBLISH_HOST, - TcpTransport.BIND_HOST, - TcpTransport.PUBLISH_PORT, - TcpTransport.PORT, - TcpTransport.BIND_HOST_PROFILE, - TcpTransport.PUBLISH_HOST_PROFILE, - TcpTransport.PUBLISH_PORT_PROFILE, - TcpTransport.PORT_PROFILE, - TcpTransport.TCP_NO_DELAY_PROFILE, - TcpTransport.TCP_KEEP_ALIVE_PROFILE, - TcpTransport.TCP_REUSE_ADDRESS_PROFILE, - TcpTransport.TCP_SEND_BUFFER_SIZE_PROFILE, - TcpTransport.TCP_RECEIVE_BUFFER_SIZE_PROFILE, - TransportService.CONNECTIONS_PER_NODE_RECOVERY, - TransportService.CONNECTIONS_PER_NODE_BULK, - TransportService.CONNECTIONS_PER_NODE_REG, - TransportService.CONNECTIONS_PER_NODE_STATE, - TransportService.CONNECTIONS_PER_NODE_PING, - TransportService.TCP_CONNECT_TIMEOUT, - TcpTransport.PING_SCHEDULE, + TransportSettings.TRANSPORT_COMPRESS, + TransportSettings.HOST, + TransportSettings.PUBLISH_HOST, + TransportSettings.BIND_HOST, + TransportSettings.PUBLISH_PORT, + TransportSettings.PORT, + TransportSettings.BIND_HOST_PROFILE, + TransportSettings.PUBLISH_HOST_PROFILE, + TransportSettings.PUBLISH_PORT_PROFILE, + TransportSettings.PORT_PROFILE, + TransportSettings.TCP_NO_DELAY_PROFILE, + TransportSettings.TCP_KEEP_ALIVE_PROFILE, + TransportSettings.TCP_REUSE_ADDRESS_PROFILE, + TransportSettings.TCP_SEND_BUFFER_SIZE_PROFILE, + TransportSettings.TCP_RECEIVE_BUFFER_SIZE_PROFILE, + TransportSettings.CONNECTIONS_PER_NODE_RECOVERY, + TransportSettings.CONNECTIONS_PER_NODE_BULK, + TransportSettings.CONNECTIONS_PER_NODE_REG, + TransportSettings.CONNECTIONS_PER_NODE_STATE, + TransportSettings.CONNECTIONS_PER_NODE_PING, + TransportSettings.CONNECT_TIMEOUT, + TransportSettings.PING_SCHEDULE, NetworkService.NETWORK_SERVER, - TcpTransport.TCP_NO_DELAY, - TcpTransport.TCP_KEEP_ALIVE, - TcpTransport.TCP_REUSE_ADDRESS, - TcpTransport.TCP_SEND_BUFFER_SIZE, - TcpTransport.TCP_RECEIVE_BUFFER_SIZE, + TransportSettings.TCP_NO_DELAY, + TransportSettings.TCP_KEEP_ALIVE, + TransportSettings.TCP_REUSE_ADDRESS, + TransportSettings.TCP_SEND_BUFFER_SIZE, + TransportSettings.TCP_RECEIVE_BUFFER_SIZE, NetworkService.GLOBAL_NETWORK_HOST_SETTING, - NetworkService.GLOBAL_NETWORK_BINDHOST_SETTING, - NetworkService.GLOBAL_NETWORK_PUBLISHHOST_SETTING, + NetworkService.GLOBAL_NETWORK_BIND_HOST_SETTING, + NetworkService.GLOBAL_NETWORK_PUBLISH_HOST_SETTING, NetworkService.TCP_NO_DELAY, NetworkService.TCP_KEEP_ALIVE, NetworkService.TCP_REUSE_ADDRESS, @@ -414,7 +412,7 @@ public void apply(Settings value, Settings current, Settings previous) { ClusterModule.SHARDS_ALLOCATOR_TYPE_SETTING, EsExecutors.PROCESSORS_SETTING, ThreadContext.DEFAULT_HEADERS_SETTING, - TcpTransport.DEFAULT_FEATURES_SETTING, + TransportSettings.DEFAULT_FEATURES_SETTING, Loggers.LOG_DEFAULT_LEVEL_SETTING, Loggers.LOG_LEVEL_SETTING, NodeEnvironment.MAX_LOCAL_STORAGE_NODES_SETTING, diff --git a/server/src/main/java/org/elasticsearch/http/AbstractHttpServerTransport.java b/server/src/main/java/org/elasticsearch/http/AbstractHttpServerTransport.java index 1afe3acba48ef..4b53ac902d96c 100644 --- a/server/src/main/java/org/elasticsearch/http/AbstractHttpServerTransport.java +++ b/server/src/main/java/org/elasticsearch/http/AbstractHttpServerTransport.java @@ -98,11 +98,11 @@ protected AbstractHttpServerTransport(Settings settings, NetworkService networkS // we can't make the network.bind_host a fallback since we already fall back to http.host hence the extra conditional here List httpBindHost = SETTING_HTTP_BIND_HOST.get(settings); - this.bindHosts = (httpBindHost.isEmpty() ? NetworkService.GLOBAL_NETWORK_BINDHOST_SETTING.get(settings) : httpBindHost) + this.bindHosts = (httpBindHost.isEmpty() ? NetworkService.GLOBAL_NETWORK_BIND_HOST_SETTING.get(settings) : httpBindHost) .toArray(Strings.EMPTY_ARRAY); // we can't make the network.publish_host a fallback since we already fall back to http.host hence the extra conditional here List httpPublishHost = SETTING_HTTP_PUBLISH_HOST.get(settings); - this.publishHosts = (httpPublishHost.isEmpty() ? NetworkService.GLOBAL_NETWORK_PUBLISHHOST_SETTING.get(settings) : httpPublishHost) + this.publishHosts = (httpPublishHost.isEmpty() ? NetworkService.GLOBAL_NETWORK_PUBLISH_HOST_SETTING.get(settings) : httpPublishHost) .toArray(Strings.EMPTY_ARRAY); this.port = SETTING_HTTP_PORT.get(settings); diff --git a/server/src/main/java/org/elasticsearch/plugins/PluginsService.java b/server/src/main/java/org/elasticsearch/plugins/PluginsService.java index 2ad9a0892b8f6..2837add3c907b 100644 --- a/server/src/main/java/org/elasticsearch/plugins/PluginsService.java +++ b/server/src/main/java/org/elasticsearch/plugins/PluginsService.java @@ -41,7 +41,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.IndexModule; import org.elasticsearch.threadpool.ExecutorBuilder; -import org.elasticsearch.transport.TcpTransport; +import org.elasticsearch.transport.TransportSettings; import java.io.IOException; import java.lang.reflect.Constructor; @@ -226,7 +226,7 @@ public Settings updatedSettings() { } } for (final String feature : features.keySet()) { - builder.put(TcpTransport.FEATURE_PREFIX + "." + feature, true); + builder.put(TransportSettings.FEATURE_PREFIX + "." + feature, true); } return builder.put(this.settings).build(); } diff --git a/server/src/main/java/org/elasticsearch/transport/ConnectionProfile.java b/server/src/main/java/org/elasticsearch/transport/ConnectionProfile.java index bcab23c1fbdd6..07d4818ffafa1 100644 --- a/server/src/main/java/org/elasticsearch/transport/ConnectionProfile.java +++ b/server/src/main/java/org/elasticsearch/transport/ConnectionProfile.java @@ -73,16 +73,16 @@ public static ConnectionProfile resolveConnectionProfile(@Nullable ConnectionPro * @return the connection profile */ public static ConnectionProfile buildDefaultConnectionProfile(Settings settings) { - int connectionsPerNodeRecovery = TransportService.CONNECTIONS_PER_NODE_RECOVERY.get(settings); - int connectionsPerNodeBulk = TransportService.CONNECTIONS_PER_NODE_BULK.get(settings); - int connectionsPerNodeReg = TransportService.CONNECTIONS_PER_NODE_REG.get(settings); - int connectionsPerNodeState = TransportService.CONNECTIONS_PER_NODE_STATE.get(settings); - int connectionsPerNodePing = TransportService.CONNECTIONS_PER_NODE_PING.get(settings); + int connectionsPerNodeRecovery = TransportSettings.CONNECTIONS_PER_NODE_RECOVERY.get(settings); + int connectionsPerNodeBulk = TransportSettings.CONNECTIONS_PER_NODE_BULK.get(settings); + int connectionsPerNodeReg = TransportSettings.CONNECTIONS_PER_NODE_REG.get(settings); + int connectionsPerNodeState = TransportSettings.CONNECTIONS_PER_NODE_STATE.get(settings); + int connectionsPerNodePing = TransportSettings.CONNECTIONS_PER_NODE_PING.get(settings); Builder builder = new Builder(); - builder.setConnectTimeout(TransportService.TCP_CONNECT_TIMEOUT.get(settings)); - builder.setHandshakeTimeout(TransportService.TCP_CONNECT_TIMEOUT.get(settings)); - builder.setPingInterval(TcpTransport.PING_SCHEDULE.get(settings)); - builder.setCompressionEnabled(Transport.TRANSPORT_TCP_COMPRESS.get(settings)); + builder.setConnectTimeout(TransportSettings.CONNECT_TIMEOUT.get(settings)); + builder.setHandshakeTimeout(TransportSettings.CONNECT_TIMEOUT.get(settings)); + builder.setPingInterval(TransportSettings.PING_SCHEDULE.get(settings)); + builder.setCompressionEnabled(TransportSettings.TRANSPORT_COMPRESS.get(settings)); builder.addConnections(connectionsPerNodeBulk, TransportRequestOptions.Type.BULK); builder.addConnections(connectionsPerNodePing, TransportRequestOptions.Type.PING); // if we are not master eligible we don't need a dedicated channel to publish the state diff --git a/server/src/main/java/org/elasticsearch/transport/RemoteClusterConnection.java b/server/src/main/java/org/elasticsearch/transport/RemoteClusterConnection.java index 674cf5ae8d356..87dd99e6590f2 100644 --- a/server/src/main/java/org/elasticsearch/transport/RemoteClusterConnection.java +++ b/server/src/main/java/org/elasticsearch/transport/RemoteClusterConnection.java @@ -738,8 +738,8 @@ private synchronized void ensureIteratorAvailable() { private static ConnectionManager createConnectionManager(Settings settings, String clusterAlias, TransportService transportService) { ConnectionProfile.Builder builder = new ConnectionProfile.Builder() - .setConnectTimeout(TransportService.TCP_CONNECT_TIMEOUT.get(settings)) - .setHandshakeTimeout(TransportService.TCP_CONNECT_TIMEOUT.get(settings)) + .setConnectTimeout(TransportSettings.CONNECT_TIMEOUT.get(settings)) + .setHandshakeTimeout(TransportSettings.CONNECT_TIMEOUT.get(settings)) .addConnections(6, TransportRequestOptions.Type.REG, TransportRequestOptions.Type.PING) // TODO make this configurable? // we don't want this to be used for anything else but search .addConnections(0, TransportRequestOptions.Type.BULK, diff --git a/server/src/main/java/org/elasticsearch/transport/RemoteClusterService.java b/server/src/main/java/org/elasticsearch/transport/RemoteClusterService.java index 52da474f2dd4a..fda0b90f19ea5 100644 --- a/server/src/main/java/org/elasticsearch/transport/RemoteClusterService.java +++ b/server/src/main/java/org/elasticsearch/transport/RemoteClusterService.java @@ -174,13 +174,13 @@ public String getKey(final String key) { public static final Setting.AffixSetting REMOTE_CLUSTER_PING_SCHEDULE = Setting.affixKeySetting( "cluster.remote.", "transport.ping_schedule", - key -> timeSetting(key, TcpTransport.PING_SCHEDULE, Setting.Property.NodeScope), + key -> timeSetting(key, TransportSettings.PING_SCHEDULE, Setting.Property.NodeScope), REMOTE_CLUSTERS_SEEDS); public static final Setting.AffixSetting REMOTE_CLUSTER_COMPRESS = Setting.affixKeySetting( "cluster.remote.", "transport.compress", - key -> boolSetting(key, Transport.TRANSPORT_TCP_COMPRESS, Setting.Property.NodeScope), + key -> boolSetting(key, TransportSettings.TRANSPORT_COMPRESS, Setting.Property.NodeScope), REMOTE_CLUSTERS_SEEDS); private static final Predicate DEFAULT_NODE_PREDICATE = (node) -> Version.CURRENT.isCompatible(node.getVersion()) diff --git a/server/src/main/java/org/elasticsearch/transport/TcpTransport.java b/server/src/main/java/org/elasticsearch/transport/TcpTransport.java index 1b408afde063e..6e9ab8a94980d 100644 --- a/server/src/main/java/org/elasticsearch/transport/TcpTransport.java +++ b/server/src/main/java/org/elasticsearch/transport/TcpTransport.java @@ -100,17 +100,10 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; -import java.util.function.Function; import java.util.regex.Matcher; import java.util.regex.Pattern; -import static java.util.Collections.emptyList; import static java.util.Collections.unmodifiableMap; -import static org.elasticsearch.common.settings.Setting.affixKeySetting; -import static org.elasticsearch.common.settings.Setting.boolSetting; -import static org.elasticsearch.common.settings.Setting.intSetting; -import static org.elasticsearch.common.settings.Setting.listSetting; -import static org.elasticsearch.common.settings.Setting.timeSetting; import static org.elasticsearch.common.transport.NetworkExceptionHelper.isCloseConnectionException; import static org.elasticsearch.common.transport.NetworkExceptionHelper.isConnectException; import static org.elasticsearch.common.util.concurrent.ConcurrentCollections.newConcurrentMap; @@ -120,59 +113,12 @@ public abstract class TcpTransport extends AbstractLifecycleComponent implements public static final String TRANSPORT_WORKER_THREAD_NAME_PREFIX = "transport_worker"; - public static final Setting> HOST = - listSetting("transport.host", emptyList(), Function.identity(), Setting.Property.NodeScope); - public static final Setting> BIND_HOST = - listSetting("transport.bind_host", HOST, Function.identity(), Setting.Property.NodeScope); - public static final Setting> PUBLISH_HOST = - listSetting("transport.publish_host", HOST, Function.identity(), Setting.Property.NodeScope); - public static final Setting PORT = - new Setting<>("transport.tcp.port", "9300-9400", Function.identity(), Setting.Property.NodeScope); - public static final Setting PUBLISH_PORT = - intSetting("transport.publish_port", -1, -1, Setting.Property.NodeScope); - public static final String DEFAULT_PROFILE = "default"; - // the scheduled internal ping interval setting, defaults to disabled (-1) - public static final Setting PING_SCHEDULE = - timeSetting("transport.ping_schedule", TimeValue.timeValueSeconds(-1), Setting.Property.NodeScope); - public static final Setting TCP_NO_DELAY = - boolSetting("transport.tcp_no_delay", NetworkService.TCP_NO_DELAY, Setting.Property.NodeScope); - public static final Setting TCP_KEEP_ALIVE = - boolSetting("transport.tcp.keep_alive", NetworkService.TCP_KEEP_ALIVE, Setting.Property.NodeScope); - public static final Setting TCP_REUSE_ADDRESS = - boolSetting("transport.tcp.reuse_address", NetworkService.TCP_REUSE_ADDRESS, Setting.Property.NodeScope); - public static final Setting TCP_SEND_BUFFER_SIZE = - Setting.byteSizeSetting("transport.tcp.send_buffer_size", NetworkService.TCP_SEND_BUFFER_SIZE, Setting.Property.NodeScope); - public static final Setting TCP_RECEIVE_BUFFER_SIZE = - Setting.byteSizeSetting("transport.tcp.receive_buffer_size", NetworkService.TCP_RECEIVE_BUFFER_SIZE, Setting.Property.NodeScope); - - - public static final Setting.AffixSetting TCP_NO_DELAY_PROFILE = affixKeySetting("transport.profiles.", "tcp_no_delay", - key -> boolSetting(key, TcpTransport.TCP_NO_DELAY, Setting.Property.NodeScope)); - public static final Setting.AffixSetting TCP_KEEP_ALIVE_PROFILE = affixKeySetting("transport.profiles.", "tcp_keep_alive", - key -> boolSetting(key, TcpTransport.TCP_KEEP_ALIVE, Setting.Property.NodeScope)); - public static final Setting.AffixSetting TCP_REUSE_ADDRESS_PROFILE = affixKeySetting("transport.profiles.", "reuse_address", - key -> boolSetting(key, TcpTransport.TCP_REUSE_ADDRESS, Setting.Property.NodeScope)); - public static final Setting.AffixSetting TCP_SEND_BUFFER_SIZE_PROFILE = affixKeySetting("transport.profiles.", - "send_buffer_size", key -> Setting.byteSizeSetting(key, TcpTransport.TCP_SEND_BUFFER_SIZE, Setting.Property.NodeScope)); - public static final Setting.AffixSetting TCP_RECEIVE_BUFFER_SIZE_PROFILE = affixKeySetting("transport.profiles.", - "receive_buffer_size", key -> Setting.byteSizeSetting(key, TcpTransport.TCP_RECEIVE_BUFFER_SIZE, Setting.Property.NodeScope)); - - public static final Setting.AffixSetting> BIND_HOST_PROFILE = affixKeySetting("transport.profiles.", "bind_host", - key -> listSetting(key, BIND_HOST, Function.identity(), Setting.Property.NodeScope)); - public static final Setting.AffixSetting> PUBLISH_HOST_PROFILE = affixKeySetting("transport.profiles.", "publish_host", - key -> listSetting(key, PUBLISH_HOST, Function.identity(), Setting.Property.NodeScope)); - public static final Setting.AffixSetting PORT_PROFILE = affixKeySetting("transport.profiles.", "port", - key -> new Setting<>(key, PORT, Function.identity(), Setting.Property.NodeScope)); - public static final Setting.AffixSetting PUBLISH_PORT_PROFILE = affixKeySetting("transport.profiles.", "publish_port", - key -> intSetting(key, -1, -1, Setting.Property.NodeScope)); // This is the number of bytes necessary to read the message size private static final int BYTES_NEEDED_FOR_MESSAGE_SIZE = TcpHeader.MARKER_BYTES_SIZE + TcpHeader.MESSAGE_LENGTH_SIZE; private static final long NINETY_PER_HEAP_SIZE = (long) (JvmInfo.jvmInfo().getMem().getHeapMax().getBytes() * 0.9); private static final BytesReference EMPTY_BYTES_REFERENCE = new BytesArray(new byte[0]); - public static final String FEATURE_PREFIX = "transport.features"; - public static final Setting DEFAULT_FEATURES_SETTING = Setting.groupSetting(FEATURE_PREFIX + ".", Setting.Property.NodeScope); private final String[] features; protected final Settings settings; @@ -220,7 +166,7 @@ public TcpTransport(String transportName, Settings settings, Version version, T this.pageCacheRecycler = pageCacheRecycler; this.circuitBreakerService = circuitBreakerService; this.namedWriteableRegistry = namedWriteableRegistry; - this.compressResponses = Transport.TRANSPORT_TCP_COMPRESS.get(settings); + this.compressResponses = TransportSettings.TRANSPORT_COMPRESS.get(settings); this.networkService = networkService; this.transportName = transportName; this.transportLogger = new TransportLogger(); @@ -233,7 +179,7 @@ public TcpTransport(String transportName, Settings settings, Version version, T this.keepAlive = new TransportKeepAlive(threadPool, this::internalSendMessage); this.nodeName = Node.NODE_NAME_SETTING.get(settings); - final Settings defaultFeatures = DEFAULT_FEATURES_SETTING.get(settings); + final Settings defaultFeatures = TransportSettings.DEFAULT_FEATURES_SETTING.get(settings); if (defaultFeatures == null) { this.features = new String[0]; } else { @@ -504,7 +450,7 @@ private BoundTransportAddress createBoundTransportAddress(ProfileSettings profil publishHosts = Arrays.asList(boundAddressesHostStrings); } if (publishHosts.isEmpty()) { - publishHosts = NetworkService.GLOBAL_NETWORK_PUBLISHHOST_SETTING.get(settings); + publishHosts = NetworkService.GLOBAL_NETWORK_PUBLISH_HOST_SETTING.get(settings); } final InetAddress publishInetAddress; @@ -550,15 +496,15 @@ static int resolvePublishPort(ProfileSettings profileSettings, List getProfileSettings(Settings settings) { boolean isDefaultSet = false; for (String profile : settings.getGroups("transport.profiles.", true).keySet()) { profiles.add(new ProfileSettings(settings, profile)); - if (DEFAULT_PROFILE.equals(profile)) { + if (TransportSettings.DEFAULT_PROFILE.equals(profile)) { isDefaultSet = true; } } if (isDefaultSet == false) { - profiles.add(new ProfileSettings(settings, DEFAULT_PROFILE)); + profiles.add(new ProfileSettings(settings, TransportSettings.DEFAULT_PROFILE)); } return Collections.unmodifiableSet(profiles); } @@ -1498,23 +1444,23 @@ public static final class ProfileSettings { public ProfileSettings(Settings settings, String profileName) { this.profileName = profileName; - isDefaultProfile = DEFAULT_PROFILE.equals(profileName); - tcpKeepAlive = TCP_KEEP_ALIVE_PROFILE.getConcreteSettingForNamespace(profileName).get(settings); - tcpNoDelay = TCP_NO_DELAY_PROFILE.getConcreteSettingForNamespace(profileName).get(settings); - reuseAddress = TCP_REUSE_ADDRESS_PROFILE.getConcreteSettingForNamespace(profileName).get(settings); - sendBufferSize = TCP_SEND_BUFFER_SIZE_PROFILE.getConcreteSettingForNamespace(profileName).get(settings); - receiveBufferSize = TCP_RECEIVE_BUFFER_SIZE_PROFILE.getConcreteSettingForNamespace(profileName).get(settings); - List profileBindHosts = BIND_HOST_PROFILE.getConcreteSettingForNamespace(profileName).get(settings); - bindHosts = (profileBindHosts.isEmpty() ? NetworkService.GLOBAL_NETWORK_BINDHOST_SETTING.get(settings) + isDefaultProfile = TransportSettings.DEFAULT_PROFILE.equals(profileName); + tcpKeepAlive = TransportSettings.TCP_KEEP_ALIVE_PROFILE.getConcreteSettingForNamespace(profileName).get(settings); + tcpNoDelay = TransportSettings.TCP_NO_DELAY_PROFILE.getConcreteSettingForNamespace(profileName).get(settings); + reuseAddress = TransportSettings.TCP_REUSE_ADDRESS_PROFILE.getConcreteSettingForNamespace(profileName).get(settings); + sendBufferSize = TransportSettings.TCP_SEND_BUFFER_SIZE_PROFILE.getConcreteSettingForNamespace(profileName).get(settings); + receiveBufferSize = TransportSettings.TCP_RECEIVE_BUFFER_SIZE_PROFILE.getConcreteSettingForNamespace(profileName).get(settings); + List profileBindHosts = TransportSettings.BIND_HOST_PROFILE.getConcreteSettingForNamespace(profileName).get(settings); + bindHosts = (profileBindHosts.isEmpty() ? NetworkService.GLOBAL_NETWORK_BIND_HOST_SETTING.get(settings) : profileBindHosts); - publishHosts = PUBLISH_HOST_PROFILE.getConcreteSettingForNamespace(profileName).get(settings); - Setting concretePort = PORT_PROFILE.getConcreteSettingForNamespace(profileName); + publishHosts = TransportSettings.PUBLISH_HOST_PROFILE.getConcreteSettingForNamespace(profileName).get(settings); + Setting concretePort = TransportSettings.PORT_PROFILE.getConcreteSettingForNamespace(profileName); if (concretePort.exists(settings) == false && isDefaultProfile == false) { throw new IllegalStateException("profile [" + profileName + "] has no port configured"); } - portOrRange = PORT_PROFILE.getConcreteSettingForNamespace(profileName).get(settings); - publishPort = isDefaultProfile ? PUBLISH_PORT.get(settings) : - PUBLISH_PORT_PROFILE.getConcreteSettingForNamespace(profileName).get(settings); + portOrRange = TransportSettings.PORT_PROFILE.getConcreteSettingForNamespace(profileName).get(settings); + publishPort = isDefaultProfile ? TransportSettings.PUBLISH_PORT.get(settings) : + TransportSettings.PUBLISH_PORT_PROFILE.getConcreteSettingForNamespace(profileName).get(settings); } } diff --git a/server/src/main/java/org/elasticsearch/transport/Transport.java b/server/src/main/java/org/elasticsearch/transport/Transport.java index e44e0b7877c2f..4a8a061602a52 100644 --- a/server/src/main/java/org/elasticsearch/transport/Transport.java +++ b/server/src/main/java/org/elasticsearch/transport/Transport.java @@ -26,8 +26,6 @@ import org.elasticsearch.common.breaker.NoopCircuitBreaker; import org.elasticsearch.common.component.LifecycleComponent; import org.elasticsearch.common.lease.Releasable; -import org.elasticsearch.common.settings.Setting; -import org.elasticsearch.common.settings.Setting.Property; import org.elasticsearch.common.transport.BoundTransportAddress; import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.common.util.concurrent.ConcurrentCollections; @@ -44,8 +42,6 @@ public interface Transport extends LifecycleComponent { - Setting TRANSPORT_TCP_COMPRESS = Setting.boolSetting("transport.tcp.compress", false, Property.NodeScope); - /** * Registers a new request handler */ diff --git a/server/src/main/java/org/elasticsearch/transport/TransportService.java b/server/src/main/java/org/elasticsearch/transport/TransportService.java index c41efbe8fd2c0..55cd384fadcc5 100644 --- a/server/src/main/java/org/elasticsearch/transport/TransportService.java +++ b/server/src/main/java/org/elasticsearch/transport/TransportService.java @@ -24,7 +24,6 @@ import org.apache.logging.log4j.message.ParameterizedMessage; import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.admin.cluster.node.liveness.TransportLivenessAction; import org.elasticsearch.client.Client; import org.elasticsearch.client.transport.TransportClient; import org.elasticsearch.cluster.ClusterName; @@ -38,15 +37,11 @@ import org.elasticsearch.common.io.stream.Streamable; import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.logging.Loggers; -import org.elasticsearch.common.network.NetworkService; import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.settings.ClusterSettings; -import org.elasticsearch.common.settings.Setting; -import org.elasticsearch.common.settings.Setting.Property; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.BoundTransportAddress; import org.elasticsearch.common.transport.TransportAddress; -import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.AbstractRunnable; import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; import org.elasticsearch.common.util.concurrent.FutureUtils; @@ -75,26 +70,9 @@ import java.util.function.Predicate; import java.util.function.Supplier; -import static java.util.Collections.emptyList; -import static org.elasticsearch.common.settings.Setting.intSetting; -import static org.elasticsearch.common.settings.Setting.listSetting; -import static org.elasticsearch.common.settings.Setting.timeSetting; - public class TransportService extends AbstractLifecycleComponent implements TransportMessageListener, TransportConnectionListener { private static final Logger logger = LogManager.getLogger(TransportService.class); - public static final Setting CONNECTIONS_PER_NODE_RECOVERY = - intSetting("transport.connections_per_node.recovery", 2, 1, Setting.Property.NodeScope); - public static final Setting CONNECTIONS_PER_NODE_BULK = - intSetting("transport.connections_per_node.bulk", 3, 1, Setting.Property.NodeScope); - public static final Setting CONNECTIONS_PER_NODE_REG = - intSetting("transport.connections_per_node.reg", 6, 1, Setting.Property.NodeScope); - public static final Setting CONNECTIONS_PER_NODE_STATE = - intSetting("transport.connections_per_node.state", 1, 1, Setting.Property.NodeScope); - public static final Setting CONNECTIONS_PER_NODE_PING = - intSetting("transport.connections_per_node.ping", 1, 1, Setting.Property.NodeScope); - public static final Setting TCP_CONNECT_TIMEOUT = - timeSetting("transport.tcp.connect_timeout", NetworkService.TCP_CONNECT_TIMEOUT, Setting.Property.NodeScope); public static final String DIRECT_RESPONSE_PROFILE = ".direct"; public static final String HANDSHAKE_ACTION_NAME = "internal:transport/handshake"; @@ -124,13 +102,6 @@ protected boolean removeEldestEntry(Map.Entry eldest) { // tracer log - public static final Setting> TRACE_LOG_INCLUDE_SETTING = - listSetting("transport.tracer.include", emptyList(), Function.identity(), Property.Dynamic, Property.NodeScope); - public static final Setting> TRACE_LOG_EXCLUDE_SETTING = - listSetting("transport.tracer.exclude", - Arrays.asList("internal:discovery/zen/fd*", "internal:coordination/fault_detection/*", TransportLivenessAction.NAME), - Function.identity(), Property.Dynamic, Property.NodeScope); - private final Logger tracerLog; volatile String[] tracerLogInclude; @@ -172,7 +143,7 @@ public void close() { * Build the service. * * @param clusterSettings if non null, the {@linkplain TransportService} will register with the {@link ClusterSettings} for settings - * updates for {@link #TRACE_LOG_EXCLUDE_SETTING} and {@link #TRACE_LOG_INCLUDE_SETTING}. + * * updates for {@link TransportSettings#TRACE_LOG_EXCLUDE_SETTING} and {@link TransportSettings#TRACE_LOG_INCLUDE_SETTING}. */ public TransportService(Settings settings, Transport transport, ThreadPool threadPool, TransportInterceptor transportInterceptor, Function localNodeFactory, @Nullable ClusterSettings clusterSettings, @@ -193,8 +164,8 @@ public TransportService(Settings settings, Transport transport, ThreadPool threa this.localNodeFactory = localNodeFactory; this.connectionManager = connectionManager; this.clusterName = ClusterName.CLUSTER_NAME_SETTING.get(settings); - setTracerLogInclude(TRACE_LOG_INCLUDE_SETTING.get(settings)); - setTracerLogExclude(TRACE_LOG_EXCLUDE_SETTING.get(settings)); + setTracerLogInclude(TransportSettings.TRACE_LOG_INCLUDE_SETTING.get(settings)); + setTracerLogExclude(TransportSettings.TRACE_LOG_EXCLUDE_SETTING.get(settings)); tracerLog = Loggers.getLogger(logger, ".tracer"); taskManager = createTaskManager(settings, threadPool, taskHeaders); this.interceptor = transportInterceptor; @@ -203,8 +174,8 @@ public TransportService(Settings settings, Transport transport, ThreadPool threa remoteClusterService = new RemoteClusterService(settings, this); responseHandlers = transport.getResponseHandlers(); if (clusterSettings != null) { - clusterSettings.addSettingsUpdateConsumer(TRACE_LOG_INCLUDE_SETTING, this::setTracerLogInclude); - clusterSettings.addSettingsUpdateConsumer(TRACE_LOG_EXCLUDE_SETTING, this::setTracerLogExclude); + clusterSettings.addSettingsUpdateConsumer(TransportSettings.TRACE_LOG_INCLUDE_SETTING, this::setTracerLogInclude); + clusterSettings.addSettingsUpdateConsumer(TransportSettings.TRACE_LOG_EXCLUDE_SETTING, this::setTracerLogExclude); if (connectToRemoteCluster) { remoteClusterService.listenForUpdates(clusterSettings); } diff --git a/server/src/main/java/org/elasticsearch/transport/TransportSettings.java b/server/src/main/java/org/elasticsearch/transport/TransportSettings.java new file mode 100644 index 0000000000000..52264f3e7e45c --- /dev/null +++ b/server/src/main/java/org/elasticsearch/transport/TransportSettings.java @@ -0,0 +1,146 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.elasticsearch.transport; + +import org.elasticsearch.action.admin.cluster.node.liveness.TransportLivenessAction; +import org.elasticsearch.common.network.NetworkService; +import org.elasticsearch.common.settings.Setting; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.unit.ByteSizeValue; +import org.elasticsearch.common.unit.TimeValue; + +import java.util.Arrays; +import java.util.List; +import java.util.function.Function; + +import static java.util.Collections.emptyList; +import static org.elasticsearch.common.settings.Setting.affixKeySetting; +import static org.elasticsearch.common.settings.Setting.boolSetting; +import static org.elasticsearch.common.settings.Setting.intSetting; +import static org.elasticsearch.common.settings.Setting.listSetting; +import static org.elasticsearch.common.settings.Setting.timeSetting; + +public class TransportSettings { + + public static final String DEFAULT_PROFILE = "default"; + public static final String FEATURE_PREFIX = "transport.features"; + + public static final Setting> HOST = + listSetting("transport.host", emptyList(), Function.identity(), Setting.Property.NodeScope); + public static final Setting> PUBLISH_HOST = + listSetting("transport.publish_host", HOST, Function.identity(), Setting.Property.NodeScope); + public static final Setting.AffixSetting> PUBLISH_HOST_PROFILE = + affixKeySetting("transport.profiles.", "publish_host", key -> listSetting(key, PUBLISH_HOST, Function.identity(), + Setting.Property.NodeScope)); + public static final Setting> BIND_HOST = + listSetting("transport.bind_host", HOST, Function.identity(), Setting.Property.NodeScope); + public static final Setting.AffixSetting> BIND_HOST_PROFILE = affixKeySetting("transport.profiles.", "bind_host", + key -> listSetting(key, BIND_HOST, Function.identity(), Setting.Property.NodeScope)); + // TODO: Deprecate in 7.0 + public static final Setting OLD_PORT = + new Setting<>("transport.tcp.port", "9300-9400", Function.identity(), Setting.Property.NodeScope); + public static final Setting PORT = + new Setting<>("transport.port", OLD_PORT, Function.identity(), Setting.Property.NodeScope); + public static final Setting.AffixSetting PORT_PROFILE = affixKeySetting("transport.profiles.", "port", + key -> new Setting<>(key, PORT, Function.identity(), Setting.Property.NodeScope)); + public static final Setting PUBLISH_PORT = + intSetting("transport.publish_port", -1, -1, Setting.Property.NodeScope); + // TODO: Deprecate in 7.0 + public static final Setting OLD_TRANSPORT_COMPRESS = + boolSetting("transport.tcp.compress", false, Setting.Property.NodeScope); + public static final Setting TRANSPORT_COMPRESS = boolSetting("transport.compress", OLD_TRANSPORT_COMPRESS, + Setting.Property.NodeScope); + // the scheduled internal ping interval setting, defaults to disabled (-1) + public static final Setting PING_SCHEDULE = + timeSetting("transport.ping_schedule", TimeValue.timeValueSeconds(-1), Setting.Property.NodeScope); + public static final Setting TCP_CONNECT_TIMEOUT = + timeSetting("transport.tcp.connect_timeout", NetworkService.TCP_CONNECT_TIMEOUT, Setting.Property.NodeScope); + public static final Setting CONNECT_TIMEOUT = + timeSetting("transport.connect_timeout", TCP_CONNECT_TIMEOUT, Setting.Property.NodeScope); + public static final Setting.AffixSetting PUBLISH_PORT_PROFILE = affixKeySetting("transport.profiles.", "publish_port", + key -> intSetting(key, -1, -1, Setting.Property.NodeScope)); + public static final Setting DEFAULT_FEATURES_SETTING = Setting.groupSetting(FEATURE_PREFIX + ".", Setting.Property.NodeScope); + + // Tcp socket settings + + // TODO: Deprecate in 7.0 + public static final Setting OLD_TCP_NO_DELAY = + boolSetting("transport.tcp_no_delay", NetworkService.TCP_NO_DELAY, Setting.Property.NodeScope); + public static final Setting TCP_NO_DELAY = + boolSetting("transport.tcp.no_delay", OLD_TCP_NO_DELAY, Setting.Property.NodeScope); + // TODO: Deprecate in 7.0 + public static final Setting.AffixSetting OLD_TCP_NO_DELAY_PROFILE = + affixKeySetting("transport.profiles.", "tcp_no_delay", key -> boolSetting(key, TCP_NO_DELAY, Setting.Property.NodeScope)); + public static final Setting.AffixSetting TCP_NO_DELAY_PROFILE = + affixKeySetting("transport.profiles.", "tcp.no_delay", key -> boolSetting(key, OLD_TCP_NO_DELAY_PROFILE, + Setting.Property.NodeScope)); + public static final Setting TCP_KEEP_ALIVE = + boolSetting("transport.tcp.keep_alive", NetworkService.TCP_KEEP_ALIVE, Setting.Property.NodeScope); + // TODO: Deprecate in 7.0 + public static final Setting.AffixSetting OLD_TCP_KEEP_ALIVE_PROFILE = + affixKeySetting("transport.profiles.", "tcp_keep_alive", key -> boolSetting(key, TCP_KEEP_ALIVE, Setting.Property.NodeScope)); + public static final Setting.AffixSetting TCP_KEEP_ALIVE_PROFILE = + affixKeySetting("transport.profiles.", "tcp.keep_alive", key -> boolSetting(key, OLD_TCP_KEEP_ALIVE_PROFILE, + Setting.Property.NodeScope)); + public static final Setting TCP_REUSE_ADDRESS = + boolSetting("transport.tcp.reuse_address", NetworkService.TCP_REUSE_ADDRESS, Setting.Property.NodeScope); + // TODO: Deprecate in 7.0 + public static final Setting.AffixSetting OLD_TCP_REUSE_ADDRESS_PROFILE = + affixKeySetting("transport.profiles.", "reuse_address", key -> boolSetting(key, TCP_REUSE_ADDRESS, Setting.Property.NodeScope)); + public static final Setting.AffixSetting TCP_REUSE_ADDRESS_PROFILE = + affixKeySetting("transport.profiles.", "tcp.reuse_address", key -> boolSetting(key, OLD_TCP_REUSE_ADDRESS_PROFILE, + Setting.Property.NodeScope)); + public static final Setting TCP_SEND_BUFFER_SIZE = + Setting.byteSizeSetting("transport.tcp.send_buffer_size", NetworkService.TCP_SEND_BUFFER_SIZE, Setting.Property.NodeScope); + // TODO: Deprecate in 7.0 + public static final Setting.AffixSetting OLD_TCP_SEND_BUFFER_SIZE_PROFILE = affixKeySetting("transport.profiles.", + "send_buffer_size", key -> Setting.byteSizeSetting(key, TCP_SEND_BUFFER_SIZE, Setting.Property.NodeScope)); + public static final Setting.AffixSetting TCP_SEND_BUFFER_SIZE_PROFILE = affixKeySetting("transport.profiles.", + "tcp.send_buffer_size", key -> Setting.byteSizeSetting(key, OLD_TCP_SEND_BUFFER_SIZE_PROFILE, Setting.Property.NodeScope)); + public static final Setting TCP_RECEIVE_BUFFER_SIZE = + Setting.byteSizeSetting("transport.tcp.receive_buffer_size", NetworkService.TCP_RECEIVE_BUFFER_SIZE, Setting.Property.NodeScope); + // TODO: Deprecate in 7.0 + public static final Setting.AffixSetting OLD_TCP_RECEIVE_BUFFER_SIZE_PROFILE = + affixKeySetting("transport.profiles.", "receive_buffer_size", key -> Setting.byteSizeSetting(key, TCP_RECEIVE_BUFFER_SIZE, + Setting.Property.NodeScope)); + public static final Setting.AffixSetting TCP_RECEIVE_BUFFER_SIZE_PROFILE = affixKeySetting("transport.profiles.", + "tcp.receive_buffer_size", key -> Setting.byteSizeSetting(key, OLD_TCP_RECEIVE_BUFFER_SIZE_PROFILE, Setting.Property.NodeScope)); + + // Connections per node settings + + public static final Setting CONNECTIONS_PER_NODE_RECOVERY = + intSetting("transport.connections_per_node.recovery", 2, 1, Setting.Property.NodeScope); + public static final Setting CONNECTIONS_PER_NODE_BULK = + intSetting("transport.connections_per_node.bulk", 3, 1, Setting.Property.NodeScope); + public static final Setting CONNECTIONS_PER_NODE_REG = + intSetting("transport.connections_per_node.reg", 6, 1, Setting.Property.NodeScope); + public static final Setting CONNECTIONS_PER_NODE_STATE = + intSetting("transport.connections_per_node.state", 1, 1, Setting.Property.NodeScope); + public static final Setting CONNECTIONS_PER_NODE_PING = + intSetting("transport.connections_per_node.ping", 1, 1, Setting.Property.NodeScope); + + // Tracer settings + + public static final Setting> TRACE_LOG_INCLUDE_SETTING = + listSetting("transport.tracer.include", emptyList(), Function.identity(), Setting.Property.Dynamic, Setting.Property.NodeScope); + public static final Setting> TRACE_LOG_EXCLUDE_SETTING = + listSetting("transport.tracer.exclude", + Arrays.asList("internal:discovery/zen/fd*", "internal:coordination/fault_detection/*", TransportLivenessAction.NAME), + Function.identity(), Setting.Property.Dynamic, Setting.Property.NodeScope); +} diff --git a/server/src/test/java/org/elasticsearch/client/transport/TransportClientTests.java b/server/src/test/java/org/elasticsearch/client/transport/TransportClientTests.java index 1dc30e951b6d3..03ac1ebc3b67b 100644 --- a/server/src/test/java/org/elasticsearch/client/transport/TransportClientTests.java +++ b/server/src/test/java/org/elasticsearch/client/transport/TransportClientTests.java @@ -31,7 +31,7 @@ import org.elasticsearch.plugins.Plugin; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.transport.MockTransportClient; -import org.elasticsearch.transport.TcpTransport; +import org.elasticsearch.transport.TransportSettings; import java.io.IOException; import java.util.Arrays; @@ -72,7 +72,7 @@ public void testSettingsContainsTransportClient() { .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()) .build(); try (TransportClient client = new MockTransportClient(baseSettings, Arrays.asList(MockPlugin.class))) { - final Settings settings = TcpTransport.DEFAULT_FEATURES_SETTING.get(client.settings()); + final Settings settings = TransportSettings.DEFAULT_FEATURES_SETTING.get(client.settings()); assertThat(settings.keySet(), hasItem("transport_client")); assertThat(settings.get("transport_client"), equalTo("true")); } diff --git a/server/src/test/java/org/elasticsearch/common/settings/ScopedSettingsTests.java b/server/src/test/java/org/elasticsearch/common/settings/ScopedSettingsTests.java index 1846e180ad6f9..1909e3c26b55e 100644 --- a/server/src/test/java/org/elasticsearch/common/settings/ScopedSettingsTests.java +++ b/server/src/test/java/org/elasticsearch/common/settings/ScopedSettingsTests.java @@ -29,7 +29,7 @@ import org.elasticsearch.common.settings.Setting.Property; import org.elasticsearch.index.IndexModule; import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.transport.TransportService; +import org.elasticsearch.transport.TransportSettings; import java.io.IOException; import java.util.ArrayList; @@ -603,7 +603,7 @@ public void testGet() { // array settings - complex matcher assertNotNull(settings.get("transport.tracer.include." + randomIntBetween(1, 100))); - assertSame(TransportService.TRACE_LOG_INCLUDE_SETTING, settings.get("transport.tracer.include." + randomIntBetween(1, 100))); + assertSame(TransportSettings.TRACE_LOG_INCLUDE_SETTING, settings.get("transport.tracer.include." + randomIntBetween(1, 100))); // array settings - complex matcher - only accepts numbers assertNull(settings.get("transport.tracer.include.FOO")); @@ -745,7 +745,7 @@ public void testDiffWithAffixAndComplexMatcher() { public void testUpdateTracer() { ClusterSettings settings = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); AtomicReference> ref = new AtomicReference<>(); - settings.addSettingsUpdateConsumer(TransportService.TRACE_LOG_INCLUDE_SETTING, ref::set); + settings.addSettingsUpdateConsumer(TransportSettings.TRACE_LOG_INCLUDE_SETTING, ref::set); settings.applySettings(Settings.builder() .putList("transport.tracer.include", "internal:index/shard/recovery/*", "internal:gateway/local*").build()); assertNotNull(ref.get().size()); diff --git a/server/src/test/java/org/elasticsearch/discovery/AbstractDisruptionTestCase.java b/server/src/test/java/org/elasticsearch/discovery/AbstractDisruptionTestCase.java index e5a21ef7e9363..7a9a6570d0d99 100644 --- a/server/src/test/java/org/elasticsearch/discovery/AbstractDisruptionTestCase.java +++ b/server/src/test/java/org/elasticsearch/discovery/AbstractDisruptionTestCase.java @@ -46,7 +46,7 @@ import org.elasticsearch.test.disruption.ServiceDisruptionScheme; import org.elasticsearch.test.disruption.SlowClusterStateProcessing; import org.elasticsearch.test.transport.MockTransportService; -import org.elasticsearch.transport.TransportService; +import org.elasticsearch.transport.TransportSettings; import org.junit.Before; import java.util.Arrays; @@ -142,7 +142,7 @@ protected void clearTemporalResponses() { .put(JoinHelper.JOIN_TIMEOUT_SETTING.getKey(), "10s") // still long to induce failures but to long so test won't time out .put(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey(), "1s") // <-- for hitting simulated network failures quickly .put(Coordinator.PUBLISH_TIMEOUT_SETTING.getKey(), "1s") // <-- for hitting simulated network failures quickly - .put(TransportService.TCP_CONNECT_TIMEOUT.getKey(), "10s") // Network delay disruption waits for the min between this + .put(TransportSettings.CONNECT_TIMEOUT.getKey(), "10s") // Network delay disruption waits for the min between this // value and the time of disruption and does not recover immediately // when disruption is stop. We should make sure we recover faster // then the default of 30s, causing ensureGreen and friends to time out diff --git a/server/src/test/java/org/elasticsearch/discovery/ZenFaultDetectionTests.java b/server/src/test/java/org/elasticsearch/discovery/ZenFaultDetectionTests.java index 03c0df43591ba..d5f516a8ef8b0 100644 --- a/server/src/test/java/org/elasticsearch/discovery/ZenFaultDetectionTests.java +++ b/server/src/test/java/org/elasticsearch/discovery/ZenFaultDetectionTests.java @@ -47,6 +47,7 @@ import org.elasticsearch.transport.TransportConnectionListener; import org.elasticsearch.transport.TransportRequestOptions; import org.elasticsearch.transport.TransportService; +import org.elasticsearch.transport.TransportSettings; import org.hamcrest.Matcher; import org.hamcrest.Matchers; import org.junit.After; @@ -136,7 +137,7 @@ protected MockTransportService build(Settings settings, Version version) { Settings.builder() .put(settings) // trace zenfd actions but keep the default otherwise - .putList(TransportService.TRACE_LOG_EXCLUDE_SETTING.getKey(), TransportLivenessAction.NAME) + .putList(TransportSettings.TRACE_LOG_EXCLUDE_SETTING.getKey(), TransportLivenessAction.NAME) .build(), new MockTcpTransport(settings, threadPool, BigArrays.NON_RECYCLING_INSTANCE, circuitBreakerService, namedWriteableRegistry, new NetworkService(Collections.emptyList()), version), diff --git a/server/src/test/java/org/elasticsearch/discovery/zen/PublishClusterStateActionTests.java b/server/src/test/java/org/elasticsearch/discovery/zen/PublishClusterStateActionTests.java index 4bd7b4e663a17..183df5c956405 100644 --- a/server/src/test/java/org/elasticsearch/discovery/zen/PublishClusterStateActionTests.java +++ b/server/src/test/java/org/elasticsearch/discovery/zen/PublishClusterStateActionTests.java @@ -57,6 +57,7 @@ import org.elasticsearch.transport.TransportConnectionListener; import org.elasticsearch.transport.TransportResponse; import org.elasticsearch.transport.TransportService; +import org.elasticsearch.transport.TransportSettings; import org.junit.After; import org.junit.Before; @@ -182,8 +183,8 @@ public static MockNode createMockNode(String name, final Settings basSettings, @ ThreadPool threadPool, Logger logger, Map nodes) throws Exception { final Settings settings = Settings.builder() .put("name", name) - .put(TransportService.TRACE_LOG_INCLUDE_SETTING.getKey(), "").put( - TransportService.TRACE_LOG_EXCLUDE_SETTING.getKey(), "NOTHING") + .put(TransportSettings.TRACE_LOG_INCLUDE_SETTING.getKey(), "").put( + TransportSettings.TRACE_LOG_EXCLUDE_SETTING.getKey(), "NOTHING") .put(basSettings) .build(); diff --git a/server/src/test/java/org/elasticsearch/discovery/zen/UnicastZenPingTests.java b/server/src/test/java/org/elasticsearch/discovery/zen/UnicastZenPingTests.java index 1c0329a51e32a..683110bfb8084 100644 --- a/server/src/test/java/org/elasticsearch/discovery/zen/UnicastZenPingTests.java +++ b/server/src/test/java/org/elasticsearch/discovery/zen/UnicastZenPingTests.java @@ -49,13 +49,13 @@ import org.elasticsearch.threadpool.TestThreadPool; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.MockTcpTransport; -import org.elasticsearch.transport.TcpTransport; import org.elasticsearch.transport.Transport; import org.elasticsearch.transport.TransportConnectionListener; import org.elasticsearch.transport.TransportException; import org.elasticsearch.transport.TransportRequestOptions; import org.elasticsearch.transport.TransportResponseHandler; import org.elasticsearch.transport.TransportService; +import org.elasticsearch.transport.TransportSettings; import org.junit.After; import org.junit.Before; import org.mockito.Matchers; @@ -137,9 +137,9 @@ public void tearDown() throws Exception { public void testSimplePings() throws IOException, InterruptedException, ExecutionException { // use ephemeral ports - final Settings settings = Settings.builder().put("cluster.name", "test").put(TcpTransport.PORT.getKey(), 0).build(); + final Settings settings = Settings.builder().put("cluster.name", "test").put(TransportSettings.PORT.getKey(), 0).build(); final Settings settingsMismatch = - Settings.builder().put(settings).put("cluster.name", "mismatch").put(TcpTransport.PORT.getKey(), 0).build(); + Settings.builder().put(settings).put("cluster.name", "mismatch").put(TransportSettings.PORT.getKey(), 0).build(); NetworkService networkService = new NetworkService(Collections.emptyList()); @@ -263,7 +263,7 @@ protected Version getVersion() { public void testUnknownHostNotCached() throws ExecutionException, InterruptedException { // use ephemeral ports - final Settings settings = Settings.builder().put("cluster.name", "test").put(TcpTransport.PORT.getKey(), 0).build(); + final Settings settings = Settings.builder().put("cluster.name", "test").put(TransportSettings.PORT.getKey(), 0).build(); final NetworkService networkService = new NetworkService(Collections.emptyList()); @@ -565,7 +565,7 @@ public TransportAddress[] addressesFromString(String address, int perAddressLimi } public void testResolveReuseExistingNodeConnections() throws ExecutionException, InterruptedException { - final Settings settings = Settings.builder().put("cluster.name", "test").put(TcpTransport.PORT.getKey(), 0).build(); + final Settings settings = Settings.builder().put("cluster.name", "test").put(TransportSettings.PORT.getKey(), 0).build(); NetworkService networkService = new NetworkService(Collections.emptyList()); @@ -630,7 +630,7 @@ public void onConnectionOpened(Transport.Connection connection) { } public void testPingingTemporalPings() throws ExecutionException, InterruptedException { - final Settings settings = Settings.builder().put("cluster.name", "test").put(TcpTransport.PORT.getKey(), 0).build(); + final Settings settings = Settings.builder().put("cluster.name", "test").put(TransportSettings.PORT.getKey(), 0).build(); NetworkService networkService = new NetworkService(Collections.emptyList()); @@ -770,7 +770,7 @@ private NetworkHandle startServices( final Set nodeRoles) { final Settings nodeSettings = Settings.builder().put(settings) .put("node.name", nodeId) - .put(TransportService.TRACE_LOG_INCLUDE_SETTING.getKey(), "internal:discovery/zen/unicast") + .put(TransportSettings.TRACE_LOG_INCLUDE_SETTING.getKey(), "internal:discovery/zen/unicast") .build(); final Transport transport = supplier.apply(nodeSettings, version); final MockTransportService transportService = diff --git a/server/src/test/java/org/elasticsearch/transport/ConnectionProfileTests.java b/server/src/test/java/org/elasticsearch/transport/ConnectionProfileTests.java index 4f380de08ed1c..e26af6719e85f 100644 --- a/server/src/test/java/org/elasticsearch/transport/ConnectionProfileTests.java +++ b/server/src/test/java/org/elasticsearch/transport/ConnectionProfileTests.java @@ -204,10 +204,10 @@ public void testDefaultConnectionProfile() { assertEquals(1, profile.getNumConnectionsPerType(TransportRequestOptions.Type.STATE)); assertEquals(2, profile.getNumConnectionsPerType(TransportRequestOptions.Type.RECOVERY)); assertEquals(3, profile.getNumConnectionsPerType(TransportRequestOptions.Type.BULK)); - assertEquals(TransportService.TCP_CONNECT_TIMEOUT.get(Settings.EMPTY), profile.getConnectTimeout()); - assertEquals(TransportService.TCP_CONNECT_TIMEOUT.get(Settings.EMPTY), profile.getHandshakeTimeout()); - assertEquals(Transport.TRANSPORT_TCP_COMPRESS.get(Settings.EMPTY), profile.getCompressionEnabled()); - assertEquals(TcpTransport.PING_SCHEDULE.get(Settings.EMPTY), profile.getPingInterval()); + assertEquals(TransportSettings.CONNECT_TIMEOUT.get(Settings.EMPTY), profile.getConnectTimeout()); + assertEquals(TransportSettings.CONNECT_TIMEOUT.get(Settings.EMPTY), profile.getHandshakeTimeout()); + assertEquals(TransportSettings.TRANSPORT_COMPRESS.get(Settings.EMPTY), profile.getCompressionEnabled()); + assertEquals(TransportSettings.PING_SCHEDULE.get(Settings.EMPTY), profile.getPingInterval()); profile = ConnectionProfile.buildDefaultConnectionProfile(Settings.builder().put("node.master", false).build()); assertEquals(12, profile.getNumConnections()); diff --git a/server/src/test/java/org/elasticsearch/transport/PublishPortTests.java b/server/src/test/java/org/elasticsearch/transport/PublishPortTests.java index 0f121f0c401ff..b246d11b097c7 100644 --- a/server/src/test/java/org/elasticsearch/transport/PublishPortTests.java +++ b/server/src/test/java/org/elasticsearch/transport/PublishPortTests.java @@ -46,13 +46,13 @@ public void testPublishPort() throws Exception { Settings settings; if (useProfile) { baseSettings = Settings.builder().put("transport.profiles.some_profile.port", 0).build(); - settings = randomBoolean() ? Settings.EMPTY : Settings.builder().put(TcpTransport.PUBLISH_PORT.getKey(), 9081).build(); + settings = randomBoolean() ? Settings.EMPTY : Settings.builder().put(TransportSettings.PUBLISH_PORT.getKey(), 9081).build(); settings = Settings.builder().put(settings).put(baseSettings).put("transport.profiles.some_profile.publish_port", 9080).build(); profile = "some_profile"; } else { baseSettings = Settings.EMPTY; - settings = Settings.builder().put(TcpTransport.PUBLISH_PORT.getKey(), 9081).build(); + settings = Settings.builder().put(TransportSettings.PUBLISH_PORT.getKey(), 9081).build(); settings = randomBoolean() ? settings : Settings.builder().put(settings).put("transport.profiles.default.publish_port", 9080).build(); profile = "default"; diff --git a/server/src/test/java/org/elasticsearch/transport/RemoteClusterServiceTests.java b/server/src/test/java/org/elasticsearch/transport/RemoteClusterServiceTests.java index 9a185163436af..dfc5d4367b417 100644 --- a/server/src/test/java/org/elasticsearch/transport/RemoteClusterServiceTests.java +++ b/server/src/test/java/org/elasticsearch/transport/RemoteClusterServiceTests.java @@ -351,7 +351,7 @@ public void testDefaultPingSchedule() throws IOException { settingsBuilder.putList("cluster.remote.cluster_1.seeds", seedNode.getAddress().toString()); if (randomBoolean()) { pingSchedule = TimeValue.timeValueSeconds(randomIntBetween(1, 10)); - settingsBuilder.put(TcpTransport.PING_SCHEDULE.getKey(), pingSchedule).build(); + settingsBuilder.put(TransportSettings.PING_SCHEDULE.getKey(), pingSchedule).build(); } else { pingSchedule = TimeValue.MINUS_ONE; } @@ -385,7 +385,7 @@ public void testCustomPingSchedule() throws IOException { Collections.shuffle(knownNodes, random()); Settings.Builder settingsBuilder = Settings.builder(); if (randomBoolean()) { - settingsBuilder.put(TcpTransport.PING_SCHEDULE.getKey(), TimeValue.timeValueSeconds(randomIntBetween(1, 10))); + settingsBuilder.put(TransportSettings.PING_SCHEDULE.getKey(), TimeValue.timeValueSeconds(randomIntBetween(1, 10))); } Settings transportSettings = settingsBuilder.build(); diff --git a/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java b/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java index 6ebcdf6358cb5..a625de4150509 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java +++ b/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java @@ -109,9 +109,8 @@ import org.elasticsearch.test.disruption.ServiceDisruptionScheme; import org.elasticsearch.test.transport.MockTransportService; import org.elasticsearch.transport.MockTransportClient; -import org.elasticsearch.transport.TcpTransport; -import org.elasticsearch.transport.Transport; import org.elasticsearch.transport.TransportService; +import org.elasticsearch.transport.TransportSettings; import org.junit.Assert; import java.io.Closeable; @@ -361,7 +360,7 @@ public InternalTestCluster( builder.put(Environment.PATH_SHARED_DATA_SETTING.getKey(), baseDir.resolve("custom")); builder.put(Environment.PATH_HOME_SETTING.getKey(), baseDir); builder.put(Environment.PATH_REPO_SETTING.getKey(), baseDir.resolve("repos")); - builder.put(TcpTransport.PORT.getKey(), 0); + builder.put(TransportSettings.PORT.getKey(), 0); builder.put("http.port", 0); if (Strings.hasLength(System.getProperty("tests.es.logger.level"))) { builder.put("logger.level", System.getProperty("tests.es.logger.level")); @@ -438,7 +437,7 @@ public Collection> getPlugins() { private Settings getRandomNodeSettings(long seed) { Random random = new Random(seed); Builder builder = Settings.builder(); - builder.put(Transport.TRANSPORT_TCP_COMPRESS.getKey(), rarely(random)); + builder.put(TransportSettings.TRANSPORT_COMPRESS.getKey(), rarely(random)); if (random.nextBoolean()) { builder.put("cache.recycler.page.type", RandomPicks.randomFrom(random, PageCacheRecycler.Type.values())); } @@ -460,9 +459,9 @@ private Settings getRandomNodeSettings(long seed) { // randomize tcp settings if (random.nextBoolean()) { - builder.put(TransportService.CONNECTIONS_PER_NODE_RECOVERY.getKey(), random.nextInt(2) + 1); - builder.put(TransportService.CONNECTIONS_PER_NODE_BULK.getKey(), random.nextInt(3) + 1); - builder.put(TransportService.CONNECTIONS_PER_NODE_REG.getKey(), random.nextInt(6) + 1); + builder.put(TransportSettings.CONNECTIONS_PER_NODE_RECOVERY.getKey(), random.nextInt(2) + 1); + builder.put(TransportSettings.CONNECTIONS_PER_NODE_BULK.getKey(), random.nextInt(3) + 1); + builder.put(TransportSettings.CONNECTIONS_PER_NODE_REG.getKey(), random.nextInt(6) + 1); } if (random.nextBoolean()) { @@ -490,7 +489,7 @@ private Settings getRandomNodeSettings(long seed) { } if (random.nextBoolean()) { - builder.put(TcpTransport.PING_SCHEDULE.getKey(), RandomNumbers.randomIntBetween(random, 100, 2000) + "ms"); + builder.put(TransportSettings.PING_SCHEDULE.getKey(), RandomNumbers.randomIntBetween(random, 100, 2000) + "ms"); } if (random.nextBoolean()) { diff --git a/test/framework/src/main/java/org/elasticsearch/test/transport/MockTransportService.java b/test/framework/src/main/java/org/elasticsearch/test/transport/MockTransportService.java index c0879af2dfa23..403ac96104a10 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/transport/MockTransportService.java +++ b/test/framework/src/main/java/org/elasticsearch/test/transport/MockTransportService.java @@ -50,12 +50,12 @@ import org.elasticsearch.transport.ConnectionManager; import org.elasticsearch.transport.ConnectionProfile; import org.elasticsearch.transport.RequestHandlerRegistry; -import org.elasticsearch.transport.TcpTransport; import org.elasticsearch.transport.Transport; import org.elasticsearch.transport.TransportInterceptor; import org.elasticsearch.transport.TransportRequest; import org.elasticsearch.transport.TransportRequestOptions; import org.elasticsearch.transport.TransportService; +import org.elasticsearch.transport.TransportSettings; import org.elasticsearch.transport.nio.MockNioTransport; import java.io.IOException; @@ -109,7 +109,7 @@ public static MockNioTransport newMockTransport(Settings settings, Version versi // be smart enough to re-connect depending on what is tested. To reduce the risk, since this is very hard to debug we use // a different default port range per JVM unless the incoming settings override it int basePort = 10300 + (JVM_ORDINAL * 100); // use a non-default port otherwise some cluster in this JVM might reuse a port - settings = Settings.builder().put(TcpTransport.PORT.getKey(), basePort + "-" + (basePort + 100)).put(settings).build(); + settings = Settings.builder().put(TransportSettings.PORT.getKey(), basePort + "-" + (basePort + 100)).put(settings).build(); NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(ClusterModule.getNamedWriteables()); return new MockNioTransport(settings, version, threadPool, new NetworkService(Collections.emptyList()), new MockPageCacheRecycler(settings), namedWriteableRegistry, new NoneCircuitBreakerService()); @@ -130,7 +130,8 @@ public static MockTransportService createNewService(Settings settings, Transport * Build the service. * * @param clusterSettings if non null the {@linkplain TransportService} will register with the {@link ClusterSettings} for settings - * updates for {@link #TRACE_LOG_EXCLUDE_SETTING} and {@link #TRACE_LOG_INCLUDE_SETTING}. + * updates for {@link TransportSettings#TRACE_LOG_EXCLUDE_SETTING} and + * {@link TransportSettings#TRACE_LOG_INCLUDE_SETTING}. */ public MockTransportService(Settings settings, Transport transport, ThreadPool threadPool, TransportInterceptor interceptor, @Nullable ClusterSettings clusterSettings) { @@ -143,7 +144,8 @@ public MockTransportService(Settings settings, Transport transport, ThreadPool t * Build the service. * * @param clusterSettings if non null the {@linkplain TransportService} will register with the {@link ClusterSettings} for settings - * updates for {@link #TRACE_LOG_EXCLUDE_SETTING} and {@link #TRACE_LOG_INCLUDE_SETTING}. + * updates for {@link TransportSettings#TRACE_LOG_EXCLUDE_SETTING} and + * {@link TransportSettings#TRACE_LOG_INCLUDE_SETTING}. */ public MockTransportService(Settings settings, Transport transport, ThreadPool threadPool, TransportInterceptor interceptor, Function localNodeFactory, @@ -319,7 +321,7 @@ public void addUnresponsiveRule(TransportAddress transportAddress, final TimeVal } // TODO: Replace with proper setting - TimeValue connectingTimeout = TransportService.TCP_CONNECT_TIMEOUT.getDefault(Settings.EMPTY); + TimeValue connectingTimeout = TransportSettings.CONNECT_TIMEOUT.getDefault(Settings.EMPTY); try { if (delay.millis() < connectingTimeout.millis()) { Thread.sleep(delay.millis()); diff --git a/test/framework/src/main/java/org/elasticsearch/transport/AbstractSimpleTransportTestCase.java b/test/framework/src/main/java/org/elasticsearch/transport/AbstractSimpleTransportTestCase.java index b2e468a9b2505..9230e1c8e9727 100644 --- a/test/framework/src/main/java/org/elasticsearch/transport/AbstractSimpleTransportTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/transport/AbstractSimpleTransportTestCase.java @@ -127,11 +127,11 @@ public void setUp() throws Exception { threadPool = new TestThreadPool(getClass().getName()); clusterSettings = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); Settings connectionSettings = Settings.builder() - .put(TransportService.CONNECTIONS_PER_NODE_RECOVERY.getKey(), 1) - .put(TransportService.CONNECTIONS_PER_NODE_BULK.getKey(), 1) - .put(TransportService.CONNECTIONS_PER_NODE_REG.getKey(), 2) - .put(TransportService.CONNECTIONS_PER_NODE_STATE.getKey(), 1) - .put(TransportService.CONNECTIONS_PER_NODE_PING.getKey(), 1) + .put(TransportSettings.CONNECTIONS_PER_NODE_RECOVERY.getKey(), 1) + .put(TransportSettings.CONNECTIONS_PER_NODE_BULK.getKey(), 1) + .put(TransportSettings.CONNECTIONS_PER_NODE_REG.getKey(), 2) + .put(TransportSettings.CONNECTIONS_PER_NODE_STATE.getKey(), 1) + .put(TransportSettings.CONNECTIONS_PER_NODE_PING.getKey(), 1) .build(); serviceA = buildService("TS_A", version0, clusterSettings, connectionSettings); // this one supports dynamic tracer updates @@ -171,8 +171,8 @@ private MockTransportService buildService(final String name, final Version versi Settings.builder() .put(settings) .put(Node.NODE_NAME_SETTING.getKey(), name) - .put(TransportService.TRACE_LOG_INCLUDE_SETTING.getKey(), "") - .put(TransportService.TRACE_LOG_EXCLUDE_SETTING.getKey(), "NOTHING") + .put(TransportSettings.TRACE_LOG_INCLUDE_SETTING.getKey(), "") + .put(TransportSettings.TRACE_LOG_EXCLUDE_SETTING.getKey(), "NOTHING") .build(), version, clusterSettings, doHandshake); @@ -513,7 +513,7 @@ public void testVoidMessageCompressed() { } }); - Settings settingsWithCompress = Settings.builder().put(Transport.TRANSPORT_TCP_COMPRESS.getKey(), true).build(); + Settings settingsWithCompress = Settings.builder().put(TransportSettings.TRANSPORT_COMPRESS.getKey(), true).build(); ConnectionProfile connectionProfile = ConnectionProfile.buildDefaultConnectionProfile(settingsWithCompress); serviceC.connectToNode(serviceA.getLocalDiscoNode(), connectionProfile); @@ -567,7 +567,7 @@ public void testHelloWorldCompressed() throws IOException { } }); - Settings settingsWithCompress = Settings.builder().put(Transport.TRANSPORT_TCP_COMPRESS.getKey(), true).build(); + Settings settingsWithCompress = Settings.builder().put(TransportSettings.TRANSPORT_COMPRESS.getKey(), true).build(); ConnectionProfile connectionProfile = ConnectionProfile.buildDefaultConnectionProfile(settingsWithCompress); serviceC.connectToNode(serviceA.getLocalDiscoNode(), connectionProfile); @@ -1050,8 +1050,8 @@ public String executor() { excludeSettings = "DOESN'T_MATCH"; } clusterSettings.applySettings(Settings.builder() - .put(TransportService.TRACE_LOG_INCLUDE_SETTING.getKey(), includeSettings) - .put(TransportService.TRACE_LOG_EXCLUDE_SETTING.getKey(), excludeSettings) + .put(TransportSettings.TRACE_LOG_INCLUDE_SETTING.getKey(), includeSettings) + .put(TransportSettings.TRACE_LOG_EXCLUDE_SETTING.getKey(), excludeSettings) .build()); tracer.reset(4); @@ -1734,8 +1734,8 @@ public void testSendRandomRequests() throws InterruptedException { TransportService serviceC = build( Settings.builder() .put("name", "TS_TEST") - .put(TransportService.TRACE_LOG_INCLUDE_SETTING.getKey(), "") - .put(TransportService.TRACE_LOG_EXCLUDE_SETTING.getKey(), "NOTHING") + .put(TransportSettings.TRACE_LOG_INCLUDE_SETTING.getKey(), "") + .put(TransportSettings.TRACE_LOG_EXCLUDE_SETTING.getKey(), "NOTHING") .build(), version0, null, true); @@ -2682,7 +2682,7 @@ public void testProfileSettings() { public void testProfilesIncludesDefault() { Set profileSettings = TcpTransport.getProfileSettings(Settings.EMPTY); assertEquals(1, profileSettings.size()); - assertEquals(TcpTransport.DEFAULT_PROFILE, profileSettings.stream().findAny().get().profileName); + assertEquals(TransportSettings.DEFAULT_PROFILE, profileSettings.stream().findAny().get().profileName); profileSettings = TcpTransport.getProfileSettings(Settings.builder() .put("transport.profiles.test.port", "0") diff --git a/test/framework/src/main/java/org/elasticsearch/transport/MockTcpTransport.java b/test/framework/src/main/java/org/elasticsearch/transport/MockTcpTransport.java index 6b328f1862577..d4cb2e2abd15b 100644 --- a/test/framework/src/main/java/org/elasticsearch/transport/MockTcpTransport.java +++ b/test/framework/src/main/java/org/elasticsearch/transport/MockTcpTransport.java @@ -115,8 +115,8 @@ public MockTcpTransport(Settings settings, ThreadPool threadPool, BigArrays bigA @Override protected MockChannel bind(final String name, InetSocketAddress address) throws IOException { MockServerSocket socket = new MockServerSocket(); - socket.setReuseAddress(TCP_REUSE_ADDRESS.get(settings)); - ByteSizeValue tcpReceiveBufferSize = TCP_RECEIVE_BUFFER_SIZE.get(settings); + socket.setReuseAddress(TransportSettings.TCP_REUSE_ADDRESS.get(settings)); + ByteSizeValue tcpReceiveBufferSize = TransportSettings.TCP_RECEIVE_BUFFER_SIZE.get(settings); if (tcpReceiveBufferSize.getBytes() > 0) { socket.setReceiveBufferSize(tcpReceiveBufferSize.bytesAsInt()); } @@ -225,16 +225,16 @@ protected ConnectionProfile maybeOverrideConnectionProfile(ConnectionProfile con } private void configureSocket(Socket socket) throws SocketException { - socket.setTcpNoDelay(TCP_NO_DELAY.get(settings)); - ByteSizeValue tcpSendBufferSize = TCP_SEND_BUFFER_SIZE.get(settings); + socket.setTcpNoDelay(TransportSettings.TCP_NO_DELAY.get(settings)); + ByteSizeValue tcpSendBufferSize = TransportSettings.TCP_SEND_BUFFER_SIZE.get(settings); if (tcpSendBufferSize.getBytes() > 0) { socket.setSendBufferSize(tcpSendBufferSize.bytesAsInt()); } - ByteSizeValue tcpReceiveBufferSize = TCP_RECEIVE_BUFFER_SIZE.get(settings); + ByteSizeValue tcpReceiveBufferSize = TransportSettings.TCP_RECEIVE_BUFFER_SIZE.get(settings); if (tcpReceiveBufferSize.getBytes() > 0) { socket.setReceiveBufferSize(tcpReceiveBufferSize.bytesAsInt()); } - socket.setReuseAddress(TCP_REUSE_ADDRESS.get(settings)); + socket.setReuseAddress(TransportSettings.TCP_REUSE_ADDRESS.get(settings)); } public final class MockChannel implements Closeable, TcpChannel, TcpServerChannel { diff --git a/test/framework/src/test/java/org/elasticsearch/test/test/InternalTestClusterTests.java b/test/framework/src/test/java/org/elasticsearch/test/test/InternalTestClusterTests.java index 05c99ef83d470..52c599c89bac6 100644 --- a/test/framework/src/test/java/org/elasticsearch/test/test/InternalTestClusterTests.java +++ b/test/framework/src/test/java/org/elasticsearch/test/test/InternalTestClusterTests.java @@ -38,7 +38,7 @@ import org.elasticsearch.test.MockHttpTransport; import org.elasticsearch.test.NodeConfigurationSource; import org.elasticsearch.test.discovery.TestZenDiscovery; -import org.elasticsearch.transport.TcpTransport; +import org.elasticsearch.transport.TransportSettings; import java.io.IOException; import java.nio.file.Files; @@ -109,7 +109,7 @@ public void testInitializiationIsConsistent() { static { clusterUniqueSettings.add(ClusterName.CLUSTER_NAME_SETTING.getKey()); - clusterUniqueSettings.add(TcpTransport.PORT.getKey()); + clusterUniqueSettings.add(TransportSettings.PORT.getKey()); clusterUniqueSettings.add("http.port"); } diff --git a/test/framework/src/test/java/org/elasticsearch/transport/nio/SimpleMockNioTransportTests.java b/test/framework/src/test/java/org/elasticsearch/transport/nio/SimpleMockNioTransportTests.java index 84b921cf88fcc..8150a1d8b8dd9 100644 --- a/test/framework/src/test/java/org/elasticsearch/transport/nio/SimpleMockNioTransportTests.java +++ b/test/framework/src/test/java/org/elasticsearch/transport/nio/SimpleMockNioTransportTests.java @@ -37,8 +37,8 @@ import org.elasticsearch.transport.ConnectTransportException; import org.elasticsearch.transport.ConnectionProfile; import org.elasticsearch.transport.TcpChannel; -import org.elasticsearch.transport.TcpTransport; import org.elasticsearch.transport.Transport; +import org.elasticsearch.transport.TransportSettings; import java.io.IOException; import java.net.InetAddress; @@ -78,7 +78,7 @@ public void executeHandshake(DiscoveryNode node, TcpChannel channel, ConnectionP @Override protected MockTransportService build(Settings settings, Version version, ClusterSettings clusterSettings, boolean doHandshake) { settings = Settings.builder().put(settings) - .put(TcpTransport.PORT.getKey(), "0") + .put(TransportSettings.PORT.getKey(), "0") .build(); MockTransportService transportService = nioFromThreadPool(settings, threadPool, version, clusterSettings, doHandshake); transportService.start(); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/transport/netty4/SecurityNetty4Transport.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/transport/netty4/SecurityNetty4Transport.java index 3712c27c4359a..4ed4246597bb5 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/transport/netty4/SecurityNetty4Transport.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/transport/netty4/SecurityNetty4Transport.java @@ -25,7 +25,7 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.ConnectTransportException; import org.elasticsearch.transport.TcpChannel; -import org.elasticsearch.transport.TcpTransport; +import org.elasticsearch.transport.TransportSettings; import org.elasticsearch.transport.netty4.Netty4Transport; import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.security.transport.SSLExceptionHelper; @@ -87,8 +87,8 @@ public static Map getTransportProfileConfigurations(Se profileConfiguration.put(profileName, configuration); } - if (profileConfiguration.containsKey(TcpTransport.DEFAULT_PROFILE) == false) { - profileConfiguration.put(TcpTransport.DEFAULT_PROFILE, defaultConfiguration); + if (profileConfiguration.containsKey(TransportSettings.DEFAULT_PROFILE) == false) { + profileConfiguration.put(TransportSettings.DEFAULT_PROFILE, defaultConfiguration); } return profileConfiguration; } diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/tool/CommandLineHttpClient.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/tool/CommandLineHttpClient.java index f69c3f6893fd8..cb0bef382071b 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/tool/CommandLineHttpClient.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/tool/CommandLineHttpClient.java @@ -137,7 +137,7 @@ String getDefaultURL() { final String scheme = XPackSettings.HTTP_SSL_ENABLED.get(settings) ? "https" : "http"; List httpPublishHost = SETTING_HTTP_PUBLISH_HOST.get(settings); if (httpPublishHost.isEmpty()) { - httpPublishHost = NetworkService.GLOBAL_NETWORK_PUBLISHHOST_SETTING.get(settings); + httpPublishHost = NetworkService.GLOBAL_NETWORK_PUBLISH_HOST_SETTING.get(settings); } // we cannot do custom name resolution here... diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/filter/IPFilter.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/filter/IPFilter.java index 10172ff95e803..c9f60dce95cef 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/filter/IPFilter.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/filter/IPFilter.java @@ -18,7 +18,7 @@ import org.elasticsearch.common.transport.BoundTransportAddress; import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.license.XPackLicenseState; -import org.elasticsearch.transport.TcpTransport; +import org.elasticsearch.transport.TransportSettings; import org.elasticsearch.xpack.security.audit.AuditTrailService; import java.net.InetSocketAddress; @@ -128,7 +128,7 @@ public IPFilter(final Settings settings, AuditTrailService auditTrail, ClusterSe isHttpFilterEnabled = IP_FILTER_ENABLED_HTTP_SETTING.get(settings); isIpFilterEnabled = IP_FILTER_ENABLED_SETTING.get(settings); - this.profiles = settings.getGroups("transport.profiles.",true).keySet().stream().filter(k -> TcpTransport + this.profiles = settings.getGroups("transport.profiles.",true).keySet().stream().filter(k -> TransportSettings .DEFAULT_PROFILE.equals(k) == false).collect(Collectors.toSet()); // exclude default profile -- it's handled differently for (String profile : profiles) { Setting> allowSetting = PROFILE_FILTER_ALLOW_SETTING.getConcreteSettingForNamespace(profile); @@ -237,7 +237,7 @@ private Map parseSettings() { if (isIpFilterEnabled && boundTransportAddress.get() != null) { TransportAddress[] localAddresses = boundTransportAddress.get().boundAddresses(); - profileRules.put(TcpTransport.DEFAULT_PROFILE, createRules(transportAllowFilter, transportDenyFilter, localAddresses)); + profileRules.put(TransportSettings.DEFAULT_PROFILE, createRules(transportAllowFilter, transportDenyFilter, localAddresses)); for (String profile : profiles) { BoundTransportAddress profileBoundTransportAddress = profileBoundAddress.get().get(profile); if (profileBoundTransportAddress == null) { diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/nio/SecurityNioTransport.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/nio/SecurityNioTransport.java index 0642f635ed0d3..b536644ad6121 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/nio/SecurityNioTransport.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/transport/nio/SecurityNioTransport.java @@ -28,7 +28,7 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.ConnectTransportException; import org.elasticsearch.transport.TcpChannel; -import org.elasticsearch.transport.TcpTransport; +import org.elasticsearch.transport.TransportSettings; import org.elasticsearch.transport.nio.NioTcpChannel; import org.elasticsearch.transport.nio.NioTcpServerChannel; import org.elasticsearch.transport.nio.NioTransport; @@ -214,7 +214,7 @@ public NioTcpServerChannel createServerChannel(NioSelector selector, ServerSocke protected SSLEngine createSSLEngine(SocketChannel channel) throws IOException { SSLEngine sslEngine; - SSLConfiguration defaultConfig = profileConfiguration.get(TcpTransport.DEFAULT_PROFILE); + SSLConfiguration defaultConfig = profileConfiguration.get(TransportSettings.DEFAULT_PROFILE); SSLConfiguration sslConfig = profileConfiguration.getOrDefault(profileName, defaultConfig); boolean hostnameVerificationEnabled = sslConfig.verificationMode().isHostnameVerificationEnabled(); if (hostnameVerificationEnabled) { @@ -233,7 +233,7 @@ private class SecurityClientTcpChannelFactory extends SecurityTcpChannelFactory private final SNIHostName serverName; private SecurityClientTcpChannelFactory(RawChannelFactory rawChannelFactory, SNIHostName serverName) { - super(rawChannelFactory, TcpTransport.DEFAULT_PROFILE, true); + super(rawChannelFactory, TransportSettings.DEFAULT_PROFILE, true); this.serverName = serverName; } diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/AbstractSimpleSecurityTransportTestCase.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/AbstractSimpleSecurityTransportTestCase.java index af865914b6bf8..ea7a6aa633164 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/AbstractSimpleSecurityTransportTestCase.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/AbstractSimpleSecurityTransportTestCase.java @@ -26,6 +26,7 @@ import org.elasticsearch.transport.Transport; import org.elasticsearch.transport.TransportRequestOptions; import org.elasticsearch.transport.TransportService; +import org.elasticsearch.transport.TransportSettings; import org.elasticsearch.xpack.core.common.socket.SocketAccess; import org.elasticsearch.xpack.core.ssl.SSLConfiguration; import org.elasticsearch.xpack.core.ssl.SSLService; @@ -115,8 +116,8 @@ public void testBindUnavailableAddress() { int port = serviceA.boundAddress().publishAddress().getPort(); Settings settings = Settings.builder() .put(Node.NODE_NAME_SETTING.getKey(), "foobar") - .put(TransportService.TRACE_LOG_INCLUDE_SETTING.getKey(), "") - .put(TransportService.TRACE_LOG_EXCLUDE_SETTING.getKey(), "NOTHING") + .put(TransportSettings.TRACE_LOG_INCLUDE_SETTING.getKey(), "") + .put(TransportSettings.TRACE_LOG_EXCLUDE_SETTING.getKey(), "NOTHING") .put("transport.tcp.port", port) .build(); ClusterSettings clusterSettings = new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ServerTransportFilterTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ServerTransportFilterTests.java index 17df337d2916f..dd340cb5839a0 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ServerTransportFilterTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ServerTransportFilterTests.java @@ -19,9 +19,9 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.transport.TcpTransport; import org.elasticsearch.transport.TransportChannel; import org.elasticsearch.transport.TransportRequest; +import org.elasticsearch.transport.TransportSettings; import org.elasticsearch.xpack.core.security.SecurityContext; import org.elasticsearch.xpack.core.security.authc.Authentication; import org.elasticsearch.xpack.core.security.authc.Authentication.RealmRef; @@ -65,7 +65,7 @@ public void init() throws Exception { authcService = mock(AuthenticationService.class); authzService = mock(AuthorizationService.class); channel = mock(TransportChannel.class); - when(channel.getProfileName()).thenReturn(TcpTransport.DEFAULT_PROFILE); + when(channel.getProfileName()).thenReturn(TransportSettings.DEFAULT_PROFILE); when(channel.getVersion()).thenReturn(Version.CURRENT); failDestructiveOperations = randomBoolean(); Settings settings = Settings.builder() diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/netty4/IPHostnameVerificationTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/netty4/IPHostnameVerificationTests.java index bc674ae1aa00e..130fa22603940 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/netty4/IPHostnameVerificationTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/netty4/IPHostnameVerificationTests.java @@ -9,7 +9,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.test.SecurityIntegTestCase; import org.elasticsearch.test.SecuritySettingsSource; -import org.elasticsearch.transport.TcpTransport; +import org.elasticsearch.transport.TransportSettings; import org.elasticsearch.xpack.core.ssl.SSLClientAuth; import java.nio.file.Files; @@ -61,7 +61,7 @@ protected Settings nodeSettings(int nodeOrdinal) { return settingsBuilder.put("xpack.ssl.key", keyPath.toAbsolutePath()) .put("xpack.ssl.certificate", certPath.toAbsolutePath()) .put("xpack.ssl.certificate_authorities", certPath.toAbsolutePath()) - .put(TcpTransport.BIND_HOST.getKey(), "127.0.0.1") + .put(TransportSettings.BIND_HOST.getKey(), "127.0.0.1") .put("network.host", "127.0.0.1") .put("xpack.ssl.client_authentication", SSLClientAuth.NONE) .put("xpack.ssl.verification_mode", "full") diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/netty4/SimpleSecurityNetty4ServerTransportTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/netty4/SimpleSecurityNetty4ServerTransportTests.java index d5a5cedc19a0a..f70a286efe055 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/netty4/SimpleSecurityNetty4ServerTransportTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/netty4/SimpleSecurityNetty4ServerTransportTests.java @@ -18,8 +18,8 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.ConnectionProfile; import org.elasticsearch.transport.TcpChannel; -import org.elasticsearch.transport.TcpTransport; import org.elasticsearch.transport.Transport; +import org.elasticsearch.transport.TransportSettings; import org.elasticsearch.xpack.security.transport.AbstractSimpleSecurityTransportTestCase; import java.util.Collections; @@ -56,9 +56,9 @@ public void executeHandshake(DiscoveryNode node, TcpChannel channel, ConnectionP @Override protected MockTransportService build(Settings settings, Version version, ClusterSettings clusterSettings, boolean doHandshake) { - if (TcpTransport.PORT.exists(settings) == false) { + if (TransportSettings.PORT.exists(settings) == false) { settings = Settings.builder().put(settings) - .put(TcpTransport.PORT.getKey(), "0") + .put(TransportSettings.PORT.getKey(), "0") .build(); } MockTransportService transportService = nettyFromThreadPool(settings, threadPool, version, clusterSettings, doHandshake); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/nio/SimpleSecurityNioTransportTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/nio/SimpleSecurityNioTransportTests.java index 11d2e2a984874..84d68ffd63e63 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/nio/SimpleSecurityNioTransportTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/nio/SimpleSecurityNioTransportTests.java @@ -18,8 +18,8 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.ConnectionProfile; import org.elasticsearch.transport.TcpChannel; -import org.elasticsearch.transport.TcpTransport; import org.elasticsearch.transport.Transport; +import org.elasticsearch.transport.TransportSettings; import org.elasticsearch.xpack.security.transport.AbstractSimpleSecurityTransportTestCase; import java.util.Collections; @@ -55,9 +55,9 @@ public void executeHandshake(DiscoveryNode node, TcpChannel channel, ConnectionP @Override protected MockTransportService build(Settings settings, Version version, ClusterSettings clusterSettings, boolean doHandshake) { - if (TcpTransport.PORT.exists(settings) == false) { + if (TransportSettings.PORT.exists(settings) == false) { settings = Settings.builder().put(settings) - .put(TcpTransport.PORT.getKey(), "0") + .put(TransportSettings.PORT.getKey(), "0") .build(); } MockTransportService transportService = nioFromThreadPool(settings, threadPool, version, clusterSettings, doHandshake); From 87ee1977cfc30c4f1fcd279b3fbe56ce4e28975a Mon Sep 17 00:00:00 2001 From: Tim Brooks Date: Wed, 12 Dec 2018 10:25:32 -0700 Subject: [PATCH 2/7] WIP --- .../main/java/org/elasticsearch/transport/TcpTransport.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/transport/TcpTransport.java b/server/src/main/java/org/elasticsearch/transport/TcpTransport.java index 6e9ab8a94980d..b48e444237c0a 100644 --- a/server/src/main/java/org/elasticsearch/transport/TcpTransport.java +++ b/server/src/main/java/org/elasticsearch/transport/TcpTransport.java @@ -1451,8 +1451,7 @@ public ProfileSettings(Settings settings, String profileName) { sendBufferSize = TransportSettings.TCP_SEND_BUFFER_SIZE_PROFILE.getConcreteSettingForNamespace(profileName).get(settings); receiveBufferSize = TransportSettings.TCP_RECEIVE_BUFFER_SIZE_PROFILE.getConcreteSettingForNamespace(profileName).get(settings); List profileBindHosts = TransportSettings.BIND_HOST_PROFILE.getConcreteSettingForNamespace(profileName).get(settings); - bindHosts = (profileBindHosts.isEmpty() ? NetworkService.GLOBAL_NETWORK_BIND_HOST_SETTING.get(settings) - : profileBindHosts); + bindHosts = (profileBindHosts.isEmpty() ? NetworkService.GLOBAL_NETWORK_BIND_HOST_SETTING.get(settings) : profileBindHosts); publishHosts = TransportSettings.PUBLISH_HOST_PROFILE.getConcreteSettingForNamespace(profileName).get(settings); Setting concretePort = TransportSettings.PORT_PROFILE.getConcreteSettingForNamespace(profileName); if (concretePort.exists(settings) == false && isDefaultProfile == false) { From 7c4a9ba8abd5de9ea54e145dc37294d208038256 Mon Sep 17 00:00:00 2001 From: Tim Brooks Date: Wed, 12 Dec 2018 11:05:10 -0700 Subject: [PATCH 3/7] WIP --- .../java/org/elasticsearch/http/HttpTransportSettings.java | 7 ++++++- .../org/elasticsearch/transport/TransportSettings.java | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/http/HttpTransportSettings.java b/server/src/main/java/org/elasticsearch/http/HttpTransportSettings.java index 4670137d09a54..ddd8bfa73850f 100644 --- a/server/src/main/java/org/elasticsearch/http/HttpTransportSettings.java +++ b/server/src/main/java/org/elasticsearch/http/HttpTransportSettings.java @@ -105,8 +105,13 @@ public final class HttpTransportSettings { public static final Setting SETTING_HTTP_READ_TIMEOUT = Setting.timeSetting("http.read_timeout", new TimeValue(0), new TimeValue(0), Property.NodeScope); - public static final Setting SETTING_HTTP_TCP_NO_DELAY = + // Tcp socket settings + + // TODO: Deprecate in 7.0 + public static final Setting OLD_SETTING_HTTP_TCP_NO_DELAY = boolSetting("http.tcp_no_delay", NetworkService.TCP_NO_DELAY, Setting.Property.NodeScope); + public static final Setting SETTING_HTTP_TCP_NO_DELAY = + boolSetting("http.tcp.no_delay", OLD_SETTING_HTTP_TCP_NO_DELAY, Setting.Property.NodeScope); public static final Setting SETTING_HTTP_TCP_KEEP_ALIVE = boolSetting("http.tcp.keep_alive", NetworkService.TCP_KEEP_ALIVE, Setting.Property.NodeScope); public static final Setting SETTING_HTTP_TCP_REUSE_ADDRESS = diff --git a/server/src/main/java/org/elasticsearch/transport/TransportSettings.java b/server/src/main/java/org/elasticsearch/transport/TransportSettings.java index 52264f3e7e45c..08642b26ceb46 100644 --- a/server/src/main/java/org/elasticsearch/transport/TransportSettings.java +++ b/server/src/main/java/org/elasticsearch/transport/TransportSettings.java @@ -36,7 +36,7 @@ import static org.elasticsearch.common.settings.Setting.listSetting; import static org.elasticsearch.common.settings.Setting.timeSetting; -public class TransportSettings { +public final class TransportSettings { public static final String DEFAULT_PROFILE = "default"; public static final String FEATURE_PREFIX = "transport.features"; @@ -143,4 +143,7 @@ public class TransportSettings { listSetting("transport.tracer.exclude", Arrays.asList("internal:discovery/zen/fd*", "internal:coordination/fault_detection/*", TransportLivenessAction.NAME), Function.identity(), Setting.Property.Dynamic, Setting.Property.NodeScope); + + private TransportSettings() { + } } From 6202e1e7d8bf3da67d221bd97000b317021f18e7 Mon Sep 17 00:00:00 2001 From: Tim Brooks Date: Thu, 13 Dec 2018 16:28:13 -0700 Subject: [PATCH 4/7] wip --- .../common/network/NetworkService.java | 3 +- .../common/settings/ClusterSettings.java | 37 +++++++++++-------- .../transport/TransportSettings.java | 4 +- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/common/network/NetworkService.java b/server/src/main/java/org/elasticsearch/common/network/NetworkService.java index a1a6d2896f1e9..cde873fa577a5 100644 --- a/server/src/main/java/org/elasticsearch/common/network/NetworkService.java +++ b/server/src/main/java/org/elasticsearch/common/network/NetworkService.java @@ -39,13 +39,14 @@ public final class NetworkService { /** By default, we bind to loopback interfaces */ public static final String DEFAULT_NETWORK_HOST = "_local_"; + public static final Setting NETWORK_SERVER = + Setting.boolSetting("network.server", true, Property.NodeScope); public static final Setting> GLOBAL_NETWORK_HOST_SETTING = Setting.listSetting("network.host", Collections.emptyList(), Function.identity(), Property.NodeScope); public static final Setting> GLOBAL_NETWORK_BIND_HOST_SETTING = Setting.listSetting("network.bind_host", GLOBAL_NETWORK_HOST_SETTING, Function.identity(), Property.NodeScope); public static final Setting> GLOBAL_NETWORK_PUBLISH_HOST_SETTING = Setting.listSetting("network.publish_host", GLOBAL_NETWORK_HOST_SETTING, Function.identity(), Property.NodeScope); - public static final Setting NETWORK_SERVER = Setting.boolSetting("network.server", true, Property.NodeScope); public static final Setting TCP_NO_DELAY = Setting.boolSetting("network.tcp.no_delay", true, Property.NodeScope); diff --git a/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java b/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java index d638147189a44..7dff778f829ac 100644 --- a/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java +++ b/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java @@ -268,6 +268,7 @@ public void apply(Settings value, Settings current, Settings previous) { HttpTransportSettings.SETTING_HTTP_MAX_INITIAL_LINE_LENGTH, HttpTransportSettings.SETTING_HTTP_READ_TIMEOUT, HttpTransportSettings.SETTING_HTTP_RESET_COOKIES, + HttpTransportSettings.OLD_SETTING_HTTP_TCP_NO_DELAY, HttpTransportSettings.SETTING_HTTP_TCP_NO_DELAY, HttpTransportSettings.SETTING_HTTP_TCP_KEEP_ALIVE, HttpTransportSettings.SETTING_HTTP_TCP_REUSE_ADDRESS, @@ -306,41 +307,48 @@ public void apply(Settings value, Settings current, Settings previous) { RemoteClusterService.SEARCH_ENABLE_REMOTE_CLUSTERS, RemoteClusterService.REMOTE_CLUSTER_PING_SCHEDULE, RemoteClusterService.REMOTE_CLUSTER_COMPRESS, - TransportSettings.TRACE_LOG_EXCLUDE_SETTING, - TransportSettings.TRACE_LOG_INCLUDE_SETTING, TransportCloseIndexAction.CLUSTER_INDICES_CLOSE_ENABLE_SETTING, ShardsLimitAllocationDecider.CLUSTER_TOTAL_SHARDS_PER_NODE_SETTING, NodeConnectionsService.CLUSTER_NODE_RECONNECT_INTERVAL_SETTING, HierarchyCircuitBreakerService.FIELDDATA_CIRCUIT_BREAKER_TYPE_SETTING, HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_TYPE_SETTING, - TransportSettings.TRANSPORT_COMPRESS, TransportSettings.HOST, TransportSettings.PUBLISH_HOST, + TransportSettings.PUBLISH_HOST_PROFILE, TransportSettings.BIND_HOST, - TransportSettings.PUBLISH_PORT, - TransportSettings.PORT, TransportSettings.BIND_HOST_PROFILE, - TransportSettings.PUBLISH_HOST_PROFILE, - TransportSettings.PUBLISH_PORT_PROFILE, + TransportSettings.OLD_PORT, + TransportSettings.PORT, TransportSettings.PORT_PROFILE, + TransportSettings.PUBLISH_PORT, + TransportSettings.PUBLISH_PORT_PROFILE, + TransportSettings.OLD_TRANSPORT_COMPRESS, + TransportSettings.TRANSPORT_COMPRESS, + TransportSettings.PING_SCHEDULE, + TransportSettings.CONNECT_TIMEOUT, + TransportSettings.DEFAULT_FEATURES_SETTING, + TransportSettings.OLD_TCP_NO_DELAY, + TransportSettings.TCP_NO_DELAY, + TransportSettings.OLD_TCP_NO_DELAY_PROFILE, TransportSettings.TCP_NO_DELAY_PROFILE, + TransportSettings.TCP_KEEP_ALIVE, + TransportSettings.OLD_TCP_KEEP_ALIVE_PROFILE, TransportSettings.TCP_KEEP_ALIVE_PROFILE, + TransportSettings.TCP_REUSE_ADDRESS, + TransportSettings.OLD_TCP_REUSE_ADDRESS_PROFILE, TransportSettings.TCP_REUSE_ADDRESS_PROFILE, + TransportSettings.TCP_SEND_BUFFER_SIZE, TransportSettings.TCP_SEND_BUFFER_SIZE_PROFILE, + TransportSettings.TCP_RECEIVE_BUFFER_SIZE, TransportSettings.TCP_RECEIVE_BUFFER_SIZE_PROFILE, TransportSettings.CONNECTIONS_PER_NODE_RECOVERY, TransportSettings.CONNECTIONS_PER_NODE_BULK, TransportSettings.CONNECTIONS_PER_NODE_REG, TransportSettings.CONNECTIONS_PER_NODE_STATE, TransportSettings.CONNECTIONS_PER_NODE_PING, - TransportSettings.CONNECT_TIMEOUT, - TransportSettings.PING_SCHEDULE, + TransportSettings.TRACE_LOG_EXCLUDE_SETTING, + TransportSettings.TRACE_LOG_INCLUDE_SETTING, NetworkService.NETWORK_SERVER, - TransportSettings.TCP_NO_DELAY, - TransportSettings.TCP_KEEP_ALIVE, - TransportSettings.TCP_REUSE_ADDRESS, - TransportSettings.TCP_SEND_BUFFER_SIZE, - TransportSettings.TCP_RECEIVE_BUFFER_SIZE, NetworkService.GLOBAL_NETWORK_HOST_SETTING, NetworkService.GLOBAL_NETWORK_BIND_HOST_SETTING, NetworkService.GLOBAL_NETWORK_PUBLISH_HOST_SETTING, @@ -413,7 +421,6 @@ public void apply(Settings value, Settings current, Settings previous) { ClusterModule.SHARDS_ALLOCATOR_TYPE_SETTING, EsExecutors.PROCESSORS_SETTING, ThreadContext.DEFAULT_HEADERS_SETTING, - TransportSettings.DEFAULT_FEATURES_SETTING, Loggers.LOG_DEFAULT_LEVEL_SETTING, Loggers.LOG_LEVEL_SETTING, NodeEnvironment.MAX_LOCAL_STORAGE_NODES_SETTING, diff --git a/server/src/main/java/org/elasticsearch/transport/TransportSettings.java b/server/src/main/java/org/elasticsearch/transport/TransportSettings.java index 08642b26ceb46..af9cd2787f66a 100644 --- a/server/src/main/java/org/elasticsearch/transport/TransportSettings.java +++ b/server/src/main/java/org/elasticsearch/transport/TransportSettings.java @@ -61,6 +61,8 @@ public final class TransportSettings { key -> new Setting<>(key, PORT, Function.identity(), Setting.Property.NodeScope)); public static final Setting PUBLISH_PORT = intSetting("transport.publish_port", -1, -1, Setting.Property.NodeScope); + public static final Setting.AffixSetting PUBLISH_PORT_PROFILE = affixKeySetting("transport.profiles.", "publish_port", + key -> intSetting(key, -1, -1, Setting.Property.NodeScope)); // TODO: Deprecate in 7.0 public static final Setting OLD_TRANSPORT_COMPRESS = boolSetting("transport.tcp.compress", false, Setting.Property.NodeScope); @@ -73,8 +75,6 @@ public final class TransportSettings { timeSetting("transport.tcp.connect_timeout", NetworkService.TCP_CONNECT_TIMEOUT, Setting.Property.NodeScope); public static final Setting CONNECT_TIMEOUT = timeSetting("transport.connect_timeout", TCP_CONNECT_TIMEOUT, Setting.Property.NodeScope); - public static final Setting.AffixSetting PUBLISH_PORT_PROFILE = affixKeySetting("transport.profiles.", "publish_port", - key -> intSetting(key, -1, -1, Setting.Property.NodeScope)); public static final Setting DEFAULT_FEATURES_SETTING = Setting.groupSetting(FEATURE_PREFIX + ".", Setting.Property.NodeScope); // Tcp socket settings From 6a1d1158f2f1cfef4884c19bce73efe78990eccf Mon Sep 17 00:00:00 2001 From: Tim Brooks Date: Thu, 13 Dec 2018 16:38:19 -0700 Subject: [PATCH 5/7] Cleanup --- .../java/org/elasticsearch/transport/TransportSettings.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/transport/TransportSettings.java b/server/src/main/java/org/elasticsearch/transport/TransportSettings.java index af9cd2787f66a..9943197559ff0 100644 --- a/server/src/main/java/org/elasticsearch/transport/TransportSettings.java +++ b/server/src/main/java/org/elasticsearch/transport/TransportSettings.java @@ -66,8 +66,8 @@ public final class TransportSettings { // TODO: Deprecate in 7.0 public static final Setting OLD_TRANSPORT_COMPRESS = boolSetting("transport.tcp.compress", false, Setting.Property.NodeScope); - public static final Setting TRANSPORT_COMPRESS = boolSetting("transport.compress", OLD_TRANSPORT_COMPRESS, - Setting.Property.NodeScope); + public static final Setting TRANSPORT_COMPRESS = + boolSetting("transport.compress", OLD_TRANSPORT_COMPRESS, Setting.Property.NodeScope); // the scheduled internal ping interval setting, defaults to disabled (-1) public static final Setting PING_SCHEDULE = timeSetting("transport.ping_schedule", TimeValue.timeValueSeconds(-1), Setting.Property.NodeScope); From 557b53b45030d302e16024ba4164391e402ac6bd Mon Sep 17 00:00:00 2001 From: Tim Brooks Date: Thu, 13 Dec 2018 17:25:45 -0700 Subject: [PATCH 6/7] Fix fallback settings --- .../transport/TransportSettings.java | 46 +++++++++++++------ 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/transport/TransportSettings.java b/server/src/main/java/org/elasticsearch/transport/TransportSettings.java index 9943197559ff0..f9bd8b4a9312b 100644 --- a/server/src/main/java/org/elasticsearch/transport/TransportSettings.java +++ b/server/src/main/java/org/elasticsearch/transport/TransportSettings.java @@ -88,39 +88,52 @@ public final class TransportSettings { public static final Setting.AffixSetting OLD_TCP_NO_DELAY_PROFILE = affixKeySetting("transport.profiles.", "tcp_no_delay", key -> boolSetting(key, TCP_NO_DELAY, Setting.Property.NodeScope)); public static final Setting.AffixSetting TCP_NO_DELAY_PROFILE = - affixKeySetting("transport.profiles.", "tcp.no_delay", key -> boolSetting(key, OLD_TCP_NO_DELAY_PROFILE, - Setting.Property.NodeScope)); + affixKeySetting("transport.profiles.", "tcp.no_delay", + key -> boolSetting(key, + fallback(key, OLD_TCP_NO_DELAY_PROFILE, "tcp\\.no_delay$", "tcp_no_delay"), + Setting.Property.NodeScope)); public static final Setting TCP_KEEP_ALIVE = boolSetting("transport.tcp.keep_alive", NetworkService.TCP_KEEP_ALIVE, Setting.Property.NodeScope); // TODO: Deprecate in 7.0 public static final Setting.AffixSetting OLD_TCP_KEEP_ALIVE_PROFILE = affixKeySetting("transport.profiles.", "tcp_keep_alive", key -> boolSetting(key, TCP_KEEP_ALIVE, Setting.Property.NodeScope)); public static final Setting.AffixSetting TCP_KEEP_ALIVE_PROFILE = - affixKeySetting("transport.profiles.", "tcp.keep_alive", key -> boolSetting(key, OLD_TCP_KEEP_ALIVE_PROFILE, - Setting.Property.NodeScope)); + affixKeySetting("transport.profiles.", "tcp.keep_alive", + key -> boolSetting(key, + fallback(key, OLD_TCP_KEEP_ALIVE_PROFILE, "tcp\\.keep_alive$", "tcp_keep_alive"), + Setting.Property.NodeScope)); public static final Setting TCP_REUSE_ADDRESS = boolSetting("transport.tcp.reuse_address", NetworkService.TCP_REUSE_ADDRESS, Setting.Property.NodeScope); // TODO: Deprecate in 7.0 public static final Setting.AffixSetting OLD_TCP_REUSE_ADDRESS_PROFILE = affixKeySetting("transport.profiles.", "reuse_address", key -> boolSetting(key, TCP_REUSE_ADDRESS, Setting.Property.NodeScope)); public static final Setting.AffixSetting TCP_REUSE_ADDRESS_PROFILE = - affixKeySetting("transport.profiles.", "tcp.reuse_address", key -> boolSetting(key, OLD_TCP_REUSE_ADDRESS_PROFILE, - Setting.Property.NodeScope)); + affixKeySetting("transport.profiles.", "tcp.reuse_address", + key -> boolSetting(key, + fallback(key, OLD_TCP_REUSE_ADDRESS_PROFILE, "tcp\\.reuse_address$", "reuse_address"), + Setting.Property.NodeScope)); public static final Setting TCP_SEND_BUFFER_SIZE = Setting.byteSizeSetting("transport.tcp.send_buffer_size", NetworkService.TCP_SEND_BUFFER_SIZE, Setting.Property.NodeScope); // TODO: Deprecate in 7.0 - public static final Setting.AffixSetting OLD_TCP_SEND_BUFFER_SIZE_PROFILE = affixKeySetting("transport.profiles.", - "send_buffer_size", key -> Setting.byteSizeSetting(key, TCP_SEND_BUFFER_SIZE, Setting.Property.NodeScope)); - public static final Setting.AffixSetting TCP_SEND_BUFFER_SIZE_PROFILE = affixKeySetting("transport.profiles.", - "tcp.send_buffer_size", key -> Setting.byteSizeSetting(key, OLD_TCP_SEND_BUFFER_SIZE_PROFILE, Setting.Property.NodeScope)); + public static final Setting.AffixSetting OLD_TCP_SEND_BUFFER_SIZE_PROFILE = + affixKeySetting("transport.profiles.", "send_buffer_size", + key -> Setting.byteSizeSetting(key, TCP_SEND_BUFFER_SIZE, Setting.Property.NodeScope)); + public static final Setting.AffixSetting TCP_SEND_BUFFER_SIZE_PROFILE = + affixKeySetting("transport.profiles.", "tcp.send_buffer_size", + key -> Setting.byteSizeSetting(key, + fallback(key, OLD_TCP_SEND_BUFFER_SIZE_PROFILE, "tcp\\.send_buffer_size$", "send_buffer_size"), + Setting.Property.NodeScope)); public static final Setting TCP_RECEIVE_BUFFER_SIZE = Setting.byteSizeSetting("transport.tcp.receive_buffer_size", NetworkService.TCP_RECEIVE_BUFFER_SIZE, Setting.Property.NodeScope); // TODO: Deprecate in 7.0 public static final Setting.AffixSetting OLD_TCP_RECEIVE_BUFFER_SIZE_PROFILE = - affixKeySetting("transport.profiles.", "receive_buffer_size", key -> Setting.byteSizeSetting(key, TCP_RECEIVE_BUFFER_SIZE, - Setting.Property.NodeScope)); - public static final Setting.AffixSetting TCP_RECEIVE_BUFFER_SIZE_PROFILE = affixKeySetting("transport.profiles.", - "tcp.receive_buffer_size", key -> Setting.byteSizeSetting(key, OLD_TCP_RECEIVE_BUFFER_SIZE_PROFILE, Setting.Property.NodeScope)); + affixKeySetting("transport.profiles.", "receive_buffer_size", + key -> Setting.byteSizeSetting(key, TCP_RECEIVE_BUFFER_SIZE, Setting.Property.NodeScope)); + public static final Setting.AffixSetting TCP_RECEIVE_BUFFER_SIZE_PROFILE = + affixKeySetting("transport.profiles.", "tcp.receive_buffer_size", + key -> Setting.byteSizeSetting(key, + fallback(key, OLD_TCP_RECEIVE_BUFFER_SIZE_PROFILE, "tcp\\.receive_buffer_size$", "receive_buffer_size"), + Setting.Property.NodeScope)); // Connections per node settings @@ -146,4 +159,9 @@ public final class TransportSettings { private TransportSettings() { } + + private static Setting fallback(String key, Setting.AffixSetting affixSetting, String regex, String replacement) { + return "_na_".equals(key) ? affixSetting.getConcreteSettingForNamespace(key) + : affixSetting.getConcreteSetting(key.replaceAll(regex, replacement)); + } } From cfa883428f78e1d90f72ccd547563ff5b3ee8c5b Mon Sep 17 00:00:00 2001 From: Tim Brooks Date: Thu, 13 Dec 2018 18:10:38 -0700 Subject: [PATCH 7/7] Fix tests --- .../transport/netty4/SimpleNetty4TransportTests.java | 2 +- .../elasticsearch/transport/nio/SimpleNioTransportTests.java | 2 +- .../java/org/elasticsearch/common/settings/ClusterSettings.java | 2 ++ .../transport/nio/SimpleMockNioTransportTests.java | 2 +- .../transport/AbstractSimpleSecurityTransportTestCase.java | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/SimpleNetty4TransportTests.java b/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/SimpleNetty4TransportTests.java index b60f720bae14f..10c91b4e8d7da 100644 --- a/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/SimpleNetty4TransportTests.java +++ b/modules/transport-netty4/src/test/java/org/elasticsearch/transport/netty4/SimpleNetty4TransportTests.java @@ -98,7 +98,7 @@ public void testBindUnavailableAddress() { .put(Node.NODE_NAME_SETTING.getKey(), "foobar") .put(TransportSettings.TRACE_LOG_INCLUDE_SETTING.getKey(), "") .put(TransportSettings.TRACE_LOG_EXCLUDE_SETTING.getKey(), "NOTHING") - .put("transport.tcp.port", port) + .put(TransportSettings.PORT.getKey(), port) .build(); ClusterSettings clusterSettings = new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); BindTransportException bindTransportException = expectThrows(BindTransportException.class, () -> { diff --git a/plugins/transport-nio/src/test/java/org/elasticsearch/transport/nio/SimpleNioTransportTests.java b/plugins/transport-nio/src/test/java/org/elasticsearch/transport/nio/SimpleNioTransportTests.java index a762ec169b8bc..82a991036270d 100644 --- a/plugins/transport-nio/src/test/java/org/elasticsearch/transport/nio/SimpleNioTransportTests.java +++ b/plugins/transport-nio/src/test/java/org/elasticsearch/transport/nio/SimpleNioTransportTests.java @@ -105,7 +105,7 @@ public void testBindUnavailableAddress() { .put(Node.NODE_NAME_SETTING.getKey(), "foobar") .put(TransportSettings.TRACE_LOG_INCLUDE_SETTING.getKey(), "") .put(TransportSettings.TRACE_LOG_EXCLUDE_SETTING.getKey(), "NOTHING") - .put("transport.tcp.port", port) + .put(TransportSettings.PORT.getKey(), port) .build(); ClusterSettings clusterSettings = new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); BindTransportException bindTransportException = expectThrows(BindTransportException.class, () -> { diff --git a/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java b/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java index 7dff778f829ac..634f722578c52 100644 --- a/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java +++ b/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java @@ -338,8 +338,10 @@ public void apply(Settings value, Settings current, Settings previous) { TransportSettings.OLD_TCP_REUSE_ADDRESS_PROFILE, TransportSettings.TCP_REUSE_ADDRESS_PROFILE, TransportSettings.TCP_SEND_BUFFER_SIZE, + TransportSettings.OLD_TCP_SEND_BUFFER_SIZE_PROFILE, TransportSettings.TCP_SEND_BUFFER_SIZE_PROFILE, TransportSettings.TCP_RECEIVE_BUFFER_SIZE, + TransportSettings.OLD_TCP_RECEIVE_BUFFER_SIZE_PROFILE, TransportSettings.TCP_RECEIVE_BUFFER_SIZE_PROFILE, TransportSettings.CONNECTIONS_PER_NODE_RECOVERY, TransportSettings.CONNECTIONS_PER_NODE_BULK, diff --git a/test/framework/src/test/java/org/elasticsearch/transport/nio/SimpleMockNioTransportTests.java b/test/framework/src/test/java/org/elasticsearch/transport/nio/SimpleMockNioTransportTests.java index 8150a1d8b8dd9..344701b7b43b5 100644 --- a/test/framework/src/test/java/org/elasticsearch/transport/nio/SimpleMockNioTransportTests.java +++ b/test/framework/src/test/java/org/elasticsearch/transport/nio/SimpleMockNioTransportTests.java @@ -108,7 +108,7 @@ public void testBindUnavailableAddress() { int port = serviceA.boundAddress().publishAddress().getPort(); Settings settings = Settings.builder() .put(Node.NODE_NAME_SETTING.getKey(), "foobar") - .put("transport.tcp.port", port) + .put(TransportSettings.PORT.getKey(), port) .build(); ClusterSettings clusterSettings = new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); BindTransportException bindTransportException = expectThrows(BindTransportException.class, () -> { diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/AbstractSimpleSecurityTransportTestCase.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/AbstractSimpleSecurityTransportTestCase.java index ea7a6aa633164..e01fecf97e1b3 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/AbstractSimpleSecurityTransportTestCase.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/AbstractSimpleSecurityTransportTestCase.java @@ -118,7 +118,7 @@ public void testBindUnavailableAddress() { .put(Node.NODE_NAME_SETTING.getKey(), "foobar") .put(TransportSettings.TRACE_LOG_INCLUDE_SETTING.getKey(), "") .put(TransportSettings.TRACE_LOG_EXCLUDE_SETTING.getKey(), "NOTHING") - .put("transport.tcp.port", port) + .put(TransportSettings.PORT.getKey(), port) .build(); ClusterSettings clusterSettings = new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); BindTransportException bindTransportException = expectThrows(BindTransportException.class, () -> {