Skip to content

Remove Cluster & XPack clients from HLRC (#83423) #83593

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Feb 10, 2022

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -365,15 +363,6 @@ public final IndicesClient indices() {
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.
*
Expand All @@ -392,19 +381,6 @@ public final SnapshotClient snapshot() {
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>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
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;
Expand Down Expand Up @@ -114,7 +113,7 @@ static List<HttpHost> parseHosts(String props) {
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()
Expand All @@ -137,13 +136,9 @@ public static void configureRemoteClusters(List<Node> remoteNodes) throws Except
.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));
Expand Down Expand Up @@ -172,7 +167,7 @@ static int indexDocs(RestHighLevelClient client, String index, int numDocs) thro
}

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()) {
Expand All @@ -193,7 +188,7 @@ void verifySearch(String localIndex, int localNumDocs, String remoteIndex, int r
}
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

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;
Expand All @@ -28,6 +27,7 @@
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 {
Expand Down Expand Up @@ -58,8 +58,12 @@ public void initClientsAndConfigureClusters() throws Exception {
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;
}
Expand Down
Loading