Forráskód Böngészése

Remove Cluster & XPack clients from HLRC (#83593)

Part of #83423
Mary Gouseti 3 éve
szülő
commit
d4caeea1f7

+ 0 - 389
client/rest-high-level/src/main/java/org/elasticsearch/client/ClusterClient.java

@@ -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.
- * <p>
- * See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster.html">Cluster API on elastic.co</a>
- *
- * @deprecated The High Level Rest Client is deprecated in favor of the
- * <a href="https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/introduction.html">
- * Elasticsearch Java API Client</a>
- */
-@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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-update-settings.html"> Cluster Update Settings
-     * API on elastic.co</a>
-     * @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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-update-settings.html"> Cluster Update Settings
-     * API on elastic.co</a>
-     * @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<ClusterUpdateSettingsResponse> listener
-    ) {
-        return restHighLevelClient.performRequestAsyncAndParseEntity(
-            clusterUpdateSettingsRequest,
-            ClusterRequestConverters::clusterPutSettings,
-            options,
-            ClusterUpdateSettingsResponse::fromXContent,
-            listener,
-            emptySet()
-        );
-    }
-
-    /**
-     * Get the cluster wide settings using the Cluster Get Settings API.
-     * See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-get-settings.html"> Cluster Get Settings
-     * API on elastic.co</a>
-     * @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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-get-settings.html"> Cluster Get Settings
-     * API on elastic.co</a>
-     * @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<ClusterGetSettingsResponse> listener
-    ) {
-        return restHighLevelClient.performRequestAsyncAndParseEntity(
-            clusterGetSettingsRequest,
-            ClusterRequestConverters::clusterGetSettings,
-            options,
-            ClusterGetSettingsResponse::fromXContent,
-            listener,
-            emptySet()
-        );
-    }
-
-    /**
-     * Get cluster health using the Cluster Health API.
-     * See
-     * <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html"> Cluster Health API on elastic.co</a>
-     * <p>
-     * 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
-     * <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html"> Cluster Health API on elastic.co</a>
-     * 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<ClusterHealthResponse> 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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-remote-info.html"> Remote cluster info
-     * API on elastic.co</a>
-     * @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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-remote-info.html"> Remote cluster info
-     * API on elastic.co</a>
-     * @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<RemoteInfoResponse> 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<AcknowledgedResponse> 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<AcknowledgedResponse> 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<GetComponentTemplatesResponse> 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<Boolean> listener
-    ) {
-
-        return restHighLevelClient.performRequestAsync(
-            componentTemplatesRequest,
-            ClusterRequestConverters::componentTemplatesExist,
-            options,
-            RestHighLevelClient::convertExistsResponse,
-            listener,
-            emptySet()
-        );
-    }
-}

+ 0 - 24
client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java

@@ -276,10 +276,8 @@ public class RestHighLevelClient implements Closeable {
     private volatile ListenableFuture<Optional<String>> 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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster.html">Cluster API on elastic.co</a>
-     */
-    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.
-     * <p>
-     * See the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/info-api.html">
-     * Info APIs on elastic.co</a> for more information.
-     */
-    public final XPackClient xpack() {
-        return xPackClient;
-    }
-
     /**
      * A wrapper for the {@link RestHighLevelClient} that provides methods for accessing the Searchable Snapshots APIs.
      * <p>

+ 0 - 115
client/rest-high-level/src/main/java/org/elasticsearch/client/XPackClient.java

@@ -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.
- * <p>
- * See the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/rest-apis.html">
- * REST APIs on elastic.co</a> for more information.
- *
- * @deprecated The High Level Rest Client is deprecated in favor of the
- * <a href="https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/introduction.html">
- * Elasticsearch Java API Client</a>
- */
-@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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/info-api.html">
-     * the docs</a> 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 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/info-api.html">
-     * the docs</a> 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<XPackInfoResponse> 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<XPackUsageResponse> listener) {
-        return restHighLevelClient.performRequestAsyncAndParseEntity(
-            request,
-            XPackRequestConverters::usage,
-            options,
-            XPackUsageResponse::fromXContent,
-            listener,
-            emptySet()
-        );
-    }
-}

+ 5 - 10
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<Node> 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<String> 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,

+ 8 - 4
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<Request> waitForYellowRequest = request -> {
+            request.addParameter("wait_for_status", "yellow");
+            request.addParameter("wait_for_nodes", "1");
+        };
+        ensureHealth(cluster1Client().getLowLevelClient(), waitForYellowRequest);
+        ensureHealth(cluster2Client().getLowLevelClient(), waitForYellowRequest);
 
         initialized = true;
     }

