summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorSimon Willnauer <simonw@apache.org>2017-07-02 10:16:50 +0200
committerGitHub <noreply@github.com>2017-07-02 10:16:50 +0200
commit5a7c8bb04ed135be1823a4db6b08f7481d7d22c0 (patch)
treeefbc4ac1d1f0bf0f09c4587d74de16d3d5096a84 /core/src
parent2975e7f511d784b1a1d6dfea95d3e75ab241dfdb (diff)
Cleanup network / transport related settings (#25489)
This commit makes the use of the global network settings explicit instead of implicit within NetworkService. It cleans up several places where we fall back to the global settings while we should have used tcp or http ones. In addition this change also removes unnecessary settings classes
Diffstat (limited to 'core/src')
-rw-r--r--core/src/main/java/org/elasticsearch/bootstrap/Security.java10
-rw-r--r--core/src/main/java/org/elasticsearch/client/transport/TransportClient.java2
-rw-r--r--core/src/main/java/org/elasticsearch/common/network/NetworkService.java89
-rw-r--r--core/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java25
-rw-r--r--core/src/main/java/org/elasticsearch/node/Node.java6
-rw-r--r--core/src/main/java/org/elasticsearch/transport/TcpTransport.java76
-rw-r--r--core/src/main/java/org/elasticsearch/transport/TransportSettings.java56
-rw-r--r--core/src/main/java/org/elasticsearch/tribe/TribeService.java8
-rw-r--r--core/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TaskManagerTestCase.java2
-rw-r--r--core/src/test/java/org/elasticsearch/action/support/replication/BroadcastReplicationTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/common/network/NetworkServiceTests.java24
-rw-r--r--core/src/test/java/org/elasticsearch/discovery/ZenFaultDetectionTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/discovery/zen/UnicastZenPingTests.java30
-rw-r--r--core/src/test/java/org/elasticsearch/index/mapper/DynamicMappingDisabledTests.java2
-rw-r--r--core/src/test/java/org/elasticsearch/transport/PublishPortTests.java6
-rw-r--r--core/src/test/java/org/elasticsearch/transport/TransportServiceHandshakeTests.java2
17 files changed, 140 insertions, 208 deletions
diff --git a/core/src/main/java/org/elasticsearch/bootstrap/Security.java b/core/src/main/java/org/elasticsearch/bootstrap/Security.java
index 9504bdefa5..075456cd9e 100644
--- a/core/src/main/java/org/elasticsearch/bootstrap/Security.java
+++ b/core/src/main/java/org/elasticsearch/bootstrap/Security.java
@@ -27,7 +27,7 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
import org.elasticsearch.http.HttpTransportSettings;
import org.elasticsearch.plugins.PluginInfo;
-import org.elasticsearch.transport.TransportSettings;
+import org.elasticsearch.transport.TcpTransport;
import java.io.FilePermission;
import java.io.IOException;
@@ -324,8 +324,8 @@ final class Security {
final Permissions policy,
final Settings settings) {
// transport is way over-engineered
- final Map<String, Settings> profiles = new HashMap<>(TransportSettings.TRANSPORT_PROFILES_SETTING.get(settings).getAsGroups());
- profiles.putIfAbsent(TransportSettings.DEFAULT_PROFILE, Settings.EMPTY);
+ final Map<String, Settings> profiles = new HashMap<>(TcpTransport.TRANSPORT_PROFILES_SETTING.get(settings).getAsGroups());
+ profiles.putIfAbsent(TcpTransport.DEFAULT_PROFILE, Settings.EMPTY);
// loop through all profiles and add permissions for each one, if it's valid; otherwise Netty transports are lenient and ignores it
for (final Map.Entry<String, Settings> entry : profiles.entrySet()) {
@@ -335,7 +335,7 @@ final class Security {
// a profile is only valid if it's the default profile, or if it has an actual name and specifies a port
// TODO: can this leniency be removed?
final boolean valid =
- TransportSettings.DEFAULT_PROFILE.equals(name) ||
+ TcpTransport.DEFAULT_PROFILE.equals(name) ||
(name != null && name.length() > 0 && profileSettings.get("port") != null);
if (valid) {
final String transportRange = profileSettings.get("port");
@@ -355,7 +355,7 @@ final class Security {
* @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 = TransportSettings.PORT.get(settings);
+ final String transportRange = TcpTransport.PORT.get(settings);
addSocketPermissionForPortRange(policy, transportRange);
}
diff --git a/core/src/main/java/org/elasticsearch/client/transport/TransportClient.java b/core/src/main/java/org/elasticsearch/client/transport/TransportClient.java
index 1cf79c26d9..83cdd95119 100644
--- a/core/src/main/java/org/elasticsearch/client/transport/TransportClient.java
+++ b/core/src/main/java/org/elasticsearch/client/transport/TransportClient.java
@@ -127,7 +127,7 @@ public abstract class TransportClient extends AbstractClient {
final List<Closeable> resourcesToClose = new ArrayList<>();
final ThreadPool threadPool = new ThreadPool(settings);
resourcesToClose.add(() -> ThreadPool.terminate(threadPool, 10, TimeUnit.SECONDS));
- final NetworkService networkService = new NetworkService(settings, Collections.emptyList());
+ final NetworkService networkService = new NetworkService(Collections.emptyList());
try {
final List<Setting<?>> additionalSettings = new ArrayList<>(pluginsService.getPluginSettings());
final List<String> additionalSettingsFilter = new ArrayList<>(pluginsService.getPluginSettingsFilter());
diff --git a/core/src/main/java/org/elasticsearch/common/network/NetworkService.java b/core/src/main/java/org/elasticsearch/common/network/NetworkService.java
index a9d3dc4a33..b9440edd5c 100644
--- a/core/src/main/java/org/elasticsearch/common/network/NetworkService.java
+++ b/core/src/main/java/org/elasticsearch/common/network/NetworkService.java
@@ -19,11 +19,8 @@
package org.elasticsearch.common.network;
-import org.elasticsearch.common.Strings;
-import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Setting.Property;
-import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.unit.TimeValue;
@@ -31,38 +28,37 @@ import java.io.IOException;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
+import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
-public class NetworkService extends AbstractComponent {
+public final class NetworkService {
/** By default, we bind to loopback interfaces */
public static final String DEFAULT_NETWORK_HOST = "_local_";
-
public static final Setting<List<String>> GLOBAL_NETWORK_HOST_SETTING =
- Setting.listSetting("network.host", Arrays.asList(DEFAULT_NETWORK_HOST), Function.identity(), Property.NodeScope);
+ Setting.listSetting("network.host", Collections.emptyList(), Function.identity(), Property.NodeScope);
public static final Setting<List<String>> GLOBAL_NETWORK_BINDHOST_SETTING =
Setting.listSetting("network.bind_host", GLOBAL_NETWORK_HOST_SETTING, Function.identity(), Property.NodeScope);
public static final Setting<List<String>> GLOBAL_NETWORK_PUBLISHHOST_SETTING =
Setting.listSetting("network.publish_host", GLOBAL_NETWORK_HOST_SETTING, Function.identity(), Property.NodeScope);
public static final Setting<Boolean> NETWORK_SERVER = Setting.boolSetting("network.server", true, Property.NodeScope);
- public static final class TcpSettings {
- public static final Setting<Boolean> TCP_NO_DELAY =
- Setting.boolSetting("network.tcp.no_delay", true, Property.NodeScope);
- public static final Setting<Boolean> TCP_KEEP_ALIVE =
- Setting.boolSetting("network.tcp.keep_alive", true, Property.NodeScope);
- public static final Setting<Boolean> TCP_REUSE_ADDRESS =
- Setting.boolSetting("network.tcp.reuse_address", NetworkUtils.defaultReuseAddress(), Property.NodeScope);
- public static final Setting<ByteSizeValue> TCP_SEND_BUFFER_SIZE =
- Setting.byteSizeSetting("network.tcp.send_buffer_size", new ByteSizeValue(-1), Property.NodeScope);
- public static final Setting<ByteSizeValue> TCP_RECEIVE_BUFFER_SIZE =
- Setting.byteSizeSetting("network.tcp.receive_buffer_size", new ByteSizeValue(-1), Property.NodeScope);
- public static final Setting<TimeValue> TCP_CONNECT_TIMEOUT =
- Setting.timeSetting("network.tcp.connect_timeout", new TimeValue(30, TimeUnit.SECONDS), Property.NodeScope);
- }
+ public static final Setting<Boolean> TCP_NO_DELAY =
+ Setting.boolSetting("network.tcp.no_delay", true, Property.NodeScope);
+ public static final Setting<Boolean> TCP_KEEP_ALIVE =
+ Setting.boolSetting("network.tcp.keep_alive", true, Property.NodeScope);
+ public static final Setting<Boolean> TCP_REUSE_ADDRESS =
+ Setting.boolSetting("network.tcp.reuse_address", NetworkUtils.defaultReuseAddress(), Property.NodeScope);
+ public static final Setting<ByteSizeValue> TCP_SEND_BUFFER_SIZE =
+ Setting.byteSizeSetting("network.tcp.send_buffer_size", new ByteSizeValue(-1), Property.NodeScope);
+ public static final Setting<ByteSizeValue> TCP_RECEIVE_BUFFER_SIZE =
+ Setting.byteSizeSetting("network.tcp.receive_buffer_size", new ByteSizeValue(-1), Property.NodeScope);
+ public static final Setting<TimeValue> TCP_CONNECT_TIMEOUT =
+ Setting.timeSetting("network.tcp.connect_timeout", new TimeValue(30, TimeUnit.SECONDS), Property.NodeScope);
/**
* A custom name resolver can support custom lookup keys (my_net_key:ipv4) and also change
@@ -82,9 +78,8 @@ public class NetworkService extends AbstractComponent {
private final List<CustomNameResolver> customNameResolvers;
- public NetworkService(Settings settings, List<CustomNameResolver> customNameResolvers) {
- super(settings);
- this.customNameResolvers = customNameResolvers;
+ public NetworkService(List<CustomNameResolver> customNameResolvers) {
+ this.customNameResolvers = Objects.requireNonNull(customNameResolvers, "customNameResolvers must be non null");
}
/**
@@ -92,29 +87,20 @@ public class NetworkService extends AbstractComponent {
* not contain duplicate addresses.
*
* @param bindHosts list of hosts to bind to. this may contain special pseudo-hostnames
- * such as _local_ (see the documentation). if it is null, it will be populated
- * based on global default settings.
+ * such as _local_ (see the documentation). if it is null, it will fall back to _local_
+ *
* @return unique set of internet addresses
*/
public InetAddress[] resolveBindHostAddresses(String bindHosts[]) throws IOException {
- // first check settings
if (bindHosts == null || bindHosts.length == 0) {
- if (GLOBAL_NETWORK_BINDHOST_SETTING.exists(settings) || GLOBAL_NETWORK_HOST_SETTING.exists(settings)) {
- // if we have settings use them (we have a fallback to GLOBAL_NETWORK_HOST_SETTING inline
- bindHosts = GLOBAL_NETWORK_BINDHOST_SETTING.get(settings).toArray(Strings.EMPTY_ARRAY);
- } else {
- // next check any registered custom resolvers if any
- if (customNameResolvers != null) {
- for (CustomNameResolver customNameResolver : customNameResolvers) {
- InetAddress addresses[] = customNameResolver.resolveDefault();
- if (addresses != null) {
- return addresses;
- }
- }
+ for (CustomNameResolver customNameResolver : customNameResolvers) {
+ InetAddress addresses[] = customNameResolver.resolveDefault();
+ if (addresses != null) {
+ return addresses;
}
- // we know it's not here. get the defaults
- bindHosts = GLOBAL_NETWORK_BINDHOST_SETTING.get(settings).toArray(Strings.EMPTY_ARRAY);
}
+ // we know it's not here. get the defaults
+ bindHosts = new String[] {"_local_"};
}
InetAddress addresses[] = resolveInetAddresses(bindHosts);
@@ -140,29 +126,20 @@ public class NetworkService extends AbstractComponent {
* If {@code publishHosts} resolves to more than one address, <b>then one is selected with magic</b>
*
* @param publishHosts list of hosts to publish as. this may contain special pseudo-hostnames
- * such as _local_ (see the documentation). if it is null, it will be populated
- * based on global default settings.
+ * such as _local_ (see the documentation). if it is null, it will fall back to _local_
* @return single internet address
*/
// TODO: needs to be InetAddress[]
public InetAddress resolvePublishHostAddresses(String publishHosts[]) throws IOException {
if (publishHosts == null || publishHosts.length == 0) {
- if (GLOBAL_NETWORK_PUBLISHHOST_SETTING.exists(settings) || GLOBAL_NETWORK_HOST_SETTING.exists(settings)) {
- // if we have settings use them (we have a fallback to GLOBAL_NETWORK_HOST_SETTING inline
- publishHosts = GLOBAL_NETWORK_PUBLISHHOST_SETTING.get(settings).toArray(Strings.EMPTY_ARRAY);
- } else {
- // next check any registered custom resolvers if any
- if (customNameResolvers != null) {
- for (CustomNameResolver customNameResolver : customNameResolvers) {
- InetAddress addresses[] = customNameResolver.resolveDefault();
- if (addresses != null) {
- return addresses[0];
- }
- }
+ for (CustomNameResolver customNameResolver : customNameResolvers) {
+ InetAddress addresses[] = customNameResolver.resolveDefault();
+ if (addresses != null) {
+ return addresses[0];
}
- // we know it's not here. get the defaults
- publishHosts = GLOBAL_NETWORK_PUBLISHHOST_SETTING.get(settings).toArray(Strings.EMPTY_ARRAY);
}
+ // we know it's not here. get the defaults
+ publishHosts = new String[] {DEFAULT_NETWORK_HOST};
}
InetAddress addresses[] = resolveInetAddresses(publishHosts);
diff --git a/core/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java b/core/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java
index 15dffc427e..febede42da 100644
--- a/core/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java
+++ b/core/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java
@@ -91,7 +91,6 @@ 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.tribe.TribeService;
import org.elasticsearch.watcher.ResourceWatcherService;
@@ -270,12 +269,12 @@ public final class ClusterSettings extends AbstractScopedSettings {
HierarchyCircuitBreakerService.FIELDDATA_CIRCUIT_BREAKER_TYPE_SETTING,
HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_TYPE_SETTING,
Transport.TRANSPORT_TCP_COMPRESS,
- TransportSettings.TRANSPORT_PROFILES_SETTING,
- TransportSettings.HOST,
- TransportSettings.PUBLISH_HOST,
- TransportSettings.BIND_HOST,
- TransportSettings.PUBLISH_PORT,
- TransportSettings.PORT,
+ TcpTransport.TRANSPORT_PROFILES_SETTING,
+ TcpTransport.HOST,
+ TcpTransport.PUBLISH_HOST,
+ TcpTransport.BIND_HOST,
+ TcpTransport.PUBLISH_PORT,
+ TcpTransport.PORT,
TcpTransport.CONNECTIONS_PER_NODE_RECOVERY,
TcpTransport.CONNECTIONS_PER_NODE_BULK,
TcpTransport.CONNECTIONS_PER_NODE_REG,
@@ -292,12 +291,12 @@ public final class ClusterSettings extends AbstractScopedSettings {
NetworkService.GLOBAL_NETWORK_HOST_SETTING,
NetworkService.GLOBAL_NETWORK_BINDHOST_SETTING,
NetworkService.GLOBAL_NETWORK_PUBLISHHOST_SETTING,
- NetworkService.TcpSettings.TCP_NO_DELAY,
- NetworkService.TcpSettings.TCP_KEEP_ALIVE,
- NetworkService.TcpSettings.TCP_REUSE_ADDRESS,
- NetworkService.TcpSettings.TCP_SEND_BUFFER_SIZE,
- NetworkService.TcpSettings.TCP_RECEIVE_BUFFER_SIZE,
- NetworkService.TcpSettings.TCP_CONNECT_TIMEOUT,
+ NetworkService.TCP_NO_DELAY,
+ NetworkService.TCP_KEEP_ALIVE,
+ NetworkService.TCP_REUSE_ADDRESS,
+ NetworkService.TCP_SEND_BUFFER_SIZE,
+ NetworkService.TCP_RECEIVE_BUFFER_SIZE,
+ NetworkService.TCP_CONNECT_TIMEOUT,
IndexSettings.QUERY_STRING_ANALYZE_WILDCARD,
IndexSettings.QUERY_STRING_ALLOW_LEADING_WILDCARD,
ScriptService.SCRIPT_CACHE_SIZE_SETTING,
diff --git a/core/src/main/java/org/elasticsearch/node/Node.java b/core/src/main/java/org/elasticsearch/node/Node.java
index 93f37cddf0..b9e6668666 100644
--- a/core/src/main/java/org/elasticsearch/node/Node.java
+++ b/core/src/main/java/org/elasticsearch/node/Node.java
@@ -52,7 +52,6 @@ import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.routing.RoutingService;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.StopWatch;
-import org.elasticsearch.common.SuppressForbidden;
import org.elasticsearch.common.component.Lifecycle;
import org.elasticsearch.common.component.LifecycleComponent;
import org.elasticsearch.common.inject.Binder;
@@ -61,7 +60,6 @@ import org.elasticsearch.common.inject.Key;
import org.elasticsearch.common.inject.Module;
import org.elasticsearch.common.inject.ModulesBuilder;
import org.elasticsearch.common.inject.util.Providers;
-import org.elasticsearch.common.io.PathUtils;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.lease.Releasables;
import org.elasticsearch.common.logging.DeprecationLogger;
@@ -151,9 +149,7 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import java.util.Locale;
import java.util.Map;
-import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
@@ -330,7 +326,7 @@ public class Node implements Closeable {
final SettingsModule settingsModule = new SettingsModule(this.settings, additionalSettings, additionalSettingsFilter);
scriptModule.registerClusterSettingsListeners(settingsModule.getClusterSettings());
resourcesToClose.add(resourceWatcherService);
- final NetworkService networkService = new NetworkService(settings,
+ final NetworkService networkService = new NetworkService(
getCustomNameResolvers(pluginsService.filterPlugins(DiscoveryPlugin.class)));
final ClusterService clusterService = new ClusterService(settings, settingsModule.getClusterSettings(), threadPool);
clusterService.addListener(scriptModule.getScriptService());
diff --git a/core/src/main/java/org/elasticsearch/transport/TcpTransport.java b/core/src/main/java/org/elasticsearch/transport/TcpTransport.java
index 9631fc977c..f03b949c58 100644
--- a/core/src/main/java/org/elasticsearch/transport/TcpTransport.java
+++ b/core/src/main/java/org/elasticsearch/transport/TcpTransport.java
@@ -24,7 +24,6 @@ import org.apache.logging.log4j.message.ParameterizedMessage;
import org.apache.logging.log4j.util.Supplier;
import org.apache.lucene.util.IOUtils;
import org.elasticsearch.ElasticsearchException;
-import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.NotifyOnceListener;
@@ -67,7 +66,6 @@ import org.elasticsearch.common.util.concurrent.AbstractRunnable;
import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException;
import org.elasticsearch.common.util.concurrent.KeyedLock;
import org.elasticsearch.common.util.concurrent.ThreadContext;
-import org.elasticsearch.common.util.iterable.Iterables;
import org.elasticsearch.indices.breaker.CircuitBreakerService;
import org.elasticsearch.monitor.jvm.JvmInfo;
import org.elasticsearch.rest.RestStatus;
@@ -103,13 +101,17 @@ import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.function.Consumer;
+import java.util.function.Function;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
+import static java.util.Collections.emptyList;
import static java.util.Collections.unmodifiableMap;
import static org.elasticsearch.common.settings.Setting.boolSetting;
+import static org.elasticsearch.common.settings.Setting.groupSetting;
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;
@@ -120,6 +122,19 @@ public abstract class TcpTransport<Channel> extends AbstractLifecycleComponent i
public static final String TRANSPORT_SERVER_WORKER_THREAD_NAME_PREFIX = "transport_server_worker";
public static final String TRANSPORT_CLIENT_BOSS_THREAD_NAME_PREFIX = "transport_client_boss";
+ public static final Setting<List<String>> HOST =
+ listSetting("transport.host", emptyList(), Function.identity(), Setting.Property.NodeScope);
+ public static final Setting<List<String>> BIND_HOST =
+ listSetting("transport.bind_host", HOST, Function.identity(), Setting.Property.NodeScope);
+ public static final Setting<List<String>> PUBLISH_HOST =
+ listSetting("transport.publish_host", HOST, Function.identity(), Setting.Property.NodeScope);
+ public static final Setting<String> PORT =
+ new Setting<>("transport.tcp.port", "9300-9400", Function.identity(), Setting.Property.NodeScope);
+ public static final Setting<Integer> PUBLISH_PORT =
+ intSetting("transport.publish_port", -1, -1, Setting.Property.NodeScope);
+ public static final String DEFAULT_PROFILE = "default";
+ public static final Setting<Settings> TRANSPORT_PROFILES_SETTING =
+ groupSetting("transport.profiles.", Setting.Property.Dynamic, Setting.Property.NodeScope);
// the scheduled internal ping interval setting, defaults to disabled (-1)
public static final Setting<TimeValue> PING_SCHEDULE =
timeSetting("transport.ping_schedule", TimeValue.timeValueSeconds(-1), Setting.Property.NodeScope);
@@ -134,20 +149,21 @@ public abstract class TcpTransport<Channel> extends AbstractLifecycleComponent i
public static final Setting<Integer> CONNECTIONS_PER_NODE_PING =
intSetting("transport.connections_per_node.ping", 1, 1, Setting.Property.NodeScope);
public static final Setting<TimeValue> TCP_CONNECT_TIMEOUT =
- timeSetting("transport.tcp.connect_timeout", NetworkService.TcpSettings.TCP_CONNECT_TIMEOUT, Setting.Property.NodeScope);
+ timeSetting("transport.tcp.connect_timeout", NetworkService.TCP_CONNECT_TIMEOUT, Setting.Property.NodeScope);
public static final Setting<Boolean> TCP_NO_DELAY =
- boolSetting("transport.tcp_no_delay", NetworkService.TcpSettings.TCP_NO_DELAY, Setting.Property.NodeScope);
+ boolSetting("transport.tcp_no_delay", NetworkService.TCP_NO_DELAY, Setting.Property.NodeScope);
public static final Setting<Boolean> TCP_KEEP_ALIVE =
- boolSetting("transport.tcp.keep_alive", NetworkService.TcpSettings.TCP_KEEP_ALIVE, Setting.Property.NodeScope);
+ boolSetting("transport.tcp.keep_alive", NetworkService.TCP_KEEP_ALIVE, Setting.Property.NodeScope);
public static final Setting<Boolean> TCP_REUSE_ADDRESS =
- boolSetting("transport.tcp.reuse_address", NetworkService.TcpSettings.TCP_REUSE_ADDRESS, Setting.Property.NodeScope);
+ boolSetting("transport.tcp.reuse_address", NetworkService.TCP_REUSE_ADDRESS, Setting.Property.NodeScope);
public static final Setting<ByteSizeValue> TCP_SEND_BUFFER_SIZE =
- Setting.byteSizeSetting("transport.tcp.send_buffer_size", NetworkService.TcpSettings.TCP_SEND_BUFFER_SIZE,
+ Setting.byteSizeSetting("transport.tcp.send_buffer_size", NetworkService.TCP_SEND_BUFFER_SIZE,
Setting.Property.NodeScope);
public static final Setting<ByteSizeValue> TCP_RECEIVE_BUFFER_SIZE =
- Setting.byteSizeSetting("transport.tcp.receive_buffer_size", NetworkService.TcpSettings.TCP_RECEIVE_BUFFER_SIZE,
+ Setting.byteSizeSetting("transport.tcp.receive_buffer_size", NetworkService.TCP_RECEIVE_BUFFER_SIZE,
Setting.Property.NodeScope);
+
private static final long NINETY_PER_HEAP_SIZE = (long) (JvmInfo.jvmInfo().getMem().getHeapMax().getBytes() * 0.9);
private static final int PING_DATA_SIZE = -1;
private final CircuitBreakerService circuitBreakerService;
@@ -650,12 +666,12 @@ public abstract class TcpTransport<Channel> extends AbstractLifecycleComponent i
protected Map<String, Settings> buildProfileSettings() {
// extract default profile first and create standard bootstrap
- Map<String, Settings> profiles = TransportSettings.TRANSPORT_PROFILES_SETTING.get(settings).getAsGroups(true);
- if (!profiles.containsKey(TransportSettings.DEFAULT_PROFILE)) {
+ Map<String, Settings> profiles = TRANSPORT_PROFILES_SETTING.get(settings).getAsGroups(true);
+ if (!profiles.containsKey(DEFAULT_PROFILE)) {
profiles = new HashMap<>(profiles);
- profiles.put(TransportSettings.DEFAULT_PROFILE, Settings.EMPTY);
+ profiles.put(DEFAULT_PROFILE, Settings.EMPTY);
}
- Settings defaultSettings = profiles.get(TransportSettings.DEFAULT_PROFILE);
+ Settings defaultSettings = profiles.get(DEFAULT_PROFILE);
Map<String, Settings> result = new HashMap<>();
// loop through all profiles and start them up, special handling for default one
for (Map.Entry<String, Settings> entry : profiles.entrySet()) {
@@ -666,10 +682,10 @@ public abstract class TcpTransport<Channel> extends AbstractLifecycleComponent i
logger.info("transport profile configured without a name. skipping profile with settings [{}]",
profileSettings.toDelimitedString(','));
continue;
- } else if (TransportSettings.DEFAULT_PROFILE.equals(name)) {
+ } else if (DEFAULT_PROFILE.equals(name)) {
profileSettings = Settings.builder()
.put(profileSettings)
- .put("port", profileSettings.get("port", TransportSettings.PORT.get(this.settings)))
+ .put("port", profileSettings.get("port", PORT.get(this.settings)))
.build();
} else if (profileSettings.get("port") == null) {
// if profile does not have a port, skip it
@@ -696,10 +712,11 @@ public abstract class TcpTransport<Channel> extends AbstractLifecycleComponent i
return local;
}
- protected void bindServer(final String name, final Settings settings) {
+ protected void bindServer(final String name, final Settings profileSettings) {
// Bind and start to accept incoming connections.
InetAddress hostAddresses[];
- String bindHosts[] = settings.getAsArray("bind_host", null);
+ String bindHosts[] = profileSettings.getAsArray("bind_host",
+ NetworkService.GLOBAL_NETWORK_BINDHOST_SETTING.get(settings).toArray(Strings.EMPTY_ARRAY));
try {
hostAddresses = networkService.resolveBindHostAddresses(bindHosts);
} catch (IOException e) {
@@ -717,12 +734,12 @@ public abstract class TcpTransport<Channel> extends AbstractLifecycleComponent i
List<InetSocketAddress> boundAddresses = new ArrayList<>();
for (InetAddress hostAddress : hostAddresses) {
- boundAddresses.add(bindToPort(name, hostAddress, settings.get("port")));
+ boundAddresses.add(bindToPort(name, hostAddress, profileSettings.get("port")));
}
- final BoundTransportAddress boundTransportAddress = createBoundTransportAddress(name, settings, boundAddresses);
+ final BoundTransportAddress boundTransportAddress = createBoundTransportAddress(name, profileSettings, boundAddresses);
- if (TransportSettings.DEFAULT_PROFILE.equals(name)) {
+ if (DEFAULT_PROFILE.equals(name)) {
this.boundAddress = boundTransportAddress;
} else {
profileBoundAddresses.put(name, boundTransportAddress);
@@ -772,12 +789,15 @@ public abstract class TcpTransport<Channel> extends AbstractLifecycleComponent i
transportBoundAddresses[i] = new TransportAddress(boundAddress);
}
- final String[] publishHosts;
- if (TransportSettings.DEFAULT_PROFILE.equals(name)) {
- publishHosts = TransportSettings.PUBLISH_HOST.get(settings).toArray(Strings.EMPTY_ARRAY);
+ String[] publishHosts;
+ if (DEFAULT_PROFILE.equals(name)) {
+ publishHosts = PUBLISH_HOST.get(settings).toArray(Strings.EMPTY_ARRAY);
} else {
publishHosts = profileSettings.getAsArray("publish_host", boundAddressesHostStrings);
}
+ if (publishHosts == null || publishHosts.length == 0) {
+ publishHosts = NetworkService.GLOBAL_NETWORK_PUBLISHHOST_SETTING.get(settings).toArray(Strings.EMPTY_ARRAY);
+ }
final InetAddress publishInetAddress;
try {
@@ -795,8 +815,8 @@ public abstract class TcpTransport<Channel> extends AbstractLifecycleComponent i
public static int resolvePublishPort(String profileName, Settings settings, Settings profileSettings,
List<InetSocketAddress> boundAddresses, InetAddress publishInetAddress) {
int publishPort;
- if (TransportSettings.DEFAULT_PROFILE.equals(profileName)) {
- publishPort = TransportSettings.PUBLISH_PORT.get(settings);
+ if (DEFAULT_PROFILE.equals(profileName)) {
+ publishPort = PUBLISH_PORT.get(settings);
} else {
publishPort = profileSettings.getAsInt("publish_port", -1);
}
@@ -824,18 +844,18 @@ public abstract class TcpTransport<Channel> extends AbstractLifecycleComponent i
}
if (publishPort < 0) {
- String profileExplanation = TransportSettings.DEFAULT_PROFILE.equals(profileName) ? "" : " for profile " + profileName;
+ String profileExplanation = DEFAULT_PROFILE.equals(profileName) ? "" : " for profile " + profileName;
throw new BindTransportException("Failed to auto-resolve publish port" + profileExplanation + ", multiple bound addresses " +
boundAddresses + " with distinct ports and none of them matched the publish address (" + publishInetAddress + "). " +
- "Please specify a unique port by setting " + TransportSettings.PORT.getKey() + " or " +
- TransportSettings.PUBLISH_PORT.getKey());
+ "Please specify a unique port by setting " + PORT.getKey() + " or " +
+ PUBLISH_PORT.getKey());
}
return publishPort;
}
@Override
public TransportAddress[] addressesFromString(String address, int perAddressLimit) throws UnknownHostException {
- return parse(address, settings.get("transport.profiles.default.port", TransportSettings.PORT.get(settings)), perAddressLimit);
+ return parse(address, settings.get("transport.profiles.default.port", PORT.get(settings)), perAddressLimit);
}
// this code is a take on guava's HostAndPort, like a HostAndPortRange
diff --git a/core/src/main/java/org/elasticsearch/transport/TransportSettings.java b/core/src/main/java/org/elasticsearch/transport/TransportSettings.java
deleted file mode 100644
index 6965e4ed24..0000000000
--- a/core/src/main/java/org/elasticsearch/transport/TransportSettings.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.common.settings.Setting;
-import org.elasticsearch.common.settings.Setting.Property;
-import org.elasticsearch.common.settings.Settings;
-
-import java.util.List;
-import java.util.function.Function;
-
-import static java.util.Collections.emptyList;
-import static org.elasticsearch.common.settings.Setting.groupSetting;
-import static org.elasticsearch.common.settings.Setting.intSetting;
-import static org.elasticsearch.common.settings.Setting.listSetting;
-
-/**
- * a collection of settings related to transport components, which are also needed in org.elasticsearch.bootstrap.Security
- * This class should only contain static code which is *safe* to load before the security manager is enforced.
- */
-public final class TransportSettings {
-
- public static final Setting<List<String>> HOST =
- listSetting("transport.host", emptyList(), Function.identity(), Property.NodeScope);
- public static final Setting<List<String>> PUBLISH_HOST =
- listSetting("transport.publish_host", HOST, Function.identity(), Property.NodeScope);
- public static final Setting<List<String>> BIND_HOST =
- listSetting("transport.bind_host", HOST, Function.identity(), Property.NodeScope);
- public static final Setting<String> PORT =
- new Setting<>("transport.tcp.port", "9300-9400", Function.identity(), Property.NodeScope);
- public static final Setting<Integer> PUBLISH_PORT =
- intSetting("transport.publish_port", -1, -1, Property.NodeScope);
- public static final String DEFAULT_PROFILE = "default";
- public static final Setting<Settings> TRANSPORT_PROFILES_SETTING =
- groupSetting("transport.profiles.", Property.Dynamic, Property.NodeScope);
-
- private TransportSettings() {
-
- }
-}
diff --git a/core/src/main/java/org/elasticsearch/tribe/TribeService.java b/core/src/main/java/org/elasticsearch/tribe/TribeService.java
index 81ed347382..a85bda7593 100644
--- a/core/src/main/java/org/elasticsearch/tribe/TribeService.java
+++ b/core/src/main/java/org/elasticsearch/tribe/TribeService.java
@@ -65,7 +65,7 @@ import org.elasticsearch.env.Environment;
import org.elasticsearch.env.NodeEnvironment;
import org.elasticsearch.node.Node;
import org.elasticsearch.rest.RestStatus;
-import org.elasticsearch.transport.TransportSettings;
+import org.elasticsearch.transport.TcpTransport;
import java.io.IOException;
import java.nio.file.Path;
@@ -207,9 +207,9 @@ public class TribeService extends AbstractLifecycleComponent {
NetworkService.GLOBAL_NETWORK_HOST_SETTING,
NetworkService.GLOBAL_NETWORK_BINDHOST_SETTING,
NetworkService.GLOBAL_NETWORK_PUBLISHHOST_SETTING,
- TransportSettings.HOST,
- TransportSettings.BIND_HOST,
- TransportSettings.PUBLISH_HOST
+ TcpTransport.HOST,
+ TcpTransport.BIND_HOST,
+ TcpTransport.PUBLISH_HOST
);
private final String onConflict;
private final Set<String> droppedIndices = ConcurrentCollections.newConcurrentSet();
diff --git a/core/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TaskManagerTestCase.java b/core/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TaskManagerTestCase.java
index fdd5091485..de5c6690a3 100644
--- a/core/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TaskManagerTestCase.java
+++ b/core/src/test/java/org/elasticsearch/action/admin/cluster/node/tasks/TaskManagerTestCase.java
@@ -176,7 +176,7 @@ public abstract class TaskManagerTestCase extends ESTestCase {
transportService = new TransportService(settings,
new MockTcpTransport(settings, threadPool, BigArrays.NON_RECYCLING_INSTANCE, new NoneCircuitBreakerService(),
new NamedWriteableRegistry(ClusterModule.getNamedWriteables()),
- new NetworkService(settings, Collections.emptyList())),
+ new NetworkService(Collections.emptyList())),
threadPool, TransportService.NOOP_TRANSPORT_INTERCEPTOR, boundTransportAddressDiscoveryNodeFunction, null) {
@Override
protected TaskManager createTaskManager() {
diff --git a/core/src/test/java/org/elasticsearch/action/support/replication/BroadcastReplicationTests.java b/core/src/test/java/org/elasticsearch/action/support/replication/BroadcastReplicationTests.java
index 7fa900a921..9f1591f6a5 100644
--- a/core/src/test/java/org/elasticsearch/action/support/replication/BroadcastReplicationTests.java
+++ b/core/src/test/java/org/elasticsearch/action/support/replication/BroadcastReplicationTests.java
@@ -93,7 +93,7 @@ public class BroadcastReplicationTests extends ESTestCase {
super.setUp();
MockTcpTransport transport = new MockTcpTransport(Settings.EMPTY,
threadPool, BigArrays.NON_RECYCLING_INSTANCE, circuitBreakerService, new NamedWriteableRegistry(Collections.emptyList()),
- new NetworkService(Settings.EMPTY, Collections.emptyList()));
+ new NetworkService(Collections.emptyList()));
clusterService = createClusterService(threadPool);
transportService = new TransportService(clusterService.getSettings(), transport, threadPool,
TransportService.NOOP_TRANSPORT_INTERCEPTOR, x -> clusterService.localNode(), null);
diff --git a/core/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java b/core/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java
index 8bfc31f871..2e4830a5a6 100644
--- a/core/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java
+++ b/core/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationActionTests.java
@@ -56,7 +56,6 @@ import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.lease.Releasable;
import org.elasticsearch.common.network.NetworkService;
import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.common.util.BigArrays;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.IndexNotFoundException;
@@ -91,13 +90,10 @@ import org.junit.Before;
import org.junit.BeforeClass;
import java.io.IOException;
-import java.net.UnknownHostException;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -941,7 +937,7 @@ public class TransportReplicationActionTests extends ESTestCase {
final ReplicationTask task = maybeTask();
NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(Collections.emptyList());
final Transport transport = new MockTcpTransport(Settings.EMPTY, threadPool, BigArrays.NON_RECYCLING_INSTANCE,
- new NoneCircuitBreakerService(), namedWriteableRegistry, new NetworkService(Settings.EMPTY, Collections.emptyList()),
+ new NoneCircuitBreakerService(), namedWriteableRegistry, new NetworkService(Collections.emptyList()),
Version.CURRENT);
transportService = new MockTransportService(Settings.EMPTY, transport, threadPool, TransportService.NOOP_TRANSPORT_INTERCEPTOR,
x -> clusterService.localNode(),null);
diff --git a/core/src/test/java/org/elasticsearch/common/network/NetworkServiceTests.java b/core/src/test/java/org/elasticsearch/common/network/NetworkServiceTests.java
index 096d3b0a9a..d446c6682b 100644
--- a/core/src/test/java/org/elasticsearch/common/network/NetworkServiceTests.java
+++ b/core/src/test/java/org/elasticsearch/common/network/NetworkServiceTests.java
@@ -19,7 +19,6 @@
package org.elasticsearch.common.network;
-import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESTestCase;
import java.net.InetAddress;
@@ -37,7 +36,7 @@ public class NetworkServiceTests extends ESTestCase {
* ensure exception if we bind to multicast ipv4 address
*/
public void testBindMulticastV4() throws Exception {
- NetworkService service = new NetworkService(Settings.EMPTY, Collections.emptyList());
+ NetworkService service = new NetworkService(Collections.emptyList());
try {
service.resolveBindHostAddresses(new String[] { "239.1.1.1" });
fail("should have hit exception");
@@ -49,7 +48,7 @@ public class NetworkServiceTests extends ESTestCase {
* ensure exception if we bind to multicast ipv6 address
*/
public void testBindMulticastV6() throws Exception {
- NetworkService service = new NetworkService(Settings.EMPTY, Collections.emptyList());
+ NetworkService service = new NetworkService(Collections.emptyList());
try {
service.resolveBindHostAddresses(new String[] { "FF08::108" });
fail("should have hit exception");
@@ -62,7 +61,7 @@ public class NetworkServiceTests extends ESTestCase {
* ensure exception if we publish to multicast ipv4 address
*/
public void testPublishMulticastV4() throws Exception {
- NetworkService service = new NetworkService(Settings.EMPTY, Collections.emptyList());
+ NetworkService service = new NetworkService(Collections.emptyList());
try {
service.resolvePublishHostAddresses(new String[] { "239.1.1.1" });
fail("should have hit exception");
@@ -75,7 +74,7 @@ public class NetworkServiceTests extends ESTestCase {
* ensure exception if we publish to multicast ipv6 address
*/
public void testPublishMulticastV6() throws Exception {
- NetworkService service = new NetworkService(Settings.EMPTY, Collections.emptyList());
+ NetworkService service = new NetworkService(Collections.emptyList());
try {
service.resolvePublishHostAddresses(new String[] { "FF08::108" });
fail("should have hit exception");
@@ -88,15 +87,16 @@ public class NetworkServiceTests extends ESTestCase {
* ensure specifying wildcard ipv4 address will bind to all interfaces
*/
public void testBindAnyLocalV4() throws Exception {
- NetworkService service = new NetworkService(Settings.EMPTY, Collections.emptyList());
- assertEquals(InetAddress.getByName("0.0.0.0"), service.resolveBindHostAddresses(new String[] { "0.0.0.0" })[0]);
+ NetworkService service = new NetworkService(Collections.emptyList());
+ assertEquals(InetAddress.getByName("0.0.0.0"), service.resolveBindHostAddresses(new String[] { "0.0.0.0" }
+ )[0]);
}
/**
* ensure specifying wildcard ipv6 address will bind to all interfaces
*/
public void testBindAnyLocalV6() throws Exception {
- NetworkService service = new NetworkService(Settings.EMPTY, Collections.emptyList());
+ NetworkService service = new NetworkService(Collections.emptyList());
assertEquals(InetAddress.getByName("::"), service.resolveBindHostAddresses(new String[] { "::" })[0]);
}
@@ -104,7 +104,7 @@ public class NetworkServiceTests extends ESTestCase {
* ensure specifying wildcard ipv4 address selects reasonable publish address
*/
public void testPublishAnyLocalV4() throws Exception {
- NetworkService service = new NetworkService(Settings.EMPTY, Collections.emptyList());
+ NetworkService service = new NetworkService(Collections.emptyList());
InetAddress address = service.resolvePublishHostAddresses(new String[] { "0.0.0.0" });
assertFalse(address.isAnyLocalAddress());
}
@@ -113,7 +113,7 @@ public class NetworkServiceTests extends ESTestCase {
* ensure specifying wildcard ipv6 address selects reasonable publish address
*/
public void testPublishAnyLocalV6() throws Exception {
- NetworkService service = new NetworkService(Settings.EMPTY, Collections.emptyList());
+ NetworkService service = new NetworkService(Collections.emptyList());
InetAddress address = service.resolvePublishHostAddresses(new String[] { "::" });
assertFalse(address.isAnyLocalAddress());
}
@@ -122,7 +122,7 @@ public class NetworkServiceTests extends ESTestCase {
* ensure we can bind to multiple addresses
*/
public void testBindMultipleAddresses() throws Exception {
- NetworkService service = new NetworkService(Settings.EMPTY, Collections.emptyList());
+ NetworkService service = new NetworkService(Collections.emptyList());
InetAddress[] addresses = service.resolveBindHostAddresses(new String[]{"127.0.0.1", "127.0.0.2"});
assertThat(addresses.length, is(2));
}
@@ -131,7 +131,7 @@ public class NetworkServiceTests extends ESTestCase {
* ensure we can't bind to multiple addresses when using wildcard
*/
public void testBindMultipleAddressesWithWildcard() throws Exception {
- NetworkService service = new NetworkService(Settings.EMPTY, Collections.emptyList());
+ NetworkService service = new NetworkService(Collections.emptyList());
try {
service.resolveBindHostAddresses(new String[]{"0.0.0.0", "127.0.0.1"});
fail("should have hit exception");
diff --git a/core/src/test/java/org/elasticsearch/discovery/ZenFaultDetectionTests.java b/core/src/test/java/org/elasticsearch/discovery/ZenFaultDetectionTests.java
index d32f8cba33..3186cdaefb 100644
--- a/core/src/test/java/org/elasticsearch/discovery/ZenFaultDetectionTests.java
+++ b/core/src/test/java/org/elasticsearch/discovery/ZenFaultDetectionTests.java
@@ -140,7 +140,7 @@ public class ZenFaultDetectionTests extends ESTestCase {
.put(TransportService.TRACE_LOG_EXCLUDE_SETTING.getKey(), singleton(TransportLivenessAction.NAME))
.build(),
new MockTcpTransport(settings, threadPool, BigArrays.NON_RECYCLING_INSTANCE, circuitBreakerService,
- namedWriteableRegistry, new NetworkService(settings, Collections.emptyList()), version),
+ namedWriteableRegistry, new NetworkService(Collections.emptyList()), version),
threadPool,
TransportService.NOOP_TRANSPORT_INTERCEPTOR,
(boundAddress) ->
diff --git a/core/src/test/java/org/elasticsearch/discovery/zen/UnicastZenPingTests.java b/core/src/test/java/org/elasticsearch/discovery/zen/UnicastZenPingTests.java
index 6aa47d27bb..0492bc82e5 100644
--- a/core/src/test/java/org/elasticsearch/discovery/zen/UnicastZenPingTests.java
+++ b/core/src/test/java/org/elasticsearch/discovery/zen/UnicastZenPingTests.java
@@ -49,13 +49,13 @@ import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.ConnectTransportException;
import org.elasticsearch.transport.ConnectionProfile;
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,11 +137,11 @@ public class UnicastZenPingTests extends ESTestCase {
public void testSimplePings() throws IOException, InterruptedException, ExecutionException {
// use ephemeral ports
- final Settings settings = Settings.builder().put("cluster.name", "test").put(TransportSettings.PORT.getKey(), 0).build();
+ final Settings settings = Settings.builder().put("cluster.name", "test").put(TcpTransport.PORT.getKey(), 0).build();
final Settings settingsMismatch =
- Settings.builder().put(settings).put("cluster.name", "mismatch").put(TransportSettings.PORT.getKey(), 0).build();
+ Settings.builder().put(settings).put("cluster.name", "mismatch").put(TcpTransport.PORT.getKey(), 0).build();
- NetworkService networkService = new NetworkService(settings, Collections.emptyList());
+ NetworkService networkService = new NetworkService(Collections.emptyList());
final BiFunction<Settings, Version, Transport> supplier = (s, v) -> new MockTcpTransport(
s,
@@ -262,9 +262,9 @@ public class UnicastZenPingTests extends ESTestCase {
public void testUnknownHostNotCached() throws ExecutionException, InterruptedException {
// use ephemeral ports
- final Settings settings = Settings.builder().put("cluster.name", "test").put(TransportSettings.PORT.getKey(), 0).build();
+ final Settings settings = Settings.builder().put("cluster.name", "test").put(TcpTransport.PORT.getKey(), 0).build();
- final NetworkService networkService = new NetworkService(settings, Collections.emptyList());
+ final NetworkService networkService = new NetworkService(Collections.emptyList());
final Map<String, TransportAddress[]> addresses = new HashMap<>();
final BiFunction<Settings, Version, Transport> supplier = (s, v) -> new MockTcpTransport(
@@ -370,7 +370,7 @@ public class UnicastZenPingTests extends ESTestCase {
}
public void testPortLimit() throws InterruptedException {
- final NetworkService networkService = new NetworkService(Settings.EMPTY, Collections.emptyList());
+ final NetworkService networkService = new NetworkService(Collections.emptyList());
final Transport transport = new MockTcpTransport(
Settings.EMPTY,
threadPool,
@@ -411,7 +411,7 @@ public class UnicastZenPingTests extends ESTestCase {
}
public void testRemovingLocalAddresses() throws InterruptedException {
- final NetworkService networkService = new NetworkService(Settings.EMPTY, Collections.emptyList());
+ final NetworkService networkService = new NetworkService(Collections.emptyList());
final InetAddress loopbackAddress = InetAddress.getLoopbackAddress();
final Transport transport = new MockTcpTransport(
Settings.EMPTY,
@@ -456,7 +456,7 @@ public class UnicastZenPingTests extends ESTestCase {
public void testUnknownHost() throws InterruptedException {
final Logger logger = mock(Logger.class);
- final NetworkService networkService = new NetworkService(Settings.EMPTY, Collections.emptyList());
+ final NetworkService networkService = new NetworkService(Collections.emptyList());
final String hostname = randomAlphaOfLength(8);
final UnknownHostException unknownHostException = new UnknownHostException(hostname);
final Transport transport = new MockTcpTransport(
@@ -504,7 +504,7 @@ public class UnicastZenPingTests extends ESTestCase {
public void testResolveTimeout() throws InterruptedException {
final Logger logger = mock(Logger.class);
- final NetworkService networkService = new NetworkService(Settings.EMPTY, Collections.emptyList());
+ final NetworkService networkService = new NetworkService(Collections.emptyList());
final CountDownLatch latch = new CountDownLatch(1);
final Transport transport = new MockTcpTransport(
Settings.EMPTY,
@@ -568,9 +568,9 @@ public class UnicastZenPingTests extends ESTestCase {
}
public void testResolveReuseExistingNodeConnections() throws ExecutionException, InterruptedException {
- final Settings settings = Settings.builder().put("cluster.name", "test").put(TransportSettings.PORT.getKey(), 0).build();
+ final Settings settings = Settings.builder().put("cluster.name", "test").put(TcpTransport.PORT.getKey(), 0).build();
- NetworkService networkService = new NetworkService(settings, Collections.emptyList());
+ NetworkService networkService = new NetworkService(Collections.emptyList());
final BiFunction<Settings, Version, Transport> supplier = (s, v) -> new MockTcpTransport(
s,
@@ -633,9 +633,9 @@ public class UnicastZenPingTests extends ESTestCase {
}
public void testPingingTemporalPings() throws ExecutionException, InterruptedException {
- final Settings settings = Settings.builder().put("cluster.name", "test").put(TransportSettings.PORT.getKey(), 0).build();
+ final Settings settings = Settings.builder().put("cluster.name", "test").put(TcpTransport.PORT.getKey(), 0).build();
- NetworkService networkService = new NetworkService(settings, Collections.emptyList());
+ NetworkService networkService = new NetworkService(Collections.emptyList());
final BiFunction<Settings, Version, Transport> supplier = (s, v) -> new MockTcpTransport(
s,
@@ -691,7 +691,7 @@ public class UnicastZenPingTests extends ESTestCase {
public void testInvalidHosts() throws InterruptedException {
final Logger logger = mock(Logger.class);
- final NetworkService networkService = new NetworkService(Settings.EMPTY, Collections.emptyList());
+ final NetworkService networkService = new NetworkService(Collections.emptyList());
final Transport transport = new MockTcpTransport(
Settings.EMPTY,
threadPool,
diff --git a/core/src/test/java/org/elasticsearch/index/mapper/DynamicMappingDisabledTests.java b/core/src/test/java/org/elasticsearch/index/mapper/DynamicMappingDisabledTests.java
index 3928dc78c8..686bbafbcd 100644
--- a/core/src/test/java/org/elasticsearch/index/mapper/DynamicMappingDisabledTests.java
+++ b/core/src/test/java/org/elasticsearch/index/mapper/DynamicMappingDisabledTests.java
@@ -79,7 +79,7 @@ public class DynamicMappingDisabledTests extends ESSingleNodeTestCase {
clusterService = createClusterService(threadPool);
Transport transport = new MockTcpTransport(settings, threadPool, BigArrays.NON_RECYCLING_INSTANCE,
new NoneCircuitBreakerService(), new NamedWriteableRegistry(Collections.emptyList()),
- new NetworkService(settings, Collections.emptyList()));
+ new NetworkService(Collections.emptyList()));
transportService = new TransportService(clusterService.getSettings(), transport, threadPool,
TransportService.NOOP_TRANSPORT_INTERCEPTOR, x -> clusterService.localNode(), null);
IndicesService indicesService = getInstanceFromNode(IndicesService.class);
diff --git a/core/src/test/java/org/elasticsearch/transport/PublishPortTests.java b/core/src/test/java/org/elasticsearch/transport/PublishPortTests.java
index ffe7a2d7ce..42cc9b876a 100644
--- a/core/src/test/java/org/elasticsearch/transport/PublishPortTests.java
+++ b/core/src/test/java/org/elasticsearch/transport/PublishPortTests.java
@@ -46,11 +46,11 @@ public class PublishPortTests extends ESTestCase {
final Settings profileSettings;
if (useProfile) {
profile = "some_profile";
- settings = randomBoolean() ? Settings.EMPTY : Settings.builder().put(TransportSettings.PUBLISH_PORT.getKey(), 9081).build();
+ settings = randomBoolean() ? Settings.EMPTY : Settings.builder().put(TcpTransport.PUBLISH_PORT.getKey(), 9081).build();
profileSettings = Settings.builder().put("publish_port", 9080).build();
} else {
- profile = TransportSettings.DEFAULT_PROFILE;
- settings = Settings.builder().put(TransportSettings.PUBLISH_PORT.getKey(), 9081).build();
+ profile = TcpTransport.DEFAULT_PROFILE;
+ settings = Settings.builder().put(TcpTransport.PUBLISH_PORT.getKey(), 9081).build();
profileSettings = randomBoolean() ? Settings.EMPTY : Settings.builder().put("publish_port", 9080).build();;
}
diff --git a/core/src/test/java/org/elasticsearch/transport/TransportServiceHandshakeTests.java b/core/src/test/java/org/elasticsearch/transport/TransportServiceHandshakeTests.java
index ab882b4031..c4fe88d2fc 100644
--- a/core/src/test/java/org/elasticsearch/transport/TransportServiceHandshakeTests.java
+++ b/core/src/test/java/org/elasticsearch/transport/TransportServiceHandshakeTests.java
@@ -65,7 +65,7 @@ public class TransportServiceHandshakeTests extends ESTestCase {
BigArrays.NON_RECYCLING_INSTANCE,
new NoneCircuitBreakerService(),
new NamedWriteableRegistry(Collections.emptyList()),
- new NetworkService(settings, Collections.emptyList()));
+ new NetworkService(Collections.emptyList()));
TransportService transportService = new MockTransportService(settings, transport, threadPool,
TransportService.NOOP_TRANSPORT_INTERCEPTOR, (boundAddress) -> new DiscoveryNode(
nodeNameAndId,