From 1fc0432b244624ef800b616324f1d4d5911fcba8 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Tue, 24 Mar 2020 19:21:56 -0400 Subject: [PATCH] Introduce formal role for remote cluster client (#53924) This commit introduce a formal role for identifying nodes that are capable of making connections to remote clusters. --- .../resources/rest-api-spec/test/11_nodes.yml | 4 +- .../migration/migrate_8_0/settings.asciidoc | 9 ++++ docs/reference/ml/ml-shared.asciidoc | 4 +- docs/reference/modules/node.asciidoc | 46 +++++++++---------- .../modules/remote-clusters.asciidoc | 8 ++-- qa/multi-cluster-search/build.gradle | 4 +- .../rest-api-spec/test/cat.nodes/10_basic.yml | 4 +- .../cluster/node/DiscoveryNode.java | 15 +++++- .../cluster/node/DiscoveryNodeRole.java | 13 +++++- .../common/settings/ClusterSettings.java | 1 + .../common/unit/ByteSizeValue.java | 3 +- .../java/org/elasticsearch/node/Node.java | 3 ++ .../transport/RemoteClusterService.java | 16 +++++-- .../transport/TransportService.java | 9 ++-- .../admin/cluster/stats/ClusterStatsIT.java | 16 +++++-- .../cluster/node/DiscoveryNodeTests.java | 30 ++++++++++++ .../transport/RemoteClusterClientTests.java | 9 ++-- .../transport/RemoteClusterServiceTests.java | 9 ++-- .../transport/RemoteClusterSettingsTests.java | 21 +++++++-- .../validation/SourceDestValidator.java | 2 +- .../xpack/core/ml/job/messages/Messages.java | 2 +- .../action/TransportStartDatafeedAction.java | 8 ++-- .../xpack/ml/datafeed/DatafeedJobBuilder.java | 8 ++-- .../ml/datafeed/DatafeedJobBuilderTests.java | 4 +- .../ClusterStatsMonitoringDocTests.java | 3 +- .../xpack/transform/Transform.java | 4 +- .../TransportPreviewTransformAction.java | 4 +- .../action/TransportPutTransformAction.java | 4 +- .../action/TransportStartTransformAction.java | 4 +- .../TransportUpdateTransformAction.java | 4 +- .../xpack/transform/TransformTests.java | 8 ++-- .../build.gradle | 4 +- .../build.gradle | 4 +- 33 files changed, 191 insertions(+), 96 deletions(-) diff --git a/distribution/docker/src/test/resources/rest-api-spec/test/11_nodes.yml b/distribution/docker/src/test/resources/rest-api-spec/test/11_nodes.yml index c5b355e9b83f3..acda1a3dcedf7 100644 --- a/distribution/docker/src/test/resources/rest-api-spec/test/11_nodes.yml +++ b/distribution/docker/src/test/resources/rest-api-spec/test/11_nodes.yml @@ -7,7 +7,7 @@ - match: $body: | / #ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name - ^ ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)?\s+ ((-)?\d*(\.\d+)?)? \s+ (-|[dilmt]{1,5}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/ + ^ ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)?\s+ ((-)?\d*(\.\d+)?)? \s+ (-|[dilmrt]{1,6}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/ - do: cat.nodes: @@ -16,7 +16,7 @@ - match: $body: | /^ ip \s+ heap\.percent \s+ ram\.percent \s+ cpu \s+ load_1m \s+ load_5m \s+ load_15m \s+ node\.role \s+ master \s+ name \n - ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ (-|[dilmt]{1,5}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/ + ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ (-|[dilmrt]{1,6}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/ - do: cat.nodes: diff --git a/docs/reference/migration/migrate_8_0/settings.asciidoc b/docs/reference/migration/migrate_8_0/settings.asciidoc index 82ef5b8190adf..ba39f3f1221df 100644 --- a/docs/reference/migration/migrate_8_0/settings.asciidoc +++ b/docs/reference/migration/migrate_8_0/settings.asciidoc @@ -37,3 +37,12 @@ processors. As this leads to more context switches and more threads but without an increase in the number of physical CPUs on which to schedule these additional threads, the `node.processors` setting is now bounded by the number of available processors. + +[float] +==== `cluster.remote.connect` is deprecated in favor of `node.remote_cluster_client` + +Previously the setting `cluster.remote.connect` was used to configure whether or +not the local node is capable of acting as a remote cluster client in +cross-cluster search and cross-cluster replication. This setting is deprecated +in favor of `node.remote_cluster_client` serves the same purpose and identifies +the local node as having the `remote_cluster_client` role. diff --git a/docs/reference/ml/ml-shared.asciidoc b/docs/reference/ml/ml-shared.asciidoc index 75dc0a946d636..1d559f85866df 100644 --- a/docs/reference/ml/ml-shared.asciidoc +++ b/docs/reference/ml/ml-shared.asciidoc @@ -798,8 +798,8 @@ An array of index names. Wildcards are supported. For example: `["it_ops_metrics", "server*"]`. + -- -NOTE: If any indices are in remote clusters then `cluster.remote.connect` must -not be set to `false` on any {ml} nodes. +NOTE: If any indices are in remote clusters then `node.remote_cluster_client` +must not be set to `false` on any {ml} nodes. -- end::indices[] diff --git a/docs/reference/modules/node.asciidoc b/docs/reference/modules/node.asciidoc index 47b64ac4bd560..380d708e80eb7 100644 --- a/docs/reference/modules/node.asciidoc +++ b/docs/reference/modules/node.asciidoc @@ -1,8 +1,8 @@ [[modules-node]] == Node -Any time that you start an instance of Elasticsearch, you are starting a _node_. -A collection of connected nodes is called a <>. If you +Any time that you start an instance of Elasticsearch, you are starting a _node_. +A collection of connected nodes is called a <>. If you are running a single node of {es}, then you have a cluster of one node. Every node in the cluster can handle <> and @@ -11,7 +11,7 @@ exclusively for communication between nodes; the HTTP layer is used by REST clients. All nodes know about all the other nodes in the cluster and can forward client -requests to the appropriate node. +requests to the appropriate node. By default, a node is all of the following types: master-eligible, data, ingest, and machine learning (if available). @@ -95,22 +95,22 @@ be elected to become the master node by the <>. IMPORTANT: Master nodes must have access to the `data/` directory (just like -`data` nodes) as this is where the cluster state is persisted between node +`data` nodes) as this is where the cluster state is persisted between node restarts. [float] [[dedicated-master-node]] ==== Dedicated master-eligible node -It is important for the health of the cluster that the elected master node has -the resources it needs to fulfill its responsibilities. If the elected master -node is overloaded with other tasks then the cluster may not operate well. In -particular, indexing and searching your data can be very resource-intensive, so -in large or high-throughput clusters it is a good idea to avoid using the -master-eligible nodes for tasks such as indexing and searching. You can do this -by configuring three of your nodes to be dedicated master-eligible nodes. +It is important for the health of the cluster that the elected master node has +the resources it needs to fulfill its responsibilities. If the elected master +node is overloaded with other tasks then the cluster may not operate well. In +particular, indexing and searching your data can be very resource-intensive, so +in large or high-throughput clusters it is a good idea to avoid using the +master-eligible nodes for tasks such as indexing and searching. You can do this +by configuring three of your nodes to be dedicated master-eligible nodes. Dedicated master-eligible nodes only have the `master` role, allowing them to -focus on managing the cluster. While master nodes can also behave as +focus on managing the cluster. While master nodes can also behave as <> and route search and indexing requests from clients to data nodes, it is better _not_ to use dedicated master nodes for this purpose. @@ -127,7 +127,7 @@ node.ml: false <5> xpack.ml.enabled: true <6> node.transform: false <7> xpack.transform.enabled: true <8> -cluster.remote.connect: false <9> +node.remote_client_client: false <9> ------------------- <1> The `node.master` role is enabled by default. <2> The `node.voting_only` role is disabled by default. @@ -146,7 +146,7 @@ To create a dedicated master-eligible node in the {oss-dist}, set: node.master: true <1> node.data: false <2> node.ingest: false <3> -cluster.remote.connect: false <4> +node.remote_cluster_client: false <4> ------------------- <1> The `node.master` role is enabled by default. <2> Disable the `node.data` role (enabled by default). @@ -210,7 +210,7 @@ node.ml: false <5> xpack.ml.enabled: true <6> node.transform: false <7> xpack.transform.enabled: true <8> -cluster.remote.connect: false <9> +node.remote_cluster_client: false <9> ------------------- <1> The `node.master` role is enabled by default. <2> Enable the `node.voting_only` role (disabled by default). @@ -243,7 +243,7 @@ node.data: true <3> node.ingest: false <4> node.ml: false <5> node.transform: false <6> -cluster.remote.connect: false <7> +node.remote_cluster_client: false <7> ------------------- <1> Disable the `node.master` role (enabled by default). <2> The `node.voting_only` role is disabled by default. @@ -259,7 +259,7 @@ To create a dedicated data node in the {oss-dist}, set: node.master: false <1> node.data: true <2> node.ingest: false <3> -cluster.remote.connect: false <4> +node.remote_cluster_client: false <4> ------------------- <1> Disable the `node.master` role (enabled by default). <2> The `node.data` role is enabled by default. @@ -285,7 +285,7 @@ node.data: false <3> node.ingest: true <4> node.ml: false <5> node.transform: false <6> -cluster.remote.connect: false <7> +node.remote_cluster_client: false <7> ------------------- <1> Disable the `node.master` role (enabled by default). <2> The `node.voting_only` role is disabled by default. @@ -302,7 +302,7 @@ To create a dedicated ingest node in the {oss-dist}, set: node.master: false <1> node.data: false <2> node.ingest: true <3> -cluster.remote.connect: false <4> +node.remote_cluster_client: false <4> ------------------- <1> Disable the `node.master` role (enabled by default). <2> Disable the `node.data` role (enabled by default). @@ -340,7 +340,7 @@ node.data: false <3> node.ingest: false <4> node.ml: false <5> node.transform: false <6> -cluster.remote.connect: false <7> +node.remote_cluster_client: false <7> ------------------- <1> Disable the `node.master` role (enabled by default). <2> The `node.voting_only` role is disabled by default. @@ -357,7 +357,7 @@ To create a dedicated coordinating node in the {oss-dist}, set: node.master: false <1> node.data: false <2> node.ingest: false <3> -cluster.remote.connect: false <4> +node.remote_cluster_client: false <4> ------------------- <1> Disable the `node.master` role (enabled by default). <2> Disable the `node.data` role (enabled by default). @@ -390,7 +390,7 @@ node.ml: true <5> xpack.ml.enabled: true <6> node.transform: false <7> xpack.transform.enabled: true <8> -cluster.remote.connect: false <9> +node.remote_cluster_client: false <9> ------------------- <1> Disable the `node.master` role (enabled by default). <2> The `node.voting_only` role is disabled by default. @@ -425,7 +425,7 @@ node.ingest: false <4> node.ml: false <5> node.transform: true <6> xpack.transform.enabled: true <7> -cluster.remote.connect: false <8> +node.remote_cluster_client: false <8> ------------------- <1> Disable the `node.master` role. <2> Disable the `node.voting_only`. diff --git a/docs/reference/modules/remote-clusters.asciidoc b/docs/reference/modules/remote-clusters.asciidoc index 07b9fd23f96dc..426f79f0f4f65 100644 --- a/docs/reference/modules/remote-clusters.asciidoc +++ b/docs/reference/modules/remote-clusters.asciidoc @@ -254,12 +254,12 @@ and <> are described below. The time to wait for remote connections to be established when the node starts. The default is `30s`. -`cluster.remote.connect`:: +`node.remote_cluster_client`:: By default, any node in the cluster can act as a cross-cluster client and - connect to remote clusters. The `cluster.remote.connect` setting can be set to - `false` (defaults to `true`) to prevent certain nodes from connecting to - remote clusters. Remote cluster requests must be sent to a node that is + connect to remote clusters. The `node.remote_cluster_client` setting can be + set to `false` (defaults to `true`) to prevent certain nodes from connecting + to remote clusters. Remote cluster requests must be sent to a node that is allowed to act as a cross-cluster client. `cluster.remote..skip_unavailable`:: diff --git a/qa/multi-cluster-search/build.gradle b/qa/multi-cluster-search/build.gradle index a0908e24b41fc..125a341de6c11 100644 --- a/qa/multi-cluster-search/build.gradle +++ b/qa/multi-cluster-search/build.gradle @@ -35,7 +35,7 @@ task 'remote-cluster'(type: RestIntegTestTask) { testClusters.'remote-cluster' { numberOfNodes = 2 - setting 'cluster.remote.connect', 'false' + setting 'node.remote_cluster_client', 'false' } task mixedClusterTest(type: RestIntegTestTask) { @@ -50,7 +50,7 @@ testClusters.mixedClusterTest { setting 'cluster.remote.my_remote_cluster.seeds', { "\"${testClusters.'remote-cluster'.getAllTransportPortURI().get(0)}\"" } setting 'cluster.remote.connections_per_cluster', '1' - setting 'cluster.remote.connect', 'true' + setting 'node.remote_cluster_client', 'true' } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/cat.nodes/10_basic.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/cat.nodes/10_basic.yml index dbe18fbd83829..4c28f0bec5dfb 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/cat.nodes/10_basic.yml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/cat.nodes/10_basic.yml @@ -7,7 +7,7 @@ - match: $body: | / #ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name - ^ ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)?\s+ ((-)?\d*(\.\d+)?)? \s+ (-|[dilmt]{1,5}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/ + ^ ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)?\s+ ((-)?\d*(\.\d+)?)? \s+ (-|[dilmrt]{1,6}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/ - do: cat.nodes: @@ -16,7 +16,7 @@ - match: $body: | /^ ip \s+ heap\.percent \s+ ram\.percent \s+ cpu \s+ load_1m \s+ load_5m \s+ load_15m \s+ node\.role \s+ master \s+ name \n - ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ (-|[dilmt]{1,5}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/ + ((\d{1,3}\.){3}\d{1,3} \s+ \d+ \s+ \d* \s+ (-)?\d* \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ ((-)?\d*(\.\d+)?)? \s+ (-|[dilmrt]{1,6}) \s+ [-*x] \s+ (\S+\s?)+ \n)+ $/ - do: cat.nodes: diff --git a/server/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java b/server/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java index 6e9ad85aec56c..f131d03b12908 100644 --- a/server/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java +++ b/server/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java @@ -73,6 +73,10 @@ public static boolean isIngestNode(Settings settings) { return Node.NODE_INGEST_SETTING.get(settings); } + public static boolean isRemoteClusterClient(final Settings settings) { + return Node.NODE_REMOTE_CLUSTER_CLIENT.get(settings); + } + private final String nodeName; private final String nodeId; private final String ephemeralId; @@ -281,7 +285,7 @@ public void writeTo(StreamOutput out) throws IOException { } else { // an old node will only understand legacy roles since pluggable roles is a new concept final List rolesToWrite = - roles.stream().filter(DiscoveryNodeRole.BUILT_IN_ROLES::contains).collect(Collectors.toUnmodifiableList()); + roles.stream().filter(DiscoveryNodeRole.LEGACY_ROLES::contains).collect(Collectors.toUnmodifiableList()); out.writeVInt(rolesToWrite.size()); for (final DiscoveryNodeRole role : rolesToWrite) { if (role == DiscoveryNodeRole.MASTER_ROLE) { @@ -356,6 +360,15 @@ public boolean isIngestNode() { return roles.contains(DiscoveryNodeRole.INGEST_ROLE); } + /** + * Returns whether or not the node can be a remote cluster client. + * + * @return true if the node can be a remote cluster client, false otherwise + */ + public boolean isRemoteClusterClient() { + return roles.contains(DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE); + } + /** * Returns a set of all the roles that the node fulfills. * If the node doesn't have any specific role, the set is returned empty, which means that the node is a coordinating only node. diff --git a/server/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodeRole.java b/server/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodeRole.java index 4bdf27793f66d..8d293b9231ae5 100644 --- a/server/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodeRole.java +++ b/server/src/main/java/org/elasticsearch/cluster/node/DiscoveryNodeRole.java @@ -134,10 +134,21 @@ protected Setting roleSetting() { }; + public static final DiscoveryNodeRole REMOTE_CLUSTER_CLIENT_ROLE = new DiscoveryNodeRole("remote_cluster_client", "r") { + + @Override + protected Setting roleSetting() { + return Node.NODE_REMOTE_CLUSTER_CLIENT; + } + + }; + /** * The built-in node roles. */ - public static Set BUILT_IN_ROLES = Set.of(DATA_ROLE, INGEST_ROLE, MASTER_ROLE); + public static Set BUILT_IN_ROLES = Set.of(DATA_ROLE, INGEST_ROLE, MASTER_ROLE, REMOTE_CLUSTER_CLIENT_ROLE); + + static Set LEGACY_ROLES = Set.of(DATA_ROLE, INGEST_ROLE, MASTER_ROLE); /** * Represents an unknown role. This can occur if a newer version adds a role that an older version does not know about, or a newer 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 88b2e83c4212e..1d254613e95af 100644 --- a/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java +++ b/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java @@ -402,6 +402,7 @@ public void apply(Settings value, Settings current, Settings previous) { Node.NODE_DATA_SETTING, Node.NODE_MASTER_SETTING, Node.NODE_INGEST_SETTING, + Node.NODE_REMOTE_CLUSTER_CLIENT, Node.NODE_ATTRIBUTES, Node.NODE_LOCAL_STORAGE_SETTING, AutoCreateIndex.AUTO_CREATE_INDEX_SETTING, diff --git a/server/src/main/java/org/elasticsearch/common/unit/ByteSizeValue.java b/server/src/main/java/org/elasticsearch/common/unit/ByteSizeValue.java index 0f7207a9d37b5..a5d7cf7d641d5 100644 --- a/server/src/main/java/org/elasticsearch/common/unit/ByteSizeValue.java +++ b/server/src/main/java/org/elasticsearch/common/unit/ByteSizeValue.java @@ -27,7 +27,6 @@ import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.logging.LogConfigurator; -import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -40,7 +39,7 @@ public class ByteSizeValue implements Writeable, Comparable, ToXC /** * We have to lazy initialize the deprecation logger as otherwise a static logger here would be constructed before logging is configured * leading to a runtime failure (see {@link LogConfigurator#checkErrorListener()} ). The premature construction would come from any - * {@link Setting} object constructed in, for example, settings in {@link org.elasticsearch.common.network.NetworkService}. + * {@link ByteSizeValue} object constructed in, for example, settings in {@link org.elasticsearch.common.network.NetworkService}. */ static class DeprecationLoggerHolder { static DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(ByteSizeValue.class)); diff --git a/server/src/main/java/org/elasticsearch/node/Node.java b/server/src/main/java/org/elasticsearch/node/Node.java index fb60be6f68548..63a756887d864 100644 --- a/server/src/main/java/org/elasticsearch/node/Node.java +++ b/server/src/main/java/org/elasticsearch/node/Node.java @@ -155,6 +155,7 @@ import org.elasticsearch.tasks.TaskResultsService; import org.elasticsearch.threadpool.ExecutorBuilder; import org.elasticsearch.threadpool.ThreadPool; +import org.elasticsearch.transport.RemoteClusterService; import org.elasticsearch.transport.Transport; import org.elasticsearch.transport.TransportInterceptor; import org.elasticsearch.transport.TransportService; @@ -200,6 +201,8 @@ public class Node implements Closeable { Setting.boolSetting("node.master", true, Property.NodeScope); public static final Setting NODE_INGEST_SETTING = Setting.boolSetting("node.ingest", true, Property.NodeScope); + public static final Setting NODE_REMOTE_CLUSTER_CLIENT = + Setting.boolSetting("node.remote_cluster_client", RemoteClusterService.ENABLE_REMOTE_CLUSTERS, Property.NodeScope); /** * controls whether the node is allowed to persist things like metadata to disk diff --git a/server/src/main/java/org/elasticsearch/transport/RemoteClusterService.java b/server/src/main/java/org/elasticsearch/transport/RemoteClusterService.java index 74bc93421b108..7dd3006cc4202 100644 --- a/server/src/main/java/org/elasticsearch/transport/RemoteClusterService.java +++ b/server/src/main/java/org/elasticsearch/transport/RemoteClusterService.java @@ -28,6 +28,7 @@ import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.client.Client; import org.elasticsearch.cluster.node.DiscoveryNode; +import org.elasticsearch.cluster.node.DiscoveryNodeRole; import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.common.settings.Setting; @@ -36,6 +37,7 @@ import org.elasticsearch.common.util.concurrent.ConcurrentCollections; import org.elasticsearch.common.util.concurrent.CountDown; import org.elasticsearch.core.internal.io.IOUtils; +import org.elasticsearch.node.Node; import org.elasticsearch.threadpool.ThreadPool; import java.io.Closeable; @@ -62,7 +64,7 @@ */ public final class RemoteClusterService extends RemoteClusterAware implements Closeable { - private static final Logger logger = LogManager.getLogger(RemoteClusterService.class); + private final Logger logger = LogManager.getLogger(RemoteClusterService.class); /** * The initial connect timeout for remote cluster connections @@ -91,6 +93,7 @@ public final class RemoteClusterService extends RemoteClusterAware implements Cl Setting.boolSetting( "cluster.remote.connect", true, + Setting.Property.Deprecated, Setting.Property.NodeScope); public static final Setting.AffixSetting REMOTE_CLUSTER_SKIP_UNAVAILABLE = @@ -127,7 +130,7 @@ public boolean isEnabled() { RemoteClusterService(Settings settings, TransportService transportService) { super(settings); - this.enabled = ENABLE_REMOTE_CLUSTERS.get(settings); + this.enabled = Node.NODE_REMOTE_CLUSTER_CLIENT.get(settings); this.transportService = transportService; } @@ -208,7 +211,8 @@ public Transport.Connection getConnection(String cluster) { RemoteClusterConnection getRemoteClusterConnection(String cluster) { if (enabled == false) { - throw new IllegalArgumentException("remote cluster service is not enabled"); + throw new IllegalArgumentException( + "this node does not have the " + DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE.roleName() + " role"); } RemoteClusterConnection connection = remoteClusters.get(cluster); if (connection == null) { @@ -347,7 +351,8 @@ public Stream getRemoteConnectionInfos() { */ public void collectNodes(Set clusters, ActionListener> listener) { if (enabled == false) { - throw new IllegalArgumentException("remote cluster service is not enabled"); + throw new IllegalArgumentException( + "this node does not have the " + DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE.roleName() + " role"); } Map remoteClusters = this.remoteClusters; for (String cluster : clusters) { @@ -393,7 +398,8 @@ public void onFailure(Exception e) { */ public Client getRemoteClusterClient(ThreadPool threadPool, String clusterAlias) { if (transportService.getRemoteClusterService().isEnabled() == false) { - throw new IllegalArgumentException("remote cluster service is not enabled"); + throw new IllegalArgumentException( + "this node does not have the " + DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE.roleName() + " role"); } if (transportService.getRemoteClusterService().getRemoteClusterNames().contains(clusterAlias) == false) { throw new NoSuchRemoteClusterException(clusterAlias); diff --git a/server/src/main/java/org/elasticsearch/transport/TransportService.java b/server/src/main/java/org/elasticsearch/transport/TransportService.java index dcf9b3595c80e..4f962a334b8a1 100644 --- a/server/src/main/java/org/elasticsearch/transport/TransportService.java +++ b/server/src/main/java/org/elasticsearch/transport/TransportService.java @@ -44,6 +44,7 @@ import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.core.internal.io.IOUtils; +import org.elasticsearch.node.Node; import org.elasticsearch.node.NodeClosedException; import org.elasticsearch.tasks.Task; import org.elasticsearch.tasks.TaskManager; @@ -81,7 +82,7 @@ public class TransportService extends AbstractLifecycleComponent implements Tran protected final TaskManager taskManager; private final TransportInterceptor.AsyncSender asyncSender; private final Function localNodeFactory; - private final boolean connectToRemoteCluster; + private final boolean remoteClusterClient; private final Transport.ResponseHandlers responseHandlers; private final TransportInterceptor interceptor; @@ -161,13 +162,13 @@ public TransportService(Settings settings, Transport transport, ThreadPool threa taskManager = createTaskManager(settings, threadPool, taskHeaders); this.interceptor = transportInterceptor; this.asyncSender = interceptor.interceptSender(this::sendRequestInternal); - this.connectToRemoteCluster = RemoteClusterService.ENABLE_REMOTE_CLUSTERS.get(settings); + this.remoteClusterClient = Node.NODE_REMOTE_CLUSTER_CLIENT.get(settings); remoteClusterService = new RemoteClusterService(settings, this); responseHandlers = transport.getResponseHandlers(); if (clusterSettings != null) { clusterSettings.addSettingsUpdateConsumer(TransportSettings.TRACE_LOG_INCLUDE_SETTING, this::setTracerLogInclude); clusterSettings.addSettingsUpdateConsumer(TransportSettings.TRACE_LOG_EXCLUDE_SETTING, this::setTracerLogExclude); - if (connectToRemoteCluster) { + if (remoteClusterClient) { remoteClusterService.listenForUpdates(clusterSettings); } } @@ -227,7 +228,7 @@ protected void doStart() { localNode = localNodeFactory.apply(transport.boundAddress()); transport.setLocalNode(localNode); - if (connectToRemoteCluster) { + if (remoteClusterClient) { // here we start to connect to the remote clusters remoteClusterService.initializeRemoteClusters(); } diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsIT.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsIT.java index 2ca10f9b34519..e5126203b988d 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsIT.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsIT.java @@ -66,6 +66,7 @@ public void testNodeCounts() { expectedCounts.put(DiscoveryNodeRole.DATA_ROLE.roleName(), 1); expectedCounts.put(DiscoveryNodeRole.MASTER_ROLE.roleName(), 1); expectedCounts.put(DiscoveryNodeRole.INGEST_ROLE.roleName(), 1); + expectedCounts.put(DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE.roleName(), 1); expectedCounts.put(ClusterStatsNodes.Counts.COORDINATING_ONLY, 0); int numNodes = randomIntBetween(1, 5); @@ -76,9 +77,13 @@ public void testNodeCounts() { boolean isDataNode = randomBoolean(); boolean isMasterNode = randomBoolean(); boolean isIngestNode = randomBoolean(); - Settings settings = Settings.builder().put(Node.NODE_DATA_SETTING.getKey(), isDataNode) - .put(Node.NODE_MASTER_SETTING.getKey(), isMasterNode).put(Node.NODE_INGEST_SETTING.getKey(), isIngestNode) - .build(); + boolean isRemoteClusterClientNode = randomBoolean(); + Settings settings = Settings.builder() + .put(Node.NODE_DATA_SETTING.getKey(), isDataNode) + .put(Node.NODE_MASTER_SETTING.getKey(), isMasterNode) + .put(Node.NODE_INGEST_SETTING.getKey(), isIngestNode) + .put(Node.NODE_REMOTE_CLUSTER_CLIENT.getKey(), isRemoteClusterClientNode) + .build(); internalCluster().startNode(settings); total++; waitForNodes(total); @@ -92,7 +97,10 @@ public void testNodeCounts() { if (isIngestNode) { incrementCountForRole(DiscoveryNodeRole.INGEST_ROLE.roleName(), expectedCounts); } - if (!isDataNode && !isMasterNode && !isIngestNode) { + if (isRemoteClusterClientNode) { + incrementCountForRole(DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE.roleName(), expectedCounts); + } + if (!isDataNode && !isMasterNode && !isIngestNode && !isRemoteClusterClientNode) { incrementCountForRole(ClusterStatsNodes.Counts.COORDINATING_ONLY, expectedCounts); } diff --git a/server/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodeTests.java b/server/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodeTests.java index b020c7e03f107..26ea2c49fb980 100644 --- a/server/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodeTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodeTests.java @@ -22,13 +22,18 @@ import org.elasticsearch.Version; import org.elasticsearch.common.io.stream.BytesStreamOutput; import org.elasticsearch.common.io.stream.StreamInput; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.TransportAddress; +import org.elasticsearch.node.Node; import org.elasticsearch.test.ESTestCase; import java.net.InetAddress; +import java.util.HashSet; +import java.util.Set; import static java.util.Collections.emptyMap; import static java.util.Collections.emptySet; +import static org.hamcrest.Matchers.equalTo; public class DiscoveryNodeTests extends ESTestCase { @@ -58,4 +63,29 @@ public void testDiscoveryNodeSerializationKeepsHost() throws Exception { assertEquals(transportAddress.getAddress(), serialized.getAddress().getAddress()); assertEquals(transportAddress.getPort(), serialized.getAddress().getPort()); } + + public void testDiscoveryNodeIsRemoteClusterClientDefault() { + runTestDiscoveryNodeIsRemoteClusterClient(Settings.EMPTY, true); + } + + public void testDiscoveryNodeIsRemoteClusterClientSet() { + runTestDiscoveryNodeIsRemoteClusterClient(Settings.builder().put(Node.NODE_REMOTE_CLUSTER_CLIENT.getKey(), true).build(), true); + } + + public void testDiscoveryNodeIsRemoteClusterClientUnset() { + runTestDiscoveryNodeIsRemoteClusterClient(Settings.builder().put(Node.NODE_REMOTE_CLUSTER_CLIENT.getKey(), false).build(), false); + } + + private void runTestDiscoveryNodeIsRemoteClusterClient(final Settings settings, final boolean expected) { + final DiscoveryNode node = DiscoveryNode.createLocal(settings, new TransportAddress(TransportAddress.META_ADDRESS, 9200), "node"); + assertThat(node.isRemoteClusterClient(), equalTo(expected)); + final Set expectedRoles = new HashSet<>(DiscoveryNodeRole.BUILT_IN_ROLES); + if (expected) { + assertThat(node.getRoles(), equalTo(expectedRoles)); + } else { + expectedRoles.remove(DiscoveryNodeRole.REMOTE_CLUSTER_CLIENT_ROLE); + assertThat(node.getRoles(), equalTo(expectedRoles)); + } + } + } diff --git a/server/src/test/java/org/elasticsearch/transport/RemoteClusterClientTests.java b/server/src/test/java/org/elasticsearch/transport/RemoteClusterClientTests.java index 7c1d3edf4550c..9bea51ddfef5a 100644 --- a/server/src/test/java/org/elasticsearch/transport/RemoteClusterClientTests.java +++ b/server/src/test/java/org/elasticsearch/transport/RemoteClusterClientTests.java @@ -24,6 +24,7 @@ import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.node.Node; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.transport.MockTransportService; import org.elasticsearch.threadpool.TestThreadPool; @@ -52,7 +53,7 @@ public void testConnectAndExecuteRequest() throws Exception { DiscoveryNode remoteNode = remoteTransport.getLocalDiscoNode(); Settings localSettings = Settings.builder() - .put(RemoteClusterService.ENABLE_REMOTE_CLUSTERS.getKey(), true) + .put(Node.NODE_REMOTE_CLUSTER_CLIENT.getKey(), true) .put("cluster.remote.test.seeds", remoteNode.getAddress().getAddress() + ":" + remoteNode.getAddress().getPort()).build(); try (MockTransportService service = MockTransportService.createNewService(localSettings, Version.CURRENT, threadPool, null)) { @@ -81,7 +82,7 @@ public void testEnsureWeReconnect() throws Exception { remoteSettings)) { DiscoveryNode remoteNode = remoteTransport.getLocalDiscoNode(); Settings localSettings = Settings.builder() - .put(RemoteClusterService.ENABLE_REMOTE_CLUSTERS.getKey(), true) + .put(Node.NODE_REMOTE_CLUSTER_CLIENT.getKey(), true) .put("cluster.remote.test.seeds", remoteNode.getAddress().getAddress() + ":" + remoteNode.getAddress().getPort()).build(); try (MockTransportService service = MockTransportService.createNewService(localSettings, Version.CURRENT, threadPool, null)) { @@ -122,14 +123,14 @@ public void onNodeDisconnected(DiscoveryNode node, Transport.Connection connecti } public void testRemoteClusterServiceNotEnabled() { - final Settings settings = Settings.builder().put(RemoteClusterService.ENABLE_REMOTE_CLUSTERS.getKey(), false).build(); + final Settings settings = Settings.builder().put(Node.NODE_REMOTE_CLUSTER_CLIENT.getKey(), false).build(); try (MockTransportService service = MockTransportService.createNewService(settings, Version.CURRENT, threadPool, null)) { service.start(); service.acceptIncomingRequests(); final RemoteClusterService remoteClusterService = service.getRemoteClusterService(); final IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> remoteClusterService.getRemoteClusterClient(threadPool, "test")); - assertThat(e.getMessage(), equalTo("remote cluster service is not enabled")); + assertThat(e.getMessage(), equalTo("this node does not have the remote_cluster_client role")); } } diff --git a/server/src/test/java/org/elasticsearch/transport/RemoteClusterServiceTests.java b/server/src/test/java/org/elasticsearch/transport/RemoteClusterServiceTests.java index d16ebe74f075e..633a668ecd2ae 100644 --- a/server/src/test/java/org/elasticsearch/transport/RemoteClusterServiceTests.java +++ b/server/src/test/java/org/elasticsearch/transport/RemoteClusterServiceTests.java @@ -30,6 +30,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.core.internal.io.IOUtils; +import org.elasticsearch.node.Node; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.transport.MockTransportService; import org.elasticsearch.threadpool.TestThreadPool; @@ -845,25 +846,25 @@ public void testSkipUnavailable() { } public void testRemoteClusterServiceNotEnabledGetRemoteClusterConnection() { - final Settings settings = Settings.builder().put(RemoteClusterService.ENABLE_REMOTE_CLUSTERS.getKey(), false).build(); + final Settings settings = Settings.builder().put(Node.NODE_REMOTE_CLUSTER_CLIENT.getKey(), false).build(); try (MockTransportService service = MockTransportService.createNewService(settings, Version.CURRENT, threadPool, null)) { service.start(); service.acceptIncomingRequests(); final IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> service.getRemoteClusterService().getRemoteClusterConnection("test")); - assertThat(e.getMessage(), equalTo("remote cluster service is not enabled")); + assertThat(e.getMessage(), equalTo("this node does not have the remote_cluster_client role")); } } public void testRemoteClusterServiceNotEnabledGetCollectNodes() { - final Settings settings = Settings.builder().put(RemoteClusterService.ENABLE_REMOTE_CLUSTERS.getKey(), false).build(); + final Settings settings = Settings.builder().put(Node.NODE_REMOTE_CLUSTER_CLIENT.getKey(), false).build(); try (MockTransportService service = MockTransportService.createNewService(settings, Version.CURRENT, threadPool, null)) { service.start(); service.acceptIncomingRequests(); final IllegalArgumentException e = expectThrows( IllegalArgumentException.class, () -> service.getRemoteClusterService().collectNodes(Set.of(), ActionListener.wrap(r -> {}, r -> {}))); - assertThat(e.getMessage(), equalTo("remote cluster service is not enabled")); + assertThat(e.getMessage(), equalTo("this node does not have the remote_cluster_client role")); } } diff --git a/server/src/test/java/org/elasticsearch/transport/RemoteClusterSettingsTests.java b/server/src/test/java/org/elasticsearch/transport/RemoteClusterSettingsTests.java index 0f2749ffacf6c..8f262ea2454aa 100644 --- a/server/src/test/java/org/elasticsearch/transport/RemoteClusterSettingsTests.java +++ b/server/src/test/java/org/elasticsearch/transport/RemoteClusterSettingsTests.java @@ -19,19 +19,21 @@ package org.elasticsearch.transport; +import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.test.ESTestCase; import java.util.concurrent.TimeUnit; -import static org.elasticsearch.transport.SniffConnectionStrategy.REMOTE_CLUSTERS_PROXY; +import static org.elasticsearch.node.Node.NODE_REMOTE_CLUSTER_CLIENT; import static org.elasticsearch.transport.RemoteClusterService.ENABLE_REMOTE_CLUSTERS; import static org.elasticsearch.transport.RemoteClusterService.REMOTE_CLUSTER_SKIP_UNAVAILABLE; -import static org.elasticsearch.transport.SniffConnectionStrategy.REMOTE_CLUSTER_SEEDS; -import static org.elasticsearch.transport.SniffConnectionStrategy.REMOTE_CONNECTIONS_PER_CLUSTER; import static org.elasticsearch.transport.RemoteClusterService.REMOTE_INITIAL_CONNECTION_TIMEOUT_SETTING; import static org.elasticsearch.transport.RemoteClusterService.REMOTE_NODE_ATTRIBUTE; +import static org.elasticsearch.transport.SniffConnectionStrategy.REMOTE_CLUSTERS_PROXY; +import static org.elasticsearch.transport.SniffConnectionStrategy.REMOTE_CLUSTER_SEEDS; +import static org.elasticsearch.transport.SniffConnectionStrategy.REMOTE_CONNECTIONS_PER_CLUSTER; import static org.hamcrest.Matchers.emptyCollectionOf; import static org.hamcrest.Matchers.equalTo; @@ -49,8 +51,17 @@ public void testRemoteNodeAttributeDefault() { assertThat(REMOTE_NODE_ATTRIBUTE.get(Settings.EMPTY), equalTo("")); } - public void testEnableRemoteClustersDefault() { - assertTrue(ENABLE_REMOTE_CLUSTERS.get(Settings.EMPTY)); + public void testRemoteClusterClientDefault() { + assertTrue(NODE_REMOTE_CLUSTER_CLIENT.get(Settings.EMPTY)); + } + + public void testDisableRemoteClusterClient() { + assertFalse(NODE_REMOTE_CLUSTER_CLIENT.get(Settings.builder().put(NODE_REMOTE_CLUSTER_CLIENT.getKey(), false).build())); + } + + public void testDisableEnableRemoteClusters() { + assertFalse(NODE_REMOTE_CLUSTER_CLIENT.get(Settings.builder().put(ENABLE_REMOTE_CLUSTERS.getKey(), false).build())); + assertSettingDeprecationsAndWarnings(new Setting[]{ENABLE_REMOTE_CLUSTERS}); } public void testSkipUnavailableDefault() { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/common/validation/SourceDestValidator.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/common/validation/SourceDestValidator.java index 1a292bbebeadd..c9b9d54896dd0 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/common/validation/SourceDestValidator.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/common/validation/SourceDestValidator.java @@ -50,7 +50,7 @@ public final class SourceDestValidator { public static final String DEST_LOWERCASE = "Destination index [{0}] must be lowercase"; public static final String NEEDS_REMOTE_CLUSTER_SEARCH = "Source index is configured with a remote index pattern(s) [{0}]" + " but the current node [{1}] is not allowed to connect to remote clusters." - + " Please enable cluster.remote.connect for all data nodes."; + + " Please enable remote.cluster_client for all data nodes."; public static final String ERROR_REMOTE_CLUSTER_SEARCH = "Error resolving remote source: {0}"; public static final String UNKNOWN_REMOTE_CLUSTER_LICENSE = "Error during license check ({0}) for remote cluster " + "alias(es) {1}, error: {2}"; diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/messages/Messages.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/messages/Messages.java index 69a99e34ca146..413d241dda693 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/messages/Messages.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/messages/Messages.java @@ -51,7 +51,7 @@ public final class Messages { public static final String DATAFEED_ID_ALREADY_TAKEN = "A datafeed with id [{0}] already exists"; public static final String DATAFEED_NEEDS_REMOTE_CLUSTER_SEARCH = "Datafeed [{0}] is configured with a remote index pattern(s) {1}" + " but the current node [{2}] is not allowed to connect to remote clusters." + - " Please enable cluster.remote.connect for all machine learning nodes."; + " Please enable node.remote_cluster_client for all machine learning nodes."; public static final String DATA_FRAME_ANALYTICS_BAD_QUERY_FORMAT = "Data Frame Analytics config query is not parsable"; public static final String DATA_FRAME_ANALYTICS_BAD_FIELD_FILTER = "No field [{0}] could be detected"; diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportStartDatafeedAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportStartDatafeedAction.java index 28dbd4ba4d683..0dd24f8f85994 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportStartDatafeedAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportStartDatafeedAction.java @@ -30,6 +30,7 @@ import org.elasticsearch.license.LicenseUtils; import org.elasticsearch.license.RemoteClusterLicenseChecker; import org.elasticsearch.license.XPackLicenseState; +import org.elasticsearch.node.Node; import org.elasticsearch.persistent.AllocatedPersistentTask; import org.elasticsearch.persistent.PersistentTaskState; import org.elasticsearch.persistent.PersistentTasksCustomMetaData; @@ -39,7 +40,6 @@ import org.elasticsearch.tasks.Task; import org.elasticsearch.tasks.TaskId; import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.transport.RemoteClusterService; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.XPackField; import org.elasticsearch.xpack.core.ml.MlTasks; @@ -91,7 +91,7 @@ public class TransportStartDatafeedAction extends TransportMasterNodeAction { if (response.isSuccess() == false) { listener.onFailure(createUnlicensedError(params.getDatafeedId(), response)); - } else if (remoteClusterSearchSupported == false) { + } else if (remoteClusterClient == false) { listener.onFailure( ExceptionsHelper.badRequestException(Messages.getMessage( Messages.DATAFEED_NEEDS_REMOTE_CLUSTER_SEARCH, diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/datafeed/DatafeedJobBuilder.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/datafeed/DatafeedJobBuilder.java index dc88dac0e7cce..499da77ecbb95 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/datafeed/DatafeedJobBuilder.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/datafeed/DatafeedJobBuilder.java @@ -12,7 +12,7 @@ import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.license.RemoteClusterLicenseChecker; -import org.elasticsearch.transport.RemoteClusterService; +import org.elasticsearch.node.Node; import org.elasticsearch.xpack.core.action.util.QueryPage; import org.elasticsearch.xpack.core.ml.datafeed.DatafeedConfig; import org.elasticsearch.xpack.core.ml.datafeed.DatafeedJobValidator; @@ -51,7 +51,7 @@ public class DatafeedJobBuilder { private final JobResultsProvider jobResultsProvider; private final DatafeedConfigProvider datafeedConfigProvider; private final JobResultsPersister jobResultsPersister; - private final boolean remoteClusterSearchSupported; + private final boolean remoteClusterClient; private final String nodeName; public DatafeedJobBuilder(Client client, NamedXContentRegistry xContentRegistry, AnomalyDetectionAuditor auditor, @@ -66,7 +66,7 @@ public DatafeedJobBuilder(Client client, NamedXContentRegistry xContentRegistry, this.jobResultsProvider = Objects.requireNonNull(jobResultsProvider); this.datafeedConfigProvider = Objects.requireNonNull(datafeedConfigProvider); this.jobResultsPersister = Objects.requireNonNull(jobResultsPersister); - this.remoteClusterSearchSupported = RemoteClusterService.ENABLE_REMOTE_CLUSTERS.get(settings); + this.remoteClusterClient = Node.NODE_REMOTE_CLUSTER_CLIENT.get(settings); this.nodeName = nodeName; } @@ -181,7 +181,7 @@ void build(String datafeedId, ActionListener listener) { configBuilder -> { try { datafeedConfigHolder.set(configBuilder.build()); - if (remoteClusterSearchSupported == false) { + if (remoteClusterClient == false) { List remoteIndices = RemoteClusterLicenseChecker.remoteIndices(datafeedConfigHolder.get().getIndices()); if (remoteIndices.isEmpty() == false) { listener.onFailure( diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedJobBuilderTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedJobBuilderTests.java index ac8657575e2dd..9646fda946aac 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedJobBuilderTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedJobBuilderTests.java @@ -11,9 +11,9 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.mock.orig.Mockito; +import org.elasticsearch.node.Node; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.transport.RemoteClusterService; import org.elasticsearch.xpack.core.action.util.QueryPage; import org.elasticsearch.xpack.core.ml.datafeed.DatafeedConfig; import org.elasticsearch.xpack.core.ml.job.config.DataDescription; @@ -207,7 +207,7 @@ public void testBuild_GivenBucketsRequestFails() { } public void testBuildGivenRemoteIndicesButNoRemoteSearching() throws Exception { - Settings settings = Settings.builder().put(RemoteClusterService.ENABLE_REMOTE_CLUSTERS.getKey(), false).build(); + Settings settings = Settings.builder().put(Node.NODE_REMOTE_CLUSTER_CLIENT.getKey(), false).build(); datafeedJobBuilder = new DatafeedJobBuilder( client, diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsMonitoringDocTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsMonitoringDocTests.java index 3fecf1bb08b89..813e99763f5a9 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsMonitoringDocTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsMonitoringDocTests.java @@ -465,7 +465,8 @@ public void testToXContent() throws IOException { + " \"coordinating_only\": 0," + " \"data\": 0," + " \"ingest\": 0," - + " \"master\": 1" + + " \"master\": 1," + + " \"remote_cluster_client\": 0" + " }," + " \"versions\": [" + " \"%s\"" diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/Transform.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/Transform.java index a58b3703c2974..479f8abd99bdc 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/Transform.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/Transform.java @@ -32,6 +32,7 @@ import org.elasticsearch.env.NodeEnvironment; import org.elasticsearch.indices.SystemIndexDescriptor; import org.elasticsearch.license.XPackLicenseState; +import org.elasticsearch.node.Node; import org.elasticsearch.persistent.PersistentTasksExecutor; import org.elasticsearch.plugins.PersistentTaskPlugin; import org.elasticsearch.plugins.Plugin; @@ -42,7 +43,6 @@ import org.elasticsearch.threadpool.ExecutorBuilder; import org.elasticsearch.threadpool.FixedExecutorBuilder; import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.transport.RemoteClusterService; import org.elasticsearch.watcher.ResourceWatcherService; import org.elasticsearch.xpack.core.XPackPlugin; import org.elasticsearch.xpack.core.XPackSettings; @@ -370,7 +370,7 @@ public Settings additionalSettings() { Settings.Builder additionalSettings = Settings.builder(); additionalSettings.put(transformEnabledNodeAttribute, TRANSFORM_ENABLED_NODE.get(settings)); - additionalSettings.put(transformRemoteEnabledNodeAttribute, RemoteClusterService.ENABLE_REMOTE_CLUSTERS.get(settings)); + additionalSettings.put(transformRemoteEnabledNodeAttribute, Node.NODE_REMOTE_CLUSTER_CLIENT.get(settings)); return additionalSettings.build(); } diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportPreviewTransformAction.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportPreviewTransformAction.java index 46f18afa23c25..9fef913443312 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportPreviewTransformAction.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportPreviewTransformAction.java @@ -34,12 +34,12 @@ import org.elasticsearch.license.LicenseUtils; import org.elasticsearch.license.RemoteClusterLicenseChecker; import org.elasticsearch.license.XPackLicenseState; +import org.elasticsearch.node.Node; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.search.aggregations.Aggregations; import org.elasticsearch.search.aggregations.bucket.composite.CompositeAggregation; import org.elasticsearch.tasks.Task; import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.transport.RemoteClusterService; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.ClientHelper; import org.elasticsearch.xpack.core.XPackField; @@ -121,7 +121,7 @@ protected TransportPreviewTransformAction( this.sourceDestValidator = new SourceDestValidator( indexNameExpressionResolver, transportService.getRemoteClusterService(), - RemoteClusterService.ENABLE_REMOTE_CLUSTERS.get(settings) + Node.NODE_REMOTE_CLUSTER_CLIENT.get(settings) ? new RemoteClusterLicenseChecker(client, XPackLicenseState::isTransformAllowedForOperationMode) : null, clusterService.getNodeName(), diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportPutTransformAction.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportPutTransformAction.java index 23bd53e4efd30..8ef9804df762f 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportPutTransformAction.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportPutTransformAction.java @@ -31,11 +31,11 @@ import org.elasticsearch.license.LicenseUtils; import org.elasticsearch.license.RemoteClusterLicenseChecker; import org.elasticsearch.license.XPackLicenseState; +import org.elasticsearch.node.Node; import org.elasticsearch.persistent.PersistentTasksCustomMetaData; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.tasks.Task; import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.transport.RemoteClusterService; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.ClientHelper; import org.elasticsearch.xpack.core.XPackField; @@ -138,7 +138,7 @@ protected TransportPutTransformAction( this.sourceDestValidator = new SourceDestValidator( indexNameExpressionResolver, transportService.getRemoteClusterService(), - RemoteClusterService.ENABLE_REMOTE_CLUSTERS.get(settings) + Node.NODE_REMOTE_CLUSTER_CLIENT.get(settings) ? new RemoteClusterLicenseChecker(client, XPackLicenseState::isTransformAllowedForOperationMode) : null, clusterService.getNodeName(), diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportStartTransformAction.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportStartTransformAction.java index 9598e2f400e6f..deb88268eb8e5 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportStartTransformAction.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportStartTransformAction.java @@ -31,12 +31,12 @@ import org.elasticsearch.license.LicenseUtils; import org.elasticsearch.license.RemoteClusterLicenseChecker; import org.elasticsearch.license.XPackLicenseState; +import org.elasticsearch.node.Node; import org.elasticsearch.persistent.PersistentTasksCustomMetaData; import org.elasticsearch.persistent.PersistentTasksService; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.tasks.Task; import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.transport.RemoteClusterService; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.ClientHelper; import org.elasticsearch.xpack.core.XPackField; @@ -137,7 +137,7 @@ protected TransportStartTransformAction( this.sourceDestValidator = new SourceDestValidator( indexNameExpressionResolver, transportService.getRemoteClusterService(), - RemoteClusterService.ENABLE_REMOTE_CLUSTERS.get(settings) + Node.NODE_REMOTE_CLUSTER_CLIENT.get(settings) ? new RemoteClusterLicenseChecker(client, XPackLicenseState::isTransformAllowedForOperationMode) : null, clusterService.getNodeName(), diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportUpdateTransformAction.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportUpdateTransformAction.java index 1df334036cd9a..cf5f57e3f71d1 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportUpdateTransformAction.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportUpdateTransformAction.java @@ -27,11 +27,11 @@ import org.elasticsearch.license.LicenseUtils; import org.elasticsearch.license.RemoteClusterLicenseChecker; import org.elasticsearch.license.XPackLicenseState; +import org.elasticsearch.node.Node; import org.elasticsearch.persistent.PersistentTasksCustomMetaData; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.tasks.Task; import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.transport.RemoteClusterService; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.ClientHelper; import org.elasticsearch.xpack.core.XPackField; @@ -126,7 +126,7 @@ protected TransportUpdateTransformAction( this.sourceDestValidator = new SourceDestValidator( indexNameExpressionResolver, transportService.getRemoteClusterService(), - RemoteClusterService.ENABLE_REMOTE_CLUSTERS.get(settings) + Node.NODE_REMOTE_CLUSTER_CLIENT.get(settings) ? new RemoteClusterLicenseChecker(client, XPackLicenseState::isTransformAllowedForOperationMode) : null, clusterService.getNodeName(), diff --git a/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/TransformTests.java b/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/TransformTests.java index fdfd5a5a1c247..2ca4b11b43dd5 100644 --- a/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/TransformTests.java +++ b/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/TransformTests.java @@ -19,7 +19,7 @@ public void testNodeAttributes() { Settings.Builder builder = Settings.builder(); boolean transformEnabled = randomBoolean(); boolean transformPluginEnabled = randomBoolean(); - boolean remoteEnabled = randomBoolean(); + boolean remoteClusterClient = randomBoolean(); // randomly use explicit or default setting if ((transformEnabled && randomBoolean()) == false) { @@ -27,8 +27,8 @@ public void testNodeAttributes() { } // randomly use explicit or default setting - if ((remoteEnabled && randomBoolean()) == false) { - builder.put("cluster.remote.connect", remoteEnabled); + if ((remoteClusterClient && randomBoolean()) == false) { + builder.put("node.remote_cluster_client", remoteClusterClient); } if (transformPluginEnabled == false) { @@ -43,7 +43,7 @@ public void testNodeAttributes() { Boolean.parseBoolean(transform.additionalSettings().get("node.attr.transform.node")) ); assertEquals( - transformPluginEnabled && remoteEnabled, + transformPluginEnabled && remoteClusterClient, Boolean.parseBoolean(transform.additionalSettings().get("node.attr.transform.remote_connect")) ); } diff --git a/x-pack/qa/multi-cluster-search-security/build.gradle b/x-pack/qa/multi-cluster-search-security/build.gradle index 715d8857bac1b..75f8af8f44b65 100644 --- a/x-pack/qa/multi-cluster-search-security/build.gradle +++ b/x-pack/qa/multi-cluster-search-security/build.gradle @@ -23,7 +23,7 @@ task 'remote-cluster'(type: RestIntegTestTask) { testClusters.'remote-cluster' { testDistribution = 'DEFAULT' numberOfNodes = 2 - setting 'cluster.remote.connect', "false" + setting 'node.remote_cluster_client', "false" setting 'xpack.ilm.enabled', 'false' setting 'xpack.security.enabled', 'true' setting 'xpack.watcher.enabled', 'false' @@ -53,7 +53,7 @@ testClusters.'mixed-cluster' { testClusters.'remote-cluster'.getAllTransportPortURI().collect { "\"$it\"" }.toString() } setting 'cluster.remote.connections_per_cluster', "1" - setting 'cluster.remote.connect', "true" + setting 'node.remote_cluster_client', "true" user username: "test_user", password: "x-pack-test-password" } diff --git a/x-pack/qa/multi-cluster-tests-with-security/build.gradle b/x-pack/qa/multi-cluster-tests-with-security/build.gradle index b6a3088f250aa..7dc422447bd1a 100644 --- a/x-pack/qa/multi-cluster-tests-with-security/build.gradle +++ b/x-pack/qa/multi-cluster-tests-with-security/build.gradle @@ -24,7 +24,7 @@ task 'remote-cluster'(type: RestIntegTestTask) { testClusters.'remote-cluster' { testDistribution = 'DEFAULT' numberOfNodes = 2 - setting 'cluster.remote.connect', "false" + setting 'node.remote_cluster_client', "false" setting 'xpack.ilm.enabled', 'false' setting 'xpack.security.enabled', 'true' setting 'xpack.watcher.enabled', 'false' @@ -52,7 +52,7 @@ testClusters.'mixed-cluster' { testClusters.'remote-cluster'.getAllTransportPortURI().collect { "\"$it\"" }.toString() } setting 'cluster.remote.connections_per_cluster', "1" - setting 'cluster.remote.connect', "true" + setting 'node.remote_cluster_client', "true" user username: "test_user", password: "x-pack-test-password" }