+ 51 - 60
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();
+
+        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,
@@ -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<Object> remoteConnectionInfo = getAsMap(restClient, "/_remote/info").values().stream().findFirst();
+        if (remoteConnectionInfo.isPresent()) {
+            logger.info("Connection info: {}", remoteConnectionInfo);
+            if (((Map<String, Object>) remoteConnectionInfo.get()).get("connected")instanceof Boolean connected) {
+                return connected;
+            }
+        }
+        return false;
+    }
 }

+ 27 - 1
test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java

@@ -1407,6 +1407,24 @@ public abstract class ESRestTestCase extends ESTestCase {
         assertThat(jsonBody, containsString("\"acknowledged\":true"));
     }
 
+    /**
+     * Updates the cluster with the provided settings (as persistent settings)
+     **/
+    public static void updateClusterSettings(Settings settings) throws IOException {
+        updateClusterSettings(client(), settings);
+    }
+
+    /**
+     * Updates the cluster with the provided settings (as persistent settings)
+     **/
+    public static void updateClusterSettings(RestClient client, Settings settings) throws IOException {
+        Request request = new Request("PUT", "/_cluster/settings");
+        String entity = "{ \"persistent\":" + Strings.toString(settings) + "}";
+        request.setJsonEntity(entity);
+        Response response = client.performRequest(request);
+        assertOK(response);
+    }
+
     /**
      * Permits subclasses to increase the default timeout when waiting for green health
      */
@@ -1440,6 +1458,10 @@ public abstract class ESRestTestCase extends ESTestCase {
         ensureHealth(client(), index, requestConsumer);
     }
 
