Skip to content

Commit d4caeea

Browse files
authored
Remove Cluster & XPack clients from HLRC (#83593)
Part of #83423
1 parent fed07a5 commit d4caeea

File tree

9 files changed

+103
-647
lines changed

9 files changed

+103
-647
lines changed

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

Lines changed: 0 additions & 389 deletions
This file was deleted.

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

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,8 @@ public class RestHighLevelClient implements Closeable {
276276
private volatile ListenableFuture<Optional<String>> versionValidationFuture;
277277

278278
private final IndicesClient indicesClient = new IndicesClient(this);
279-
private final ClusterClient clusterClient = new ClusterClient(this);
280279
private final IngestClient ingestClient = new IngestClient(this);
281280
private final SnapshotClient snapshotClient = new SnapshotClient(this);
282-
private final XPackClient xPackClient = new XPackClient(this);
283281
private final MachineLearningClient machineLearningClient = new MachineLearningClient(this);
284282
private final SecurityClient securityClient = new SecurityClient(this);
285283
private final TransformClient transformClient = new TransformClient(this);
@@ -365,15 +363,6 @@ public final IndicesClient indices() {
365363
return indicesClient;
366364
}
367365

368-
/**
369-
* Provides a {@link ClusterClient} which can be used to access the Cluster API.
370-
*
371-
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster.html">Cluster API on elastic.co</a>
372-
*/
373-
public final ClusterClient cluster() {
374-
return clusterClient;
375-
}
376-
377366
/**
378367
* Provides a {@link IngestClient} which can be used to access the Ingest API.
379368
*
@@ -392,19 +381,6 @@ public final SnapshotClient snapshot() {
392381
return snapshotClient;
393382
}
394383

395-
/**
396-
* Provides methods for accessing the Elastic Licensed X-Pack Info
397-
* and Usage APIs that are shipped with the default distribution of
398-
* Elasticsearch. All of these APIs will 404 if run against the OSS
399-
* distribution of Elasticsearch.
400-
* <p>
401-
* See the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/info-api.html">
402-
* Info APIs on elastic.co</a> for more information.
403-
*/
404-
public final XPackClient xpack() {
405-
return xPackClient;
406-
}
407-
408384
/**
409385
* A wrapper for the {@link RestHighLevelClient} that provides methods for accessing the Searchable Snapshots APIs.
410386
* <p>

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

Lines changed: 0 additions & 115 deletions
This file was deleted.

qa/ccs-rolling-upgrade-remote-cluster/src/test/java/org/elasticsearch/upgrades/SearchStatesIT.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.apache.logging.log4j.LogManager;
3232
import org.apache.logging.log4j.Logger;
3333
import org.elasticsearch.Version;
34-
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest;
3534
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
3635
import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
3736
import org.elasticsearch.action.index.IndexRequest;
@@ -114,7 +113,7 @@ static List<HttpHost> parseHosts(String props) {
114113
public static void configureRemoteClusters(List<Node> remoteNodes) throws Exception {
115114
assertThat(remoteNodes, hasSize(3));
116115
final String remoteClusterSettingPrefix = "cluster.remote." + CLUSTER_ALIAS + ".";
117-
try (RestHighLevelClient localClient = newLocalClient()) {
116+
try (RestClient localClient = newLocalClient().getLowLevelClient()) {
118117
final Settings remoteConnectionSettings;
119118
if (randomBoolean()) {
120119
final List<String> seeds = remoteNodes.stream()
@@ -137,13 +136,9 @@ public static void configureRemoteClusters(List<Node> remoteNodes) throws Except
137136
.put(remoteClusterSettingPrefix + "proxy_address", proxyNode.transportAddress)
138137
.build();
139138
}
140-
assertTrue(
141-
localClient.cluster()
142-
.putSettings(new ClusterUpdateSettingsRequest().persistentSettings(remoteConnectionSettings), RequestOptions.DEFAULT)
143-
.isAcknowledged()
144-
);
139+
updateClusterSettings(localClient, remoteConnectionSettings);
145140
assertBusy(() -> {
146-
final Response resp = localClient.getLowLevelClient().performRequest(new Request("GET", "/_remote/info"));
141+
final Response resp = localClient.performRequest(new Request("GET", "/_remote/info"));
147142
assertOK(resp);
148143
final ObjectPath objectPath = ObjectPath.createFromResponse(resp);
149144
assertNotNull(objectPath.evaluate(CLUSTER_ALIAS));
@@ -172,7 +167,7 @@ static int indexDocs(RestHighLevelClient client, String index, int numDocs) thro
172167
}
173168

174169
void verifySearch(String localIndex, int localNumDocs, String remoteIndex, int remoteNumDocs, Integer preFilterShardSize) {
175-
try (RestHighLevelClient localClient = newLocalClient()) {
170+
try (RestClient localClient = newLocalClient().getLowLevelClient()) {
176171
Request request = new Request("POST", "/_search");
177172
final int expectedDocs;
178173
if (randomBoolean()) {
@@ -193,7 +188,7 @@ void verifySearch(String localIndex, int localNumDocs, String remoteIndex, int r
193188
}
194189
int size = between(1, 100);
195190
request.setJsonEntity("{\"sort\": \"f\", \"size\": " + size + "}");
196-
Response response = localClient.getLowLevelClient().performRequest(request);
191+
Response response = localClient.performRequest(request);
197192
try (
198193
XContentParser parser = JsonXContent.jsonXContent.createParser(
199194
NamedXContentRegistry.EMPTY,

qa/remote-clusters/src/test/java/org/elasticsearch/cluster/remote/test/AbstractMultiClusterRemoteTestCase.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99

1010
import org.apache.http.HttpHost;
1111
import org.elasticsearch.ElasticsearchException;
12-
import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
13-
import org.elasticsearch.client.RequestOptions;
12+
import org.elasticsearch.client.Request;
1413
import org.elasticsearch.client.RestClient;
1514
import org.elasticsearch.client.RestHighLevelClient;
1615
import org.elasticsearch.common.settings.SecureString;
@@ -28,6 +27,7 @@
2827
import java.nio.file.Files;
2928
import java.nio.file.Path;
3029
import java.util.Collections;
30+
import java.util.function.Consumer;
3131

3232
@SuppressWarnings("removal")
3333
public abstract class AbstractMultiClusterRemoteTestCase extends ESRestTestCase {
@@ -58,8 +58,12 @@ public void initClientsAndConfigureClusters() throws Exception {
5858
cluster1Client = buildClient("localhost:" + getProperty("test.fixtures.elasticsearch-" + getDistribution() + "-1.tcp.9200"));
5959
cluster2Client = buildClient("localhost:" + getProperty("test.fixtures.elasticsearch-" + getDistribution() + "-2.tcp.9200"));
6060

61-
cluster1Client().cluster().health(new ClusterHealthRequest().waitForNodes("1").waitForYellowStatus(), RequestOptions.DEFAULT);
62-
cluster2Client().cluster().health(new ClusterHealthRequest().waitForNodes("1").waitForYellowStatus(), RequestOptions.DEFAULT);
61+
Consumer<Request> waitForYellowRequest = request -> {
62+
request.addParameter("wait_for_status", "yellow");
63+
request.addParameter("wait_for_nodes", "1");
64+
};
65+
ensureHealth(cluster1Client().getLowLevelClient(), waitForYellowRequest);
66+
ensureHealth(cluster2Client().getLowLevelClient(), waitForYellowRequest);
6367

6468
initialized = true;
6569
}

0 commit comments

Comments
 (0)