diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy index f32d0d858f81f..7a0a7d9436ee2 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterFormationTasks.groovy @@ -131,10 +131,12 @@ class ClusterFormationTasks { writeConfigSetup = { Map esConfig -> if (config.getAutoSetHostsProvider()) { // Don't force discovery provider if one is set by the test cluster specs already - if (esConfig.containsKey('discovery.zen.hosts_provider') == false) { - esConfig['discovery.zen.hosts_provider'] = 'file' + final String seedProvidersSettingName = + node.nodeVersion.onOrAfter("7.0.0") ? "discovery.seed_providers" : "discovery.zen.hosts_provider"; + if (esConfig.containsKey(seedProvidersSettingName) == false) { + esConfig[seedProvidersSettingName] = 'file' } - esConfig['discovery.zen.ping.unicast.hosts'] = [] + esConfig[node.nodeVersion.onOrAfter("7.0.0") ? "discovery.seed_hosts" : "discovery.zen.ping.unicast.hosts"] = [] } boolean supportsInitialMasterNodes = hasBwcNodes == false || config.bwcVersion.onOrAfter("7.0.0") if (esConfig['discovery.type'] == null && config.getAutoSetInitialMasterNodes() && supportsInitialMasterNodes) { diff --git a/distribution/src/config/elasticsearch.yml b/distribution/src/config/elasticsearch.yml index ceb1fc078648f..a87d7f70825ed 100644 --- a/distribution/src/config/elasticsearch.yml +++ b/distribution/src/config/elasticsearch.yml @@ -62,10 +62,10 @@ ${path.logs} # # --------------------------------- Discovery ---------------------------------- # -# Pass an initial list of hosts to perform discovery when new node is started: +# Pass an initial list of hosts to perform discovery when this node is started: # The default list of hosts is ["127.0.0.1", "[::1]"] # -#discovery.zen.ping.unicast.hosts: ["host1", "host2"] +#discovery.seed_hosts: ["host1", "host2"] # # Bootstrap the cluster using an initial set of master-eligible nodes: # diff --git a/docs/plugins/discovery-azure-classic.asciidoc b/docs/plugins/discovery-azure-classic.asciidoc index 30a8ee9c43df8..0e93d065a42fe 100644 --- a/docs/plugins/discovery-azure-classic.asciidoc +++ b/docs/plugins/discovery-azure-classic.asciidoc @@ -30,7 +30,7 @@ cloud: type: pkcs12 discovery: - zen.hosts_provider: azure + seed_providers: azure ---- [IMPORTANT] diff --git a/docs/plugins/discovery-ec2.asciidoc b/docs/plugins/discovery-ec2.asciidoc index 57b5b8468fafb..fbf24a9463bb1 100644 --- a/docs/plugins/discovery-ec2.asciidoc +++ b/docs/plugins/discovery-ec2.asciidoc @@ -20,7 +20,7 @@ provider for Zen discovery to `ec2`: [source,yaml] ---- -discovery.zen.hosts_provider: ec2 +discovery.seed_providers: ec2 ---- ==== Settings diff --git a/docs/plugins/discovery-gce.asciidoc b/docs/plugins/discovery-gce.asciidoc index 633b136bc7186..0324a8ff559a0 100644 --- a/docs/plugins/discovery-gce.asciidoc +++ b/docs/plugins/discovery-gce.asciidoc @@ -19,7 +19,7 @@ cloud: project_id: zone: discovery: - zen.hosts_provider: gce + seed_providers: gce -------------------------------------------------- The following gce settings (prefixed with `cloud.gce`) are supported: @@ -232,7 +232,7 @@ cloud: project_id: es-cloud zone: europe-west1-a discovery: - zen.hosts_provider: gce + seed_providers: gce -------------------------------------------------- @@ -346,7 +346,7 @@ cloud: project_id: zone: ["", ""] discovery: - zen.hosts_provider: gce + seed_providers: gce -------------------------------------------------- @@ -382,7 +382,7 @@ cloud: project_id: es-cloud zone: europe-west1-a discovery: - zen.hosts_provider: gce + seed_providers: gce gce: tags: elasticsearch, dev -------------------------------------------------- @@ -497,7 +497,7 @@ cloud: project_id: es-cloud zone: europe-west1-a discovery: - zen.hosts_provider: gce + seed_providers: gce -------------------------------------------------- Replaces `project_id` and `zone` with your settings. diff --git a/docs/reference/migration/migrate_7_0/discovery.asciidoc b/docs/reference/migration/migrate_7_0/discovery.asciidoc index 193f6bdd86a6f..d7e2a494206a0 100644 --- a/docs/reference/migration/migrate_7_0/discovery.asciidoc +++ b/docs/reference/migration/migrate_7_0/discovery.asciidoc @@ -35,6 +35,6 @@ Production deployments of Elasticsearch now require at least one of the following settings to be specified in the `elasticsearch.yml` configuration file: -- `discovery.zen.ping.unicast.hosts` -- `discovery.zen.hosts_provider` +- `discovery.seed_hosts` +- `discovery.seed_providers` - `cluster.initial_master_nodes` diff --git a/docs/reference/modules/discovery/bootstrapping.asciidoc b/docs/reference/modules/discovery/bootstrapping.asciidoc index ee77dca342533..5be2e170cc3b6 100644 --- a/docs/reference/modules/discovery/bootstrapping.asciidoc +++ b/docs/reference/modules/discovery/bootstrapping.asciidoc @@ -94,6 +94,6 @@ If any of the following settings are configured then auto-bootstrapping will not take place, and you must configure `cluster.initial_master_nodes` as described in the <>: -* `discovery.zen.hosts_provider` -* `discovery.zen.ping.unicast.hosts` +* `discovery.seed_providers` +* `discovery.seed_hosts` * `cluster.initial_master_nodes` diff --git a/docs/reference/modules/discovery/discovery-settings.asciidoc b/docs/reference/modules/discovery/discovery-settings.asciidoc index 4d6301fe1a9f5..517712c513f86 100644 --- a/docs/reference/modules/discovery/discovery-settings.asciidoc +++ b/docs/reference/modules/discovery/discovery-settings.asciidoc @@ -105,9 +105,10 @@ Discovery and cluster formation are affected by the following settings: `discovery.cluster_formation_warning_timeout`:: Sets how long a node will try to form a cluster before logging a warning - that the cluster did not form. Defaults to `10s`. If a cluster has not + that the cluster did not form. Defaults to `10s`. If a cluster has not formed after `discovery.cluster_formation_warning_timeout` has elapsed then - the node will log a warning message that starts with the phrase `master not discovered` which describes the current state of the discovery process. + the node will log a warning message that starts with the phrase `master not + discovered` which describes the current state of the discovery process. `discovery.find_peers_interval`:: @@ -128,9 +129,9 @@ Discovery and cluster formation are affected by the following settings: Sets how long a node will wait after asking its peers again before considering the request to have failed. Defaults to `3s`. -`discovery.zen.hosts_provider`:: - Specifies which type of <> provides - the list of seed nodes. By default, it is the +`discovery.seed_providers`:: + Specifies which types of <> provide + the addresses of seed nodes. By default, it is the <>. [[no-master-block]]`discovery.zen.no_master_block`:: @@ -157,7 +158,7 @@ APIs are not be blocked and can run on any available node. =============================== -- -`discovery.zen.ping.unicast.hosts`:: +`discovery.seed_hosts`:: Provides a list of master-eligible nodes in the cluster. The list contains either an array of hosts or a comma-delimited string. Each value has the @@ -165,7 +166,12 @@ APIs are not be blocked and can run on any available node. `transport.profiles.default.port`. Note that IPv6 hosts must be bracketed. The default value is `127.0.0.1, [::1]`. See <>. -`discovery.zen.ping.unicast.hosts.resolve_timeout`:: +`discovery.seed_resolver.timeout`:: Sets the amount of time to wait for DNS lookups on each round of discovery. This is specified as a <> and defaults to `5s`. + +`discovery.seed_resolver.max_concurrent_resolvers`:: + + Sets the number of threads with which to perform DNS lookups for seed nodes. + This defaults to `10`. diff --git a/docs/reference/modules/discovery/discovery.asciidoc b/docs/reference/modules/discovery/discovery.asciidoc index 737f8718113f1..daf60831818e9 100644 --- a/docs/reference/modules/discovery/discovery.asciidoc +++ b/docs/reference/modules/discovery/discovery.asciidoc @@ -34,7 +34,7 @@ By default the cluster formation module offers two hosts providers to configure the list of seed nodes: a _settings_-based and a _file_-based hosts provider. It can be extended to support cloud environments and other forms of hosts providers via {plugins}/discovery.html[discovery plugins]. Hosts providers are -configured using the `discovery.zen.hosts_provider` setting, which defaults to +configured using the `discovery.seed_providers` setting, which defaults to the _settings_-based hosts provider. Multiple hosts providers can be specified as a list. @@ -49,12 +49,12 @@ round of discovery. Note that if you are in an environment where DNS resolutions vary with time, you might need to adjust your <>. -The list of hosts is set using the <> static +The list of hosts is set using the <> static setting. For example: [source,yaml] -------------------------------------------------- -discovery.zen.ping.unicast.hosts: +discovery.seed_hosts: - 192.168.1.10:9300 - 192.168.1.11 <1> - seeds.mydomain.com <2> @@ -64,9 +64,9 @@ discovery.zen.ping.unicast.hosts: <2> A hostname that resolves to multiple IP addresses will try all resolved addresses. -Additionally, the `discovery.zen.ping.unicast.hosts.resolve_timeout` configures -the amount of time to wait for DNS lookups on each round of discovery. This is -specified as a <> and defaults to 5s. +Additionally, the `discovery.seed_resolver.timeout` configures the amount of +time to wait for DNS lookups on each round of discovery. This is specified as a +<> and defaults to 5s. Unicast discovery uses the <> module to perform the discovery. @@ -87,7 +87,7 @@ in the `elasticsearch.yml` file: [source,yml] ---------------------------------------------------------------- -discovery.zen.hosts_provider: file +discovery.seed_providers: file ---------------------------------------------------------------- Then create a file at `$ES_PATH_CONF/unicast_hosts.txt` in the format described @@ -95,13 +95,13 @@ below. Any time a change is made to the `unicast_hosts.txt` file the new changes will be picked up by Elasticsearch and the new hosts list will be used. Note that the file-based discovery plugin augments the unicast hosts list in -`elasticsearch.yml`. If there are valid unicast host entries in -`discovery.zen.ping.unicast.hosts`, they are used in addition to those -supplied in `unicast_hosts.txt`. +`elasticsearch.yml`. If there are valid seed addresses in +`discovery.seed_hosts` then they are used in addition to those supplied in +`unicast_hosts.txt`. -The `discovery.zen.ping.unicast.hosts.resolve_timeout` setting also applies to -DNS lookups for nodes specified by address via file-based discovery. This is -specified as a <> and defaults to 5s. +The `discovery.seed_resolver.timeout` setting also applies to DNS lookups for +seed addresses given via file-based discovery. This is specified as a +<> and defaults to 5s. The format of the file is to specify one node entry per line. Each node entry consists of the host (host name or IP address) and an optional transport port @@ -123,7 +123,7 @@ the default port: ---------------------------------------------------------------- Host names are allowed instead of IP addresses (similar to -`discovery.zen.ping.unicast.hosts`), and IPv6 addresses must be specified in +`discovery.seed_hosts`), and IPv6 addresses must be specified in brackets with the port coming after the brackets. You can also add comments to this file. All comments must appear on diff --git a/docs/reference/modules/network.asciidoc b/docs/reference/modules/network.asciidoc index e8dd3adef6ed7..5806b4a1034a5 100644 --- a/docs/reference/modules/network.asciidoc +++ b/docs/reference/modules/network.asciidoc @@ -28,19 +28,18 @@ because `:` is a special character in YAML. + Defaults to `_local_`. -`discovery.zen.ping.unicast.hosts`:: +`discovery.seed_hosts`:: In order to join a cluster, a node needs to know the hostname or IP address of at least some of the other nodes in the cluster. This setting provides the -initial list of other nodes that this node will try to contact. Accepts IP -addresses or hostnames. If a hostname lookup resolves to multiple IP -addresses then each IP address will be used for discovery. +initial list of addresses this node will try to contact. Accepts IP addresses +or hostnames. If a hostname lookup resolves to multiple IP addresses then each +IP address will be used for discovery. https://en.wikipedia.org/wiki/Round-robin_DNS[Round robin DNS] -- returning a different IP from a list on each lookup -- can be used for discovery; non- -existent IP addresses will throw exceptions and cause another DNS lookup -on the next round of pinging (subject to JVM DNS caching). -+ -Defaults to `["127.0.0.1", "[::1]"]`. +existent IP addresses will throw exceptions and cause another DNS lookup on the +next round of pinging (subject to JVM DNS caching). + Defaults to +`["127.0.0.1", "[::1]"]`. `http.port`:: diff --git a/docs/reference/security/securing-communications/configuring-tls-docker.asciidoc b/docs/reference/security/securing-communications/configuring-tls-docker.asciidoc index 50c63de4b4fef..2588a49fc72b9 100644 --- a/docs/reference/security/securing-communications/configuring-tls-docker.asciidoc +++ b/docs/reference/security/securing-communications/configuring-tls-docker.asciidoc @@ -136,7 +136,7 @@ services: image: {docker-image} environment: - node.name=es02 - - discovery.zen.ping.unicast.hosts=es01 + - discovery.seed_hosts=es01 - cluster.initial_master_nodes=es01,es02 - ELASTIC_PASSWORD=$ELASTIC_PASSWORD - "ES_JAVA_OPTS=-Xms512m -Xmx512m" diff --git a/docs/reference/setup/bootstrap-checks.asciidoc b/docs/reference/setup/bootstrap-checks.asciidoc index d9b540d39ceb3..83209cbf3b853 100644 --- a/docs/reference/setup/bootstrap-checks.asciidoc +++ b/docs/reference/setup/bootstrap-checks.asciidoc @@ -252,6 +252,6 @@ This bootstrap check ensures that discovery is not running with the default configuration. It can be satisfied by setting at least one of the following properties: -- `discovery.zen.ping.unicast.hosts` -- `discovery.zen.hosts_provider` +- `discovery.seed_hosts` +- `discovery.seed_providers` - `cluster.initial_master_nodes` diff --git a/docs/reference/setup/important-settings/discovery-settings.asciidoc b/docs/reference/setup/important-settings/discovery-settings.asciidoc index 6f40289f902ff..5bc07382039cb 100644 --- a/docs/reference/setup/important-settings/discovery-settings.asciidoc +++ b/docs/reference/setup/important-settings/discovery-settings.asciidoc @@ -10,7 +10,7 @@ each other and elect a master node. [float] [[unicast.hosts]] -==== `discovery.zen.ping.unicast.hosts` +==== `discovery.seed_hosts` Out of the box, without any network configuration, Elasticsearch will bind to the available loopback addresses and will scan local ports 9300 to 9305 to try @@ -18,7 +18,7 @@ to connect to other nodes running on the same server. This provides an auto- clustering experience without having to do any configuration. When the moment comes to form a cluster with nodes on other servers, you must -use the `discovery.zen.ping.unicast.hosts` setting to provide a seed list of +use the `discovery.seed_hosts` setting to provide a seed list of other nodes in the cluster that are master-eligible and likely to be live and contactable. This setting should normally contain the addresses of all the master-eligible nodes in the cluster. @@ -44,7 +44,7 @@ This list is set using the `cluster.initial_master_nodes` setting. [source,yaml] -------------------------------------------------- -discovery.zen.ping.unicast.hosts: +discovery.seed_hosts: - 192.168.1.10:9300 - 192.168.1.11 <1> - seeds.mydomain.com <2> @@ -62,4 +62,4 @@ cluster.initial_master_nodes: <5> If multiple master nodes share an IP address then the port must be used to disambiguate them. -For more information, see <>. \ No newline at end of file +For more information, see <>. diff --git a/docs/reference/setup/install/docker.asciidoc b/docs/reference/setup/install/docker.asciidoc index 92710f4429f8a..b64b15703b215 100644 --- a/docs/reference/setup/install/docker.asciidoc +++ b/docs/reference/setup/install/docker.asciidoc @@ -187,7 +187,7 @@ services: container_name: es02 environment: - node.name=es02 - - discovery.zen.ping.unicast.hosts=es01 + - discovery.seed_hosts=es01 - cluster.initial_master_nodes=es01,es02 - cluster.name=docker-cluster - bootstrap.memory_lock=true diff --git a/plugins/discovery-azure-classic/src/test/java/org/elasticsearch/cloud/azure/classic/AbstractAzureComputeServiceTestCase.java b/plugins/discovery-azure-classic/src/test/java/org/elasticsearch/cloud/azure/classic/AbstractAzureComputeServiceTestCase.java index 7d77b9994d589..131099dd1e7e9 100644 --- a/plugins/discovery-azure-classic/src/test/java/org/elasticsearch/cloud/azure/classic/AbstractAzureComputeServiceTestCase.java +++ b/plugins/discovery-azure-classic/src/test/java/org/elasticsearch/cloud/azure/classic/AbstractAzureComputeServiceTestCase.java @@ -49,6 +49,7 @@ import java.util.concurrent.ConcurrentHashMap; import static org.elasticsearch.common.util.CollectionUtils.newSingletonArrayList; +import static org.elasticsearch.discovery.DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING; public abstract class AbstractAzureComputeServiceTestCase extends ESIntegTestCase { @@ -63,7 +64,7 @@ public void clearAzureNodes() { protected Settings nodeSettings(int nodeOrdinal) { Settings.Builder builder = Settings.builder() .put(super.nodeSettings(nodeOrdinal)) - .put("discovery.zen.hosts_provider", "azure"); + .put(DISCOVERY_SEED_PROVIDERS_SETTING.getKey(), "azure"); // We add a fake subscription_id to start mock compute service builder.put(Management.SUBSCRIPTION_ID_SETTING.getKey(), "fake") 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 a833d196ed502..45540ca5d8f05 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 @@ -116,7 +116,7 @@ protected Settings nodeSettings(int nodeOrdinal) { throw new RuntimeException(e); } return Settings.builder().put(super.nodeSettings(nodeOrdinal)) - .put(DiscoveryModule.DISCOVERY_HOSTS_PROVIDER_SETTING.getKey(), AzureDiscoveryPlugin.AZURE) + .put(DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING.getKey(), AzureDiscoveryPlugin.AZURE) .put(Environment.PATH_LOGS_SETTING.getKey(), resolve) .put(TransportSettings.PORT.getKey(), 0) .put(Node.WRITE_PORTS_FILE_SETTING.getKey(), "true") diff --git a/plugins/discovery-ec2/qa/amazon-ec2/build.gradle b/plugins/discovery-ec2/qa/amazon-ec2/build.gradle index 898a31192ffb0..b5a6d1bb7d41c 100644 --- a/plugins/discovery-ec2/qa/amazon-ec2/build.gradle +++ b/plugins/discovery-ec2/qa/amazon-ec2/build.gradle @@ -54,7 +54,7 @@ integTestCluster { plugin ':plugins:discovery-ec2' keystoreSetting 'discovery.ec2.access_key', 'ec2_integration_test_access_key' keystoreSetting 'discovery.ec2.secret_key', 'ec2_integration_test_secret_key' - setting 'discovery.zen.hosts_provider', 'ec2' + setting 'discovery.seed_providers', 'ec2' setting 'network.host', '_ec2_' setting 'discovery.ec2.endpoint', "http://${-> ec2Fixture.addressAndPort}" systemProperty "com.amazonaws.sdk.ec2MetadataServiceEndpointOverride", "http://${-> ec2Fixture.addressAndPort}" diff --git a/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryUpdateSettingsTests.java b/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryUpdateSettingsTests.java index f11bd539fba7d..9802479fe84d3 100644 --- a/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryUpdateSettingsTests.java +++ b/plugins/discovery-ec2/src/test/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryUpdateSettingsTests.java @@ -38,7 +38,7 @@ public class Ec2DiscoveryUpdateSettingsTests extends AbstractAwsTestCase { public void testMinimumMasterNodesStart() { Settings nodeSettings = Settings.builder() - .put(DiscoveryModule.DISCOVERY_HOSTS_PROVIDER_SETTING.getKey(), "ec2") + .put(DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING.getKey(), "ec2") .build(); internalCluster().startNode(nodeSettings); diff --git a/plugins/discovery-gce/qa/gce/build.gradle b/plugins/discovery-gce/qa/gce/build.gradle index 9b496207c5619..c02aecc27ed53 100644 --- a/plugins/discovery-gce/qa/gce/build.gradle +++ b/plugins/discovery-gce/qa/gce/build.gradle @@ -51,7 +51,7 @@ integTestCluster { dependsOn gceFixture numNodes = gceNumberOfNodes plugin ':plugins:discovery-gce' - setting 'discovery.zen.hosts_provider', 'gce' + setting 'discovery.seed_providers', 'gce' // use gce fixture for Auth calls instead of http://metadata.google.internal integTestCluster.environment 'GCE_METADATA_HOST', "http://${-> gceFixture.addressAndPort}" diff --git a/plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/GceDiscoverTests.java b/plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/GceDiscoverTests.java index 078a21ee842b6..bec65908d95da 100644 --- a/plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/GceDiscoverTests.java +++ b/plugins/discovery-gce/src/test/java/org/elasticsearch/discovery/gce/GceDiscoverTests.java @@ -40,6 +40,7 @@ import java.util.concurrent.ConcurrentHashMap; import static java.util.Collections.singletonList; +import static org.elasticsearch.discovery.DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoTimeout; @ESIntegTestCase.ClusterScope(supportsDedicatedMasters = false, numDataNodes = 0, numClientNodes = 0) @@ -62,7 +63,7 @@ protected Collection> nodePlugins() { protected Settings nodeSettings(int nodeOrdinal) { return Settings.builder() .put(super.nodeSettings(nodeOrdinal)) - .put("discovery.zen.hosts_provider", "gce") + .put(DISCOVERY_SEED_PROVIDERS_SETTING.getKey(), "gce") .put("cloud.gce.project_id", "test") .put("cloud.gce.zone", "test") .build(); diff --git a/server/src/main/java/org/elasticsearch/bootstrap/BootstrapChecks.java b/server/src/main/java/org/elasticsearch/bootstrap/BootstrapChecks.java index ebda7df66dc09..89d4e1bcece57 100644 --- a/server/src/main/java/org/elasticsearch/bootstrap/BootstrapChecks.java +++ b/server/src/main/java/org/elasticsearch/bootstrap/BootstrapChecks.java @@ -52,8 +52,8 @@ import java.util.stream.Stream; import static org.elasticsearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; -import static org.elasticsearch.discovery.DiscoveryModule.DISCOVERY_HOSTS_PROVIDER_SETTING; -import static org.elasticsearch.discovery.zen.SettingsBasedHostsProvider.DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING; +import static org.elasticsearch.discovery.DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING; +import static org.elasticsearch.discovery.zen.SettingsBasedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING; /** * We enforce bootstrap checks once a node has the transport protocol bound to a non-loopback interface or if the system property {@code @@ -735,7 +735,7 @@ public BootstrapCheckResult check(BootstrapContext context) { return BootstrapCheckResult.failure(String.format( Locale.ROOT, "the default discovery settings are unsuitable for production use; at least one of [%s] must be configured", - Stream.of(DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING, DISCOVERY_HOSTS_PROVIDER_SETTING, INITIAL_MASTER_NODES_SETTING) + Stream.of(DISCOVERY_SEED_HOSTS_SETTING, DISCOVERY_SEED_PROVIDERS_SETTING, INITIAL_MASTER_NODES_SETTING) .map(Setting::getKey).collect(Collectors.joining(", ")))); } } diff --git a/server/src/main/java/org/elasticsearch/cluster/coordination/ClusterBootstrapService.java b/server/src/main/java/org/elasticsearch/cluster/coordination/ClusterBootstrapService.java index cdbf6b6691077..78009b002cb71 100644 --- a/server/src/main/java/org/elasticsearch/cluster/coordination/ClusterBootstrapService.java +++ b/server/src/main/java/org/elasticsearch/cluster/coordination/ClusterBootstrapService.java @@ -48,8 +48,10 @@ import static java.util.Collections.emptyList; import static java.util.Collections.unmodifiableSet; -import static org.elasticsearch.discovery.DiscoveryModule.DISCOVERY_HOSTS_PROVIDER_SETTING; -import static org.elasticsearch.discovery.zen.SettingsBasedHostsProvider.DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING; +import static org.elasticsearch.discovery.DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING; +import static org.elasticsearch.discovery.DiscoveryModule.LEGACY_DISCOVERY_HOSTS_PROVIDER_SETTING; +import static org.elasticsearch.discovery.zen.SettingsBasedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING; +import static org.elasticsearch.discovery.zen.SettingsBasedHostsProvider.LEGACY_DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING; public class ClusterBootstrapService { @@ -91,8 +93,9 @@ public ClusterBootstrapService(Settings settings, TransportService transportServ } public static boolean discoveryIsConfigured(Settings settings) { - return Stream.of(DISCOVERY_HOSTS_PROVIDER_SETTING, DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING, INITIAL_MASTER_NODES_SETTING) - .anyMatch(s -> s.exists(settings)); + return Stream.of(DISCOVERY_SEED_PROVIDERS_SETTING, LEGACY_DISCOVERY_HOSTS_PROVIDER_SETTING, + DISCOVERY_SEED_HOSTS_SETTING, LEGACY_DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING, + INITIAL_MASTER_NODES_SETTING).anyMatch(s -> s.exists(settings)); } void onFoundPeersUpdated() { 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 f0331ad2e30b2..758b6532a61a1 100644 --- a/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java +++ b/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java @@ -387,7 +387,8 @@ public void apply(Settings value, Settings current, Settings previous) { NodeEnvironment.NODE_ID_SEED_SETTING, DiscoverySettings.INITIAL_STATE_TIMEOUT_SETTING, DiscoveryModule.DISCOVERY_TYPE_SETTING, - DiscoveryModule.DISCOVERY_HOSTS_PROVIDER_SETTING, + DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING, + DiscoveryModule.LEGACY_DISCOVERY_HOSTS_PROVIDER_SETTING, FaultDetection.PING_RETRIES_SETTING, FaultDetection.PING_TIMEOUT_SETTING, FaultDetection.REGISTER_CONNECTION_LISTENER_SETTING, @@ -402,9 +403,12 @@ public void apply(Settings value, Settings current, Settings previous) { ZenDiscovery.MASTER_ELECTION_WAIT_FOR_JOINS_TIMEOUT_SETTING, ZenDiscovery.MASTER_ELECTION_IGNORE_NON_MASTER_PINGS_SETTING, ZenDiscovery.MAX_PENDING_CLUSTER_STATES_SETTING, - SettingsBasedHostsProvider.DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING, - UnicastZenPing.DISCOVERY_ZEN_PING_UNICAST_CONCURRENT_CONNECTS_SETTING, - UnicastZenPing.DISCOVERY_ZEN_PING_UNICAST_HOSTS_RESOLVE_TIMEOUT, + SettingsBasedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING, + SettingsBasedHostsProvider.LEGACY_DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING, + UnicastZenPing.DISCOVERY_SEED_RESOLVER_MAX_CONCURRENT_RESOLVERS_SETTING, + UnicastZenPing.DISCOVERY_SEED_RESOLVER_TIMEOUT_SETTING, + UnicastZenPing.LEGACY_DISCOVERY_ZEN_PING_UNICAST_CONCURRENT_CONNECTS_SETTING, + UnicastZenPing.LEGACY_DISCOVERY_ZEN_PING_UNICAST_HOSTS_RESOLVE_TIMEOUT, SearchService.DEFAULT_KEEPALIVE_SETTING, SearchService.KEEPALIVE_INTERVAL_SETTING, SearchService.MAX_KEEPALIVE_SETTING, diff --git a/server/src/main/java/org/elasticsearch/discovery/DiscoveryModule.java b/server/src/main/java/org/elasticsearch/discovery/DiscoveryModule.java index 042eb9daa0d9d..5db6cd3ee0fc3 100644 --- a/server/src/main/java/org/elasticsearch/discovery/DiscoveryModule.java +++ b/server/src/main/java/org/elasticsearch/discovery/DiscoveryModule.java @@ -74,8 +74,12 @@ public class DiscoveryModule { public static final Setting DISCOVERY_TYPE_SETTING = new Setting<>("discovery.type", ZEN2_DISCOVERY_TYPE, Function.identity(), Property.NodeScope); - public static final Setting> DISCOVERY_HOSTS_PROVIDER_SETTING = - Setting.listSetting("discovery.zen.hosts_provider", Collections.emptyList(), Function.identity(), Property.NodeScope); + public static final Setting> LEGACY_DISCOVERY_HOSTS_PROVIDER_SETTING = + Setting.listSetting("discovery.zen.hosts_provider", Collections.emptyList(), Function.identity(), + Property.NodeScope, Property.Deprecated); + public static final Setting> DISCOVERY_SEED_PROVIDERS_SETTING = + Setting.listSetting("discovery.seed_providers", Collections.emptyList(), Function.identity(), + Property.NodeScope); private final Discovery discovery; @@ -90,7 +94,7 @@ public DiscoveryModule(Settings settings, ThreadPool threadPool, TransportServic for (DiscoveryPlugin plugin : plugins) { plugin.getZenHostsProviders(transportService, networkService).forEach((key, value) -> { if (hostProviders.put(key, value) != null) { - throw new IllegalArgumentException("Cannot register zen hosts provider [" + key + "] twice"); + throw new IllegalArgumentException("Cannot register seed provider [" + key + "] twice"); } }); BiConsumer joinValidator = plugin.getJoinValidator(); @@ -98,7 +102,8 @@ public DiscoveryModule(Settings settings, ThreadPool threadPool, TransportServic joinValidators.add(joinValidator); } } - List hostsProviderNames = DISCOVERY_HOSTS_PROVIDER_SETTING.get(settings); + + List hostsProviderNames = getSeedProviderNames(settings); // for bwc purposes, add settings provider even if not explicitly specified if (hostsProviderNames.contains("settings") == false) { List extendedHostsProviderNames = new ArrayList<>(); @@ -110,7 +115,7 @@ public DiscoveryModule(Settings settings, ThreadPool threadPool, TransportServic final Set missingProviderNames = new HashSet<>(hostsProviderNames); missingProviderNames.removeAll(hostProviders.keySet()); if (missingProviderNames.isEmpty() == false) { - throw new IllegalArgumentException("Unknown zen hosts providers " + missingProviderNames); + throw new IllegalArgumentException("Unknown seed providers " + missingProviderNames); } List filteredHostsProviders = hostsProviderNames.stream() @@ -151,8 +156,18 @@ public DiscoveryModule(Settings settings, ThreadPool threadPool, TransportServic discovery = Objects.requireNonNull(discoverySupplier.get()); } + private List getSeedProviderNames(Settings settings) { + if (LEGACY_DISCOVERY_HOSTS_PROVIDER_SETTING.exists(settings)) { + if (DISCOVERY_SEED_PROVIDERS_SETTING.exists(settings)) { + throw new IllegalArgumentException("it is forbidden to set both [" + DISCOVERY_SEED_PROVIDERS_SETTING.getKey() + "] and [" + + LEGACY_DISCOVERY_HOSTS_PROVIDER_SETTING.getKey() + "]"); + } + return LEGACY_DISCOVERY_HOSTS_PROVIDER_SETTING.get(settings); + } + return DISCOVERY_SEED_PROVIDERS_SETTING.get(settings); + } + public Discovery getDiscovery() { return discovery; } - } diff --git a/server/src/main/java/org/elasticsearch/discovery/UnicastConfiguredHostsResolver.java b/server/src/main/java/org/elasticsearch/discovery/UnicastConfiguredHostsResolver.java index fcc716a7785a4..87fc411a938b3 100644 --- a/server/src/main/java/org/elasticsearch/discovery/UnicastConfiguredHostsResolver.java +++ b/server/src/main/java/org/elasticsearch/discovery/UnicastConfiguredHostsResolver.java @@ -41,8 +41,6 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Consumer; -import static org.elasticsearch.discovery.zen.UnicastZenPing.DISCOVERY_ZEN_PING_UNICAST_CONCURRENT_CONNECTS_SETTING; - public class UnicastConfiguredHostsResolver extends AbstractLifecycleComponent implements ConfiguredHostsResolver { private static final Logger logger = LogManager.getLogger(UnicastConfiguredHostsResolver.class); @@ -53,6 +51,7 @@ public class UnicastConfiguredHostsResolver extends AbstractLifecycleComponent i private final SetOnce executorService = new SetOnce<>(); private final TimeValue resolveTimeout; private final String nodeName; + private final int concurrentConnects; public UnicastConfiguredHostsResolver(String nodeName, Settings settings, TransportService transportService, UnicastHostsProvider hostsProvider) { @@ -60,13 +59,13 @@ public UnicastConfiguredHostsResolver(String nodeName, Settings settings, Transp this.nodeName = nodeName; this.transportService = transportService; this.hostsProvider = hostsProvider; - resolveTimeout = UnicastZenPing.DISCOVERY_ZEN_PING_UNICAST_HOSTS_RESOLVE_TIMEOUT.get(settings); + resolveTimeout = UnicastZenPing.getResolveTimeout(settings); + concurrentConnects = UnicastZenPing.getMaxConcurrentResolvers(settings); } @Override protected void doStart() { - final int concurrentConnects = DISCOVERY_ZEN_PING_UNICAST_CONCURRENT_CONNECTS_SETTING.get(settings); - logger.debug("using concurrent_connects [{}], resolve_timeout [{}]", concurrentConnects, resolveTimeout); + logger.debug("using max_concurrent_resolvers [{}], resolver timeout [{}]", concurrentConnects, resolveTimeout); final ThreadFactory threadFactory = EsExecutors.daemonThreadFactory(settings, "[unicast_configured_hosts_resolver]"); executorService.set(EsExecutors.newScaling(nodeName + "/" + "unicast_configured_hosts_resolver", 0, concurrentConnects, 60, TimeUnit.SECONDS, threadFactory, transportService.getThreadPool().getThreadContext())); diff --git a/server/src/main/java/org/elasticsearch/discovery/zen/SettingsBasedHostsProvider.java b/server/src/main/java/org/elasticsearch/discovery/zen/SettingsBasedHostsProvider.java index 3b16c3734156f..b23d07cb68818 100644 --- a/server/src/main/java/org/elasticsearch/discovery/zen/SettingsBasedHostsProvider.java +++ b/server/src/main/java/org/elasticsearch/discovery/zen/SettingsBasedHostsProvider.java @@ -22,6 +22,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.elasticsearch.common.settings.Setting; +import org.elasticsearch.common.settings.Setting.Property; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.transport.TransportService; @@ -33,7 +34,7 @@ /** * An implementation of {@link UnicastHostsProvider} that reads hosts/ports - * from the "discovery.zen.ping.unicast.hosts" node setting. If the port is + * from the "discovery.seed_hosts" node setting. If the port is * left off an entry, a default port of 9300 is assumed. * * An example unicast hosts setting might look as follows: @@ -43,20 +44,31 @@ public class SettingsBasedHostsProvider implements UnicastHostsProvider { private static final Logger logger = LogManager.getLogger(SettingsBasedHostsProvider.class); - public static final Setting> DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING = - Setting.listSetting("discovery.zen.ping.unicast.hosts", emptyList(), Function.identity(), Setting.Property.NodeScope); + public static final Setting> LEGACY_DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING = + Setting.listSetting("discovery.zen.ping.unicast.hosts", emptyList(), Function.identity(), Property.NodeScope, Property.Deprecated); + + public static final Setting> DISCOVERY_SEED_HOSTS_SETTING = + Setting.listSetting("discovery.seed_hosts", emptyList(), Function.identity(), Property.NodeScope); // these limits are per-address - public static final int LIMIT_FOREIGN_PORTS_COUNT = 1; - public static final int LIMIT_LOCAL_PORTS_COUNT = 5; + private static final int LIMIT_FOREIGN_PORTS_COUNT = 1; + private static final int LIMIT_LOCAL_PORTS_COUNT = 5; private final List configuredHosts; - private final int limitPortCounts; public SettingsBasedHostsProvider(Settings settings, TransportService transportService) { - if (DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.exists(settings)) { - configuredHosts = DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.get(settings); + if (LEGACY_DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.exists(settings)) { + if (DISCOVERY_SEED_HOSTS_SETTING.exists(settings)) { + throw new IllegalArgumentException("it is forbidden to set both [" + + DISCOVERY_SEED_HOSTS_SETTING.getKey() + "] and [" + + LEGACY_DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.getKey() + "]"); + } + configuredHosts = LEGACY_DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.get(settings); + // we only limit to 1 address, makes no sense to ping 100 ports + limitPortCounts = LIMIT_FOREIGN_PORTS_COUNT; + } else if (DISCOVERY_SEED_HOSTS_SETTING.exists(settings)) { + configuredHosts = DISCOVERY_SEED_HOSTS_SETTING.get(settings); // we only limit to 1 address, makes no sense to ping 100 ports limitPortCounts = LIMIT_FOREIGN_PORTS_COUNT; } else { @@ -72,5 +84,4 @@ public SettingsBasedHostsProvider(Settings settings, TransportService transportS public List buildDynamicHosts(HostsResolver hostsResolver) { return hostsResolver.resolveHosts(configuredHosts, limitPortCounts); } - } diff --git a/server/src/main/java/org/elasticsearch/discovery/zen/UnicastZenPing.java b/server/src/main/java/org/elasticsearch/discovery/zen/UnicastZenPing.java index e1261b3d322a3..a9b0f4e941dec 100644 --- a/server/src/main/java/org/elasticsearch/discovery/zen/UnicastZenPing.java +++ b/server/src/main/java/org/elasticsearch/discovery/zen/UnicastZenPing.java @@ -96,10 +96,17 @@ public class UnicastZenPing implements ZenPing { private static final Logger logger = LogManager.getLogger(UnicastZenPing.class); public static final String ACTION_NAME = "internal:discovery/zen/unicast"; - public static final Setting DISCOVERY_ZEN_PING_UNICAST_CONCURRENT_CONNECTS_SETTING = - Setting.intSetting("discovery.zen.ping.unicast.concurrent_connects", 10, 0, Property.NodeScope); - public static final Setting DISCOVERY_ZEN_PING_UNICAST_HOSTS_RESOLVE_TIMEOUT = - Setting.positiveTimeSetting("discovery.zen.ping.unicast.hosts.resolve_timeout", TimeValue.timeValueSeconds(5), Property.NodeScope); + + public static final Setting LEGACY_DISCOVERY_ZEN_PING_UNICAST_CONCURRENT_CONNECTS_SETTING = + Setting.intSetting("discovery.zen.ping.unicast.concurrent_connects", 10, 0, Property.NodeScope, Property.Deprecated); + public static final Setting LEGACY_DISCOVERY_ZEN_PING_UNICAST_HOSTS_RESOLVE_TIMEOUT = + Setting.positiveTimeSetting("discovery.zen.ping.unicast.hosts.resolve_timeout", TimeValue.timeValueSeconds(5), + Property.NodeScope, Property.Deprecated); + + public static final Setting DISCOVERY_SEED_RESOLVER_MAX_CONCURRENT_RESOLVERS_SETTING = + Setting.intSetting("discovery.seed_resolver.max_concurrent_resolvers", 10, 0, Property.NodeScope); + public static final Setting DISCOVERY_SEED_RESOLVER_TIMEOUT_SETTING = + Setting.positiveTimeSetting("discovery.seed_resolver.timeout", TimeValue.timeValueSeconds(5), Property.NodeScope); private final ThreadPool threadPool; private final TransportService transportService; @@ -132,12 +139,11 @@ public UnicastZenPing(Settings settings, ThreadPool threadPool, TransportService this.hostsProvider = unicastHostsProvider; this.contextProvider = contextProvider; - final int concurrentConnects = DISCOVERY_ZEN_PING_UNICAST_CONCURRENT_CONNECTS_SETTING.get(settings); - - resolveTimeout = DISCOVERY_ZEN_PING_UNICAST_HOSTS_RESOLVE_TIMEOUT.get(settings); + final int concurrentConnects = getMaxConcurrentResolvers(settings); + resolveTimeout = getResolveTimeout(settings); nodeName = Node.NODE_NAME_SETTING.get(settings); logger.debug( - "using concurrent_connects [{}], resolve_timeout [{}]", + "using max_concurrent_resolvers [{}], resolver timeout [{}]", concurrentConnects, resolveTimeout); @@ -663,4 +669,28 @@ public void writeTo(StreamOutput out) throws IOException { protected Version getVersion() { return Version.CURRENT; // for tests } + + public static int getMaxConcurrentResolvers(Settings settings) { + if (LEGACY_DISCOVERY_ZEN_PING_UNICAST_CONCURRENT_CONNECTS_SETTING.exists(settings)) { + if (DISCOVERY_SEED_RESOLVER_MAX_CONCURRENT_RESOLVERS_SETTING.exists(settings)) { + throw new IllegalArgumentException("it is forbidden to set both [" + + DISCOVERY_SEED_RESOLVER_MAX_CONCURRENT_RESOLVERS_SETTING.getKey() + "] and [" + + LEGACY_DISCOVERY_ZEN_PING_UNICAST_CONCURRENT_CONNECTS_SETTING.getKey() + "]"); + } + return LEGACY_DISCOVERY_ZEN_PING_UNICAST_CONCURRENT_CONNECTS_SETTING.get(settings); + } + return DISCOVERY_SEED_RESOLVER_MAX_CONCURRENT_RESOLVERS_SETTING.get(settings); + } + + public static TimeValue getResolveTimeout(Settings settings) { + if (LEGACY_DISCOVERY_ZEN_PING_UNICAST_HOSTS_RESOLVE_TIMEOUT.exists(settings)) { + if (DISCOVERY_SEED_RESOLVER_TIMEOUT_SETTING.exists(settings)) { + throw new IllegalArgumentException("it is forbidden to set both [" + + DISCOVERY_SEED_RESOLVER_TIMEOUT_SETTING.getKey() + "] and [" + + LEGACY_DISCOVERY_ZEN_PING_UNICAST_HOSTS_RESOLVE_TIMEOUT.getKey() + "]"); + } + return LEGACY_DISCOVERY_ZEN_PING_UNICAST_HOSTS_RESOLVE_TIMEOUT.get(settings); + } + return DISCOVERY_SEED_RESOLVER_TIMEOUT_SETTING.get(settings); + } } diff --git a/server/src/main/java/org/elasticsearch/plugins/DiscoveryPlugin.java b/server/src/main/java/org/elasticsearch/plugins/DiscoveryPlugin.java index 90afaa8b70062..994607a9c97f7 100644 --- a/server/src/main/java/org/elasticsearch/plugins/DiscoveryPlugin.java +++ b/server/src/main/java/org/elasticsearch/plugins/DiscoveryPlugin.java @@ -100,7 +100,7 @@ default NetworkService.CustomNameResolver getCustomNameResolver(Settings setting * Returns providers of unicast host lists for zen discovery. * * The key of the returned map is the name of the host provider - * (see {@link org.elasticsearch.discovery.DiscoveryModule#DISCOVERY_HOSTS_PROVIDER_SETTING}), and + * (see {@link org.elasticsearch.discovery.DiscoveryModule#DISCOVERY_SEED_PROVIDERS_SETTING}), and * the value is a supplier to construct the host provider when it is selected for use. * * @param transportService Use to form the {@link org.elasticsearch.common.transport.TransportAddress} portion diff --git a/server/src/test/java/org/elasticsearch/bootstrap/BootstrapChecksTests.java b/server/src/test/java/org/elasticsearch/bootstrap/BootstrapChecksTests.java index 33a3aea37b4c5..9af7357717f5b 100644 --- a/server/src/test/java/org/elasticsearch/bootstrap/BootstrapChecksTests.java +++ b/server/src/test/java/org/elasticsearch/bootstrap/BootstrapChecksTests.java @@ -718,7 +718,7 @@ public void testDiscoveryConfiguredCheck() throws NodeValidationException { final NodeValidationException e = expectThrows(NodeValidationException.class, () -> BootstrapChecks.check(zen2Context, true, checks)); assertThat(e, hasToString(containsString("the default discovery settings are unsuitable for production use; at least one " + - "of [discovery.zen.ping.unicast.hosts, discovery.zen.hosts_provider, cluster.initial_master_nodes] must be configured"))); + "of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured"))); CheckedConsumer ensureChecksPass = b -> { @@ -727,8 +727,11 @@ public void testDiscoveryConfiguredCheck() throws NodeValidationException { BootstrapChecks.check(context, true, checks); }; - ensureChecksPass.accept(Settings.builder().putList(DiscoveryModule.DISCOVERY_HOSTS_PROVIDER_SETTING.getKey())); - ensureChecksPass.accept(Settings.builder().putList(SettingsBasedHostsProvider.DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.getKey())); ensureChecksPass.accept(Settings.builder().putList(ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING.getKey())); + ensureChecksPass.accept(Settings.builder().putList(DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING.getKey())); + ensureChecksPass.accept(Settings.builder().putList(SettingsBasedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING.getKey())); + ensureChecksPass.accept(Settings.builder().putList(DiscoveryModule.LEGACY_DISCOVERY_HOSTS_PROVIDER_SETTING.getKey())); + ensureChecksPass.accept(Settings.builder().putList(SettingsBasedHostsProvider.LEGACY_DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING + .getKey())); } } diff --git a/server/src/test/java/org/elasticsearch/cluster/coordination/ClusterBootstrapServiceTests.java b/server/src/test/java/org/elasticsearch/cluster/coordination/ClusterBootstrapServiceTests.java index c9ebdf278c71d..633a532cbd5b3 100644 --- a/server/src/test/java/org/elasticsearch/cluster/coordination/ClusterBootstrapServiceTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/coordination/ClusterBootstrapServiceTests.java @@ -48,8 +48,8 @@ import static org.elasticsearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; import static org.elasticsearch.cluster.coordination.ClusterBootstrapService.UNCONFIGURED_BOOTSTRAP_TIMEOUT_SETTING; import static org.elasticsearch.common.settings.Settings.builder; -import static org.elasticsearch.discovery.DiscoveryModule.DISCOVERY_HOSTS_PROVIDER_SETTING; -import static org.elasticsearch.discovery.zen.SettingsBasedHostsProvider.DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING; +import static org.elasticsearch.discovery.DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING; +import static org.elasticsearch.discovery.zen.SettingsBasedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING; import static org.elasticsearch.node.Node.NODE_NAME_SETTING; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.containsInAnyOrder; @@ -125,11 +125,11 @@ public void testBootstrapsAutomaticallyWithDefaultConfiguration() { } public void testDoesNothingByDefaultIfHostsProviderConfigured() { - testDoesNothingWithSettings(builder().putList(DISCOVERY_HOSTS_PROVIDER_SETTING.getKey())); + testDoesNothingWithSettings(builder().putList(DISCOVERY_SEED_PROVIDERS_SETTING.getKey())); } public void testDoesNothingByDefaultIfUnicastHostsConfigured() { - testDoesNothingWithSettings(builder().putList(DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.getKey())); + testDoesNothingWithSettings(builder().putList(DISCOVERY_SEED_HOSTS_SETTING.getKey())); } public void testDoesNothingByDefaultIfMasterNodesConfigured() { diff --git a/server/src/test/java/org/elasticsearch/discovery/DiscoveryModuleTests.java b/server/src/test/java/org/elasticsearch/discovery/DiscoveryModuleTests.java index e237415a9c60e..f44f33e71ee06 100644 --- a/server/src/test/java/org/elasticsearch/discovery/DiscoveryModuleTests.java +++ b/server/src/test/java/org/elasticsearch/discovery/DiscoveryModuleTests.java @@ -143,7 +143,7 @@ public void testDuplicateDiscovery() { } public void testHostsProvider() { - Settings settings = Settings.builder().put(DiscoveryModule.DISCOVERY_HOSTS_PROVIDER_SETTING.getKey(), "custom").build(); + Settings settings = Settings.builder().put(DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING.getKey(), "custom").build(); AtomicBoolean created = new AtomicBoolean(false); DummyHostsProviderPlugin plugin = () -> Collections.singletonMap("custom", () -> { created.set(true); @@ -153,11 +153,32 @@ public void testHostsProvider() { assertTrue(created.get()); } + public void testLegacyHostsProvider() { + Settings settings = Settings.builder().put(DiscoveryModule.LEGACY_DISCOVERY_HOSTS_PROVIDER_SETTING.getKey(), "custom").build(); + AtomicBoolean created = new AtomicBoolean(false); + DummyHostsProviderPlugin plugin = () -> Collections.singletonMap("custom", () -> { + created.set(true); + return hostsResolver -> Collections.emptyList(); + }); + newModule(settings, Collections.singletonList(plugin)); + assertTrue(created.get()); + assertWarnings("[discovery.zen.hosts_provider] setting was deprecated in Elasticsearch and will be removed in a future release! " + + "See the breaking changes documentation for the next major version."); + } + + public void testLegacyAndNonLegacyProvidersRejected() { + Settings settings = Settings.builder().putList(DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING.getKey()) + .putList(DiscoveryModule.LEGACY_DISCOVERY_HOSTS_PROVIDER_SETTING.getKey()).build(); + IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> + newModule(settings, Collections.emptyList())); + assertEquals("it is forbidden to set both [discovery.seed_providers] and [discovery.zen.hosts_provider]", e.getMessage()); + } + public void testUnknownHostsProvider() { - Settings settings = Settings.builder().put(DiscoveryModule.DISCOVERY_HOSTS_PROVIDER_SETTING.getKey(), "dne").build(); + Settings settings = Settings.builder().put(DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING.getKey(), "dne").build(); IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> newModule(settings, Collections.emptyList())); - assertEquals("Unknown zen hosts providers [dne]", e.getMessage()); + assertEquals("Unknown seed providers [dne]", e.getMessage()); } public void testDuplicateHostsProvider() { @@ -165,14 +186,14 @@ public void testDuplicateHostsProvider() { DummyHostsProviderPlugin plugin2 = () -> Collections.singletonMap("dup", () -> null); IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> newModule(Settings.EMPTY, Arrays.asList(plugin1, plugin2))); - assertEquals("Cannot register zen hosts provider [dup] twice", e.getMessage()); + assertEquals("Cannot register seed provider [dup] twice", e.getMessage()); } public void testSettingsHostsProvider() { DummyHostsProviderPlugin plugin = () -> Collections.singletonMap("settings", () -> null); IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> newModule(Settings.EMPTY, Arrays.asList(plugin))); - assertEquals("Cannot register zen hosts provider [settings] twice", e.getMessage()); + assertEquals("Cannot register seed provider [settings] twice", e.getMessage()); } public void testMultiHostsProvider() { @@ -191,7 +212,7 @@ public void testMultiHostsProvider() { created3.set(true); return hostsResolver -> Collections.emptyList(); }); - Settings settings = Settings.builder().putList(DiscoveryModule.DISCOVERY_HOSTS_PROVIDER_SETTING.getKey(), + Settings settings = Settings.builder().putList(DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING.getKey(), "provider1", "provider3").build(); newModule(settings, Arrays.asList(plugin1, plugin2, plugin3)); assertTrue(created1.get()); diff --git a/server/src/test/java/org/elasticsearch/discovery/zen/SettingsBasedHostsProviderIT.java b/server/src/test/java/org/elasticsearch/discovery/zen/SettingsBasedHostsProviderIT.java index b79fb05d40111..59c66a7d4f9c7 100644 --- a/server/src/test/java/org/elasticsearch/discovery/zen/SettingsBasedHostsProviderIT.java +++ b/server/src/test/java/org/elasticsearch/discovery/zen/SettingsBasedHostsProviderIT.java @@ -24,8 +24,8 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.test.ESIntegTestCase; -import static org.elasticsearch.discovery.DiscoveryModule.DISCOVERY_HOSTS_PROVIDER_SETTING; -import static org.elasticsearch.discovery.zen.SettingsBasedHostsProvider.DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING; +import static org.elasticsearch.discovery.DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING; +import static org.elasticsearch.discovery.zen.SettingsBasedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING; @ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0, numClientNodes = 0) public class SettingsBasedHostsProviderIT extends ESIntegTestCase { @@ -36,13 +36,13 @@ protected Settings nodeSettings(int nodeOrdinal) { // super.nodeSettings enables file-based discovery, but here we disable it again so we can test the static list: if (randomBoolean()) { - builder.putList(DISCOVERY_HOSTS_PROVIDER_SETTING.getKey()); + builder.putList(DISCOVERY_SEED_PROVIDERS_SETTING.getKey()); } else { - builder.remove(DISCOVERY_HOSTS_PROVIDER_SETTING.getKey()); + builder.remove(DISCOVERY_SEED_PROVIDERS_SETTING.getKey()); } // super.nodeSettings sets this to an empty list, which disables any search for other nodes, but here we want this to happen: - builder.remove(DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.getKey()); + builder.remove(DISCOVERY_SEED_HOSTS_SETTING.getKey()); return builder.build(); } @@ -56,7 +56,7 @@ public void testClusterFormsWithSingleSeedHostInSettings() { int extraNodes = randomIntBetween(1, 5); internalCluster().startNodes(extraNodes, - Settings.builder().putList(DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.getKey(), seedNodeAddress).build()); + Settings.builder().putList(DISCOVERY_SEED_HOSTS_SETTING.getKey(), seedNodeAddress).build()); ensureStableCluster(extraNodes + 1); } diff --git a/server/src/test/java/org/elasticsearch/discovery/zen/SettingsBasedHostsProviderTests.java b/server/src/test/java/org/elasticsearch/discovery/zen/SettingsBasedHostsProviderTests.java new file mode 100644 index 0000000000000..c08b5514de700 --- /dev/null +++ b/server/src/test/java/org/elasticsearch/discovery/zen/SettingsBasedHostsProviderTests.java @@ -0,0 +1,94 @@ +/* + * 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.discovery.zen; + +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.transport.TransportAddress; +import org.elasticsearch.common.util.set.Sets; +import org.elasticsearch.discovery.zen.UnicastHostsProvider.HostsResolver; +import org.elasticsearch.test.ESTestCase; +import org.elasticsearch.transport.TransportService; + +import java.util.Arrays; +import java.util.List; +import java.util.Set; + +import static java.util.Collections.emptyList; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class SettingsBasedHostsProviderTests extends ESTestCase { + + private class AssertingHostsResolver implements HostsResolver { + private final Set expectedHosts; + private final int expectedPortCount; + + private boolean resolvedHosts; + + AssertingHostsResolver(int expectedPortCount, String... expectedHosts) { + this.expectedPortCount = expectedPortCount; + this.expectedHosts = Sets.newHashSet(expectedHosts); + } + + @Override + public List resolveHosts(List hosts, int limitPortCounts) { + assertEquals(expectedPortCount, limitPortCounts); + assertEquals(expectedHosts, Sets.newHashSet(hosts)); + resolvedHosts = true; + return emptyList(); + } + + boolean getResolvedHosts() { + return resolvedHosts; + } + } + + public void testScansPortsByDefault() { + final AssertingHostsResolver hostsResolver = new AssertingHostsResolver(5, "::1", "127.0.0.1"); + final TransportService transportService = mock(TransportService.class); + when(transportService.getLocalAddresses()).thenReturn(Arrays.asList("::1", "127.0.0.1")); + new SettingsBasedHostsProvider(Settings.EMPTY, transportService).buildDynamicHosts(hostsResolver); + assertTrue(hostsResolver.getResolvedHosts()); + } + + public void testGetsHostsFromSetting() { + final AssertingHostsResolver hostsResolver = new AssertingHostsResolver(1, "bar", "foo"); + new SettingsBasedHostsProvider(Settings.builder() + .putList(SettingsBasedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING.getKey(), "foo", "bar") + .build(), null).buildDynamicHosts(hostsResolver); + assertTrue(hostsResolver.getResolvedHosts()); + } + + public void testGetsHostsFromLegacySetting() { + final AssertingHostsResolver hostsResolver = new AssertingHostsResolver(1, "bar", "foo"); + new SettingsBasedHostsProvider(Settings.builder() + .putList(SettingsBasedHostsProvider.LEGACY_DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.getKey(), "foo", "bar") + .build(), null).buildDynamicHosts(hostsResolver); + assertTrue(hostsResolver.getResolvedHosts()); + assertWarnings("[discovery.zen.ping.unicast.hosts] setting was deprecated in Elasticsearch and will be removed in a future " + + "release! See the breaking changes documentation for the next major version."); + } + + public void testForbidsBothSettingsAtTheSameTime() { + expectThrows(IllegalArgumentException.class, () -> new SettingsBasedHostsProvider(Settings.builder() + .putList(SettingsBasedHostsProvider.LEGACY_DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.getKey()) + .putList(SettingsBasedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING.getKey()) + .build(), null)); + } +} 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 f06ef3e72808a..f7047abf721ce 100644 --- a/server/src/test/java/org/elasticsearch/discovery/zen/UnicastZenPingTests.java +++ b/server/src/test/java/org/elasticsearch/discovery/zen/UnicastZenPingTests.java @@ -90,6 +90,7 @@ import static java.util.Collections.emptyMap; import static java.util.Collections.emptySet; +import static org.elasticsearch.discovery.zen.SettingsBasedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING; import static org.elasticsearch.gateway.GatewayService.STATE_NOT_RECOVERED_BLOCK; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.equalTo; @@ -172,7 +173,7 @@ public void testSimplePings() throws IOException, InterruptedException, Executio final ClusterState stateMismatch = ClusterState.builder(new ClusterName("mismatch")).version(randomNonNegativeLong()).build(); final Settings hostsSettings = Settings.builder() - .putList("discovery.zen.ping.unicast.hosts", + .putList(DISCOVERY_SEED_HOSTS_SETTING.getKey(), NetworkAddress.format(new InetSocketAddress(handleA.address.address().getAddress(), handleA.address.address().getPort())), NetworkAddress.format(new InetSocketAddress(handleB.address.address().getAddress(), handleB.address.address().getPort())), NetworkAddress.format(new InetSocketAddress(handleC.address.address().getAddress(), handleC.address.address().getPort())), @@ -306,7 +307,7 @@ public TransportAddress[] addressesFromString(String address, int perAddressLimi new InetSocketAddress(handleC.address.address().getAddress(), handleC.address.address().getPort()))}); final Settings hostsSettings = Settings.builder() - .putList("discovery.zen.ping.unicast.hosts", "UZP_A", "UZP_B", "UZP_C") + .putList(DISCOVERY_SEED_HOSTS_SETTING.getKey(), "UZP_A", "UZP_B", "UZP_C") .put("cluster.name", "test") .build(); @@ -590,11 +591,11 @@ public void testResolveReuseExistingNodeConnections() throws ExecutionException, final boolean useHosts = randomBoolean(); final Settings.Builder hostsSettingsBuilder = Settings.builder().put("cluster.name", "test"); if (useHosts) { - hostsSettingsBuilder.putList("discovery.zen.ping.unicast.hosts", + hostsSettingsBuilder.putList(DISCOVERY_SEED_HOSTS_SETTING.getKey(), NetworkAddress.format(new InetSocketAddress(handleB.address.address().getAddress(), handleB.address.address().getPort())) ); } else { - hostsSettingsBuilder.put("discovery.zen.ping.unicast.hosts", (String) null); + hostsSettingsBuilder.put(DISCOVERY_SEED_HOSTS_SETTING.getKey(), (String) null); } final Settings hostsSettings = hostsSettingsBuilder.build(); @@ -655,7 +656,7 @@ public void testPingingTemporalPings() throws ExecutionException, InterruptedExc final Settings hostsSettings = Settings.builder() .put("cluster.name", "test") - .put("discovery.zen.ping.unicast.hosts", (String) null) // use nodes for simplicity + .put(DISCOVERY_SEED_HOSTS_SETTING.getKey(), (String) null) // use nodes for simplicity .build(); final ClusterState state = ClusterState.builder(new ClusterName("test")).version(randomNonNegativeLong()).build(); diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java index 0dfdd2505235a..363050fde26cb 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java @@ -195,8 +195,8 @@ import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; import static org.elasticsearch.common.util.CollectionUtils.eagerPartition; -import static org.elasticsearch.discovery.DiscoveryModule.DISCOVERY_HOSTS_PROVIDER_SETTING; -import static org.elasticsearch.discovery.zen.SettingsBasedHostsProvider.DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING; +import static org.elasticsearch.discovery.DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING; +import static org.elasticsearch.discovery.zen.SettingsBasedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.test.XContentTestUtils.convertToMap; import static org.elasticsearch.test.XContentTestUtils.differenceBetweenMapsIgnoringArrayOrder; @@ -1816,8 +1816,8 @@ protected Settings nodeSettings(int nodeOrdinal) { .put(IndicesStore.INDICES_STORE_DELETE_SHARD_TIMEOUT.getKey(), new TimeValue(1, TimeUnit.SECONDS)) // randomly enable low-level search cancellation to make sure it does not alter results .put(SearchService.LOW_LEVEL_CANCELLATION_SETTING.getKey(), randomBoolean()) - .putList(DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.getKey()) // empty list disables a port scan for other nodes - .putList(DISCOVERY_HOSTS_PROVIDER_SETTING.getKey(), "file"); + .putList(DISCOVERY_SEED_HOSTS_SETTING.getKey()) // empty list disables a port scan for other nodes + .putList(DISCOVERY_SEED_PROVIDERS_SETTING.getKey(), "file"); if (rarely()) { // Sometimes adjust the minimum search thread pool size, causing // QueueResizingEsThreadPoolExecutor to be used instead of a regular diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESSingleNodeTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESSingleNodeTestCase.java index 32aa1c2107d5a..e2d21043282ae 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESSingleNodeTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESSingleNodeTestCase.java @@ -63,7 +63,7 @@ import java.util.Collections; import static org.elasticsearch.cluster.coordination.ClusterBootstrapService.INITIAL_MASTER_NODES_SETTING; -import static org.elasticsearch.discovery.zen.SettingsBasedHostsProvider.DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING; +import static org.elasticsearch.discovery.zen.SettingsBasedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.lessThanOrEqualTo; @@ -202,7 +202,7 @@ private Node newNode() { // turning on the real memory circuit breaker leads to spurious test failures. As have no full control over heap usage, we // turn it off for these tests. .put(HierarchyCircuitBreakerService.USE_REAL_MEMORY_USAGE_SETTING.getKey(), false) - .putList(DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.getKey()) // empty list disables a port scan for other nodes + .putList(DISCOVERY_SEED_HOSTS_SETTING.getKey()) // empty list disables a port scan for other nodes .putList(INITIAL_MASTER_NODES_SETTING.getKey(), nodeName) .put(nodeSettings()) // allow test cases to provide their own settings or override these .build(); diff --git a/test/framework/src/main/java/org/elasticsearch/test/discovery/TestZenDiscovery.java b/test/framework/src/main/java/org/elasticsearch/test/discovery/TestZenDiscovery.java index 56e6c24571715..43976b9dfc76f 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/discovery/TestZenDiscovery.java +++ b/test/framework/src/main/java/org/elasticsearch/test/discovery/TestZenDiscovery.java @@ -47,7 +47,7 @@ import java.util.Random; import java.util.function.Supplier; -import static org.elasticsearch.discovery.zen.SettingsBasedHostsProvider.DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING; +import static org.elasticsearch.discovery.zen.SettingsBasedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING; /** * A alternative zen discovery which allows using mocks for things like pings, as well as @@ -76,7 +76,7 @@ public Map> getDiscoveryTypes(ThreadPool threadPool, ClusterSettings clusterSettings, UnicastHostsProvider hostsProvider, AllocationService allocationService, GatewayMetaState gatewayMetaState) { // we don't get the latest setting which were updated by the extra settings for the plugin. TODO: fix. - Settings fixedSettings = Settings.builder().put(settings).putList(DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.getKey()).build(); + Settings fixedSettings = Settings.builder().put(settings).putList(DISCOVERY_SEED_HOSTS_SETTING.getKey()).build(); return Collections.singletonMap("test-zen", () -> { if (USE_ZEN2.get(settings)) { return new Coordinator("test_node", fixedSettings, clusterSettings, transportService, namedWriteableRegistry, @@ -99,7 +99,7 @@ public List> getSettings() { public Settings additionalSettings() { return Settings.builder() .put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), TEST_ZEN_DISCOVERY_TYPE) - .putList(DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.getKey()) + .putList(DISCOVERY_SEED_HOSTS_SETTING.getKey()) .build(); } } 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 e75d7eab626a8..f1028322754a5 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 @@ -58,7 +58,7 @@ import static org.elasticsearch.cluster.node.DiscoveryNode.Role.DATA; import static org.elasticsearch.cluster.node.DiscoveryNode.Role.INGEST; import static org.elasticsearch.cluster.node.DiscoveryNode.Role.MASTER; -import static org.elasticsearch.discovery.DiscoveryModule.DISCOVERY_HOSTS_PROVIDER_SETTING; +import static org.elasticsearch.discovery.DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertFileExists; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertFileNotExists; import static org.hamcrest.Matchers.equalTo; @@ -162,8 +162,8 @@ public Settings nodeSettings(int nodeOrdinal) { .put( NodeEnvironment.MAX_LOCAL_STORAGE_NODES_SETTING.getKey(), 2 * ((masterNodes ? InternalTestCluster.DEFAULT_HIGH_NUM_MASTER_NODES : 0) + maxNumDataNodes + numClientNodes)) - .put(DiscoveryModule.DISCOVERY_HOSTS_PROVIDER_SETTING.getKey(), "file") - .putList(SettingsBasedHostsProvider.DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.getKey()) + .put(DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING.getKey(), "file") + .putList(SettingsBasedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING.getKey()) .put(NetworkModule.TRANSPORT_TYPE_KEY, getTestTransportType()); if (autoManageMinMasterNodes == false) { assert minNumDataNodes == maxNumDataNodes; @@ -239,8 +239,8 @@ public Settings nodeSettings(int nodeOrdinal) { NodeEnvironment.MAX_LOCAL_STORAGE_NODES_SETTING.getKey(), 2 + (masterNodes ? InternalTestCluster.DEFAULT_HIGH_NUM_MASTER_NODES : 0) + maxNumDataNodes + numClientNodes) .put(NetworkModule.TRANSPORT_TYPE_KEY, getTestTransportType()) - .putList(DISCOVERY_HOSTS_PROVIDER_SETTING.getKey(), "file") - .putList(SettingsBasedHostsProvider.DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.getKey()) + .putList(DISCOVERY_SEED_PROVIDERS_SETTING.getKey(), "file") + .putList(SettingsBasedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING.getKey()) .build(); } @@ -337,8 +337,8 @@ public Settings nodeSettings(int nodeOrdinal) { .put(NodeEnvironment.MAX_LOCAL_STORAGE_NODES_SETTING.getKey(), numNodes) .put(NetworkModule.TRANSPORT_TYPE_KEY, getTestTransportType()) .put(DiscoverySettings.INITIAL_STATE_TIMEOUT_SETTING.getKey(), 0) - .putList(DISCOVERY_HOSTS_PROVIDER_SETTING.getKey(), "file") - .putList(SettingsBasedHostsProvider.DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.getKey()) + .putList(DISCOVERY_SEED_PROVIDERS_SETTING.getKey(), "file") + .putList(SettingsBasedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING.getKey()) .build(); } @@ -420,8 +420,8 @@ public Settings nodeSettings(int nodeOrdinal) { return Settings.builder() .put(NodeEnvironment.MAX_LOCAL_STORAGE_NODES_SETTING.getKey(), 2) .put(NetworkModule.TRANSPORT_TYPE_KEY, getTestTransportType()) - .putList(DISCOVERY_HOSTS_PROVIDER_SETTING.getKey(), "file") - .putList(SettingsBasedHostsProvider.DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.getKey()) + .putList(DISCOVERY_SEED_PROVIDERS_SETTING.getKey(), "file") + .putList(SettingsBasedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING.getKey()) .build(); } diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrIntegTestCase.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrIntegTestCase.java index 2f34315b46e69..d28969bc10c8e 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrIntegTestCase.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrIntegTestCase.java @@ -98,8 +98,8 @@ import java.util.stream.Collectors; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; -import static org.elasticsearch.discovery.DiscoveryModule.DISCOVERY_HOSTS_PROVIDER_SETTING; -import static org.elasticsearch.discovery.zen.SettingsBasedHostsProvider.DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING; +import static org.elasticsearch.discovery.DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING; +import static org.elasticsearch.discovery.zen.SettingsBasedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures; import static org.hamcrest.Matchers.empty; @@ -194,8 +194,8 @@ private NodeConfigurationSource createNodeConfigurationSource(String leaderSeedA builder.put(ScriptService.SCRIPT_MAX_COMPILATIONS_RATE.getKey(), "2048/1m"); // wait short time for other active shards before actually deleting, default 30s not needed in tests builder.put(IndicesStore.INDICES_STORE_DELETE_SHARD_TIMEOUT.getKey(), new TimeValue(1, TimeUnit.SECONDS)); - builder.putList(DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.getKey()); // empty list disables a port scan for other nodes - builder.putList(DISCOVERY_HOSTS_PROVIDER_SETTING.getKey(), "file"); + builder.putList(DISCOVERY_SEED_HOSTS_SETTING.getKey()); // empty list disables a port scan for other nodes + builder.putList(DISCOVERY_SEED_PROVIDERS_SETTING.getKey(), "file"); builder.put(NetworkModule.TRANSPORT_TYPE_KEY, getTestTransportType()); builder.put(XPackSettings.SECURITY_ENABLED.getKey(), false); builder.put(XPackSettings.MONITORING_ENABLED.getKey(), false); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/license/LicensingTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/license/LicensingTests.java index f146f12245e1f..3d19568772128 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/license/LicensingTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/license/LicensingTests.java @@ -59,7 +59,7 @@ import java.util.stream.Collectors; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; -import static org.elasticsearch.discovery.zen.SettingsBasedHostsProvider.DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING; +import static org.elasticsearch.discovery.zen.SettingsBasedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.greaterThanOrEqualTo; @@ -300,8 +300,8 @@ public void testNodeJoinWithoutSecurityExplicitlyEnabled() throws Exception { .put(TestZenDiscovery.USE_MOCK_PINGS.getKey(), false) .put(DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey(), "test-zen") .put(TestZenDiscovery.USE_ZEN2.getKey(), getUseZen2()) - .putList(DiscoveryModule.DISCOVERY_HOSTS_PROVIDER_SETTING.getKey()) - .putList(DISCOVERY_ZEN_PING_UNICAST_HOSTS_SETTING.getKey(), unicastHostsList); + .putList(DiscoveryModule.DISCOVERY_SEED_PROVIDERS_SETTING.getKey()) + .putList(DISCOVERY_SEED_HOSTS_SETTING.getKey(), unicastHostsList); if (getUseZen2() == false) { nodeSettings.put(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.get(internalCluster().getInstance(Settings.class))); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ServerTransportFilterIntegrationTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ServerTransportFilterIntegrationTests.java index 83640d9e931b5..5dcb48173969b 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ServerTransportFilterIntegrationTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ServerTransportFilterIntegrationTests.java @@ -44,6 +44,7 @@ import java.util.Collections; import java.util.concurrent.CountDownLatch; +import static org.elasticsearch.discovery.zen.SettingsBasedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING; import static org.elasticsearch.test.SecuritySettingsSource.addSSLSettingsForNodePEMFiles; import static org.elasticsearch.test.SecuritySettingsSource.addSSLSettingsForPEMFiles; import static org.elasticsearch.xpack.security.test.SecurityTestUtils.writeFile; @@ -101,7 +102,7 @@ public void testThatConnectionToServerTypeConnectionWorks() throws IOException, .put("node.name", "my-test-node") .put("network.host", "localhost") .put("cluster.name", internalCluster().getClusterName()) - .put("discovery.zen.ping.unicast.hosts", unicastHost) + .put(DISCOVERY_SEED_HOSTS_SETTING.getKey(), unicastHost) .put("xpack.security.enabled", true) .put("xpack.security.audit.enabled", false) .put("xpack.security.transport.ssl.enabled", true) @@ -146,7 +147,7 @@ public void testThatConnectionToClientTypeConnectionIsRejected() throws IOExcept .put("node.name", "my-test-node") .put(SecurityField.USER_SETTING.getKey(), "test_user:" + SecuritySettingsSourceField.TEST_PASSWORD) .put("cluster.name", internalCluster().getClusterName()) - .put("discovery.zen.ping.unicast.hosts", unicastHost) + .put(DISCOVERY_SEED_HOSTS_SETTING.getKey(), unicastHost) .put("xpack.security.enabled", true) .put("xpack.security.audit.enabled", false) .put("xpack.security.transport.ssl.enabled", true) 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 b1ecad0e4b4a5..fd9213965a975 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 @@ -17,6 +17,7 @@ import java.util.ArrayList; import java.util.List; +import static org.elasticsearch.discovery.zen.SettingsBasedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING; import static org.hamcrest.CoreMatchers.is; // TODO delete this test? @@ -38,13 +39,13 @@ protected Settings nodeSettings(int nodeOrdinal) { // The default Unicast test behavior is to use 'localhost' with the port number. For this test we need to use IP List newUnicastAddresses = new ArrayList<>(); - for (String address : settings.getAsList("discovery.zen.ping.unicast.hosts")) { + for (String address : settings.getAsList(DISCOVERY_SEED_HOSTS_SETTING.getKey())) { newUnicastAddresses.add(address.replace("localhost", "127.0.0.1")); } Settings.Builder settingsBuilder = Settings.builder() .put(settings) - .putList("discovery.zen.ping.unicast.hosts", newUnicastAddresses); + .putList(DISCOVERY_SEED_HOSTS_SETTING.getKey(), newUnicastAddresses); try { //Use a cert with a CN of "Elasticsearch Test Node" and IPv4+IPv6 ip addresses as SubjectAlternativeNames diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/bench/WatcherExecutorServiceBenchmark.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/bench/WatcherExecutorServiceBenchmark.java index 81a2911be28d6..7a8512f17c988 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/bench/WatcherExecutorServiceBenchmark.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/bench/WatcherExecutorServiceBenchmark.java @@ -28,6 +28,7 @@ import java.util.Arrays; import static java.util.Collections.emptyMap; +import static org.elasticsearch.discovery.zen.SettingsBasedHostsProvider.DISCOVERY_SEED_HOSTS_SETTING; import static org.elasticsearch.xpack.watcher.actions.ActionBuilders.indexAction; import static org.elasticsearch.xpack.watcher.input.InputBuilders.httpInput; import static org.elasticsearch.xpack.watcher.input.InputBuilders.searchInput; @@ -48,7 +49,7 @@ public class WatcherExecutorServiceBenchmark { .put("cluster.name", "bench") .put("network.host", "localhost") .put("script.disable_dynamic", false) - .put("discovery.zen.ping.unicast.hosts", "localhost") + .put(DISCOVERY_SEED_HOSTS_SETTING.getKey(), "localhost") .put("http.cors.enabled", true) .put("cluster.routing.allocation.disk.threshold_enabled", false) // .put("recycler.page.limit.heap", "60%") diff --git a/x-pack/qa/vagrant/src/test/resources/packaging/tests/certgen.bash b/x-pack/qa/vagrant/src/test/resources/packaging/tests/certgen.bash index 83f967c39891b..c0ae9aac4db30 100644 --- a/x-pack/qa/vagrant/src/test/resources/packaging/tests/certgen.bash +++ b/x-pack/qa/vagrant/src/test/resources/packaging/tests/certgen.bash @@ -248,7 +248,7 @@ cat >> $ESCONFIG/elasticsearch.yml <<- EOF node.name: "node-master" node.master: true node.data: false -discovery.zen.ping.unicast.hosts: ["127.0.0.1:9301"] +discovery.seed_hosts: ["127.0.0.1:9301"] cluster.initial_master_nodes: ["node-master"] xpack.security.transport.ssl.key: $ESCONFIG/certs/node-master/node-master.key @@ -335,7 +335,7 @@ cat >> $ESCONFIG/elasticsearch.yml <<- EOF node.name: "node-data" node.master: false node.data: true -discovery.zen.ping.unicast.hosts: ["127.0.0.1:9300"] +discovery.seed_hosts: ["127.0.0.1:9300"] xpack.security.transport.ssl.key: $ESCONFIG/certs/node-data/node-data.key xpack.security.transport.ssl.certificate: $ESCONFIG/certs/node-data/node-data.crt