+    public static void ensureHealth(RestClient restClient, Consumer<Request> requestConsumer) throws IOException {
+        ensureHealth(restClient, "", requestConsumer);
+    }
+
     protected static void ensureHealth(RestClient restClient, String index, Consumer<Request> requestConsumer) throws IOException {
         Request request = new Request("GET", "/_cluster/health" + (index.isBlank() ? "" : "/" + index));
         requestConsumer.accept(request);
@@ -1604,7 +1626,11 @@ public abstract class ESRestTestCase extends ESTestCase {
     }
 
     protected static Map<String, Object> getAsMap(final String endpoint) throws IOException {
-        Response response = client().performRequest(new Request("GET", endpoint));
+        return getAsMap(client(), endpoint);
+    }
+
+    protected static Map<String, Object> getAsMap(RestClient client, final String endpoint) throws IOException {
+        Response response = client.performRequest(new Request("GET", endpoint));
         return responseAsMap(response);
     }
 

+ 2 - 20
x-pack/qa/repository-old-versions/src/test/java/org/elasticsearch/oldrepos/OldRepositoryAccessIT.java

@@ -10,7 +10,6 @@ package org.elasticsearch.oldrepos;
 import org.apache.http.HttpHost;
 import org.elasticsearch.Build;
 import org.elasticsearch.Version;
-import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
 import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryRequest;
 import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsRequest;
 import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotRequest;
@@ -29,7 +28,6 @@ import org.elasticsearch.client.indices.GetMappingsRequest;
 import org.elasticsearch.client.indices.PutMappingRequest;
 import org.elasticsearch.client.searchable_snapshots.MountSnapshotRequest;
 import org.elasticsearch.cluster.SnapshotsInProgress;
-import org.elasticsearch.cluster.health.ClusterHealthStatus;
 import org.elasticsearch.cluster.metadata.IndexMetadata;
 import org.elasticsearch.cluster.metadata.MappingMetadata;
 import org.elasticsearch.cluster.routing.Murmur3HashFunction;
@@ -342,15 +340,7 @@ public class OldRepositoryAccessIT extends ESRestTestCase {
         assertEquals(numberOfShards, restoreSnapshotResponse.getRestoreInfo().totalShards());
         assertEquals(numberOfShards, restoreSnapshotResponse.getRestoreInfo().successfulShards());
 
-        assertEquals(
-            ClusterHealthStatus.GREEN,
-            client.cluster()
-                .health(
-                    new ClusterHealthRequest("restored_" + indexName).waitForGreenStatus().waitForNoRelocatingShards(true),
-                    RequestOptions.DEFAULT
-                )
-                .getStatus()
-        );
+        ensureGreen("restored_" + indexName);
 
         MappingMetadata mapping = client.indices()
             .getMapping(new GetMappingsRequest().indices("restored_" + indexName), RequestOptions.DEFAULT)
@@ -401,15 +391,7 @@ public class OldRepositoryAccessIT extends ESRestTestCase {
         assertEquals(numberOfShards, mountSnapshotResponse.getRestoreInfo().totalShards());
         assertEquals(numberOfShards, mountSnapshotResponse.getRestoreInfo().successfulShards());
 
-        assertEquals(
-            ClusterHealthStatus.GREEN,
-            client.cluster()
-                .health(
-                    new ClusterHealthRequest("mounted_full_copy_" + indexName).waitForGreenStatus().waitForNoRelocatingShards(true),
-                    RequestOptions.DEFAULT
-                )
-                .getStatus()
-        );
+        ensureGreen("mounted_full_copy_" + indexName);
 
         // run a search against the index
         assertDocs("mounted_full_copy_" + indexName, numDocs, expectedIds, client, sourceOnlyRepository, oldVersion);

+ 10 - 24
x-pack/qa/smoke-test-plugins-ssl/src/test/java/org/elasticsearch/smoketest/SmokeTestMonitoringWithSecurityIT.java

@@ -10,10 +10,6 @@ import io.netty.util.ThreadDeathWatcher;
 import io.netty.util.concurrent.GlobalEventExecutor;
 
 import org.elasticsearch.ElasticsearchException;
-import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
-import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
-import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest;
-import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsResponse;
 import org.elasticsearch.action.search.SearchRequest;
 import org.elasticsearch.client.Request;
 import org.elasticsearch.client.RequestOptions;
@@ -23,10 +19,6 @@ import org.elasticsearch.client.RestHighLevelClient;
 import org.elasticsearch.client.indices.GetIndexRequest;
 import org.elasticsearch.client.indices.GetIndexTemplatesRequest;
 import org.elasticsearch.client.indices.GetIndexTemplatesResponse;
-import org.elasticsearch.client.xpack.XPackUsageRequest;
-import org.elasticsearch.client.xpack.XPackUsageResponse;
-import org.elasticsearch.cluster.health.ClusterHealthStatus;
-import org.elasticsearch.common.Priority;
 import org.elasticsearch.common.settings.MockSecureSettings;
 import org.elasticsearch.common.settings.SecureString;
 import org.elasticsearch.common.settings.Settings;
@@ -165,9 +157,7 @@ public class SmokeTestMonitoringWithSecurityIT extends ESRestTestCase {
             .put("xpack.monitoring.exporters._http.ssl.certificate_authorities", "testnode.crt")
             .setSecureSettings(secureSettings)
             .build();
-        ClusterUpdateSettingsResponse response = newHighLevelClient().cluster()
-            .putSettings(new ClusterUpdateSettingsRequest().transientSettings(exporterSettings), RequestOptions.DEFAULT);
-        assertTrue(response.isAcknowledged());
+        updateClusterSettings(exporterSettings);
     }
 
     @After
@@ -181,15 +171,12 @@ public class SmokeTestMonitoringWithSecurityIT extends ESRestTestCase {
             .putNull("xpack.monitoring.exporters._http.ssl.verification_mode")
             .putNull("xpack.monitoring.exporters._http.ssl.certificate_authorities")
             .build();
-        ClusterUpdateSettingsResponse response = newHighLevelClient().cluster()
-            .putSettings(new ClusterUpdateSettingsRequest().transientSettings(exporterSettings), RequestOptions.DEFAULT);
-        assertTrue(response.isAcknowledged());
+        updateClusterSettings(exporterSettings);
     }
 
+    @SuppressWarnings("unchecked")
     private boolean getMonitoringUsageExportersDefined() throws Exception {
-        RestHighLevelClient client = newHighLevelClient();
-        final XPackUsageResponse usageResponse = client.xpack().usage(new XPackUsageRequest(), RequestOptions.DEFAULT);
-        Map<String, Object> monitoringUsage = usageResponse.getUsages().get("monitoring");
+        Map<String, Object> monitoringUsage = (Map<String, Object>) getAsMap("/_xpack/usage").get("monitoring");
         assertThat("Monitoring feature set does not exist", monitoringUsage, notNullValue());
 
         @SuppressWarnings("unchecked")
@@ -225,13 +212,12 @@ public class SmokeTestMonitoringWithSecurityIT extends ESRestTestCase {
         });
 
         // Waits for indices to be ready
-        ClusterHealthRequest healthRequest = new ClusterHealthRequest(MONITORING_PATTERN);
-        healthRequest.waitForStatus(ClusterHealthStatus.YELLOW);
-        healthRequest.waitForEvents(Priority.LANGUID);
-        healthRequest.waitForNoRelocatingShards(true);
-        healthRequest.waitForNoInitializingShards(true);
-        ClusterHealthResponse response = client.cluster().health(healthRequest, RequestOptions.DEFAULT);
-        assertThat(response.isTimedOut(), is(false));
+        ensureHealth(MONITORING_PATTERN, (request) -> {
+            request.addParameter("wait_for_status", "yellow");
+            request.addParameter("wait_for_events", "languid");
+            request.addParameter("wait_for_no_relocating_shards", "true");
+            request.addParameter("wait_for_no_initializing_shards", "true");
+        });
 
         // Checks that the HTTP exporter has successfully exported some data
         SearchRequest searchRequest = new SearchRequest(new String[] { MONITORING_PATTERN }, new SearchSourceBuilder().size(0));