diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/ClusterClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/ClusterClient.java
deleted file mode 100644
index a9a119da79ba..000000000000
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/ClusterClient.java
+++ /dev/null
@@ -1,389 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-package org.elasticsearch.client;
-
-import org.elasticsearch.action.ActionListener;
-import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
-import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
-import org.elasticsearch.action.admin.cluster.settings.ClusterGetSettingsRequest;
-import org.elasticsearch.action.admin.cluster.settings.ClusterGetSettingsResponse;
-import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest;
-import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse;
-import org.elasticsearch.action.support.master.AcknowledgedResponse;
-import org.elasticsearch.client.cluster.RemoteInfoRequest;
-import org.elasticsearch.client.cluster.RemoteInfoResponse;
-import org.elasticsearch.client.indices.ComponentTemplatesExistRequest;
-import org.elasticsearch.client.indices.DeleteComponentTemplateRequest;
-import org.elasticsearch.client.indices.GetComponentTemplatesRequest;
-import org.elasticsearch.client.indices.GetComponentTemplatesResponse;
-import org.elasticsearch.client.indices.PutComponentTemplateRequest;
-import org.elasticsearch.rest.RestStatus;
-
-import java.io.IOException;
-
-import static java.util.Collections.emptySet;
-import static java.util.Collections.singleton;
-
-/**
- * A wrapper for the {@link RestHighLevelClient} that provides methods for accessing the Cluster API.
- *
- * See Cluster API on elastic.co
- *
- * @deprecated The High Level Rest Client is deprecated in favor of the
- *
- * Elasticsearch Java API Client
- */
-@Deprecated(since = "7.16.0", forRemoval = true)
-@SuppressWarnings("removal")
-public final class ClusterClient {
- private final RestHighLevelClient restHighLevelClient;
-
- ClusterClient(RestHighLevelClient restHighLevelClient) {
- this.restHighLevelClient = restHighLevelClient;
- }
-
- /**
- * Updates cluster wide specific settings using the Cluster Update Settings API.
- * See Cluster Update Settings
- * API on elastic.co
- * @param clusterUpdateSettingsRequest the request
- * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
- * @return the response
- * @throws IOException in case there is a problem sending the request or parsing back the response
- */
- public ClusterUpdateSettingsResponse putSettings(ClusterUpdateSettingsRequest clusterUpdateSettingsRequest, RequestOptions options)
- throws IOException {
- return restHighLevelClient.performRequestAndParseEntity(
- clusterUpdateSettingsRequest,
- ClusterRequestConverters::clusterPutSettings,
- options,
- ClusterUpdateSettingsResponse::fromXContent,
- emptySet()
- );
- }
-
- /**
- * Asynchronously updates cluster wide specific settings using the Cluster Update Settings API.
- * See Cluster Update Settings
- * API on elastic.co
- * @param clusterUpdateSettingsRequest the request
- * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
- * @param listener the listener to be notified upon request completion
- * @return cancellable that may be used to cancel the request
- */
- public Cancellable putSettingsAsync(
- ClusterUpdateSettingsRequest clusterUpdateSettingsRequest,
- RequestOptions options,
- ActionListener listener
- ) {
- return restHighLevelClient.performRequestAsyncAndParseEntity(
- clusterUpdateSettingsRequest,
- ClusterRequestConverters::clusterPutSettings,
- options,
- ClusterUpdateSettingsResponse::fromXContent,
- listener,
- emptySet()
- );
- }
-
- /**
- * Get the cluster wide settings using the Cluster Get Settings API.
- * See Cluster Get Settings
- * API on elastic.co
- * @param clusterGetSettingsRequest the request
- * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
- * @return the response
- * @throws IOException in case there is a problem sending the request or parsing back the response
- */
- public ClusterGetSettingsResponse getSettings(ClusterGetSettingsRequest clusterGetSettingsRequest, RequestOptions options)
- throws IOException {
- return restHighLevelClient.performRequestAndParseEntity(
- clusterGetSettingsRequest,
- ClusterRequestConverters::clusterGetSettings,
- options,
- ClusterGetSettingsResponse::fromXContent,
- emptySet()
- );
- }
-
- /**
- * Asynchronously get the cluster wide settings using the Cluster Get Settings API.
- * See Cluster Get Settings
- * API on elastic.co
- * @param clusterGetSettingsRequest the request
- * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
- * @param listener the listener to be notified upon request completion
- * @return cancellable that may be used to cancel the request
- */
- public Cancellable getSettingsAsync(
- ClusterGetSettingsRequest clusterGetSettingsRequest,
- RequestOptions options,
- ActionListener listener
- ) {
- return restHighLevelClient.performRequestAsyncAndParseEntity(
- clusterGetSettingsRequest,
- ClusterRequestConverters::clusterGetSettings,
- options,
- ClusterGetSettingsResponse::fromXContent,
- listener,
- emptySet()
- );
- }
-
- /**
- * Get cluster health using the Cluster Health API.
- * See
- * Cluster Health API on elastic.co
- *
- * If timeout occurred, {@link ClusterHealthResponse} will have isTimedOut() == true and status() == RestStatus.REQUEST_TIMEOUT
- * @param healthRequest the request
- * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
- * @return the response
- * @throws IOException in case there is a problem sending the request or parsing back the response
- */
- public ClusterHealthResponse health(ClusterHealthRequest healthRequest, RequestOptions options) throws IOException {
- return restHighLevelClient.performRequestAndParseEntity(
- healthRequest,
- ClusterRequestConverters::clusterHealth,
- options,
- ClusterHealthResponse::fromXContent,
- singleton(RestStatus.REQUEST_TIMEOUT.getStatus())
- );
- }
-
- /**
- * Asynchronously get cluster health using the Cluster Health API.
- * See
- * Cluster Health API on elastic.co
- * If timeout occurred, {@link ClusterHealthResponse} will have isTimedOut() == true and status() == RestStatus.REQUEST_TIMEOUT
- * @param healthRequest the request
- * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
- * @param listener the listener to be notified upon request completion
- * @return cancellable that may be used to cancel the request
- */
- public Cancellable healthAsync(
- ClusterHealthRequest healthRequest,
- RequestOptions options,
- ActionListener listener
- ) {
- return restHighLevelClient.performRequestAsyncAndParseEntity(
- healthRequest,
- ClusterRequestConverters::clusterHealth,
- options,
- ClusterHealthResponse::fromXContent,
- listener,
- singleton(RestStatus.REQUEST_TIMEOUT.getStatus())
- );
- }
-
- /**
- * Get the remote cluster information using the Remote cluster info API.
- * See Remote cluster info
- * API on elastic.co
- * @param request the request
- * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
- * @return the response
- * @throws IOException in case there is a problem sending the request or parsing back the response
- */
- public RemoteInfoResponse remoteInfo(RemoteInfoRequest request, RequestOptions options) throws IOException {
- return restHighLevelClient.performRequestAndParseEntity(
- request,
- ClusterRequestConverters::remoteInfo,
- options,
- RemoteInfoResponse::fromXContent,
- singleton(RestStatus.REQUEST_TIMEOUT.getStatus())
- );
- }
-
- /**
- * Asynchronously get remote cluster information using the Remote cluster info API.
- * See Remote cluster info
- * API on elastic.co
- * @param request the request
- * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
- * @param listener the listener to be notified upon request completion
- * @return cancellable that may be used to cancel the request
- */
- public Cancellable remoteInfoAsync(RemoteInfoRequest request, RequestOptions options, ActionListener listener) {
- return restHighLevelClient.performRequestAsyncAndParseEntity(
- request,
- ClusterRequestConverters::remoteInfo,
- options,
- RemoteInfoResponse::fromXContent,
- listener,
- singleton(RestStatus.REQUEST_TIMEOUT.getStatus())
- );
- }
-
- /**
- * Delete a component template using the Component Templates API
- *
- * @param req the request
- * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
- * @throws IOException in case there is a problem sending the request or parsing back the response
- */
- public AcknowledgedResponse deleteComponentTemplate(DeleteComponentTemplateRequest req, RequestOptions options) throws IOException {
- return restHighLevelClient.performRequestAndParseEntity(
- req,
- ClusterRequestConverters::deleteComponentTemplate,
- options,
- AcknowledgedResponse::fromXContent,
- emptySet()
- );
- }
-
- /**
- * Asynchronously delete a component template using the Component Templates API
- *
- * @param request the request
- * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
- * @param listener the listener to be notified upon request completion
- * @return cancellable that may be used to cancel the request
- */
- public Cancellable deleteComponentTemplateAsync(
- DeleteComponentTemplateRequest request,
- RequestOptions options,
- ActionListener listener
- ) {
- return restHighLevelClient.performRequestAsyncAndParseEntity(
- request,
- ClusterRequestConverters::deleteComponentTemplate,
- options,
- AcknowledgedResponse::fromXContent,
- listener,
- emptySet()
- );
- }
-
- /**
- * Puts a component template using the Component Templates API.
- *
- * @param putComponentTemplateRequest the request
- * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
- * @return the response
- * @throws IOException in case there is a problem sending the request or parsing back the response
- */
- public AcknowledgedResponse putComponentTemplate(PutComponentTemplateRequest putComponentTemplateRequest, RequestOptions options)
- throws IOException {
- return restHighLevelClient.performRequestAndParseEntity(
- putComponentTemplateRequest,
- ClusterRequestConverters::putComponentTemplate,
- options,
- AcknowledgedResponse::fromXContent,
- emptySet()
- );
- }
-
- /**
- * Asynchronously puts a component template using the Component Templates API.
- *
- * @param putComponentTemplateRequest the request
- * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
- * @param listener the listener to be notified upon request completion
- * @return cancellable that may be used to cancel the request
- */
- public Cancellable putComponentTemplateAsync(
- PutComponentTemplateRequest putComponentTemplateRequest,
- RequestOptions options,
- ActionListener listener
- ) {
- return restHighLevelClient.performRequestAsyncAndParseEntity(
- putComponentTemplateRequest,
- ClusterRequestConverters::putComponentTemplate,
- options,
- AcknowledgedResponse::fromXContent,
- listener,
- emptySet()
- );
- }
-
- /**
- * Gets component templates using the Components Templates API
- * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
- * @param getComponentTemplatesRequest the request
- * @return the response
- * @throws IOException in case there is a problem sending the request or parsing back the response
- */
- public GetComponentTemplatesResponse getComponentTemplate(
- GetComponentTemplatesRequest getComponentTemplatesRequest,
- RequestOptions options
- ) throws IOException {
- return restHighLevelClient.performRequestAndParseEntity(
- getComponentTemplatesRequest,
- ClusterRequestConverters::getComponentTemplates,
- options,
- GetComponentTemplatesResponse::fromXContent,
- emptySet()
- );
- }
-
- /**
- * Asynchronously gets component templates using the Components Templates API
- * @param getComponentTemplatesRequest the request
- * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
- * @param listener the listener to be notified upon request completion
- * @return cancellable that may be used to cancel the request
- */
- public Cancellable getComponentTemplateAsync(
- GetComponentTemplatesRequest getComponentTemplatesRequest,
- RequestOptions options,
- ActionListener listener
- ) {
- return restHighLevelClient.performRequestAsyncAndParseEntity(
- getComponentTemplatesRequest,
- ClusterRequestConverters::getComponentTemplates,
- options,
- GetComponentTemplatesResponse::fromXContent,
- listener,
- emptySet()
- );
- }
-
- /**
- * Uses the Component Templates API to determine if component templates exist
- *
- * @param componentTemplatesRequest the request
- * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
- * @return true if any index templates in the request exist, false otherwise
- * @throws IOException in case there is a problem sending the request or parsing back the response
- */
- public boolean existsComponentTemplate(ComponentTemplatesExistRequest componentTemplatesRequest, RequestOptions options)
- throws IOException {
- return restHighLevelClient.performRequest(
- componentTemplatesRequest,
- ClusterRequestConverters::componentTemplatesExist,
- options,
- RestHighLevelClient::convertExistsResponse,
- emptySet()
- );
- }
-
- /**
- * Uses the Index Templates API to determine if index templates exist
- * @param componentTemplatesRequest the request
- * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
- * @param listener the listener to be notified upon request completion. The listener will be called with the value {@code true}
- * @return cancellable that may be used to cancel the request
- */
- public Cancellable existsComponentTemplateAsync(
- ComponentTemplatesExistRequest componentTemplatesRequest,
- RequestOptions options,
- ActionListener listener
- ) {
-
- return restHighLevelClient.performRequestAsync(
- componentTemplatesRequest,
- ClusterRequestConverters::componentTemplatesExist,
- options,
- RestHighLevelClient::convertExistsResponse,
- listener,
- emptySet()
- );
- }
-}
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java
index 695ae9b69aea..d94071ccac1d 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java
@@ -276,10 +276,8 @@ public class RestHighLevelClient implements Closeable {
private volatile ListenableFuture> versionValidationFuture;
private final IndicesClient indicesClient = new IndicesClient(this);
- private final ClusterClient clusterClient = new ClusterClient(this);
private final IngestClient ingestClient = new IngestClient(this);
private final SnapshotClient snapshotClient = new SnapshotClient(this);
- private final XPackClient xPackClient = new XPackClient(this);
private final MachineLearningClient machineLearningClient = new MachineLearningClient(this);
private final SecurityClient securityClient = new SecurityClient(this);
private final TransformClient transformClient = new TransformClient(this);
@@ -365,15 +363,6 @@ public class RestHighLevelClient implements Closeable {
return indicesClient;
}
- /**
- * Provides a {@link ClusterClient} which can be used to access the Cluster API.
- *
- * See Cluster API on elastic.co
- */
- public final ClusterClient cluster() {
- return clusterClient;
- }
-
/**
* Provides a {@link IngestClient} which can be used to access the Ingest API.
*
@@ -392,19 +381,6 @@ public class RestHighLevelClient implements Closeable {
return snapshotClient;
}
- /**
- * Provides methods for accessing the Elastic Licensed X-Pack Info
- * and Usage APIs that are shipped with the default distribution of
- * Elasticsearch. All of these APIs will 404 if run against the OSS
- * distribution of Elasticsearch.
- *
- * See the
- * Info APIs on elastic.co for more information.
- */
- public final XPackClient xpack() {
- return xPackClient;
- }
-
/**
* A wrapper for the {@link RestHighLevelClient} that provides methods for accessing the Searchable Snapshots APIs.
*
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/XPackClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/XPackClient.java
deleted file mode 100644
index f019a262b607..000000000000
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/XPackClient.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-
-package org.elasticsearch.client;
-
-import org.elasticsearch.action.ActionListener;
-import org.elasticsearch.client.xpack.XPackInfoRequest;
-import org.elasticsearch.client.xpack.XPackInfoResponse;
-import org.elasticsearch.client.xpack.XPackUsageRequest;
-import org.elasticsearch.client.xpack.XPackUsageResponse;
-
-import java.io.IOException;
-
-import static java.util.Collections.emptySet;
-
-/**
- * A wrapper for the {@link RestHighLevelClient} that provides methods for
- * accessing the Elastic Licensed X-Pack APIs that are shipped with the
- * default distribution of Elasticsearch. All of these APIs will 404 if run
- * against the OSS distribution of Elasticsearch.
- *
- * See the
- * REST APIs on elastic.co for more information.
- *
- * @deprecated The High Level Rest Client is deprecated in favor of the
- *
- * Elasticsearch Java API Client
- */
-@Deprecated(since = "7.16.0", forRemoval = true)
-@SuppressWarnings("removal")
-public final class XPackClient {
-
- private final RestHighLevelClient restHighLevelClient;
-
- XPackClient(RestHighLevelClient restHighLevelClient) {
- this.restHighLevelClient = restHighLevelClient;
- }
-
- /**
- * Fetch information about X-Pack from the cluster.
- * See
- * the docs for more.
- * @param request the request
- * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
- * @return the response
- * @throws IOException in case there is a problem sending the request or parsing back the response
- */
- public XPackInfoResponse info(XPackInfoRequest request, RequestOptions options) throws IOException {
- return restHighLevelClient.performRequestAndParseEntity(
- request,
- XPackRequestConverters::info,
- options,
- XPackInfoResponse::fromXContent,
- emptySet()
- );
- }
-
- /**
- * Asynchronously fetch information about X-Pack from the cluster.
- * See
- * the docs for more.
- * @param request the request
- * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
- * @param listener the listener to be notified upon request completion
- * @return cancellable that may be used to cancel the request
- */
- public Cancellable infoAsync(XPackInfoRequest request, RequestOptions options, ActionListener listener) {
- return restHighLevelClient.performRequestAsyncAndParseEntity(
- request,
- XPackRequestConverters::info,
- options,
- XPackInfoResponse::fromXContent,
- listener,
- emptySet()
- );
- }
-
- /**
- * Fetch usage information about X-Pack features from the cluster.
- * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
- * @return the response
- * @throws IOException in case there is a problem sending the request or parsing back the response
- */
- public XPackUsageResponse usage(XPackUsageRequest request, RequestOptions options) throws IOException {
- return restHighLevelClient.performRequestAndParseEntity(
- request,
- XPackRequestConverters::usage,
- options,
- XPackUsageResponse::fromXContent,
- emptySet()
- );
- }
-
- /**
- * Asynchronously fetch usage information about X-Pack features from the cluster.
- * @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
- * @param listener the listener to be notified upon request completion
- * @return cancellable that may be used to cancel the request
- */
- public Cancellable usageAsync(XPackUsageRequest request, RequestOptions options, ActionListener listener) {
- return restHighLevelClient.performRequestAsyncAndParseEntity(
- request,
- XPackRequestConverters::usage,
- options,
- XPackUsageResponse::fromXContent,
- listener,
- emptySet()
- );
- }
-}
diff --git a/qa/ccs-rolling-upgrade-remote-cluster/src/test/java/org/elasticsearch/upgrades/SearchStatesIT.java b/qa/ccs-rolling-upgrade-remote-cluster/src/test/java/org/elasticsearch/upgrades/SearchStatesIT.java
index c1db9d77f61d..6dec927308c3 100644
--- a/qa/ccs-rolling-upgrade-remote-cluster/src/test/java/org/elasticsearch/upgrades/SearchStatesIT.java
+++ b/qa/ccs-rolling-upgrade-remote-cluster/src/test/java/org/elasticsearch/upgrades/SearchStatesIT.java
@@ -31,7 +31,6 @@ import org.apache.http.HttpHost;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.Version;
-import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
import org.elasticsearch.action.index.IndexRequest;
@@ -114,7 +113,7 @@ public class SearchStatesIT extends ESRestTestCase {
public static void configureRemoteClusters(List remoteNodes) throws Exception {
assertThat(remoteNodes, hasSize(3));
final String remoteClusterSettingPrefix = "cluster.remote." + CLUSTER_ALIAS + ".";
- try (RestHighLevelClient localClient = newLocalClient()) {
+ try (RestClient localClient = newLocalClient().getLowLevelClient()) {
final Settings remoteConnectionSettings;
if (randomBoolean()) {
final List seeds = remoteNodes.stream()
@@ -137,13 +136,9 @@ public class SearchStatesIT extends ESRestTestCase {
.put(remoteClusterSettingPrefix + "proxy_address", proxyNode.transportAddress)
.build();
}
- assertTrue(
- localClient.cluster()
- .putSettings(new ClusterUpdateSettingsRequest().persistentSettings(remoteConnectionSettings), RequestOptions.DEFAULT)
- .isAcknowledged()
- );
+ updateClusterSettings(localClient, remoteConnectionSettings);
assertBusy(() -> {
- final Response resp = localClient.getLowLevelClient().performRequest(new Request("GET", "/_remote/info"));
+ final Response resp = localClient.performRequest(new Request("GET", "/_remote/info"));
assertOK(resp);
final ObjectPath objectPath = ObjectPath.createFromResponse(resp);
assertNotNull(objectPath.evaluate(CLUSTER_ALIAS));
@@ -172,7 +167,7 @@ public class SearchStatesIT extends ESRestTestCase {
}
void verifySearch(String localIndex, int localNumDocs, String remoteIndex, int remoteNumDocs, Integer preFilterShardSize) {
- try (RestHighLevelClient localClient = newLocalClient()) {
+ try (RestClient localClient = newLocalClient().getLowLevelClient()) {
Request request = new Request("POST", "/_search");
final int expectedDocs;
if (randomBoolean()) {
@@ -193,7 +188,7 @@ public class SearchStatesIT extends ESRestTestCase {
}
int size = between(1, 100);
request.setJsonEntity("{\"sort\": \"f\", \"size\": " + size + "}");
- Response response = localClient.getLowLevelClient().performRequest(request);
+ Response response = localClient.performRequest(request);
try (
XContentParser parser = JsonXContent.jsonXContent.createParser(
NamedXContentRegistry.EMPTY,
diff --git a/qa/remote-clusters/src/test/java/org/elasticsearch/cluster/remote/test/AbstractMultiClusterRemoteTestCase.java b/qa/remote-clusters/src/test/java/org/elasticsearch/cluster/remote/test/AbstractMultiClusterRemoteTestCase.java
index c5bee9694a27..c778d6fe4c51 100644
--- a/qa/remote-clusters/src/test/java/org/elasticsearch/cluster/remote/test/AbstractMultiClusterRemoteTestCase.java
+++ b/qa/remote-clusters/src/test/java/org/elasticsearch/cluster/remote/test/AbstractMultiClusterRemoteTestCase.java
@@ -9,8 +9,7 @@ package org.elasticsearch.cluster.remote.test;
import org.apache.http.HttpHost;
import org.elasticsearch.ElasticsearchException;
-import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
-import org.elasticsearch.client.RequestOptions;
+import org.elasticsearch.client.Request;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.settings.SecureString;
@@ -28,6 +27,7 @@ import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collections;
+import java.util.function.Consumer;
@SuppressWarnings("removal")
public abstract class AbstractMultiClusterRemoteTestCase extends ESRestTestCase {
@@ -58,8 +58,12 @@ public abstract class AbstractMultiClusterRemoteTestCase extends ESRestTestCase
cluster1Client = buildClient("localhost:" + getProperty("test.fixtures.elasticsearch-" + getDistribution() + "-1.tcp.9200"));
cluster2Client = buildClient("localhost:" + getProperty("test.fixtures.elasticsearch-" + getDistribution() + "-2.tcp.9200"));
- cluster1Client().cluster().health(new ClusterHealthRequest().waitForNodes("1").waitForYellowStatus(), RequestOptions.DEFAULT);
- cluster2Client().cluster().health(new ClusterHealthRequest().waitForNodes("1").waitForYellowStatus(), RequestOptions.DEFAULT);
+ Consumer waitForYellowRequest = request -> {
+ request.addParameter("wait_for_status", "yellow");
+ request.addParameter("wait_for_nodes", "1");
+ };
+ ensureHealth(cluster1Client().getLowLevelClient(), waitForYellowRequest);
+ ensureHealth(cluster2Client().getLowLevelClient(), waitForYellowRequest);
initialized = true;
}
diff --git a/qa/remote-clusters/src/test/java/org/elasticsearch/cluster/remote/test/RemoteClustersIT.java b/qa/remote-clusters/src/test/java/org/elasticsearch/cluster/remote/test/RemoteClustersIT.java
index 6e4d83873f9d..78aa2b7e1c5d 100644
--- a/qa/remote-clusters/src/test/java/org/elasticsearch/cluster/remote/test/RemoteClustersIT.java
+++ b/qa/remote-clusters/src/test/java/org/elasticsearch/cluster/remote/test/RemoteClustersIT.java
@@ -7,14 +7,12 @@
*/
package org.elasticsearch.cluster.remote.test;
-import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.support.WriteRequest;
import org.elasticsearch.client.RequestOptions;
-import org.elasticsearch.client.cluster.RemoteConnectionInfo;
-import org.elasticsearch.client.cluster.RemoteInfoRequest;
+import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.indices.CreateIndexRequest;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.xcontent.XContentFactory;
@@ -22,6 +20,8 @@ import org.junit.After;
import org.junit.Before;
import java.io.IOException;
+import java.util.Map;
+import java.util.Optional;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assume.assumeThat;
@@ -74,27 +74,22 @@ public class RemoteClustersIT extends AbstractMultiClusterRemoteTestCase {
@After
public void clearRemoteClusterSettings() throws IOException {
- ClusterUpdateSettingsRequest request = new ClusterUpdateSettingsRequest().persistentSettings(
- Settings.builder().putNull("cluster.remote.*").build()
- );
- assertTrue(cluster1Client().cluster().putSettings(request, RequestOptions.DEFAULT).isAcknowledged());
- assertTrue(cluster2Client().cluster().putSettings(request, RequestOptions.DEFAULT).isAcknowledged());
+ Settings setting = Settings.builder().putNull("cluster.remote.*").build();
+ updateClusterSettings(cluster1Client().getLowLevelClient(), setting);
+ updateClusterSettings(cluster2Client().getLowLevelClient(), setting);
}
public void testProxyModeConnectionWorks() throws IOException {
String cluster2RemoteClusterSeed = "elasticsearch-" + getDistribution() + "-2:9300";
logger.info("Configuring remote cluster [{}]", cluster2RemoteClusterSeed);
- ClusterUpdateSettingsRequest request = new ClusterUpdateSettingsRequest().persistentSettings(
- Settings.builder()
- .put("cluster.remote.cluster2.mode", "proxy")
- .put("cluster.remote.cluster2.proxy_address", cluster2RemoteClusterSeed)
- .build()
- );
- assertTrue(cluster1Client().cluster().putSettings(request, RequestOptions.DEFAULT).isAcknowledged());
+ Settings settings = Settings.builder()
+ .put("cluster.remote.cluster2.mode", "proxy")
+ .put("cluster.remote.cluster2.proxy_address", cluster2RemoteClusterSeed)
+ .build();
- RemoteConnectionInfo rci = cluster1Client().cluster().remoteInfo(new RemoteInfoRequest(), RequestOptions.DEFAULT).getInfos().get(0);
- logger.info("Connection info: {}", rci);
- assertTrue(rci.isConnected());
+ updateClusterSettings(cluster1Client().getLowLevelClient(), settings);
+
+ assertTrue(isConnected(cluster1Client().getLowLevelClient()));
assertEquals(
2L,
@@ -105,33 +100,25 @@ public class RemoteClustersIT extends AbstractMultiClusterRemoteTestCase {
public void testSniffModeConnectionFails() throws IOException {
String cluster2RemoteClusterSeed = "elasticsearch-" + getDistribution() + "-2:9300";
logger.info("Configuring remote cluster [{}]", cluster2RemoteClusterSeed);
- ClusterUpdateSettingsRequest request = new ClusterUpdateSettingsRequest().persistentSettings(
- Settings.builder()
- .put("cluster.remote.cluster2alt.mode", "sniff")
- .put("cluster.remote.cluster2alt.seeds", cluster2RemoteClusterSeed)
- .build()
- );
- assertTrue(cluster1Client().cluster().putSettings(request, RequestOptions.DEFAULT).isAcknowledged());
+ Settings settings = Settings.builder()
+ .put("cluster.remote.cluster2alt.mode", "sniff")
+ .put("cluster.remote.cluster2alt.seeds", cluster2RemoteClusterSeed)
+ .build();
+ updateClusterSettings(cluster1Client().getLowLevelClient(), settings);
- RemoteConnectionInfo rci = cluster1Client().cluster().remoteInfo(new RemoteInfoRequest(), RequestOptions.DEFAULT).getInfos().get(0);
- logger.info("Connection info: {}", rci);
- assertFalse(rci.isConnected());
+ assertFalse(isConnected(cluster1Client().getLowLevelClient()));
}
public void testHAProxyModeConnectionWorks() throws IOException {
String proxyAddress = "haproxy:9600";
logger.info("Configuring remote cluster [{}]", proxyAddress);
- ClusterUpdateSettingsRequest request = new ClusterUpdateSettingsRequest().persistentSettings(
- Settings.builder()
- .put("cluster.remote.haproxynosn.mode", "proxy")
- .put("cluster.remote.haproxynosn.proxy_address", proxyAddress)
- .build()
- );
- assertTrue(cluster1Client().cluster().putSettings(request, RequestOptions.DEFAULT).isAcknowledged());
+ Settings settings = Settings.builder()
+ .put("cluster.remote.haproxynosn.mode", "proxy")
+ .put("cluster.remote.haproxynosn.proxy_address", proxyAddress)
+ .build();
+ updateClusterSettings(cluster1Client().getLowLevelClient(), settings);
- RemoteConnectionInfo rci = cluster1Client().cluster().remoteInfo(new RemoteInfoRequest(), RequestOptions.DEFAULT).getInfos().get(0);
- logger.info("Connection info: {}", rci);
- assertTrue(rci.isConnected());
+ assertTrue(isConnected(cluster1Client().getLowLevelClient()));
assertEquals(
2L,
@@ -142,18 +129,14 @@ public class RemoteClustersIT extends AbstractMultiClusterRemoteTestCase {
public void testHAProxyModeConnectionWithSNIToCluster1Works() throws IOException {
assumeThat("test is only supported if the distribution contains xpack", getDistribution(), equalTo("default"));
- ClusterUpdateSettingsRequest request = new ClusterUpdateSettingsRequest().persistentSettings(
- Settings.builder()
- .put("cluster.remote.haproxysni1.mode", "proxy")
- .put("cluster.remote.haproxysni1.proxy_address", "haproxy:9600")
- .put("cluster.remote.haproxysni1.server_name", "application1.example.com")
- .build()
- );
- assertTrue(cluster2Client().cluster().putSettings(request, RequestOptions.DEFAULT).isAcknowledged());
+ Settings settings = Settings.builder()
+ .put("cluster.remote.haproxysni1.mode", "proxy")
+ .put("cluster.remote.haproxysni1.proxy_address", "haproxy:9600")
+ .put("cluster.remote.haproxysni1.server_name", "application1.example.com")
+ .build();
+ updateClusterSettings(cluster2Client().getLowLevelClient(), settings);
- RemoteConnectionInfo rci = cluster2Client().cluster().remoteInfo(new RemoteInfoRequest(), RequestOptions.DEFAULT).getInfos().get(0);
- logger.info("Connection info: {}", rci);
- assertTrue(rci.isConnected());
+ assertTrue(isConnected(cluster2Client().getLowLevelClient()));
assertEquals(
1L,
@@ -164,22 +147,30 @@ public class RemoteClustersIT extends AbstractMultiClusterRemoteTestCase {
public void testHAProxyModeConnectionWithSNIToCluster2Works() throws IOException {
assumeThat("test is only supported if the distribution contains xpack", getDistribution(), equalTo("default"));
- ClusterUpdateSettingsRequest request = new ClusterUpdateSettingsRequest().persistentSettings(
- Settings.builder()
- .put("cluster.remote.haproxysni2.mode", "proxy")
- .put("cluster.remote.haproxysni2.proxy_address", "haproxy:9600")
- .put("cluster.remote.haproxysni2.server_name", "application2.example.com")
- .build()
- );
- assertTrue(cluster1Client().cluster().putSettings(request, RequestOptions.DEFAULT).isAcknowledged());
+ Settings settings = Settings.builder()
+ .put("cluster.remote.haproxysni2.mode", "proxy")
+ .put("cluster.remote.haproxysni2.proxy_address", "haproxy:9600")
+ .put("cluster.remote.haproxysni2.server_name", "application2.example.com")
+ .build();
+ updateClusterSettings(cluster1Client().getLowLevelClient(), settings);
- RemoteConnectionInfo rci = cluster1Client().cluster().remoteInfo(new RemoteInfoRequest(), RequestOptions.DEFAULT).getInfos().get(0);
- logger.info("Connection info: {}", rci);
- assertTrue(rci.isConnected());
+ assertTrue(isConnected(cluster1Client().getLowLevelClient()));
assertEquals(
2L,
cluster1Client().search(new SearchRequest("haproxysni2:test2"), RequestOptions.DEFAULT).getHits().getTotalHits().value
);
}
+
+ @SuppressWarnings("unchecked")
+ private boolean isConnected(RestClient restClient) throws IOException {
+ Optional