diff --git a/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamIT.java b/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamIT.java index 60b8a91bb468..83bb6eebb1ec 100644 --- a/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamIT.java +++ b/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamIT.java @@ -587,14 +587,14 @@ public class DataStreamIT extends ESIntegTestCase { false ); verifyResolvability(dataStreamName, indicesAdmin().prepareGetSettings(dataStreamName), false); - verifyResolvability(dataStreamName, client().admin().cluster().prepareHealth(dataStreamName), false); - verifyResolvability(dataStreamName, client().admin().cluster().prepareState().setIndices(dataStreamName), false); + verifyResolvability(dataStreamName, clusterAdmin().prepareHealth(dataStreamName), false); + verifyResolvability(dataStreamName, clusterAdmin().prepareState().setIndices(dataStreamName), false); verifyResolvability(dataStreamName, client().prepareFieldCaps(dataStreamName).setFields("*"), false); verifyResolvability(dataStreamName, indicesAdmin().prepareGetIndex().addIndices(dataStreamName), false); verifyResolvability(dataStreamName, indicesAdmin().prepareOpen(dataStreamName), false); verifyResolvability(dataStreamName, indicesAdmin().prepareClose(dataStreamName), true); verifyResolvability(aliasToDataStream, indicesAdmin().prepareClose(aliasToDataStream), true); - verifyResolvability(dataStreamName, client().admin().cluster().prepareSearchShards(dataStreamName), false); + verifyResolvability(dataStreamName, clusterAdmin().prepareSearchShards(dataStreamName), false); verifyResolvability(dataStreamName, indicesAdmin().prepareShardStores(dataStreamName), false); request = new CreateDataStreamAction.Request("logs-barbaz"); @@ -633,13 +633,13 @@ public class DataStreamIT extends ESIntegTestCase { indicesAdmin().prepareUpdateSettings(wildcardExpression).setSettings(Settings.builder().put("index.number_of_replicas", 0)), false ); - verifyResolvability(wildcardExpression, client().admin().cluster().prepareHealth(wildcardExpression), false); - verifyResolvability(wildcardExpression, client().admin().cluster().prepareState().setIndices(wildcardExpression), false); + verifyResolvability(wildcardExpression, clusterAdmin().prepareHealth(wildcardExpression), false); + verifyResolvability(wildcardExpression, clusterAdmin().prepareState().setIndices(wildcardExpression), false); verifyResolvability(wildcardExpression, client().prepareFieldCaps(wildcardExpression).setFields("*"), false); verifyResolvability(wildcardExpression, indicesAdmin().prepareGetIndex().addIndices(wildcardExpression), false); verifyResolvability(wildcardExpression, indicesAdmin().prepareOpen(wildcardExpression), false); verifyResolvability(wildcardExpression, indicesAdmin().prepareClose(wildcardExpression), false); - verifyResolvability(wildcardExpression, client().admin().cluster().prepareSearchShards(wildcardExpression), false); + verifyResolvability(wildcardExpression, clusterAdmin().prepareSearchShards(wildcardExpression), false); verifyResolvability(wildcardExpression, indicesAdmin().prepareShardStores(wildcardExpression), false); } @@ -1512,7 +1512,7 @@ public class DataStreamIT extends ESIntegTestCase { // when querying a backing index then the data stream should be included as well. ClusterStateRequest request = new ClusterStateRequest().indices(".ds-metrics-foo-*000001"); - ClusterState state = client().admin().cluster().state(request).get().getState(); + ClusterState state = clusterAdmin().state(request).get().getState(); assertThat(state.metadata().dataStreams().size(), equalTo(1)); assertThat(state.metadata().dataStreams().get("metrics-foo").getName(), equalTo("metrics-foo")); } diff --git a/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamsSnapshotsIT.java b/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamsSnapshotsIT.java index 61db4bfd9625..9b07828e0422 100644 --- a/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamsSnapshotsIT.java +++ b/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/DataStreamsSnapshotsIT.java @@ -823,7 +823,7 @@ public class DataStreamsSnapshotsIT extends AbstractSnapshotIntegTestCase { is(true) ); - final RestoreSnapshotResponse restoreSnapshotResponse = client().admin().cluster().prepareRestoreSnapshot(REPO, snapshotName).get(); + final RestoreSnapshotResponse restoreSnapshotResponse = clusterAdmin().prepareRestoreSnapshot(REPO, snapshotName).get(); assertThat(restoreSnapshotResponse.getRestoreInfo().indices(), empty()); } @@ -831,7 +831,7 @@ public class DataStreamsSnapshotsIT extends AbstractSnapshotIntegTestCase { Client client1 = client(); // this test uses a MockRepository - assertAcked(client().admin().cluster().prepareDeleteRepository(REPO)); + assertAcked(clusterAdmin().prepareDeleteRepository(REPO)); final String repositoryName = "test-repo"; createRepository( @@ -910,11 +910,7 @@ public class DataStreamsSnapshotsIT extends AbstractSnapshotIntegTestCase { .execute() ); assertAcked( - client().admin() - .cluster() - .prepareCloneSnapshot(REPO, sourceSnapshotName, "target-snapshot-1") - .setIndices(indexWithoutDataStream) - .get() + clusterAdmin().prepareCloneSnapshot(REPO, sourceSnapshotName, "target-snapshot-1").setIndices(indexWithoutDataStream).get() ); } @@ -944,9 +940,7 @@ public class DataStreamsSnapshotsIT extends AbstractSnapshotIntegTestCase { final boolean partial = randomBoolean(); blockAllDataNodes(repoName); final String snapshotName = "ds-snap"; - final ActionFuture snapshotFuture = client().admin() - .cluster() - .prepareCreateSnapshot(repoName, snapshotName) + final ActionFuture snapshotFuture = clusterAdmin().prepareCreateSnapshot(repoName, snapshotName) .setWaitForCompletion(true) .setPartial(partial) .setIncludeGlobalState(randomBoolean()) @@ -967,9 +961,7 @@ public class DataStreamsSnapshotsIT extends AbstractSnapshotIntegTestCase { assertThat(snapshotInfo.dataStreams(), hasItems("ds")); assertAcked(client().execute(DeleteDataStreamAction.INSTANCE, new DeleteDataStreamAction.Request(new String[] { "ds" })).get()); - RestoreInfo restoreSnapshotResponse = client().admin() - .cluster() - .prepareRestoreSnapshot(repoName, snapshotName) + RestoreInfo restoreSnapshotResponse = clusterAdmin().prepareRestoreSnapshot(repoName, snapshotName) .setWaitForCompletion(true) .setIndices("ds") .get() @@ -986,9 +978,7 @@ public class DataStreamsSnapshotsIT extends AbstractSnapshotIntegTestCase { createRepository(repoName, "mock"); blockAllDataNodes(repoName); final String snapshotName = "ds-snap"; - final ActionFuture snapshotFuture = client().admin() - .cluster() - .prepareCreateSnapshot(repoName, snapshotName) + final ActionFuture snapshotFuture = clusterAdmin().prepareCreateSnapshot(repoName, snapshotName) .setWaitForCompletion(true) .setPartial(true) .setIncludeGlobalState(randomBoolean()) @@ -1013,9 +1003,7 @@ public class DataStreamsSnapshotsIT extends AbstractSnapshotIntegTestCase { client().execute(DeleteDataStreamAction.INSTANCE, new DeleteDataStreamAction.Request(new String[] { "other-ds" })).get() ); - RestoreInfo restoreSnapshotResponse = client().admin() - .cluster() - .prepareRestoreSnapshot(repoName, snapshotName) + RestoreInfo restoreSnapshotResponse = clusterAdmin().prepareRestoreSnapshot(repoName, snapshotName) .setWaitForCompletion(true) .setIndices("other-ds") .get() diff --git a/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/SystemDataStreamSnapshotIT.java b/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/SystemDataStreamSnapshotIT.java index 33991e3b52fc..865de8b41cc6 100644 --- a/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/SystemDataStreamSnapshotIT.java +++ b/modules/data-streams/src/internalClusterTest/java/org/elasticsearch/datastreams/SystemDataStreamSnapshotIT.java @@ -79,12 +79,7 @@ public class SystemDataStreamSnapshotIT extends AbstractSnapshotIntegTestCase { } assertSuccessful( - client().admin() - .cluster() - .prepareCreateSnapshot(REPO, SNAPSHOT) - .setWaitForCompletion(true) - .setIncludeGlobalState(true) - .execute() + clusterAdmin().prepareCreateSnapshot(REPO, SNAPSHOT).setWaitForCompletion(true).setIncludeGlobalState(true).execute() ); // We have to delete the data stream directly, as the feature reset API doesn't clean up system data streams yet @@ -104,9 +99,7 @@ public class SystemDataStreamSnapshotIT extends AbstractSnapshotIntegTestCase { // Make sure requesting the data stream by name throws. // For some reason, expectThrows() isn't working for me here, hence the try/catch. try { - client().admin() - .cluster() - .prepareRestoreSnapshot(REPO, SNAPSHOT) + clusterAdmin().prepareRestoreSnapshot(REPO, SNAPSHOT) .setIndices(".test-data-stream") .setWaitForCompletion(true) .setRestoreGlobalState(randomBoolean()) // this shouldn't matter @@ -125,9 +118,7 @@ public class SystemDataStreamSnapshotIT extends AbstractSnapshotIntegTestCase { assertSystemDataStreamDoesNotExist(); // Now actually restore the data stream - RestoreSnapshotResponse restoreSnapshotResponse = client().admin() - .cluster() - .prepareRestoreSnapshot(REPO, SNAPSHOT) + RestoreSnapshotResponse restoreSnapshotResponse = clusterAdmin().prepareRestoreSnapshot(REPO, SNAPSHOT) .setWaitForCompletion(true) .setRestoreGlobalState(true) .get(); @@ -142,7 +133,7 @@ public class SystemDataStreamSnapshotIT extends AbstractSnapshotIntegTestCase { // Attempting to restore again without specifying indices or global/feature states should work, as the wildcard should not be // resolved to system indices/data streams. - client().admin().cluster().prepareRestoreSnapshot(REPO, SNAPSHOT).setWaitForCompletion(true).setRestoreGlobalState(false).get(); + clusterAdmin().prepareRestoreSnapshot(REPO, SNAPSHOT).setWaitForCompletion(true).setRestoreGlobalState(false).get(); assertEquals(restoreSnapshotResponse.getRestoreInfo().totalShards(), restoreSnapshotResponse.getRestoreInfo().successfulShards()); } @@ -196,9 +187,7 @@ public class SystemDataStreamSnapshotIT extends AbstractSnapshotIntegTestCase { } SnapshotInfo snapshotInfo = assertSuccessful( - client().admin() - .cluster() - .prepareCreateSnapshot(REPO, SNAPSHOT) + clusterAdmin().prepareCreateSnapshot(REPO, SNAPSHOT) .setIndices("my-index") .setFeatureStates(SystemDataStreamTestPlugin.class.getSimpleName()) .setWaitForCompletion(true) @@ -223,9 +212,7 @@ public class SystemDataStreamSnapshotIT extends AbstractSnapshotIntegTestCase { assertThat(indicesRemaining.indices(), arrayWithSize(0)); } - RestoreSnapshotResponse restoreSnapshotResponse = client().admin() - .cluster() - .prepareRestoreSnapshot(REPO, SNAPSHOT) + RestoreSnapshotResponse restoreSnapshotResponse = clusterAdmin().prepareRestoreSnapshot(REPO, SNAPSHOT) .setWaitForCompletion(true) .setIndices("my-index") .setFeatureStates(SystemDataStreamTestPlugin.class.getSimpleName()) diff --git a/modules/data-streams/src/test/java/org/elasticsearch/datastreams/DataStreamsStatsTests.java b/modules/data-streams/src/test/java/org/elasticsearch/datastreams/DataStreamsStatsTests.java index aa8d313bd26b..b66f734dfac5 100644 --- a/modules/data-streams/src/test/java/org/elasticsearch/datastreams/DataStreamsStatsTests.java +++ b/modules/data-streams/src/test/java/org/elasticsearch/datastreams/DataStreamsStatsTests.java @@ -130,9 +130,9 @@ public class DataStreamsStatsTests extends ESSingleNodeTestCase { assertTrue(indicesAdmin().rolloverIndex(new RolloverRequest(dataStreamName, null)).get().isAcknowledged()); assertTrue(indicesAdmin().close(new CloseIndexRequest(".ds-" + dataStreamName + "-*-000001")).actionGet().isAcknowledged()); - assertBusy(() -> { - assertNotEquals(ClusterHealthStatus.RED, client().admin().cluster().health(new ClusterHealthRequest()).actionGet().getStatus()); - }); + assertBusy( + () -> assertNotEquals(ClusterHealthStatus.RED, clusterAdmin().health(new ClusterHealthRequest()).actionGet().getStatus()) + ); DataStreamsStatsAction.Response stats = getDataStreamsStats(); assertEquals(2, stats.getSuccessfulShards()); diff --git a/modules/data-streams/src/test/java/org/elasticsearch/datastreams/LookAHeadTimeTests.java b/modules/data-streams/src/test/java/org/elasticsearch/datastreams/LookAHeadTimeTests.java index be36a76cd5b4..a0ed1a83d0de 100644 --- a/modules/data-streams/src/test/java/org/elasticsearch/datastreams/LookAHeadTimeTests.java +++ b/modules/data-streams/src/test/java/org/elasticsearch/datastreams/LookAHeadTimeTests.java @@ -107,7 +107,7 @@ public class LookAHeadTimeTests extends ESSingleNodeTestCase { } private void updateClusterSettings(Settings settings) { - client().admin().cluster().updateSettings(new ClusterUpdateSettingsRequest().persistentSettings(settings)).actionGet(); + clusterAdmin().updateSettings(new ClusterUpdateSettingsRequest().persistentSettings(settings)).actionGet(); } private void updateIndexSettings(Settings settings) throws IOException { diff --git a/modules/ingest-common/src/internalClusterTest/java/org/elasticsearch/ingest/common/IngestRestartIT.java b/modules/ingest-common/src/internalClusterTest/java/org/elasticsearch/ingest/common/IngestRestartIT.java index b1a4c0bd3a59..acd0ed59da13 100644 --- a/modules/ingest-common/src/internalClusterTest/java/org/elasticsearch/ingest/common/IngestRestartIT.java +++ b/modules/ingest-common/src/internalClusterTest/java/org/elasticsearch/ingest/common/IngestRestartIT.java @@ -62,7 +62,7 @@ public class IngestRestartIT extends ESIntegTestCase { internalCluster().ensureAtLeastNumDataNodes(1); internalCluster().startMasterOnlyNode(); final String pipelineId = "foo"; - client().admin().cluster().preparePutPipeline(pipelineId, new BytesArray(Strings.format(""" + clusterAdmin().preparePutPipeline(pipelineId, new BytesArray(Strings.format(""" { "processors": [ { @@ -95,7 +95,7 @@ public class IngestRestartIT extends ESIntegTestCase { ); assertTrue(e.getMessage().contains("this script always fails")); - NodesStatsResponse r = client().admin().cluster().prepareNodesStats(internalCluster().getNodeNames()).setIngest(true).get(); + NodesStatsResponse r = clusterAdmin().prepareNodesStats(internalCluster().getNodeNames()).setIngest(true).get(); int nodeCount = r.getNodes().size(); for (int k = 0; k < nodeCount; k++) { List stats = r.getNodes().get(k).getIngestStats().processorStats().get(pipelineId); @@ -120,12 +120,12 @@ public class IngestRestartIT extends ESIntegTestCase { }"""); Consumer checkPipelineExists = (id) -> assertThat( - client().admin().cluster().prepareGetPipeline(id).get().pipelines().get(0).getId(), + clusterAdmin().prepareGetPipeline(id).get().pipelines().get(0).getId(), equalTo(id) ); - client().admin().cluster().preparePutPipeline(pipelineIdWithScript, pipelineWithScript, XContentType.JSON).get(); - client().admin().cluster().preparePutPipeline(pipelineIdWithoutScript, pipelineWithoutScript, XContentType.JSON).get(); + clusterAdmin().preparePutPipeline(pipelineIdWithScript, pipelineWithScript, XContentType.JSON).get(); + clusterAdmin().preparePutPipeline(pipelineIdWithoutScript, pipelineWithoutScript, XContentType.JSON).get(); checkPipelineExists.accept(pipelineIdWithScript); checkPipelineExists.accept(pipelineIdWithoutScript); @@ -180,7 +180,7 @@ public class IngestRestartIT extends ESIntegTestCase { public void testPipelineWithScriptProcessorThatHasStoredScript() throws Exception { internalCluster().startNode(); - client().admin().cluster().preparePutStoredScript().setId("1").setContent(new BytesArray(Strings.format(""" + clusterAdmin().preparePutStoredScript().setId("1").setContent(new BytesArray(Strings.format(""" {"script": {"lang": "%s", "source": "my_script"} } """, MockScriptEngine.NAME)), XContentType.JSON).get(); BytesReference pipeline = new BytesArray(""" @@ -190,7 +190,7 @@ public class IngestRestartIT extends ESIntegTestCase { {"script" : {"id": "1"}} ] }"""); - client().admin().cluster().preparePutPipeline("_id", pipeline, XContentType.JSON).get(); + clusterAdmin().preparePutPipeline("_id", pipeline, XContentType.JSON).get(); client().prepareIndex("index") .setId("1") @@ -234,7 +234,7 @@ public class IngestRestartIT extends ESIntegTestCase { {"set" : {"field": "y", "value": 0}} ] }"""); - client().admin().cluster().preparePutPipeline("_id", pipeline, XContentType.JSON).get(); + clusterAdmin().preparePutPipeline("_id", pipeline, XContentType.JSON).get(); client().prepareIndex("index") .setId("1") diff --git a/modules/ingest-geoip/src/internalClusterTest/java/org/elasticsearch/ingest/geoip/GeoIpDownloaderIT.java b/modules/ingest-geoip/src/internalClusterTest/java/org/elasticsearch/ingest/geoip/GeoIpDownloaderIT.java index 26469b1c8d9c..edb572e988fe 100644 --- a/modules/ingest-geoip/src/internalClusterTest/java/org/elasticsearch/ingest/geoip/GeoIpDownloaderIT.java +++ b/modules/ingest-geoip/src/internalClusterTest/java/org/elasticsearch/ingest/geoip/GeoIpDownloaderIT.java @@ -554,7 +554,7 @@ public class GeoIpDownloaderIT extends AbstractGeoIpIT { builder.endObject(); bytes = BytesReference.bytes(builder); } - assertAcked(client().admin().cluster().preparePutPipeline(pipelineId, bytes, XContentType.JSON).get()); + assertAcked(clusterAdmin().preparePutPipeline(pipelineId, bytes, XContentType.JSON).get()); } /** @@ -592,7 +592,7 @@ public class GeoIpDownloaderIT extends AbstractGeoIpIT { builder.endObject(); bytes = BytesReference.bytes(builder); } - assertAcked(client().admin().cluster().preparePutPipeline(pipelineId, bytes, XContentType.JSON).get()); + assertAcked(clusterAdmin().preparePutPipeline(pipelineId, bytes, XContentType.JSON).get()); } private List getGeoIpTmpDirs() throws IOException { diff --git a/modules/ingest-geoip/src/internalClusterTest/java/org/elasticsearch/ingest/geoip/GeoIpDownloaderStatsIT.java b/modules/ingest-geoip/src/internalClusterTest/java/org/elasticsearch/ingest/geoip/GeoIpDownloaderStatsIT.java index dda62d662d35..4d656bed5381 100644 --- a/modules/ingest-geoip/src/internalClusterTest/java/org/elasticsearch/ingest/geoip/GeoIpDownloaderStatsIT.java +++ b/modules/ingest-geoip/src/internalClusterTest/java/org/elasticsearch/ingest/geoip/GeoIpDownloaderStatsIT.java @@ -122,7 +122,7 @@ public class GeoIpDownloaderStatsIT extends AbstractGeoIpIT { builder.endObject(); bytes = BytesReference.bytes(builder); } - assertAcked(client().admin().cluster().preparePutPipeline("_id", bytes, XContentType.JSON).get()); + assertAcked(clusterAdmin().preparePutPipeline("_id", bytes, XContentType.JSON).get()); } public static Map convertToMap(ToXContent part) throws IOException { diff --git a/modules/ingest-geoip/src/internalClusterTest/java/org/elasticsearch/ingest/geoip/GeoIpDownloaderTaskIT.java b/modules/ingest-geoip/src/internalClusterTest/java/org/elasticsearch/ingest/geoip/GeoIpDownloaderTaskIT.java index 3511d0f94da9..ff7a72799986 100644 --- a/modules/ingest-geoip/src/internalClusterTest/java/org/elasticsearch/ingest/geoip/GeoIpDownloaderTaskIT.java +++ b/modules/ingest-geoip/src/internalClusterTest/java/org/elasticsearch/ingest/geoip/GeoIpDownloaderTaskIT.java @@ -53,18 +53,12 @@ public class GeoIpDownloaderTaskIT extends AbstractGeoIpIT { assertTrue(task.isAssigned()); }); assertBusy(() -> { - ListTasksResponse tasks = client().admin() - .cluster() - .listTasks(new ListTasksRequest().setActions("geoip-downloader[c]")) - .actionGet(); + ListTasksResponse tasks = clusterAdmin().listTasks(new ListTasksRequest().setActions("geoip-downloader[c]")).actionGet(); assertEquals(1, tasks.getTasks().size()); }); updateClusterSettings(Settings.builder().put(GeoIpDownloaderTaskExecutor.ENABLED_SETTING.getKey(), false)); assertBusy(() -> { - ListTasksResponse tasks2 = client().admin() - .cluster() - .listTasks(new ListTasksRequest().setActions("geoip-downloader[c]")) - .actionGet(); + ListTasksResponse tasks2 = clusterAdmin().listTasks(new ListTasksRequest().setActions("geoip-downloader[c]")).actionGet(); assertEquals(0, tasks2.getTasks().size()); }); } diff --git a/modules/ingest-geoip/src/internalClusterTest/java/org/elasticsearch/ingest/geoip/GeoIpProcessorNonIngestNodeIT.java b/modules/ingest-geoip/src/internalClusterTest/java/org/elasticsearch/ingest/geoip/GeoIpProcessorNonIngestNodeIT.java index 178cfe0a20c4..dbfde52fd62e 100644 --- a/modules/ingest-geoip/src/internalClusterTest/java/org/elasticsearch/ingest/geoip/GeoIpProcessorNonIngestNodeIT.java +++ b/modules/ingest-geoip/src/internalClusterTest/java/org/elasticsearch/ingest/geoip/GeoIpProcessorNonIngestNodeIT.java @@ -89,7 +89,7 @@ public class GeoIpProcessorNonIngestNodeIT extends AbstractGeoIpIT { builder.endObject(); bytes = BytesReference.bytes(builder); } - assertAcked(client().admin().cluster().putPipeline(new PutPipelineRequest("geoip", bytes, XContentType.JSON)).actionGet()); + assertAcked(clusterAdmin().putPipeline(new PutPipelineRequest("geoip", bytes, XContentType.JSON)).actionGet()); // the geo-IP databases should not be loaded on any nodes as they are all non-ingest nodes Arrays.stream(internalCluster().getNodeNames()).forEach(node -> assertDatabaseLoadStatus(node, false)); diff --git a/modules/lang-expression/src/internalClusterTest/java/org/elasticsearch/script/expression/StoredExpressionIT.java b/modules/lang-expression/src/internalClusterTest/java/org/elasticsearch/script/expression/StoredExpressionIT.java index 1041bd8e14af..6fde54668cf5 100644 --- a/modules/lang-expression/src/internalClusterTest/java/org/elasticsearch/script/expression/StoredExpressionIT.java +++ b/modules/lang-expression/src/internalClusterTest/java/org/elasticsearch/script/expression/StoredExpressionIT.java @@ -39,7 +39,7 @@ public class StoredExpressionIT extends ESIntegTestCase { } public void testAllOpsDisabledIndexedScripts() throws IOException { - client().admin().cluster().preparePutStoredScript().setId("script1").setContent(new BytesArray(""" + clusterAdmin().preparePutStoredScript().setId("script1").setContent(new BytesArray(""" {"script": {"lang": "expression", "source": "2"} }"""), XContentType.JSON).get(); client().prepareIndex("test").setId("1").setSource("{\"theField\":\"foo\"}", XContentType.JSON).get(); try { diff --git a/modules/lang-mustache/src/internalClusterTest/java/org/elasticsearch/script/mustache/SearchTemplateIT.java b/modules/lang-mustache/src/internalClusterTest/java/org/elasticsearch/script/mustache/SearchTemplateIT.java index 0b823b5064eb..c2d48fccf27d 100644 --- a/modules/lang-mustache/src/internalClusterTest/java/org/elasticsearch/script/mustache/SearchTemplateIT.java +++ b/modules/lang-mustache/src/internalClusterTest/java/org/elasticsearch/script/mustache/SearchTemplateIT.java @@ -148,7 +148,7 @@ public class SearchTemplateIT extends ESSingleNodeTestCase { } public void testIndexedTemplateClient() throws Exception { - assertAcked(client().admin().cluster().preparePutStoredScript().setId("testTemplate").setContent(new BytesArray(""" + assertAcked(clusterAdmin().preparePutStoredScript().setId("testTemplate").setContent(new BytesArray(""" { "script": { "lang": "mustache", @@ -162,7 +162,7 @@ public class SearchTemplateIT extends ESSingleNodeTestCase { } }"""), XContentType.JSON)); - GetStoredScriptResponse getResponse = client().admin().cluster().prepareGetStoredScript("testTemplate").get(); + GetStoredScriptResponse getResponse = clusterAdmin().prepareGetStoredScript("testTemplate").get(); assertNotNull(getResponse.getSource()); BulkRequestBuilder bulkRequestBuilder = client().prepareBulk(); @@ -184,9 +184,9 @@ public class SearchTemplateIT extends ESSingleNodeTestCase { .get(); assertHitCount(searchResponse.getResponse(), 4); - assertAcked(client().admin().cluster().prepareDeleteStoredScript("testTemplate")); + assertAcked(clusterAdmin().prepareDeleteStoredScript("testTemplate")); - getResponse = client().admin().cluster().prepareGetStoredScript("testTemplate").get(); + getResponse = clusterAdmin().prepareGetStoredScript("testTemplate").get(); assertNull(getResponse.getSource()); } @@ -207,9 +207,9 @@ public class SearchTemplateIT extends ESSingleNodeTestCase { } """; - assertAcked(client().admin().cluster().preparePutStoredScript().setId("1a").setContent(new BytesArray(script), XContentType.JSON)); - assertAcked(client().admin().cluster().preparePutStoredScript().setId("2").setContent(new BytesArray(script), XContentType.JSON)); - assertAcked(client().admin().cluster().preparePutStoredScript().setId("3").setContent(new BytesArray(script), XContentType.JSON)); + assertAcked(clusterAdmin().preparePutStoredScript().setId("1a").setContent(new BytesArray(script), XContentType.JSON)); + assertAcked(clusterAdmin().preparePutStoredScript().setId("2").setContent(new BytesArray(script), XContentType.JSON)); + assertAcked(clusterAdmin().preparePutStoredScript().setId("3").setContent(new BytesArray(script), XContentType.JSON)); BulkRequestBuilder bulkRequestBuilder = client().prepareBulk(); bulkRequestBuilder.add(client().prepareIndex("test").setId("1").setSource("{\"theField\":\"foo\"}", XContentType.JSON)); @@ -275,14 +275,12 @@ public class SearchTemplateIT extends ESSingleNodeTestCase { }"""; for (int i = 1; i < iterations; i++) { assertAcked( - client().admin() - .cluster() - .preparePutStoredScript() + clusterAdmin().preparePutStoredScript() .setId("git01") .setContent(new BytesArray(query.replace("{{slop}}", Integer.toString(-1))), XContentType.JSON) ); - GetStoredScriptResponse getResponse = client().admin().cluster().prepareGetStoredScript("git01").get(); + GetStoredScriptResponse getResponse = clusterAdmin().prepareGetStoredScript("git01").get(); assertNotNull(getResponse.getSource()); Map templateParams = new HashMap<>(); @@ -299,9 +297,7 @@ public class SearchTemplateIT extends ESSingleNodeTestCase { assertThat(e.getMessage(), containsString("No negative slop allowed")); assertAcked( - client().admin() - .cluster() - .preparePutStoredScript() + clusterAdmin().preparePutStoredScript() .setId("git01") .setContent(new BytesArray(query.replace("{{slop}}", Integer.toString(0))), XContentType.JSON) ); @@ -333,9 +329,7 @@ public class SearchTemplateIT extends ESSingleNodeTestCase { } } }"""; - assertAcked( - client().admin().cluster().preparePutStoredScript().setId("4").setContent(new BytesArray(multiQuery), XContentType.JSON) - ); + assertAcked(clusterAdmin().preparePutStoredScript().setId("4").setContent(new BytesArray(multiQuery), XContentType.JSON)); BulkRequestBuilder bulkRequestBuilder = client().prepareBulk(); bulkRequestBuilder.add(client().prepareIndex("test").setId("1").setSource("{\"theField\":\"foo\"}", XContentType.JSON)); bulkRequestBuilder.add(client().prepareIndex("test").setId("2").setSource("{\"theField\":\"foo 2\"}", XContentType.JSON)); diff --git a/modules/lang-mustache/src/internalClusterTest/java/org/elasticsearch/script/mustache/SearchUsageStatsIT.java b/modules/lang-mustache/src/internalClusterTest/java/org/elasticsearch/script/mustache/SearchUsageStatsIT.java index 6a53aae617c0..b14ca7ea7cfa 100644 --- a/modules/lang-mustache/src/internalClusterTest/java/org/elasticsearch/script/mustache/SearchUsageStatsIT.java +++ b/modules/lang-mustache/src/internalClusterTest/java/org/elasticsearch/script/mustache/SearchUsageStatsIT.java @@ -36,7 +36,7 @@ public class SearchUsageStatsIT extends ESIntegTestCase { public void testSearchUsageStats() throws IOException { { - SearchUsageStats stats = client().admin().cluster().prepareClusterStats().get().getIndicesStats().getSearchUsageStats(); + SearchUsageStats stats = clusterAdmin().prepareClusterStats().get().getIndicesStats().getSearchUsageStats(); assertEquals(0, stats.getTotalSearchCount()); assertEquals(0, stats.getQueryUsage().size()); assertEquals(0, stats.getSectionsUsage().size()); @@ -62,7 +62,7 @@ public class SearchUsageStatsIT extends ESIntegTestCase { getRestClient().performRequest(request); } { - assertAcked(client().admin().cluster().preparePutStoredScript().setId("testTemplate").setContent(new BytesArray(""" + assertAcked(clusterAdmin().preparePutStoredScript().setId("testTemplate").setContent(new BytesArray(""" { "script": { "lang": "mustache", @@ -97,7 +97,7 @@ public class SearchUsageStatsIT extends ESIntegTestCase { getRestClient().performRequest(request); } - SearchUsageStats stats = client().admin().cluster().prepareClusterStats().get().getIndicesStats().getSearchUsageStats(); + SearchUsageStats stats = clusterAdmin().prepareClusterStats().get().getIndicesStats().getSearchUsageStats(); assertEquals(4, stats.getTotalSearchCount()); assertEquals(1, stats.getQueryUsage().size()); assertEquals(4, stats.getQueryUsage().get("match").longValue()); diff --git a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchTests.java b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchTests.java index 120f3db39057..acfc95fd1817 100644 --- a/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchTests.java +++ b/modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorQuerySearchTests.java @@ -176,7 +176,7 @@ public class PercolatorQuerySearchTests extends ESSingleNodeTestCase { // We can't check via api... because BitsetCacheListener requires that it can extract shardId from index reader // and for percolator it can't do that, but that means we don't keep track of // memory for BitsetCache in case of percolator - long bitsetSize = client().admin().cluster().prepareClusterStats().get().getIndicesStats().getSegments().getBitsetMemoryInBytes(); + long bitsetSize = clusterAdmin().prepareClusterStats().get().getIndicesStats().getSegments().getBitsetMemoryInBytes(); assertEquals("The percolator works with in-memory index and therefor shouldn't use bitset cache", 0L, bitsetSize); } @@ -250,7 +250,7 @@ public class PercolatorQuerySearchTests extends ESSingleNodeTestCase { assertHitCount(response, 1); } - long fieldDataSize = client().admin().cluster().prepareClusterStats().get().getIndicesStats().getFieldData().getMemorySizeInBytes(); + long fieldDataSize = clusterAdmin().prepareClusterStats().get().getIndicesStats().getFieldData().getMemorySizeInBytes(); assertEquals("The percolator works with in-memory index and therefor shouldn't use field-data cache", 0L, fieldDataSize); } diff --git a/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/FeatureMigrationIT.java b/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/FeatureMigrationIT.java index 730796d4b772..465829847799 100644 --- a/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/FeatureMigrationIT.java +++ b/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/FeatureMigrationIT.java @@ -196,7 +196,7 @@ public class FeatureMigrationIT extends AbstractFeatureMigrationIntegTest { assertTrue("the pre-migration hook wasn't actually called", preUpgradeHookCalled.get()); assertTrue("the post-migration hook wasn't actually called", postUpgradeHookCalled.get()); - Metadata finalMetadata = client().admin().cluster().prepareState().get().getState().metadata(); + Metadata finalMetadata = clusterAdmin().prepareState().get().getState().metadata(); // Check that the results metadata is what we expect. FeatureMigrationResults currentResults = finalMetadata.custom(FeatureMigrationResults.TYPE); assertThat(currentResults, notNullValue()); diff --git a/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/MultiFeatureMigrationIT.java b/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/MultiFeatureMigrationIT.java index 03700dd3452a..52b366a85205 100644 --- a/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/MultiFeatureMigrationIT.java +++ b/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/MultiFeatureMigrationIT.java @@ -202,7 +202,7 @@ public class MultiFeatureMigrationIT extends AbstractFeatureMigrationIntegTest { assertTrue("the second plugin's pre-migration hook wasn't actually called", secondPluginPreMigrationHookCalled.get()); assertTrue("the second plugin's post-migration hook wasn't actually called", secondPluginPostMigrationHookCalled.get()); - Metadata finalMetadata = client().admin().cluster().prepareState().get().getState().metadata(); + Metadata finalMetadata = clusterAdmin().prepareState().get().getState().metadata(); // Check that the results metadata is what we expect FeatureMigrationResults currentResults = finalMetadata.custom(FeatureMigrationResults.TYPE); assertThat(currentResults, notNullValue()); diff --git a/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/SystemIndexMigrationIT.java b/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/SystemIndexMigrationIT.java index f6570816a19f..d0b9ad11777e 100644 --- a/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/SystemIndexMigrationIT.java +++ b/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/SystemIndexMigrationIT.java @@ -108,7 +108,7 @@ public class SystemIndexMigrationIT extends AbstractFeatureMigrationIntegTest { assertBusy(() -> { // Wait for the node we restarted to completely rejoin the cluster - ClusterState clusterState = client().admin().cluster().prepareState().get().getState(); + ClusterState clusterState = clusterAdmin().prepareState().get().getState(); assertThat("expected restarted node to rejoin cluster", clusterState.getNodes().size(), equalTo(2)); GetFeatureUpgradeStatusResponse statusResponse = client().execute( diff --git a/modules/reindex/src/test/java/org/elasticsearch/reindex/CancelTests.java b/modules/reindex/src/test/java/org/elasticsearch/reindex/CancelTests.java index 9fcc0216c91f..e1956b2da646 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/reindex/CancelTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/reindex/CancelTests.java @@ -139,22 +139,20 @@ public class CancelTests extends ReindexTestCase { // Cancel the request while the action is blocked by the indexing operation listeners. // This will prevent further requests from being sent. - ListTasksResponse cancelTasksResponse = client().admin().cluster().prepareCancelTasks().setTargetTaskId(mainTask.taskId()).get(); + ListTasksResponse cancelTasksResponse = clusterAdmin().prepareCancelTasks().setTargetTaskId(mainTask.taskId()).get(); cancelTasksResponse.rethrowFailures("Cancel"); assertThat(cancelTasksResponse.getTasks(), hasSize(1)); /* The status should now show canceled. The request will still be in the * list because it is (or its children are) still blocked. */ - mainTask = client().admin().cluster().prepareGetTask(mainTask.taskId()).get().getTask().getTask(); + mainTask = clusterAdmin().prepareGetTask(mainTask.taskId()).get().getTask().getTask(); status = (BulkByScrollTask.Status) mainTask.status(); logger.debug("asserting that parent is marked canceled {}", status); assertEquals(CancelTasksRequest.DEFAULT_REASON, status.getReasonCancelled()); if (builder.request().getSlices() > 1) { boolean foundCancelled = false; - ListTasksResponse sliceList = client().admin() - .cluster() - .prepareListTasks() + ListTasksResponse sliceList = clusterAdmin().prepareListTasks() .setTargetParentTaskId(mainTask.taskId()) .setDetailed(true) .get(); @@ -190,13 +188,7 @@ public class CancelTests extends ReindexTestCase { if (ExceptionsHelper.unwrapCausesAndSuppressed(e, t -> t instanceof TaskCancelledException).isPresent()) { return; // the scroll request was cancelled } - String tasks = client().admin() - .cluster() - .prepareListTasks() - .setTargetParentTaskId(mainTask.taskId()) - .setDetailed(true) - .get() - .toString(); + String tasks = clusterAdmin().prepareListTasks().setTargetParentTaskId(mainTask.taskId()).setDetailed(true).get().toString(); throw new RuntimeException("Exception while waiting for the response. Running tasks: " + tasks, e); } finally { if (builder.request().getSlices() >= 1) { @@ -216,7 +208,7 @@ public class CancelTests extends ReindexTestCase { ListTasksResponse tasks; long start = System.nanoTime(); do { - tasks = client().admin().cluster().prepareListTasks().setActions(actionName).setDetailed(true).get(); + tasks = clusterAdmin().prepareListTasks().setActions(actionName).setDetailed(true).get(); tasks.rethrowFailures("Find tasks to cancel"); for (TaskInfo taskInfo : tasks.getTasks()) { // Skip tasks with a parent because those are children of the task we want to cancel @@ -245,14 +237,14 @@ public class CancelTests extends ReindexTestCase { "test" : {} } ] }"""); - assertAcked(client().admin().cluster().preparePutPipeline("set-processed", pipeline, XContentType.JSON).get()); + assertAcked(clusterAdmin().preparePutPipeline("set-processed", pipeline, XContentType.JSON).get()); testCancel(UpdateByQueryAction.NAME, updateByQuery().setPipeline("set-processed").source(INDEX), (response, total, modified) -> { assertThat(response, matcher().updated(modified).reasonCancelled(equalTo("by user request"))); assertHitCount(client().prepareSearch(INDEX).setSize(0).setQuery(termQuery("processed", true)).get(), modified); }, equalTo("update-by-query [" + INDEX + "]")); - assertAcked(client().admin().cluster().deletePipeline(new DeletePipelineRequest("set-processed")).get()); + assertAcked(clusterAdmin().deletePipeline(new DeletePipelineRequest("set-processed")).get()); } public void testDeleteByQueryCancel() throws Exception { @@ -288,7 +280,7 @@ public class CancelTests extends ReindexTestCase { "test" : {} } ] }"""); - assertAcked(client().admin().cluster().preparePutPipeline("set-processed", pipeline, XContentType.JSON).get()); + assertAcked(clusterAdmin().preparePutPipeline("set-processed", pipeline, XContentType.JSON).get()); testCancel( UpdateByQueryAction.NAME, @@ -300,7 +292,7 @@ public class CancelTests extends ReindexTestCase { equalTo("update-by-query [" + INDEX + "]") ); - assertAcked(client().admin().cluster().deletePipeline(new DeletePipelineRequest("set-processed")).get()); + assertAcked(clusterAdmin().deletePipeline(new DeletePipelineRequest("set-processed")).get()); } public void testDeleteByQueryCancelWithWorkers() throws Exception { diff --git a/modules/reindex/src/test/java/org/elasticsearch/reindex/ReindexFromRemoteWithAuthTests.java b/modules/reindex/src/test/java/org/elasticsearch/reindex/ReindexFromRemoteWithAuthTests.java index ce9a2ca107e9..24d1e032501c 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/reindex/ReindexFromRemoteWithAuthTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/reindex/ReindexFromRemoteWithAuthTests.java @@ -99,7 +99,7 @@ public class ReindexFromRemoteWithAuthTests extends ESSingleNodeTestCase { @Before public void fetchTransportAddress() { - NodeInfo nodeInfo = client().admin().cluster().prepareNodesInfo().get().getNodes().get(0); + NodeInfo nodeInfo = clusterAdmin().prepareNodesInfo().get().getNodes().get(0); address = nodeInfo.getInfo(HttpInfo.class).getAddress().publishAddress(); } diff --git a/modules/reindex/src/test/java/org/elasticsearch/reindex/RethrottleTests.java b/modules/reindex/src/test/java/org/elasticsearch/reindex/RethrottleTests.java index 7d05452b709b..5bbff9da85b2 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/reindex/RethrottleTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/reindex/RethrottleTests.java @@ -100,15 +100,13 @@ public class RethrottleTests extends ReindexTestCase { assertThat(taskGroupToRethrottle.childTasks(), hasSize(allOf(greaterThanOrEqualTo(1), lessThanOrEqualTo(numSlices)))); // Wait for all of the sub tasks to start (or finish, some might finish early, all that matters is that not all do) assertBusy(() -> { - BulkByScrollTask.Status parent = (BulkByScrollTask.Status) client().admin() - .cluster() - .prepareGetTask(taskToRethrottle) + BulkByScrollTask.Status parent = (BulkByScrollTask.Status) clusterAdmin().prepareGetTask(taskToRethrottle) .get() .getTask() .getTask() .status(); long finishedSubTasks = parent.getSliceStatuses().stream().filter(Objects::nonNull).count(); - ListTasksResponse list = client().admin().cluster().prepareListTasks().setTargetParentTaskId(taskToRethrottle).get(); + ListTasksResponse list = clusterAdmin().prepareListTasks().setTargetParentTaskId(taskToRethrottle).get(); list.rethrowFailures("subtasks"); assertThat(finishedSubTasks + list.getTasks().size(), greaterThanOrEqualTo((long) numSlices)); assertThat(list.getTasks().size(), greaterThan(0)); @@ -223,7 +221,7 @@ public class RethrottleTests extends ReindexTestCase { private TaskGroup findTaskToRethrottle(String actionName, int sliceCount) { long start = System.nanoTime(); do { - ListTasksResponse tasks = client().admin().cluster().prepareListTasks().setActions(actionName).setDetailed(true).get(); + ListTasksResponse tasks = clusterAdmin().prepareListTasks().setActions(actionName).setDetailed(true).get(); tasks.rethrowFailures("Finding tasks to rethrottle"); assertThat("tasks are left over from the last execution of this test", tasks.getTaskGroups(), hasSize(lessThan(2))); if (0 == tasks.getTaskGroups().size()) { @@ -257,7 +255,7 @@ public class RethrottleTests extends ReindexTestCase { return taskGroup; } while (System.nanoTime() - start < TimeUnit.SECONDS.toNanos(10)); throw new AssertionError( - "Couldn't find tasks to rethrottle. Here are the running tasks " + client().admin().cluster().prepareListTasks().get() + "Couldn't find tasks to rethrottle. Here are the running tasks " + clusterAdmin().prepareListTasks().get() ); } } diff --git a/modules/reindex/src/test/java/org/elasticsearch/reindex/RetryTests.java b/modules/reindex/src/test/java/org/elasticsearch/reindex/RetryTests.java index c7a955035b66..1e338b28a5d4 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/reindex/RetryTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/reindex/RetryTests.java @@ -249,7 +249,7 @@ public class RetryTests extends ESIntegTestCase { * master. We do this simply to make sure that the test request is not started on the * node who's queue we're manipulating. */ - ListTasksResponse response = client().admin().cluster().prepareListTasks().setActions(action).setDetailed(true).get(); + ListTasksResponse response = clusterAdmin().prepareListTasks().setActions(action).setDetailed(true).get(); assertThat(response.getTasks(), hasSize(1)); return (BulkByScrollTask.Status) response.getTasks().get(0).status(); } diff --git a/modules/repository-azure/src/internalClusterTest/java/org/elasticsearch/repositories/azure/AzureStorageCleanupThirdPartyTests.java b/modules/repository-azure/src/internalClusterTest/java/org/elasticsearch/repositories/azure/AzureStorageCleanupThirdPartyTests.java index 4ffffb2c5bd4..4f2d7eb1afcf 100644 --- a/modules/repository-azure/src/internalClusterTest/java/org/elasticsearch/repositories/azure/AzureStorageCleanupThirdPartyTests.java +++ b/modules/repository-azure/src/internalClusterTest/java/org/elasticsearch/repositories/azure/AzureStorageCleanupThirdPartyTests.java @@ -87,9 +87,7 @@ public class AzureStorageCleanupThirdPartyTests extends AbstractThirdPartyReposi @Override protected void createRepository(String repoName) { - AcknowledgedResponse putRepositoryResponse = client().admin() - .cluster() - .preparePutRepository(repoName) + AcknowledgedResponse putRepositoryResponse = clusterAdmin().preparePutRepository(repoName) .setType("azure") .setSettings( Settings.builder() diff --git a/modules/repository-gcs/src/internalClusterTest/java/org/elasticsearch/repositories/gcs/GoogleCloudStorageThirdPartyTests.java b/modules/repository-gcs/src/internalClusterTest/java/org/elasticsearch/repositories/gcs/GoogleCloudStorageThirdPartyTests.java index 5b9b20c084d8..ffb5fd71f0c0 100644 --- a/modules/repository-gcs/src/internalClusterTest/java/org/elasticsearch/repositories/gcs/GoogleCloudStorageThirdPartyTests.java +++ b/modules/repository-gcs/src/internalClusterTest/java/org/elasticsearch/repositories/gcs/GoogleCloudStorageThirdPartyTests.java @@ -71,9 +71,7 @@ public class GoogleCloudStorageThirdPartyTests extends AbstractThirdPartyReposit @Override protected void createRepository(final String repoName) { - AcknowledgedResponse putRepositoryResponse = client().admin() - .cluster() - .preparePutRepository("test-repo") + AcknowledgedResponse putRepositoryResponse = clusterAdmin().preparePutRepository("test-repo") .setType("gcs") .setSettings( Settings.builder() diff --git a/modules/repository-s3/src/internalClusterTest/java/org/elasticsearch/repositories/s3/S3BlobStoreRepositoryTests.java b/modules/repository-s3/src/internalClusterTest/java/org/elasticsearch/repositories/s3/S3BlobStoreRepositoryTests.java index 8ba0494484a7..08b91f304a70 100644 --- a/modules/repository-s3/src/internalClusterTest/java/org/elasticsearch/repositories/s3/S3BlobStoreRepositoryTests.java +++ b/modules/repository-s3/src/internalClusterTest/java/org/elasticsearch/repositories/s3/S3BlobStoreRepositoryTests.java @@ -155,9 +155,7 @@ public class S3BlobStoreRepositoryTests extends ESMockAPIBasedRepositoryIntegTes true ); - final SnapshotId fakeOldSnapshot = client().admin() - .cluster() - .prepareCreateSnapshot(repoName, "snapshot-old") + final SnapshotId fakeOldSnapshot = clusterAdmin().prepareCreateSnapshot(repoName, "snapshot-old") .setWaitForCompletion(true) .setIndices() .get() @@ -197,15 +195,15 @@ public class S3BlobStoreRepositoryTests extends ESMockAPIBasedRepositoryIntegTes final String newSnapshotName = "snapshot-new"; final long beforeThrottledSnapshot = repository.threadPool().relativeTimeInNanos(); - client().admin().cluster().prepareCreateSnapshot(repoName, newSnapshotName).setWaitForCompletion(true).setIndices().get(); + clusterAdmin().prepareCreateSnapshot(repoName, newSnapshotName).setWaitForCompletion(true).setIndices().get(); assertThat(repository.threadPool().relativeTimeInNanos() - beforeThrottledSnapshot, greaterThan(TEST_COOLDOWN_PERIOD.getNanos())); final long beforeThrottledDelete = repository.threadPool().relativeTimeInNanos(); - client().admin().cluster().prepareDeleteSnapshot(repoName, newSnapshotName).get(); + clusterAdmin().prepareDeleteSnapshot(repoName, newSnapshotName).get(); assertThat(repository.threadPool().relativeTimeInNanos() - beforeThrottledDelete, greaterThan(TEST_COOLDOWN_PERIOD.getNanos())); final long beforeFastDelete = repository.threadPool().relativeTimeInNanos(); - client().admin().cluster().prepareDeleteSnapshot(repoName, fakeOldSnapshot.getName()).get(); + clusterAdmin().prepareDeleteSnapshot(repoName, fakeOldSnapshot.getName()).get(); assertThat(repository.threadPool().relativeTimeInNanos() - beforeFastDelete, lessThan(TEST_COOLDOWN_PERIOD.getNanos())); } diff --git a/modules/repository-s3/src/internalClusterTest/java/org/elasticsearch/repositories/s3/S3RepositoryThirdPartyTests.java b/modules/repository-s3/src/internalClusterTest/java/org/elasticsearch/repositories/s3/S3RepositoryThirdPartyTests.java index bbfd17bf2139..375da5f71b04 100644 --- a/modules/repository-s3/src/internalClusterTest/java/org/elasticsearch/repositories/s3/S3RepositoryThirdPartyTests.java +++ b/modules/repository-s3/src/internalClusterTest/java/org/elasticsearch/repositories/s3/S3RepositoryThirdPartyTests.java @@ -61,9 +61,7 @@ public class S3RepositoryThirdPartyTests extends AbstractThirdPartyRepositoryTes settings.put("storage_class", storageClass); } } - AcknowledgedResponse putRepositoryResponse = client().admin() - .cluster() - .preparePutRepository("test-repo") + AcknowledgedResponse putRepositoryResponse = clusterAdmin().preparePutRepository("test-repo") .setType("s3") .setSettings(settings) .get(); diff --git a/modules/repository-s3/src/test/java/org/elasticsearch/repositories/s3/RepositoryCredentialsTests.java b/modules/repository-s3/src/test/java/org/elasticsearch/repositories/s3/RepositoryCredentialsTests.java index 1cddd9ee471c..6f78da1e9da0 100644 --- a/modules/repository-s3/src/test/java/org/elasticsearch/repositories/s3/RepositoryCredentialsTests.java +++ b/modules/repository-s3/src/test/java/org/elasticsearch/repositories/s3/RepositoryCredentialsTests.java @@ -243,14 +243,7 @@ public class RepositoryCredentialsTests extends ESSingleNodeTestCase { } private void createRepository(final String name, final Settings repositorySettings) { - assertAcked( - client().admin() - .cluster() - .preparePutRepository(name) - .setType(S3Repository.TYPE) - .setVerify(false) - .setSettings(repositorySettings) - ); + assertAcked(clusterAdmin().preparePutRepository(name).setType(S3Repository.TYPE).setVerify(false).setSettings(repositorySettings)); } /** diff --git a/modules/transport-netty4/src/internalClusterTest/java/org/elasticsearch/transport/netty4/ESLoggingHandlerIT.java b/modules/transport-netty4/src/internalClusterTest/java/org/elasticsearch/transport/netty4/ESLoggingHandlerIT.java index fc56fd49332a..61ef5f197385 100644 --- a/modules/transport-netty4/src/internalClusterTest/java/org/elasticsearch/transport/netty4/ESLoggingHandlerIT.java +++ b/modules/transport-netty4/src/internalClusterTest/java/org/elasticsearch/transport/netty4/ESLoggingHandlerIT.java @@ -84,7 +84,7 @@ public class ESLoggingHandlerIT extends ESNetty4IntegTestCase { appender.addExpectation(writeExpectation); appender.addExpectation(flushExpectation); appender.addExpectation(readExpectation); - client().admin().cluster().prepareNodesHotThreads().get(); + clusterAdmin().prepareNodesHotThreads().get(); appender.assertAllExpectationsMatched(); } diff --git a/modules/transport-netty4/src/internalClusterTest/java/org/elasticsearch/transport/netty4/Netty4TransportMultiPortIntegrationIT.java b/modules/transport-netty4/src/internalClusterTest/java/org/elasticsearch/transport/netty4/Netty4TransportMultiPortIntegrationIT.java index 3eccb8386066..14952a2d3786 100644 --- a/modules/transport-netty4/src/internalClusterTest/java/org/elasticsearch/transport/netty4/Netty4TransportMultiPortIntegrationIT.java +++ b/modules/transport-netty4/src/internalClusterTest/java/org/elasticsearch/transport/netty4/Netty4TransportMultiPortIntegrationIT.java @@ -52,7 +52,7 @@ public class Netty4TransportMultiPortIntegrationIT extends ESNetty4IntegTestCase @Network public void testThatInfosAreExposed() throws Exception { - NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().clear().setTransport(true).get(); + NodesInfoResponse response = clusterAdmin().prepareNodesInfo().clear().setTransport(true).get(); for (NodeInfo nodeInfo : response.getNodes()) { assertThat(nodeInfo.getInfo(TransportInfo.class).getProfileAddresses().keySet(), hasSize(1)); assertThat(nodeInfo.getInfo(TransportInfo.class).getProfileAddresses(), hasKey("client1")); diff --git a/modules/transport-netty4/src/internalClusterTest/java/org/elasticsearch/transport/netty4/Netty4TransportPublishAddressIT.java b/modules/transport-netty4/src/internalClusterTest/java/org/elasticsearch/transport/netty4/Netty4TransportPublishAddressIT.java index 3a8f34322669..bfad7889baa1 100644 --- a/modules/transport-netty4/src/internalClusterTest/java/org/elasticsearch/transport/netty4/Netty4TransportPublishAddressIT.java +++ b/modules/transport-netty4/src/internalClusterTest/java/org/elasticsearch/transport/netty4/Netty4TransportPublishAddressIT.java @@ -55,7 +55,7 @@ public class Netty4TransportPublishAddressIT extends ESNetty4IntegTestCase { ensureStableCluster(2); // fails if port of publish address does not match corresponding bound address logger.info("--> checking if boundAddress matching publishAddress has same port"); - NodesInfoResponse nodesInfoResponse = client().admin().cluster().prepareNodesInfo().get(); + NodesInfoResponse nodesInfoResponse = clusterAdmin().prepareNodesInfo().get(); for (NodeInfo nodeInfo : nodesInfoResponse.getNodes()) { BoundTransportAddress boundTransportAddress = nodeInfo.getInfo(TransportInfo.class).getAddress(); if (nodeInfo.getNode().getName().equals(ipv4OnlyNode)) { diff --git a/plugins/discovery-azure-classic/src/internalClusterTest/java/org/elasticsearch/cloud/azure/classic/AbstractAzureComputeServiceTestCase.java b/plugins/discovery-azure-classic/src/internalClusterTest/java/org/elasticsearch/cloud/azure/classic/AbstractAzureComputeServiceTestCase.java index 39d468786f07..5d0ec9749950 100644 --- a/plugins/discovery-azure-classic/src/internalClusterTest/java/org/elasticsearch/cloud/azure/classic/AbstractAzureComputeServiceTestCase.java +++ b/plugins/discovery-azure-classic/src/internalClusterTest/java/org/elasticsearch/cloud/azure/classic/AbstractAzureComputeServiceTestCase.java @@ -86,7 +86,7 @@ public abstract class AbstractAzureComputeServiceTestCase extends ESIntegTestCas } protected void assertNumberOfNodes(int expected) { - NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().clear().execute().actionGet(); + NodesInfoResponse nodeInfos = clusterAdmin().prepareNodesInfo().clear().execute().actionGet(); assertNotNull(nodeInfos); assertNotNull(nodeInfos.getNodes()); assertEquals(expected, nodeInfos.getNodes().size()); diff --git a/plugins/discovery-ec2/src/internalClusterTest/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryUpdateSettingsTests.java b/plugins/discovery-ec2/src/internalClusterTest/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryUpdateSettingsTests.java index c77d1e57e2c8..033e0e382353 100644 --- a/plugins/discovery-ec2/src/internalClusterTest/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryUpdateSettingsTests.java +++ b/plugins/discovery-ec2/src/internalClusterTest/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryUpdateSettingsTests.java @@ -31,9 +31,7 @@ public class Ec2DiscoveryUpdateSettingsTests extends AbstractAwsTestCase { // We try to update a setting now final String expectedValue = UUIDs.randomBase64UUID(random()); final String settingName = "cluster.routing.allocation.exclude.any_attribute"; - final ClusterUpdateSettingsResponse response = client().admin() - .cluster() - .prepareUpdateSettings() + final ClusterUpdateSettingsResponse response = clusterAdmin().prepareUpdateSettings() .setPersistentSettings(Settings.builder().put(settingName, expectedValue)) .get(); diff --git a/plugins/discovery-gce/src/internalClusterTest/java/org/elasticsearch/discovery/gce/GceDiscoverTests.java b/plugins/discovery-gce/src/internalClusterTest/java/org/elasticsearch/discovery/gce/GceDiscoverTests.java index b3eac7e48635..c655b8ca0a17 100644 --- a/plugins/discovery-gce/src/internalClusterTest/java/org/elasticsearch/discovery/gce/GceDiscoverTests.java +++ b/plugins/discovery-gce/src/internalClusterTest/java/org/elasticsearch/discovery/gce/GceDiscoverTests.java @@ -118,7 +118,7 @@ public class GceDiscoverTests extends ESIntegTestCase { * @param expected the expected number of nodes */ private static void assertNumberOfNodes(final int expected) { - assertEquals(expected, client().admin().cluster().prepareNodesInfo().clear().get().getNodes().size()); + assertEquals(expected, clusterAdmin().prepareNodesInfo().clear().get().getNodes().size()); } /** diff --git a/plugins/repository-hdfs/src/test/java/org/elasticsearch/repositories/hdfs/HdfsRepositoryTests.java b/plugins/repository-hdfs/src/test/java/org/elasticsearch/repositories/hdfs/HdfsRepositoryTests.java index f81182b42d1e..b3d391ce13cb 100644 --- a/plugins/repository-hdfs/src/test/java/org/elasticsearch/repositories/hdfs/HdfsRepositoryTests.java +++ b/plugins/repository-hdfs/src/test/java/org/elasticsearch/repositories/hdfs/HdfsRepositoryTests.java @@ -37,9 +37,7 @@ public class HdfsRepositoryTests extends AbstractThirdPartyRepositoryTestCase { @Override protected void createRepository(String repoName) { - AcknowledgedResponse putRepositoryResponse = client().admin() - .cluster() - .preparePutRepository(repoName) + AcknowledgedResponse putRepositoryResponse = clusterAdmin().preparePutRepository(repoName) .setType("hdfs") .setSettings( Settings.builder() diff --git a/plugins/repository-hdfs/src/test/java/org/elasticsearch/repositories/hdfs/HdfsTests.java b/plugins/repository-hdfs/src/test/java/org/elasticsearch/repositories/hdfs/HdfsTests.java index f85ae51d5417..be0111f9b478 100644 --- a/plugins/repository-hdfs/src/test/java/org/elasticsearch/repositories/hdfs/HdfsTests.java +++ b/plugins/repository-hdfs/src/test/java/org/elasticsearch/repositories/hdfs/HdfsTests.java @@ -143,7 +143,7 @@ public class HdfsTests extends ESSingleNodeTestCase { public void testMissingUri() { try { - client().admin().cluster().preparePutRepository("test-repo").setType("hdfs").setSettings(Settings.EMPTY).get(); + clusterAdmin().preparePutRepository("test-repo").setType("hdfs").setSettings(Settings.EMPTY).get(); fail(); } catch (RepositoryException e) { assertTrue(e.getCause() instanceof IllegalArgumentException); @@ -153,9 +153,7 @@ public class HdfsTests extends ESSingleNodeTestCase { public void testEmptyUri() { try { - client().admin() - .cluster() - .preparePutRepository("test-repo") + clusterAdmin().preparePutRepository("test-repo") .setType("hdfs") .setSettings(Settings.builder().put("uri", "/path").build()) .get(); @@ -168,9 +166,7 @@ public class HdfsTests extends ESSingleNodeTestCase { public void testNonHdfsUri() { try { - client().admin() - .cluster() - .preparePutRepository("test-repo") + clusterAdmin().preparePutRepository("test-repo") .setType("hdfs") .setSettings(Settings.builder().put("uri", "file:///").build()) .get(); @@ -183,9 +179,7 @@ public class HdfsTests extends ESSingleNodeTestCase { public void testPathSpecifiedInHdfs() { try { - client().admin() - .cluster() - .preparePutRepository("test-repo") + clusterAdmin().preparePutRepository("test-repo") .setType("hdfs") .setSettings(Settings.builder().put("uri", "hdfs:///some/path").build()) .get(); @@ -198,9 +192,7 @@ public class HdfsTests extends ESSingleNodeTestCase { public void testMissingPath() { try { - client().admin() - .cluster() - .preparePutRepository("test-repo") + clusterAdmin().preparePutRepository("test-repo") .setType("hdfs") .setSettings(Settings.builder().put("uri", "hdfs:///").build()) .get(); diff --git a/qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/ClusterStateRestCancellationIT.java b/qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/ClusterStateRestCancellationIT.java index 389c4e02758f..d51ac416d275 100644 --- a/qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/ClusterStateRestCancellationIT.java +++ b/qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/ClusterStateRestCancellationIT.java @@ -89,7 +89,7 @@ public class ClusterStateRestCancellationIT extends HttpSmokeTestCase { logger.info("--> checking cluster state task completed"); assertBusy(() -> { updateClusterState(clusterService, s -> ClusterState.builder(s).build()); - final List tasks = client().admin().cluster().prepareListTasks().get().getTasks(); + final List tasks = clusterAdmin().prepareListTasks().get().getTasks(); assertTrue(tasks.toString(), tasks.stream().noneMatch(t -> t.action().equals(ClusterStateAction.NAME))); }); diff --git a/qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/SearchRestCancellationIT.java b/qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/SearchRestCancellationIT.java index 509ddd648c7b..d0ed74928faa 100644 --- a/qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/SearchRestCancellationIT.java +++ b/qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/SearchRestCancellationIT.java @@ -154,7 +154,7 @@ public class SearchRestCancellationIT extends HttpSmokeTestCase { private static Map readNodesInfo() { Map nodeIdToName = new HashMap<>(); - NodesInfoResponse nodesInfoResponse = client().admin().cluster().prepareNodesInfo().get(); + NodesInfoResponse nodesInfoResponse = clusterAdmin().prepareNodesInfo().get(); assertFalse(nodesInfoResponse.hasFailures()); for (NodeInfo node : nodesInfoResponse.getNodes()) { nodeIdToName.put(node.getNode().getId(), node.getNode().getName()); @@ -164,7 +164,7 @@ public class SearchRestCancellationIT extends HttpSmokeTestCase { private static void ensureSearchTaskIsCancelled(String transportAction, Function nodeIdToName) throws Exception { SetOnce searchTask = new SetOnce<>(); - ListTasksResponse listTasksResponse = client().admin().cluster().prepareListTasks().get(); + ListTasksResponse listTasksResponse = clusterAdmin().prepareListTasks().get(); for (TaskInfo task : listTasksResponse.getTasks()) { if (task.action().equals(transportAction)) { searchTask.set(task); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/TaskStorageRetryIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/TaskStorageRetryIT.java index b2299746b224..1fb21572f2f4 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/TaskStorageRetryIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/TaskStorageRetryIT.java @@ -69,10 +69,7 @@ public class TaskStorageRetryIT extends ESSingleNodeTestCase { logger.info("verify that the task has started and is still running"); assertBusy(() -> { - GetTaskResponse runningTask = client().admin() - .cluster() - .prepareGetTask(new TaskId(nodeClient().getLocalNodeId(), task.getId())) - .get(); + GetTaskResponse runningTask = clusterAdmin().prepareGetTask(new TaskId(nodeClient().getLocalNodeId(), task.getId())).get(); assertNotNull(runningTask.getTask()); assertFalse(runningTask.getTask().isCompleted()); assertEquals(emptyMap(), runningTask.getTask().getErrorAsMap()); @@ -88,10 +85,7 @@ public class TaskStorageRetryIT extends ESSingleNodeTestCase { future.get(10, TimeUnit.SECONDS); logger.info("check that it was written successfully"); - GetTaskResponse finishedTask = client().admin() - .cluster() - .prepareGetTask(new TaskId(nodeClient().getLocalNodeId(), task.getId())) - .get(); + GetTaskResponse finishedTask = clusterAdmin().prepareGetTask(new TaskId(nodeClient().getLocalNodeId(), task.getId())).get(); assertTrue(finishedTask.getTask().isCompleted()); assertEquals(emptyMap(), finishedTask.getTask().getErrorAsMap()); assertEquals(singletonMap("failure_count", 0), finishedTask.getTask().getResponseAsMap()); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/tasks/ListTasksIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/tasks/ListTasksIT.java index f4b1903bba67..0c92836cd475 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/tasks/ListTasksIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/tasks/ListTasksIT.java @@ -44,13 +44,10 @@ public class ListTasksIT extends ESSingleNodeTestCase { public void testListTasksFilteredByDescription() { // The list tasks action itself is filtered out via this description filter - assertThat( - client().admin().cluster().prepareListTasks().setDetailed(true).setDescriptions("match_nothing*").get().getTasks(), - is(empty()) - ); + assertThat(clusterAdmin().prepareListTasks().setDetailed(true).setDescriptions("match_nothing*").get().getTasks(), is(empty())); // The list tasks action itself is kept via this description filter which matches everything - assertThat(client().admin().cluster().prepareListTasks().setDetailed(true).setDescriptions("*").get().getTasks(), is(not(empty()))); + assertThat(clusterAdmin().prepareListTasks().setDetailed(true).setDescriptions("*").get().getTasks(), is(not(empty()))); } @@ -58,7 +55,7 @@ public class ListTasksIT extends ESSingleNodeTestCase { ActionRequestValidationException ex = expectThrows( ActionRequestValidationException.class, - () -> client().admin().cluster().prepareListTasks().setDescriptions("*").get() + () -> clusterAdmin().prepareListTasks().setDescriptions("*").get() ); assertThat(ex.getMessage(), containsString("matching on descriptions is not available when [detailed] is false")); @@ -79,23 +76,21 @@ public class ListTasksIT extends ESSingleNodeTestCase { barrier.await(10, TimeUnit.SECONDS); - final var listTasksResponse = client().admin().cluster().prepareListTasks().setActions(TestTransportAction.NAME).get(); + final var listTasksResponse = clusterAdmin().prepareListTasks().setActions(TestTransportAction.NAME).get(); assertThat(listTasksResponse.getNodeFailures(), empty()); assertEquals(1, listTasksResponse.getTasks().size()); final var task = listTasksResponse.getTasks().get(0); assertEquals(TestTransportAction.NAME, task.action()); final var listWaitFuture = new PlainActionFuture(); - client().admin() - .cluster() - .prepareListTasks() + clusterAdmin().prepareListTasks() .setTargetTaskId(task.taskId()) .setWaitForCompletion(true) .execute(listWaitFuture.delegateFailure((l, listResult) -> { assertEquals(1, listResult.getTasks().size()); assertEquals(task.taskId(), listResult.getTasks().get(0).taskId()); // the task must now be complete: - client().admin().cluster().prepareListTasks().setActions(TestTransportAction.NAME).execute(l.map(listAfterWaitResult -> { + clusterAdmin().prepareListTasks().setActions(TestTransportAction.NAME).execute(l.map(listAfterWaitResult -> { assertThat(listAfterWaitResult.getTasks(), empty()); assertThat(listAfterWaitResult.getNodeFailures(), empty()); assertThat(listAfterWaitResult.getTaskFailures(), empty()); @@ -109,23 +104,19 @@ public class ListTasksIT extends ESSingleNodeTestCase { flushThreadPool(threadPool, ThreadPool.Names.MANAGEMENT); final var getWaitFuture = new PlainActionFuture(); - client().admin() - .cluster() - .prepareGetTask(task.taskId()) - .setWaitForCompletion(true) - .execute(getWaitFuture.delegateFailure((l, getResult) -> { - assertTrue(getResult.getTask().isCompleted()); - assertEquals(task.taskId(), getResult.getTask().getTask().taskId()); - // the task must now be complete: - client().admin().cluster().prepareListTasks().setActions(TestTransportAction.NAME).execute(l.map(listAfterWaitResult -> { - assertThat(listAfterWaitResult.getTasks(), empty()); - assertThat(listAfterWaitResult.getNodeFailures(), empty()); - assertThat(listAfterWaitResult.getTaskFailures(), empty()); - return null; - })); - // and we must not see its header: - assertNull(threadContext.getResponseHeaders().get(TestTransportAction.HEADER_NAME)); + clusterAdmin().prepareGetTask(task.taskId()).setWaitForCompletion(true).execute(getWaitFuture.delegateFailure((l, getResult) -> { + assertTrue(getResult.getTask().isCompleted()); + assertEquals(task.taskId(), getResult.getTask().getTask().taskId()); + // the task must now be complete: + clusterAdmin().prepareListTasks().setActions(TestTransportAction.NAME).execute(l.map(listAfterWaitResult -> { + assertThat(listAfterWaitResult.getTasks(), empty()); + assertThat(listAfterWaitResult.getNodeFailures(), empty()); + assertThat(listAfterWaitResult.getTaskFailures(), empty()); + return null; })); + // and we must not see its header: + assertNull(threadContext.getResponseHeaders().get(TestTransportAction.HEADER_NAME)); + })); assertFalse(listWaitFuture.isDone()); assertFalse(testActionFuture.isDone()); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java index 0490a4d3e47a..a362ca681313 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/MinimumMasterNodesIT.java @@ -98,13 +98,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase { } // make sure that all shards recovered before trying to flush assertThat( - client().admin() - .cluster() - .prepareHealth("test") - .setWaitForActiveShards(numShards.totalNumShards) - .execute() - .actionGet() - .getActiveShards(), + clusterAdmin().prepareHealth("test").setWaitForActiveShards(numShards.totalNumShards).execute().actionGet().getActiveShards(), equalTo(numShards.totalNumShards) ); // flush for simpler debugging diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/NoMasterNodeIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/NoMasterNodeIT.java index dab97ef38286..f513e4fa74de 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/NoMasterNodeIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/NoMasterNodeIT.java @@ -72,7 +72,7 @@ public class NoMasterNodeIT extends ESIntegTestCase { final List nodes = internalCluster().startNodes(3, settings); createIndex("test"); - client().admin().cluster().prepareHealth("test").setWaitForGreenStatus().execute().actionGet(); + clusterAdmin().prepareHealth("test").setWaitForGreenStatus().execute().actionGet(); final NetworkDisruption disruptionScheme = new NetworkDisruption( new IsolateAllNodes(new HashSet<>(nodes)), @@ -223,14 +223,14 @@ public class NoMasterNodeIT extends ESIntegTestCase { prepareCreate("test1").setSettings(indexSettings(1, 2)).get(); prepareCreate("test2").setSettings(indexSettings(3, 0)).get(); - client().admin().cluster().prepareHealth("_all").setWaitForGreenStatus().get(); + clusterAdmin().prepareHealth("_all").setWaitForGreenStatus().get(); client().prepareIndex("test1").setId("1").setSource("field", "value1").get(); client().prepareIndex("test2").setId("1").setSource("field", "value1").get(); refresh(); ensureSearchable("test1", "test2"); - ClusterStateResponse clusterState = client().admin().cluster().prepareState().get(); + ClusterStateResponse clusterState = clusterAdmin().prepareState().get(); logger.info("Cluster state:\n{}", clusterState.getState()); final NetworkDisruption disruptionScheme = new NetworkDisruption( @@ -300,13 +300,13 @@ public class NoMasterNodeIT extends ESIntegTestCase { final List nodes = internalCluster().startNodes(3, settings); prepareCreate("test1").setSettings(indexSettings(1, 1)).get(); - client().admin().cluster().prepareHealth("_all").setWaitForGreenStatus().get(); + clusterAdmin().prepareHealth("_all").setWaitForGreenStatus().get(); client().prepareIndex("test1").setId("1").setSource("field", "value1").get(); refresh(); ensureGreen("test1"); - ClusterStateResponse clusterState = client().admin().cluster().prepareState().get(); + ClusterStateResponse clusterState = clusterAdmin().prepareState().get(); logger.info("Cluster state:\n{}", clusterState.getState()); final List nodesWithShards = clusterState.getState() diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/SimpleClusterStateIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/SimpleClusterStateIT.java index 4d513d72d217..a7460ef0e8ab 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/SimpleClusterStateIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/SimpleClusterStateIT.java @@ -86,13 +86,13 @@ public class SimpleClusterStateIT extends ESIntegTestCase { } public void testRoutingTable() throws Exception { - ClusterStateResponse clusterStateResponseUnfiltered = client().admin().cluster().prepareState().clear().setRoutingTable(true).get(); + ClusterStateResponse clusterStateResponseUnfiltered = clusterAdmin().prepareState().clear().setRoutingTable(true).get(); assertThat(clusterStateResponseUnfiltered.getState().routingTable().hasIndex("foo"), is(true)); assertThat(clusterStateResponseUnfiltered.getState().routingTable().hasIndex("fuu"), is(true)); assertThat(clusterStateResponseUnfiltered.getState().routingTable().hasIndex("baz"), is(true)); assertThat(clusterStateResponseUnfiltered.getState().routingTable().hasIndex("non-existent"), is(false)); - ClusterStateResponse clusterStateResponse = client().admin().cluster().prepareState().clear().get(); + ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState().clear().get(); assertThat(clusterStateResponse.getState().routingTable().hasIndex("foo"), is(false)); assertThat(clusterStateResponse.getState().routingTable().hasIndex("fuu"), is(false)); assertThat(clusterStateResponse.getState().routingTable().hasIndex("baz"), is(false)); @@ -100,43 +100,43 @@ public class SimpleClusterStateIT extends ESIntegTestCase { } public void testNodes() throws Exception { - ClusterStateResponse clusterStateResponse = client().admin().cluster().prepareState().clear().setNodes(true).get(); + ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState().clear().setNodes(true).get(); assertThat(clusterStateResponse.getState().nodes().getNodes().size(), is(cluster().size())); - ClusterStateResponse clusterStateResponseFiltered = client().admin().cluster().prepareState().clear().get(); + ClusterStateResponse clusterStateResponseFiltered = clusterAdmin().prepareState().clear().get(); assertThat(clusterStateResponseFiltered.getState().nodes().getNodes().size(), is(0)); } public void testMetadata() throws Exception { - ClusterStateResponse clusterStateResponseUnfiltered = client().admin().cluster().prepareState().clear().setMetadata(true).get(); + ClusterStateResponse clusterStateResponseUnfiltered = clusterAdmin().prepareState().clear().setMetadata(true).get(); assertThat(clusterStateResponseUnfiltered.getState().metadata().indices().size(), is(3)); - ClusterStateResponse clusterStateResponse = client().admin().cluster().prepareState().clear().get(); + ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState().clear().get(); assertThat(clusterStateResponse.getState().metadata().indices().size(), is(0)); } public void testMetadataVersion() { createIndex("index-1"); createIndex("index-2"); - long baselineVersion = client().admin().cluster().prepareState().get().getState().metadata().version(); + long baselineVersion = clusterAdmin().prepareState().get().getState().metadata().version(); assertThat(baselineVersion, greaterThan(0L)); assertThat( - client().admin().cluster().prepareState().setIndices("index-1").get().getState().metadata().version(), + clusterAdmin().prepareState().setIndices("index-1").get().getState().metadata().version(), greaterThanOrEqualTo(baselineVersion) ); assertThat( - client().admin().cluster().prepareState().setIndices("index-2").get().getState().metadata().version(), + clusterAdmin().prepareState().setIndices("index-2").get().getState().metadata().version(), greaterThanOrEqualTo(baselineVersion) ); assertThat( - client().admin().cluster().prepareState().setIndices("*").get().getState().metadata().version(), + clusterAdmin().prepareState().setIndices("*").get().getState().metadata().version(), greaterThanOrEqualTo(baselineVersion) ); assertThat( - client().admin().cluster().prepareState().setIndices("not-found").get().getState().metadata().version(), + clusterAdmin().prepareState().setIndices("not-found").get().getState().metadata().version(), greaterThanOrEqualTo(baselineVersion) ); - assertThat(client().admin().cluster().prepareState().clear().setMetadata(false).get().getState().metadata().version(), equalTo(0L)); + assertThat(clusterAdmin().prepareState().clear().setMetadata(false).get().getState().metadata().version(), equalTo(0L)); } public void testIndexTemplates() throws Exception { @@ -180,7 +180,7 @@ public class SimpleClusterStateIT extends ESIntegTestCase { ) .get(); - ClusterStateResponse clusterStateResponseUnfiltered = client().admin().cluster().prepareState().get(); + ClusterStateResponse clusterStateResponseUnfiltered = clusterAdmin().prepareState().get(); assertThat(clusterStateResponseUnfiltered.getState().metadata().templates().size(), is(greaterThanOrEqualTo(2))); GetIndexTemplatesResponse getIndexTemplatesResponse = indicesAdmin().prepareGetTemplates("foo_template").get(); @@ -279,7 +279,7 @@ public class SimpleClusterStateIT extends ESIntegTestCase { // close one index assertAcked(indicesAdmin().close(new CloseIndexRequest("fuu")).get()); - clusterStateResponse = client().admin().cluster().prepareState().clear().setMetadata(true).setIndices("f*").get(); + clusterStateResponse = clusterAdmin().prepareState().clear().setMetadata(true).setIndices("f*").get(); assertThat(clusterStateResponse.getState().metadata().indices().size(), is(1)); assertThat(clusterStateResponse.getState().metadata().index("foo").getState(), equalTo(IndexMetadata.State.OPEN)); @@ -320,7 +320,7 @@ public class SimpleClusterStateIT extends ESIntegTestCase { // empty wildcard expansion throws exception when allowNoIndices is turned off IndicesOptions allowNoIndices = IndicesOptions.fromOptions(false, false, true, false); try { - client().admin().cluster().prepareState().clear().setMetadata(true).setIndices("a*").setIndicesOptions(allowNoIndices).get(); + clusterAdmin().prepareState().clear().setMetadata(true).setIndices("a*").setIndicesOptions(allowNoIndices).get(); fail("Expected IndexNotFoundException"); } catch (IndexNotFoundException e) { assertThat(e.getMessage(), is("no such index [a*]")); @@ -341,7 +341,7 @@ public class SimpleClusterStateIT extends ESIntegTestCase { public void testPrivateCustomsAreExcluded() throws Exception { // ensure that the custom is injected into the cluster state assertBusy(() -> assertTrue(clusterService().state().customs().containsKey("test"))); - ClusterStateResponse clusterStateResponse = client().admin().cluster().prepareState().setCustoms(true).get(); + ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState().setCustoms(true).get(); assertFalse(clusterStateResponse.getState().customs().containsKey("test")); } diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/SimpleDataNodesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/SimpleDataNodesIT.java index af6742f4c742..9687fcd4a52e 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/SimpleDataNodesIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/SimpleDataNodesIT.java @@ -125,7 +125,7 @@ public class SimpleDataNodesIT extends ESIntegTestCase { internalCluster().startNode(); internalCluster().startNode(); - client().admin().cluster().prepareReroute().setRetryFailed(true).get(); + clusterAdmin().prepareReroute().setRetryFailed(true).get(); } } diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java index ae769855e395..34682637b063 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java @@ -36,15 +36,7 @@ public class SpecificMasterNodesIT extends ESIntegTestCase { internalCluster().startNode(Settings.builder().put(dataOnlyNode()).put("discovery.initial_state_timeout", "1s")); try { assertThat( - client().admin() - .cluster() - .prepareState() - .setMasterNodeTimeout("100ms") - .execute() - .actionGet() - .getState() - .nodes() - .getMasterNodeId(), + clusterAdmin().prepareState().setMasterNodeTimeout("100ms").execute().actionGet().getState().nodes().getMasterNodeId(), nullValue() ); fail("should not be able to find master"); @@ -86,15 +78,7 @@ public class SpecificMasterNodesIT extends ESIntegTestCase { try { assertThat( - client().admin() - .cluster() - .prepareState() - .setMasterNodeTimeout("100ms") - .execute() - .actionGet() - .getState() - .nodes() - .getMasterNodeId(), + clusterAdmin().prepareState().setMasterNodeTimeout("100ms").execute().actionGet().getState().nodes().getMasterNodeId(), nullValue() ); fail("should not be able to find master"); @@ -140,15 +124,7 @@ public class SpecificMasterNodesIT extends ESIntegTestCase { internalCluster().startNode(Settings.builder().put(dataOnlyNode()).put("discovery.initial_state_timeout", "1s")); try { assertThat( - client().admin() - .cluster() - .prepareState() - .setMasterNodeTimeout("100ms") - .execute() - .actionGet() - .getState() - .nodes() - .getMasterNodeId(), + clusterAdmin().prepareState().setMasterNodeTimeout("100ms").execute().actionGet().getState().nodes().getMasterNodeId(), nullValue() ); fail("should not be able to find master"); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/allocation/SimpleAllocationIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/allocation/SimpleAllocationIT.java index 7f436283b0e5..55814dba3356 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/allocation/SimpleAllocationIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/allocation/SimpleAllocationIT.java @@ -33,7 +33,7 @@ public class SimpleAllocationIT extends ESIntegTestCase { } ensureGreen("test"); - ClusterState state = client().admin().cluster().prepareState().execute().actionGet().getState(); + ClusterState state = clusterAdmin().prepareState().execute().actionGet().getState(); assertThat(state.getRoutingNodes().unassigned().size(), equalTo(0)); for (RoutingNode node : state.getRoutingNodes()) { if (node.isEmpty() == false) { @@ -42,7 +42,7 @@ public class SimpleAllocationIT extends ESIntegTestCase { } setReplicaCount(0, "test"); ensureGreen("test"); - state = client().admin().cluster().prepareState().execute().actionGet().getState(); + state = clusterAdmin().prepareState().execute().actionGet().getState(); assertThat(state.getRoutingNodes().unassigned().size(), equalTo(0)); for (RoutingNode node : state.getRoutingNodes()) { @@ -60,7 +60,7 @@ public class SimpleAllocationIT extends ESIntegTestCase { setReplicaCount(1, "test"); ensureGreen("test"); - state = client().admin().cluster().prepareState().execute().actionGet().getState(); + state = clusterAdmin().prepareState().execute().actionGet().getState(); assertThat(state.getRoutingNodes().unassigned().size(), equalTo(0)); for (RoutingNode node : state.getRoutingNodes()) { diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/RareClusterStateIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/RareClusterStateIT.java index 38c364347d45..f56972772984 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/RareClusterStateIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/RareClusterStateIT.java @@ -180,7 +180,7 @@ public class RareClusterStateIT extends ESIntegTestCase { public void testDeleteCreateInOneBulk() throws Exception { internalCluster().startMasterOnlyNode(); String dataNode = internalCluster().startDataOnlyNode(); - assertFalse(client().admin().cluster().prepareHealth().setWaitForNodes("2").get().isTimedOut()); + assertFalse(clusterAdmin().prepareHealth().setWaitForNodes("2").get().isTimedOut()); prepareCreate("test").setSettings(Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)).get(); ensureGreen("test"); @@ -224,7 +224,7 @@ public class RareClusterStateIT extends ESIntegTestCase { // operation yet final List nodeNames = internalCluster().startNodes(2); - assertFalse(client().admin().cluster().prepareHealth().setWaitForNodes("2").get().isTimedOut()); + assertFalse(clusterAdmin().prepareHealth().setWaitForNodes("2").get().isTimedOut()); final String master = internalCluster().getMasterName(); assertThat(nodeNames, hasItem(master)); @@ -242,7 +242,7 @@ public class RareClusterStateIT extends ESIntegTestCase { ensureGreen(); // Check routing tables - ClusterState state = client().admin().cluster().prepareState().get().getState(); + ClusterState state = clusterAdmin().prepareState().get().getState(); assertEquals(master, state.nodes().getMasterNode().getName()); List shards = state.routingTable().allShards("index"); assertThat(shards, hasSize(1)); @@ -306,7 +306,7 @@ public class RareClusterStateIT extends ESIntegTestCase { // are needed for a document are not available on the replica at the // time of indexing it final List nodeNames = internalCluster().startNodes(2); - assertFalse(client().admin().cluster().prepareHealth().setWaitForNodes("2").get().isTimedOut()); + assertFalse(clusterAdmin().prepareHealth().setWaitForNodes("2").get().isTimedOut()); final String master = internalCluster().getMasterName(); assertThat(nodeNames, hasItem(master)); @@ -326,7 +326,7 @@ public class RareClusterStateIT extends ESIntegTestCase { ensureGreen(); // Check routing tables - ClusterState state = client().admin().cluster().prepareState().get().getState(); + ClusterState state = clusterAdmin().prepareState().get().getState(); assertEquals(master, state.nodes().getMasterNode().getName()); List shards = state.routingTable().allShards("index"); assertThat(shards, hasSize(2)); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/RemoveCustomsCommandIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/RemoveCustomsCommandIT.java index c909229cac79..65484066ee9b 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/RemoveCustomsCommandIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/RemoveCustomsCommandIT.java @@ -46,7 +46,7 @@ public class RemoveCustomsCommandIT extends ESIntegTestCase { String node = internalCluster().startNode(); createIndex("test"); indicesAdmin().prepareDelete("test").get(); - assertEquals(1, client().admin().cluster().prepareState().get().getState().metadata().indexGraveyard().getTombstones().size()); + assertEquals(1, clusterAdmin().prepareState().get().getState().metadata().indexGraveyard().getTombstones().size()); Settings dataPathSettings = internalCluster().dataPathSettings(node); ensureStableCluster(1); internalCluster().stopRandomDataNode(); @@ -64,7 +64,7 @@ public class RemoveCustomsCommandIT extends ESIntegTestCase { assertThat(terminal.getOutput(), containsString("index-graveyard")); internalCluster().startNode(dataPathSettings); - assertEquals(0, client().admin().cluster().prepareState().get().getState().metadata().indexGraveyard().getTombstones().size()); + assertEquals(0, clusterAdmin().prepareState().get().getState().metadata().indexGraveyard().getTombstones().size()); } public void testCustomDoesNotMatch() throws Exception { @@ -72,7 +72,7 @@ public class RemoveCustomsCommandIT extends ESIntegTestCase { String node = internalCluster().startNode(); createIndex("test"); indicesAdmin().prepareDelete("test").get(); - assertEquals(1, client().admin().cluster().prepareState().get().getState().metadata().indexGraveyard().getTombstones().size()); + assertEquals(1, clusterAdmin().prepareState().get().getState().metadata().indexGraveyard().getTombstones().size()); Settings dataPathSettings = internalCluster().dataPathSettings(node); ensureStableCluster(1); internalCluster().stopRandomDataNode(); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/UnsafeBootstrapAndDetachCommandIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/UnsafeBootstrapAndDetachCommandIT.java index 849dffaefa3b..265cc9ee364d 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/UnsafeBootstrapAndDetachCommandIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/UnsafeBootstrapAndDetachCommandIT.java @@ -137,7 +137,7 @@ public class UnsafeBootstrapAndDetachCommandIT extends ESIntegTestCase { .build() ); assertBusy(() -> { - ClusterState state = client().admin().cluster().prepareState().setLocal(true).execute().actionGet().getState(); + ClusterState state = clusterAdmin().prepareState().setLocal(true).execute().actionGet().getState(); assertTrue(state.blocks().hasGlobalBlockWithId(NoMasterBlockService.NO_MASTER_BLOCK_ID)); }); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/VotingConfigurationIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/VotingConfigurationIT.java index f8e724467fe2..33e67520b82b 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/VotingConfigurationIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/VotingConfigurationIT.java @@ -44,7 +44,7 @@ public class VotingConfigurationIT extends ESIntegTestCase { logger.info("--> excluding master node {}", originalMaster); client().execute(AddVotingConfigExclusionsAction.INSTANCE, new AddVotingConfigExclusionsRequest(originalMaster)).get(); - client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).get(); + clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).get(); assertNotEquals(originalMaster, internalCluster().getMasterName()); } diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/AllocationIdIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/AllocationIdIT.java index 5e92badf6751..7d1d35c165e5 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/AllocationIdIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/AllocationIdIT.java @@ -111,7 +111,7 @@ public class AllocationIdIT extends ESIntegTestCase { // allocation fails due to corruption marker assertBusy(() -> { - final ClusterState state = client().admin().cluster().prepareState().get().getState(); + final ClusterState state = clusterAdmin().prepareState().get().getState(); final ShardRouting shardRouting = state.routingTable().index(indexName).shard(shardId.id()).primaryShard(); assertThat(shardRouting.state(), equalTo(ShardRoutingState.UNASSIGNED)); assertThat(shardRouting.unassignedInfo().getReason(), equalTo(UnassignedInfo.Reason.ALLOCATION_FAILED)); @@ -128,7 +128,7 @@ public class AllocationIdIT extends ESIntegTestCase { checkNoValidShardCopy(indexName, shardId); // no any valid shard is there; have to invoke AllocateStalePrimary again - client().admin().cluster().prepareReroute().add(new AllocateStalePrimaryAllocationCommand(indexName, 0, node1, true)).get(); + clusterAdmin().prepareReroute().add(new AllocateStalePrimaryAllocationCommand(indexName, 0, node1, true)).get(); ensureYellow(indexName); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/ShardStateIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/ShardStateIT.java index a6c27fba26e3..e3b6f2ddba4c 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/ShardStateIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/ShardStateIT.java @@ -28,7 +28,7 @@ public class ShardStateIT extends ESIntegTestCase { logger.info("--> disabling allocation to capture shard failure"); disableAllocation("test"); - ClusterState state = client().admin().cluster().prepareState().get().getState(); + ClusterState state = clusterAdmin().prepareState().get().getState(); final int shard = randomBoolean() ? 0 : 1; final String nodeId = state.routingTable().index("test").shard(shard).primaryShard().currentNodeId(); final String node = state.nodes().get(nodeId).getName(); @@ -38,9 +38,7 @@ public class ShardStateIT extends ESIntegTestCase { logger.info("--> waiting for a yellow index"); // we can't use ensureYellow since that one is just as happy with a GREEN status. - assertBusy( - () -> assertThat(client().admin().cluster().prepareHealth("test").get().getStatus(), equalTo(ClusterHealthStatus.YELLOW)) - ); + assertBusy(() -> assertThat(clusterAdmin().prepareHealth("test").get().getStatus(), equalTo(ClusterHealthStatus.YELLOW))); final long term0 = shard == 0 ? 2 : 1; final long term1 = shard == 1 ? 2 : 1; diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderIT.java index c7e7d8549a06..ead474e6eea2 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderIT.java @@ -120,9 +120,7 @@ public class DiskThresholdDeciderIT extends DiskUsageIntegTestCase { createIndex(indexName, indexSettings(6, 0).put(INDEX_STORE_STATS_REFRESH_INTERVAL_SETTING.getKey(), "0ms").build()); var smallestShard = createReasonableSizedShards(indexName); - final CreateSnapshotResponse createSnapshotResponse = client().admin() - .cluster() - .prepareCreateSnapshot("repo", "snap") + final CreateSnapshotResponse createSnapshotResponse = clusterAdmin().prepareCreateSnapshot("repo", "snap") .setWaitForCompletion(true) .get(); final SnapshotInfo snapshotInfo = createSnapshotResponse.getSnapshotInfo(); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/decider/UpdateShardAllocationSettingsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/decider/UpdateShardAllocationSettingsIT.java index acbb71aa57d6..da1156953e26 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/decider/UpdateShardAllocationSettingsIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/routing/allocation/decider/UpdateShardAllocationSettingsIT.java @@ -50,7 +50,7 @@ public class UpdateShardAllocationSettingsIT extends ESIntegTestCase { .put(EnableAllocationDecider.INDEX_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), EnableAllocationDecider.Rebalance.NONE), "test" ); - client().admin().cluster().prepareReroute().get(); + clusterAdmin().prepareReroute().get(); ensureGreen(); assertAllShardsOnNodes("test", firstNode); assertAllShardsOnNodes("test_1", firstNode); @@ -65,7 +65,7 @@ public class UpdateShardAllocationSettingsIT extends ESIntegTestCase { "test" ); logger.info("--> balance index [test]"); - client().admin().cluster().prepareReroute().get(); + clusterAdmin().prepareReroute().get(); ensureGreen("test"); Set test = assertAllShardsOnNodes("test", firstNode, secondNode); assertThat("index: [test] expected to be rebalanced on both nodes", test.size(), equalTo(2)); @@ -80,7 +80,7 @@ public class UpdateShardAllocationSettingsIT extends ESIntegTestCase { ) ); logger.info("--> balance index [test_1]"); - client().admin().cluster().prepareReroute().get(); + clusterAdmin().prepareReroute().get(); ensureGreen("test_1"); Set test_1 = assertAllShardsOnNodes("test_1", firstNode, secondNode); assertThat("index: [test_1] expected to be rebalanced on both nodes", test_1.size(), equalTo(2)); @@ -99,7 +99,7 @@ public class UpdateShardAllocationSettingsIT extends ESIntegTestCase { updateClusterSettings(Settings.builder().put(CLUSTER_ROUTING_ALLOCATION_SAME_HOST_SETTING.getKey(), true)); final String indexName = "idx"; createIndex(indexName, 1, 1); - ClusterState clusterState = client().admin().cluster().prepareState().get().getState(); + ClusterState clusterState = clusterAdmin().prepareState().get().getState(); assertFalse( "replica should be unassigned", clusterState.getRoutingTable().index(indexName).shardsWithState(ShardRoutingState.UNASSIGNED).isEmpty() @@ -108,7 +108,7 @@ public class UpdateShardAllocationSettingsIT extends ESIntegTestCase { // the same host - the replica should get assigned updateClusterSettings(Settings.builder().put(CLUSTER_ROUTING_ALLOCATION_SAME_HOST_SETTING.getKey(), false)); - clusterState = client().admin().cluster().prepareState().get().getState(); + clusterState = clusterAdmin().prepareState().get().getState(); assertTrue( "all shards should be assigned", clusterState.getRoutingTable().index(indexName).shardsWithState(ShardRoutingState.UNASSIGNED).isEmpty() diff --git a/server/src/internalClusterTest/java/org/elasticsearch/cluster/settings/SettingsFilteringIT.java b/server/src/internalClusterTest/java/org/elasticsearch/cluster/settings/SettingsFilteringIT.java index 0ffed0f2a4bd..283898738859 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/cluster/settings/SettingsFilteringIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/cluster/settings/SettingsFilteringIT.java @@ -93,7 +93,7 @@ public class SettingsFilteringIT extends ESIntegTestCase { } public void testNodeInfoIsFiltered() { - NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().clear().setSettings(true).get(); + NodesInfoResponse nodeInfos = clusterAdmin().prepareNodesInfo().clear().setSettings(true).get(); for (NodeInfo info : nodeInfos.getNodes()) { Settings settings = info.getSettings(); assertNotNull(settings); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/common/settings/UpgradeSettingsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/common/settings/UpgradeSettingsIT.java index e02974ffed81..55983e0959c7 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/common/settings/UpgradeSettingsIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/common/settings/UpgradeSettingsIT.java @@ -28,9 +28,7 @@ public class UpgradeSettingsIT extends ESSingleNodeTestCase { @After public void cleanup() throws Exception { - client().admin() - .cluster() - .prepareUpdateSettings() + clusterAdmin().prepareUpdateSettings() .setPersistentSettings(Settings.builder().putNull("*")) .setTransientSettings(Settings.builder().putNull("*")) .get(); @@ -90,11 +88,11 @@ public class UpgradeSettingsIT extends ESSingleNodeTestCase { final Function settingsFunction ) { final String value = randomAlphaOfLength(8); - final ClusterUpdateSettingsRequestBuilder builder = client().admin().cluster().prepareUpdateSettings(); + final ClusterUpdateSettingsRequestBuilder builder = clusterAdmin().prepareUpdateSettings(); consumer.accept(Settings.builder().put("foo.old", value).build(), builder); builder.get(); - final ClusterStateResponse response = client().admin().cluster().prepareState().clear().setMetadata(true).get(); + final ClusterStateResponse response = clusterAdmin().prepareState().clear().setMetadata(true).get(); assertFalse(UpgradeSettingsPlugin.oldSetting.exists(settingsFunction.apply(response.getState().metadata()))); assertTrue(UpgradeSettingsPlugin.newSetting.exists(settingsFunction.apply(response.getState().metadata()))); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/discovery/MasterDisruptionIT.java b/server/src/internalClusterTest/java/org/elasticsearch/discovery/MasterDisruptionIT.java index 790fd2fd8182..8a83dcf80800 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/discovery/MasterDisruptionIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/discovery/MasterDisruptionIT.java @@ -116,7 +116,7 @@ public class MasterDisruptionIT extends AbstractDisruptionTestCase { logger.info("issue a reroute"); // trigger a reroute now, instead of waiting for the background reroute of RerouteService - assertAcked(client().admin().cluster().prepareReroute()); + assertAcked(clusterAdmin().prepareReroute()); // and wait for it to finish and for the cluster to stabilize ensureGreen("test"); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/discovery/SnapshotDisruptionIT.java b/server/src/internalClusterTest/java/org/elasticsearch/discovery/SnapshotDisruptionIT.java index 3af01bc23aff..757297e6c531 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/discovery/SnapshotDisruptionIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/discovery/SnapshotDisruptionIT.java @@ -211,7 +211,7 @@ public class SnapshotDisruptionIT extends AbstractSnapshotIntegTestCase { assertThat(successfulSnapshotInfo.state(), is(SnapshotState.SUCCESS)); logger.info("--> making sure snapshot delete works out cleanly"); - assertAcked(client().admin().cluster().prepareDeleteSnapshot(repoName, "snapshot-2").get()); + assertAcked(clusterAdmin().prepareDeleteSnapshot(repoName, "snapshot-2").get()); } public void testMasterFailOverDuringShardSnapshots() throws Exception { diff --git a/server/src/internalClusterTest/java/org/elasticsearch/index/shard/RemoveCorruptedShardDataCommandIT.java b/server/src/internalClusterTest/java/org/elasticsearch/index/shard/RemoveCorruptedShardDataCommandIT.java index 49d7bb429db1..7ffa092a3046 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/index/shard/RemoveCorruptedShardDataCommandIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/index/shard/RemoveCorruptedShardDataCommandIT.java @@ -201,7 +201,7 @@ public class RemoveCorruptedShardDataCommandIT extends ESIntegTestCase { waitNoPendingTasksOnAll(); String nodeId = null; - final ClusterState state = client().admin().cluster().prepareState().get().getState(); + final ClusterState state = clusterAdmin().prepareState().get().getState(); final DiscoveryNodes nodes = state.nodes(); for (Map.Entry cursor : nodes.getNodes().entrySet()) { final String name = cursor.getValue().getName(); @@ -234,7 +234,7 @@ public class RemoveCorruptedShardDataCommandIT extends ESIntegTestCase { ); }); - client().admin().cluster().prepareReroute().add(new AllocateStalePrimaryAllocationCommand(indexName, 0, nodeId, true)).get(); + clusterAdmin().prepareReroute().add(new AllocateStalePrimaryAllocationCommand(indexName, 0, nodeId, true)).get(); assertBusy(() -> { final ClusterAllocationExplanation explanation = clusterAdmin().prepareAllocationExplain() @@ -376,7 +376,7 @@ public class RemoveCorruptedShardDataCommandIT extends ESIntegTestCase { }); String primaryNodeId = null; - final ClusterState state = client().admin().cluster().prepareState().get().getState(); + final ClusterState state = clusterAdmin().prepareState().get().getState(); final DiscoveryNodes nodes = state.nodes(); for (Map.Entry cursor : nodes.getNodes().entrySet()) { final String name = cursor.getValue().getName(); @@ -407,7 +407,7 @@ public class RemoveCorruptedShardDataCommandIT extends ESIntegTestCase { ); }); - client().admin().cluster().prepareReroute().add(new AllocateStalePrimaryAllocationCommand(indexName, 0, primaryNodeId, true)).get(); + clusterAdmin().prepareReroute().add(new AllocateStalePrimaryAllocationCommand(indexName, 0, primaryNodeId, true)).get(); assertBusy(() -> { final ClusterAllocationExplanation explanation = clusterAdmin().prepareAllocationExplain() @@ -611,7 +611,7 @@ public class RemoveCorruptedShardDataCommandIT extends ESIntegTestCase { } private Path getPathToShardData(String indexName, String dirSuffix) { - ClusterState state = client().admin().cluster().prepareState().get().getState(); + ClusterState state = clusterAdmin().prepareState().get().getState(); GroupShardsIterator shardIterators = state.getRoutingTable() .activePrimaryShardsGrouped(new String[] { indexName }, false); List iterators = iterableAsArrayList(shardIterators); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/index/store/ExceptionRetryIT.java b/server/src/internalClusterTest/java/org/elasticsearch/index/store/ExceptionRetryIT.java index cd4e91df9863..8b1c44703569 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/index/store/ExceptionRetryIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/index/store/ExceptionRetryIT.java @@ -67,7 +67,7 @@ public class ExceptionRetryIT extends ESIntegTestCase { final AtomicBoolean exceptionThrown = new AtomicBoolean(false); int numDocs = scaledRandomIntBetween(100, 1000); Client client = internalCluster().coordOnlyNodeClient(); - NodesStatsResponse nodeStats = client().admin().cluster().prepareNodesStats().get(); + NodesStatsResponse nodeStats = clusterAdmin().prepareNodesStats().get(); NodeStats unluckyNode = randomFrom(nodeStats.getNodes().stream().filter((s) -> s.getNode().canContainData()).toList()); assertAcked(indicesAdmin().prepareCreate("index").setSettings(indexSettings(5, 1))); ensureGreen("index"); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/index/suggest/stats/SuggestStatsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/index/suggest/stats/SuggestStatsIT.java index e7f761b41602..95846fcb5559 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/index/suggest/stats/SuggestStatsIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/index/suggest/stats/SuggestStatsIT.java @@ -105,7 +105,7 @@ public class SuggestStatsIT extends ESIntegTestCase { // the upperbound is num shards * total time since we do searches in parallel assertThat(suggest.getSuggestTimeInMillis(), lessThanOrEqualTo(totalShards * (endTime - startTime))); - NodesStatsResponse nodeStats = client().admin().cluster().prepareNodesStats().execute().actionGet(); + NodesStatsResponse nodeStats = clusterAdmin().prepareNodesStats().execute().actionGet(); Set nodeIdsWithIndex = nodeIdsWithIndex("test1", "test2"); int num = 0; for (NodeStats stat : nodeStats.getNodes()) { @@ -138,7 +138,7 @@ public class SuggestStatsIT extends ESIntegTestCase { } private Set nodeIdsWithIndex(String... indices) { - ClusterState state = client().admin().cluster().prepareState().execute().actionGet().getState(); + ClusterState state = clusterAdmin().prepareState().execute().actionGet().getState(); GroupShardsIterator allAssignedShardsGrouped = state.routingTable().allAssignedShardsGrouped(indices, true); Set nodes = new HashSet<>(); for (ShardIterator shardIterator : allAssignedShardsGrouped) { @@ -153,7 +153,7 @@ public class SuggestStatsIT extends ESIntegTestCase { } protected int numAssignedShards(String... indices) { - ClusterState state = client().admin().cluster().prepareState().execute().actionGet().getState(); + ClusterState state = clusterAdmin().prepareState().execute().actionGet().getState(); GroupShardsIterator allAssignedShardsGrouped = state.routingTable().allAssignedShardsGrouped(indices, true); return allAssignedShardsGrouped.size(); } diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indexlifecycle/IndexLifecycleActionIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indexlifecycle/IndexLifecycleActionIT.java index df29260508e6..9cef9becd6aa 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/indexlifecycle/IndexLifecycleActionIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/indexlifecycle/IndexLifecycleActionIT.java @@ -57,7 +57,7 @@ public class IndexLifecycleActionIT extends ESIntegTestCase { CreateIndexResponse createIndexResponse = indicesAdmin().create(new CreateIndexRequest("test").settings(settings)).actionGet(); assertAcked(createIndexResponse); - ClusterState clusterState = client().admin().cluster().prepareState().get().getState(); + ClusterState clusterState = clusterAdmin().prepareState().get().getState(); RoutingNode routingNodeEntry1 = clusterState.getRoutingNodes().node(node1); assertThat(routingNodeEntry1.numberOfShardsWithState(STARTED), equalTo(11)); @@ -79,7 +79,7 @@ public class IndexLifecycleActionIT extends ESIntegTestCase { final String node2 = getLocalNodeId(server_2); // explicitly call reroute, so shards will get relocated to the new node (we delay it in ES in case other nodes join) - client().admin().cluster().prepareReroute().execute().actionGet(); + clusterAdmin().prepareReroute().execute().actionGet(); clusterHealth = clusterAdmin().health( new ClusterHealthRequest(new String[] {}).waitForGreenStatus().waitForNodes("2").waitForNoRelocatingShards(true) @@ -93,7 +93,7 @@ public class IndexLifecycleActionIT extends ESIntegTestCase { assertThat(clusterHealth.getActiveShards(), equalTo(22)); assertThat(clusterHealth.getActivePrimaryShards(), equalTo(11)); - clusterState = client().admin().cluster().prepareState().get().getState(); + clusterState = clusterAdmin().prepareState().get().getState(); assertNodesPresent(clusterState.getRoutingNodes(), node1, node2); routingNodeEntry1 = clusterState.getRoutingNodes().node(node1); assertThat(routingNodeEntry1.numberOfShardsWithState(RELOCATING), equalTo(0)); @@ -120,7 +120,7 @@ public class IndexLifecycleActionIT extends ESIntegTestCase { final String node3 = getLocalNodeId(server_3); // explicitly call reroute, so shards will get relocated to the new node (we delay it in ES in case other nodes join) - client().admin().cluster().prepareReroute().execute().actionGet(); + clusterAdmin().prepareReroute().execute().actionGet(); clusterHealth = clusterAdmin().prepareHealth() .setWaitForGreenStatus() @@ -137,7 +137,7 @@ public class IndexLifecycleActionIT extends ESIntegTestCase { assertThat(clusterHealth.getActiveShards(), equalTo(22)); assertThat(clusterHealth.getActivePrimaryShards(), equalTo(11)); - clusterState = client().admin().cluster().prepareState().get().getState(); + clusterState = clusterAdmin().prepareState().get().getState(); assertNodesPresent(clusterState.getRoutingNodes(), node1, node2, node3); routingNodeEntry1 = clusterState.getRoutingNodes().node(node1); @@ -174,7 +174,7 @@ public class IndexLifecycleActionIT extends ESIntegTestCase { assertThat(clusterHealth.isTimedOut(), equalTo(false)); assertThat(clusterHealth.getStatus(), equalTo(ClusterHealthStatus.GREEN)); - client().admin().cluster().prepareReroute().get(); + clusterAdmin().prepareReroute().get(); clusterHealth = clusterAdmin().prepareHealth() .setWaitForGreenStatus() @@ -188,7 +188,7 @@ public class IndexLifecycleActionIT extends ESIntegTestCase { assertThat(clusterHealth.getActiveShards(), equalTo(22)); assertThat(clusterHealth.getActivePrimaryShards(), equalTo(11)); - clusterState = client().admin().cluster().prepareState().get().getState(); + clusterState = clusterAdmin().prepareState().get().getState(); assertNodesPresent(clusterState.getRoutingNodes(), node3, node2); routingNodeEntry2 = clusterState.getRoutingNodes().node(node2); routingNodeEntry3 = clusterState.getRoutingNodes().node(node3); @@ -206,7 +206,7 @@ public class IndexLifecycleActionIT extends ESIntegTestCase { AcknowledgedResponse deleteIndexResponse = indicesAdmin().prepareDelete("test").execute().actionGet(); assertThat(deleteIndexResponse.isAcknowledged(), equalTo(true)); - clusterState = client().admin().cluster().prepareState().get().getState(); + clusterState = clusterAdmin().prepareState().get().getState(); assertNodesPresent(clusterState.getRoutingNodes(), node3, node2); routingNodeEntry2 = clusterState.getRoutingNodes().node(node2); assertThat(routingNodeEntry2.isEmpty(), equalTo(true)); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/DateMathIndexExpressionsIntegrationIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/DateMathIndexExpressionsIntegrationIT.java index 0aab131bc5aa..cbe7af4d05d9 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/indices/DateMathIndexExpressionsIntegrationIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/DateMathIndexExpressionsIntegrationIT.java @@ -169,7 +169,7 @@ public class DateMathIndexExpressionsIntegrationIT extends ESIntegTestCase { assertEquals(dateMathExp2, getSettingsResponse.getSetting(index2, IndexMetadata.SETTING_INDEX_PROVIDED_NAME)); assertEquals(dateMathExp3, getSettingsResponse.getSetting(index3, IndexMetadata.SETTING_INDEX_PROVIDED_NAME)); - ClusterState clusterState = client().admin().cluster().prepareState().get().getState(); + ClusterState clusterState = clusterAdmin().prepareState().get().getState(); assertThat(clusterState.metadata().index(index1), notNullValue()); assertThat(clusterState.metadata().index(index2), notNullValue()); assertThat(clusterState.metadata().index(index3), notNullValue()); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/IndicesLifecycleListenerIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/IndicesLifecycleListenerIT.java index 0e86c1fc4fed..0caf5e569ab0 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/indices/IndicesLifecycleListenerIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/IndicesLifecycleListenerIT.java @@ -99,7 +99,7 @@ public class IndicesLifecycleListenerIT extends ESIntegTestCase { fail("should have thrown an exception during creation"); } catch (Exception e) { assertTrue(e.getMessage().contains("failing on purpose")); - ClusterStateResponse resp = client().admin().cluster().prepareState().get(); + ClusterStateResponse resp = clusterAdmin().prepareState().get(); assertFalse(resp.getState().routingTable().indicesRouting().keySet().contains("failed")); } } @@ -120,9 +120,9 @@ public class IndicesLifecycleListenerIT extends ESIntegTestCase { throw new RuntimeException("FAIL"); } }); - client().admin().cluster().prepareReroute().add(new MoveAllocationCommand("index1", 0, node1, node2)).get(); + clusterAdmin().prepareReroute().add(new MoveAllocationCommand("index1", 0, node1, node2)).get(); ensureGreen("index1"); - ClusterState state = client().admin().cluster().prepareState().get().getState(); + ClusterState state = clusterAdmin().prepareState().get().getState(); List shard = RoutingNodesHelper.shardsWithState(state.getRoutingNodes(), ShardRoutingState.STARTED); assertThat(shard, hasSize(1)); assertThat(state.nodes().resolveNode(shard.get(0).currentNodeId()).getName(), Matchers.equalTo(node1)); @@ -160,7 +160,7 @@ public class IndicesLifecycleListenerIT extends ESIntegTestCase { fail("should have thrown an exception"); } catch (ElasticsearchException e) { assertTrue(e.getMessage().contains("failing on purpose")); - ClusterStateResponse resp = client().admin().cluster().prepareState().get(); + ClusterStateResponse resp = clusterAdmin().prepareState().get(); assertFalse(resp.getState().routingTable().indicesRouting().keySet().contains("failed")); } diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/IndicesOptionsIntegrationIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/IndicesOptionsIntegrationIT.java index c50f77e91ecc..4e3464eac749 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/indices/IndicesOptionsIntegrationIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/IndicesOptionsIntegrationIT.java @@ -253,7 +253,7 @@ public class IndicesOptionsIntegrationIT extends ESIntegTestCase { .setSettings(Settings.builder().put("location", randomRepoPath())) .get(); assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true)); - client().admin().cluster().prepareCreateSnapshot("dummy-repo", "snap1").setWaitForCompletion(true).get(); + clusterAdmin().prepareCreateSnapshot("dummy-repo", "snap1").setWaitForCompletion(true).get(); verify(snapshot("snap2", "test1", "test2"), true); verify(restore("snap1", "test1", "test2"), true); @@ -370,7 +370,7 @@ public class IndicesOptionsIntegrationIT extends ESIntegTestCase { .setSettings(Settings.builder().put("location", randomRepoPath())) .get(); assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true)); - client().admin().cluster().prepareCreateSnapshot("dummy-repo", "snap1").setWaitForCompletion(true).get(); + clusterAdmin().prepareCreateSnapshot("dummy-repo", "snap1").setWaitForCompletion(true).get(); IndicesOptions options = IndicesOptions.fromOptions(false, false, true, false); verify(snapshot("snap2", "foo*", "bar*").setIndicesOptions(options), true); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/cluster/ShardLockFailureIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/cluster/ShardLockFailureIT.java index 18a12fa798b3..488641c85356 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/indices/cluster/ShardLockFailureIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/cluster/ShardLockFailureIT.java @@ -108,7 +108,7 @@ public class ShardLockFailureIT extends ESIntegTestCase { updateIndexSettings(Settings.builder().putNull(IndexMetadata.INDEX_ROUTING_EXCLUDE_GROUP_PREFIX + "._name"), indexName); ensureYellow(indexName); assertTrue(countDownLatch.await(30, TimeUnit.SECONDS)); - assertEquals(ClusterHealthStatus.YELLOW, client().admin().cluster().prepareHealth(indexName).get().getStatus()); + assertEquals(ClusterHealthStatus.YELLOW, clusterAdmin().prepareHealth(indexName).get().getStatus()); mockLogAppender.assertAllExpectationsMatched(); } @@ -167,7 +167,7 @@ public class ShardLockFailureIT extends ESIntegTestCase { assertEquals(1, clusterHealthResponse.getUnassignedShards()); } - assertAcked(client().admin().cluster().prepareReroute().setRetryFailed(true)); + assertAcked(clusterAdmin().prepareReroute().setRetryFailed(true)); ensureGreen(indexName); } } diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java index fde60f8f4fa5..5e1e81945c17 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/mapping/UpdateMappingIntegrationIT.java @@ -104,7 +104,7 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase { indicesAdmin().prepareCreate("test").setSettings(indexSettings(1, 0)).setMapping(""" {"properties":{"body":{"type":"text"}}} """).execute().actionGet(); - client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet(); + clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet(); AcknowledgedResponse putMappingResponse = indicesAdmin().preparePutMapping("test").setSource(""" {"properties":{"date":{"type":"integer"}}} @@ -119,7 +119,7 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase { public void testUpdateMappingWithoutTypeMultiObjects() { createIndex("test", 1, 0); - client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet(); + clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet(); AcknowledgedResponse putMappingResponse = indicesAdmin().preparePutMapping("test").setSource(""" {"properties":{"date":{"type":"integer"}}}""", XContentType.JSON).execute().actionGet(); @@ -135,7 +135,7 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase { indicesAdmin().prepareCreate("test").setSettings(indexSettings(2, 0)).setMapping(""" {"properties":{"body":{"type":"text"}}} """).execute().actionGet(); - client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet(); + clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet(); try { indicesAdmin().preparePutMapping("test").setSource(""" @@ -167,7 +167,7 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase { public void testUpdateMappingNoChanges() { indicesAdmin().prepareCreate("test").setSettings(indexSettings(2, 0)).setMapping(""" {"properties":{"body":{"type":"text"}}}""").execute().actionGet(); - client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet(); + clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet(); AcknowledgedResponse putMappingResponse = indicesAdmin().preparePutMapping("test").setSource(""" {"_doc":{"properties":{"body":{"type":"text"}}}} diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerServiceIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerServiceIT.java index 072cd2fe9414..a1068654daef 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerServiceIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/memory/breaker/CircuitBreakerServiceIT.java @@ -93,7 +93,7 @@ public class CircuitBreakerServiceIT extends ESIntegTestCase { /** Returns true if any of the nodes used a noop breaker */ private boolean noopBreakerUsed() { - NodesStatsResponse stats = client().admin().cluster().prepareNodesStats().setBreaker(true).get(); + NodesStatsResponse stats = clusterAdmin().prepareNodesStats().setBreaker(true).get(); for (NodeStats nodeStats : stats.getNodes()) { if (nodeStats.getBreaker().getStats(CircuitBreaker.REQUEST).getLimit() == NoopCircuitBreaker.LIMIT) { return true; diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/memory/breaker/RandomExceptionCircuitBreakerIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/memory/breaker/RandomExceptionCircuitBreakerIT.java index 18ed73b50be8..1e8f5b7f1f5e 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/indices/memory/breaker/RandomExceptionCircuitBreakerIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/memory/breaker/RandomExceptionCircuitBreakerIT.java @@ -61,7 +61,7 @@ public class RandomExceptionCircuitBreakerIT extends ESIntegTestCase { } public void testBreakerWithRandomExceptions() throws IOException, InterruptedException, ExecutionException { - for (NodeStats node : client().admin().cluster().prepareNodesStats().clear().setBreaker(true).execute().actionGet().getNodes()) { + for (NodeStats node : clusterAdmin().prepareNodesStats().clear().setBreaker(true).execute().actionGet().getNodes()) { assertThat("Breaker is not set to 0", node.getBreaker().getStats(CircuitBreaker.FIELDDATA).getEstimated(), equalTo(0L)); } @@ -146,7 +146,7 @@ public class RandomExceptionCircuitBreakerIT extends ESIntegTestCase { refreshResponse.getTotalShards() ); final int numSearches = scaledRandomIntBetween(50, 150); - NodesStatsResponse resp = client().admin().cluster().prepareNodesStats().clear().setBreaker(true).execute().actionGet(); + NodesStatsResponse resp = clusterAdmin().prepareNodesStats().clear().setBreaker(true).execute().actionGet(); for (NodeStats stats : resp.getNodes()) { assertThat("Breaker is set to 0", stats.getBreaker().getStats(CircuitBreaker.FIELDDATA).getEstimated(), equalTo(0L)); } @@ -181,13 +181,7 @@ public class RandomExceptionCircuitBreakerIT extends ESIntegTestCase { // Clean up the cache, ensuring that entries' listeners have been called fdCache.getCache().refresh(); } - NodesStatsResponse nodeStats = client().admin() - .cluster() - .prepareNodesStats() - .clear() - .setBreaker(true) - .execute() - .actionGet(); + NodesStatsResponse nodeStats = clusterAdmin().prepareNodesStats().clear().setBreaker(true).execute().actionGet(); for (NodeStats stats : nodeStats.getNodes()) { assertThat( "Breaker reset to 0 last search success: " + success + " mapping: " + mapping, diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/DanglingIndicesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/DanglingIndicesIT.java index dff0c7856db3..1b330e19f62e 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/DanglingIndicesIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/DanglingIndicesIT.java @@ -95,10 +95,7 @@ public class DanglingIndicesIT extends ESIntegTestCase { final String stoppedNodeName = createDanglingIndices(INDEX_NAME); - final ListDanglingIndicesResponse response = client().admin() - .cluster() - .listDanglingIndices(new ListDanglingIndicesRequest()) - .actionGet(); + final ListDanglingIndicesResponse response = clusterAdmin().listDanglingIndices(new ListDanglingIndicesRequest()).actionGet(); assertThat(response.status(), equalTo(RestStatus.OK)); final List nodeResponses = response.getNodes(); @@ -234,10 +231,7 @@ public class DanglingIndicesIT extends ESIntegTestCase { danglingIndices.set(results); // Try to delete the index - this request should succeed - client().admin() - .cluster() - .deleteDanglingIndex(new DeleteDanglingIndexRequest(danglingIndices.get().get(0).getIndexUUID(), true)) - .actionGet(); + clusterAdmin().deleteDanglingIndex(new DeleteDanglingIndexRequest(danglingIndices.get().get(0).getIndexUUID(), true)).actionGet(); // The dangling index that we deleted ought to have been removed from disk. Check by // creating and deleting another index, which creates a new tombstone entry, which should @@ -337,10 +331,7 @@ public class DanglingIndicesIT extends ESIntegTestCase { * Helper that fetches the current list of dangling indices. */ private List listDanglingIndices() { - final ListDanglingIndicesResponse response = client().admin() - .cluster() - .listDanglingIndices(new ListDanglingIndicesRequest()) - .actionGet(); + final ListDanglingIndicesResponse response = clusterAdmin().listDanglingIndices(new ListDanglingIndicesRequest()).actionGet(); assertThat(response.status(), equalTo(RestStatus.OK)); final List nodeResponses = response.getNodes(); @@ -404,10 +395,7 @@ public class DanglingIndicesIT extends ESIntegTestCase { private String findDanglingIndexForNode(String stoppedNodeName, String indexName) { String danglingIndexUUID = null; - final ListDanglingIndicesResponse response = client().admin() - .cluster() - .listDanglingIndices(new ListDanglingIndicesRequest()) - .actionGet(); + final ListDanglingIndicesResponse response = clusterAdmin().listDanglingIndices(new ListDanglingIndicesRequest()).actionGet(); assertThat(response.status(), equalTo(RestStatus.OK)); final List nodeResponses = response.getNodes(); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/IndexPrimaryRelocationIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/IndexPrimaryRelocationIT.java index 731681fd26b3..b41b4727dc12 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/IndexPrimaryRelocationIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/IndexPrimaryRelocationIT.java @@ -52,7 +52,7 @@ public class IndexPrimaryRelocationIT extends ESIntegTestCase { }; indexingThread.start(); - ClusterState initialState = client().admin().cluster().prepareState().get().getState(); + ClusterState initialState = clusterAdmin().prepareState().get().getState(); DiscoveryNode[] dataNodes = initialState.getNodes().getDataNodes().values().toArray(DiscoveryNode[]::new); DiscoveryNode relocationSource = initialState.getNodes() .getDataNodes() @@ -63,31 +63,25 @@ public class IndexPrimaryRelocationIT extends ESIntegTestCase { relocationTarget = randomFrom(dataNodes); } logger.info("--> [iteration {}] relocating from {} to {} ", i, relocationSource.getName(), relocationTarget.getName()); - client().admin() - .cluster() - .prepareReroute() + clusterAdmin().prepareReroute() .add(new MoveAllocationCommand("test", 0, relocationSource.getId(), relocationTarget.getId())) .execute() .actionGet(); - ClusterHealthResponse clusterHealthResponse = client().admin() - .cluster() - .prepareHealth() + ClusterHealthResponse clusterHealthResponse = clusterAdmin().prepareHealth() .setTimeout(TimeValue.timeValueSeconds(60)) .setWaitForEvents(Priority.LANGUID) .setWaitForNoRelocatingShards(true) .execute() .actionGet(); if (clusterHealthResponse.isTimedOut()) { - final String hotThreads = client().admin() - .cluster() - .prepareNodesHotThreads() + final String hotThreads = clusterAdmin().prepareNodesHotThreads() .setIgnoreIdleThreads(false) .get() .getNodes() .stream() .map(NodeHotThreads::getHotThreads) .collect(Collectors.joining("\n")); - final ClusterState clusterState = client().admin().cluster().prepareState().get().getState(); + final ClusterState clusterState = clusterAdmin().prepareState().get().getState(); logger.info( "timed out for waiting for relocation iteration [{}] \ncluster state {} \nhot threads {}", i, diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java index 0ae89ebd06a7..ae0bcfff992f 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/IndexRecoveryIT.java @@ -420,7 +420,7 @@ public class IndexRecoveryIT extends AbstractIndexRecoveryIntegTestCase { transportService.clearAllRules(); // make sure nodeA has primary and nodeB has replica - ClusterState state = client().admin().cluster().prepareState().get().getState(); + ClusterState state = clusterAdmin().prepareState().get().getState(); List startedShards = RoutingNodesHelper.shardsWithState(state.getRoutingNodes(), ShardRoutingState.STARTED); assertThat(startedShards.size(), equalTo(2)); for (ShardRouting shardRouting : startedShards) { @@ -450,13 +450,7 @@ public class IndexRecoveryIT extends AbstractIndexRecoveryIntegTestCase { slowDownRecovery(shardSize); logger.info("--> move shard from: {} to: {}", nodeA, nodeB); - client().admin() - .cluster() - .prepareReroute() - .add(new MoveAllocationCommand(INDEX_NAME, 0, nodeA, nodeB)) - .execute() - .actionGet() - .getState(); + clusterAdmin().prepareReroute().add(new MoveAllocationCommand(INDEX_NAME, 0, nodeA, nodeB)).execute().actionGet().getState(); logger.info("--> waiting for recovery to start both on source and target"); final Index index = resolveIndex(INDEX_NAME); @@ -483,9 +477,7 @@ public class IndexRecoveryIT extends AbstractIndexRecoveryIntegTestCase { validateIndexRecoveryState(nodeBRecoveryStates.get(0).getIndex()); logger.info("--> request node recovery stats"); - NodesStatsResponse statsResponse = client().admin() - .cluster() - .prepareNodesStats() + NodesStatsResponse statsResponse = clusterAdmin().prepareNodesStats() .clear() .setIndices(new CommonStatsFlags(CommonStatsFlags.Flag.Recovery)) .get(); @@ -509,9 +501,7 @@ public class IndexRecoveryIT extends AbstractIndexRecoveryIntegTestCase { final long finalNodeAThrottling = nodeAThrottling; final long finalNodeBThrottling = nodeBThrottling; assertBusy(() -> { - NodesStatsResponse statsResponse1 = client().admin() - .cluster() - .prepareNodesStats() + NodesStatsResponse statsResponse1 = clusterAdmin().prepareNodesStats() .clear() .setIndices(new CommonStatsFlags(CommonStatsFlags.Flag.Recovery)) .get(); @@ -549,9 +539,7 @@ public class IndexRecoveryIT extends AbstractIndexRecoveryIntegTestCase { assertRecoveryState(recoveryStates.get(0), 0, PeerRecoverySource.INSTANCE, true, Stage.DONE, nodeA, nodeB); validateIndexRecoveryState(recoveryStates.get(0).getIndex()); Consumer assertNodeHasThrottleTimeAndNoRecoveries = nodeName -> { - NodesStatsResponse nodesStatsResponse = client().admin() - .cluster() - .prepareNodesStats() + NodesStatsResponse nodesStatsResponse = clusterAdmin().prepareNodesStats() .setNodesIds(nodeName) .clear() .setIndices(new CommonStatsFlags(CommonStatsFlags.Flag.Recovery)) @@ -577,19 +565,13 @@ public class IndexRecoveryIT extends AbstractIndexRecoveryIntegTestCase { logger.info("--> start node C"); String nodeC = internalCluster().startNode(); - assertFalse(client().admin().cluster().prepareHealth().setWaitForNodes("3").get().isTimedOut()); + assertFalse(clusterAdmin().prepareHealth().setWaitForNodes("3").get().isTimedOut()); logger.info("--> slowing down recoveries"); slowDownRecovery(shardSize); logger.info("--> move replica shard from: {} to: {}", nodeA, nodeC); - client().admin() - .cluster() - .prepareReroute() - .add(new MoveAllocationCommand(INDEX_NAME, 0, nodeA, nodeC)) - .execute() - .actionGet() - .getState(); + clusterAdmin().prepareReroute().add(new MoveAllocationCommand(INDEX_NAME, 0, nodeA, nodeC)).execute().actionGet().getState(); response = indicesAdmin().prepareRecoveries(INDEX_NAME).execute().actionGet(); recoveryStates = response.shardRecoveryStates().get(INDEX_NAME); @@ -673,9 +655,7 @@ public class IndexRecoveryIT extends AbstractIndexRecoveryIntegTestCase { indicesAdmin().prepareClose(INDEX_NAME).execute().actionGet(); logger.info("--> restore"); - RestoreSnapshotResponse restoreSnapshotResponse = client().admin() - .cluster() - .prepareRestoreSnapshot(REPO_NAME, SNAP_NAME) + RestoreSnapshotResponse restoreSnapshotResponse = clusterAdmin().prepareRestoreSnapshot(REPO_NAME, SNAP_NAME) .setWaitForCompletion(true) .execute() .actionGet(); @@ -941,7 +921,7 @@ public class IndexRecoveryIT extends AbstractIndexRecoveryIntegTestCase { Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 2).putNull("index.routing.allocation.include._name"), indexName ); - assertFalse(client().admin().cluster().prepareHealth(indexName).setWaitForActiveShards(2).get().isTimedOut()); + assertFalse(clusterAdmin().prepareHealth(indexName).setWaitForActiveShards(2).get().isTimedOut()); } finally { allowToCompletePhase1Latch.countDown(); } @@ -1086,9 +1066,7 @@ public class IndexRecoveryIT extends AbstractIndexRecoveryIntegTestCase { @Override public Settings onNodeStopped(String nodeName) throws Exception { assertFalse( - client().admin() - .cluster() - .prepareHealth() + clusterAdmin().prepareHealth() .setWaitForNodes(Integer.toString(discoveryNodes.getSize() - 1)) .setWaitForEvents(Priority.LANGUID) .get() @@ -1152,9 +1130,7 @@ public class IndexRecoveryIT extends AbstractIndexRecoveryIntegTestCase { @Override public Settings onNodeStopped(String nodeName) throws Exception { assertFalse( - client().admin() - .cluster() - .prepareHealth() + clusterAdmin().prepareHealth() .setWaitForNodes(Integer.toString(discoveryNodes.getSize() - 1)) .setWaitForEvents(Priority.LANGUID) .get() @@ -1263,9 +1239,7 @@ public class IndexRecoveryIT extends AbstractIndexRecoveryIntegTestCase { @Override public Settings onNodeStopped(String nodeName) throws Exception { assertFalse( - client().admin() - .cluster() - .prepareHealth() + clusterAdmin().prepareHealth() .setWaitForNodes(Integer.toString(discoveryNodes.getSize() - 1)) .setWaitForEvents(Priority.LANGUID) .get() @@ -1482,11 +1456,7 @@ public class IndexRecoveryIT extends AbstractIndexRecoveryIntegTestCase { internalCluster().stopRandomDataNode(); final String nodeWithoutData = internalCluster().startDataOnlyNode(); assertAcked( - client().admin() - .cluster() - .prepareReroute() - .add(new AllocateEmptyPrimaryAllocationCommand(indexName, 0, nodeWithoutData, true)) - .get() + clusterAdmin().prepareReroute().add(new AllocateEmptyPrimaryAllocationCommand(indexName, 0, nodeWithoutData, true)).get() ); internalCluster().startDataOnlyNode(randomNodeDataPathSettings); ensureGreen(); @@ -1503,7 +1473,7 @@ public class IndexRecoveryIT extends AbstractIndexRecoveryIntegTestCase { String indexName = "test-index"; createIndex(indexName, indexSettings(1, 1).put("index.routing.allocation.include._name", String.join(",", dataNodes)).build()); ensureGreen(indexName); - ClusterState clusterState = client().admin().cluster().prepareState().get().getState(); + ClusterState clusterState = clusterAdmin().prepareState().get().getState(); DiscoveryNode nodeWithOldPrimary = clusterState.nodes() .get(clusterState.routingTable().index(indexName).shard(0).primaryShard().currentNodeId()); MockTransportService transportService = (MockTransportService) internalCluster().getInstance( @@ -1558,7 +1528,7 @@ public class IndexRecoveryIT extends AbstractIndexRecoveryIntegTestCase { ); internalCluster().startNode(); internalCluster().startNode(); - client().admin().cluster().prepareReroute().setRetryFailed(true).get(); + clusterAdmin().prepareReroute().setRetryFailed(true).get(); assertAcked(indicesAdmin().prepareDelete("test")); // cancel recoveries assertBusy(() -> { for (PeerRecoverySourceService recoveryService : internalCluster().getDataNodeInstances(PeerRecoverySourceService.class)) { @@ -1579,7 +1549,7 @@ public class IndexRecoveryIT extends AbstractIndexRecoveryIntegTestCase { indexRandom(randomBoolean(), true, true, indexRequests); assertThat(indicesAdmin().prepareFlush(indexName).get().getFailedShards(), equalTo(0)); - ClusterState clusterState = client().admin().cluster().prepareState().get().getState(); + ClusterState clusterState = clusterAdmin().prepareState().get().getState(); DiscoveryNode nodeWithPrimary = clusterState.nodes() .get(clusterState.routingTable().index(indexName).shard(0).primaryShard().currentNodeId()); MockTransportService transportService = (MockTransportService) internalCluster().getInstance( @@ -1592,9 +1562,7 @@ public class IndexRecoveryIT extends AbstractIndexRecoveryIntegTestCase { transportService.addSendBehavior((connection, requestId, action, request, options) -> { if (action.equals(PeerRecoveryTargetService.Actions.FILES_INFO)) { if (fileInfoIntercepted.compareAndSet(false, true)) { - final NodeIndicesStats nodeIndicesStats = client().admin() - .cluster() - .prepareNodesStats(connection.getNode().getId()) + final NodeIndicesStats nodeIndicesStats = clusterAdmin().prepareNodesStats(connection.getNode().getId()) .clear() .setIndices(new CommonStatsFlags(CommonStatsFlags.Flag.Store)) .get() @@ -1614,9 +1582,7 @@ public class IndexRecoveryIT extends AbstractIndexRecoveryIntegTestCase { } else if (action.equals(PeerRecoveryTargetService.Actions.FILE_CHUNK)) { if (fileChunkIntercepted.compareAndSet(false, true)) { assertThat( - client().admin() - .cluster() - .prepareNodesStats(connection.getNode().getId()) + clusterAdmin().prepareNodesStats(connection.getNode().getId()) .clear() .setIndices(new CommonStatsFlags(CommonStatsFlags.Flag.Store)) .get() @@ -1639,9 +1605,7 @@ public class IndexRecoveryIT extends AbstractIndexRecoveryIntegTestCase { assertTrue(fileChunkIntercepted.get()); assertThat( - client().admin() - .cluster() - .prepareNodesStats() + clusterAdmin().prepareNodesStats() .get() .getNodes() .stream() @@ -1670,9 +1634,7 @@ public class IndexRecoveryIT extends AbstractIndexRecoveryIntegTestCase { private void createRepository(boolean enableSnapshotPeerRecoveries) { assertAcked( - client().admin() - .cluster() - .preparePutRepository(REPO_NAME) + clusterAdmin().preparePutRepository(REPO_NAME) .setType("fs") .setSettings( Settings.builder() @@ -1685,9 +1647,7 @@ public class IndexRecoveryIT extends AbstractIndexRecoveryIntegTestCase { } private CreateSnapshotResponse createSnapshot(String indexName) { - CreateSnapshotResponse createSnapshotResponse = client().admin() - .cluster() - .prepareCreateSnapshot(REPO_NAME, SNAP_NAME) + CreateSnapshotResponse createSnapshotResponse = clusterAdmin().prepareCreateSnapshot(REPO_NAME, SNAP_NAME) .setWaitForCompletion(true) .setIndices(indexName) .get(); @@ -1698,7 +1658,7 @@ public class IndexRecoveryIT extends AbstractIndexRecoveryIntegTestCase { ); assertThat( - client().admin().cluster().prepareGetSnapshots(REPO_NAME).setSnapshots(SNAP_NAME).get().getSnapshots().get(0).state(), + clusterAdmin().prepareGetSnapshots(REPO_NAME).setSnapshots(SNAP_NAME).get().getSnapshots().get(0).state(), equalTo(SnapshotState.SUCCESS) ); return createSnapshotResponse; diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/TaskRecoveryIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/TaskRecoveryIT.java index 1d9a591e005f..579ffea31ca6 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/TaskRecoveryIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/TaskRecoveryIT.java @@ -67,16 +67,12 @@ public class TaskRecoveryIT extends ESIntegTestCase { ); // Translog recovery is stalled, so we can inspect the running tasks. assertBusy(() -> { - List primaryTasks = client().admin() - .cluster() - .prepareListTasks(nodeWithPrimary) + List primaryTasks = clusterAdmin().prepareListTasks(nodeWithPrimary) .setActions(PeerRecoverySourceService.Actions.START_RECOVERY) .get() .getTasks(); assertThat("Expected a single primary task", primaryTasks.size(), equalTo(1)); - List replicaTasks = client().admin() - .cluster() - .prepareListTasks(nodeWithReplica) + List replicaTasks = clusterAdmin().prepareListTasks(nodeWithReplica) .setActions(PeerRecoveryTargetService.Actions.PREPARE_TRANSLOG) .get() .getTasks(); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/plan/ShardSnapshotsServiceIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/plan/ShardSnapshotsServiceIT.java index 3ffd81d1ed96..f95c4cc3ee62 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/plan/ShardSnapshotsServiceIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/recovery/plan/ShardSnapshotsServiceIT.java @@ -241,9 +241,7 @@ public class ShardSnapshotsServiceIT extends ESIntegTestCase { ); assertAcked( - client().admin() - .cluster() - .preparePutRepository(failingRepo.v1()) + clusterAdmin().preparePutRepository(failingRepo.v1()) .setType(FailingRepoPlugin.TYPE) .setVerify(false) .setSettings(Settings.builder().put(repoFailureType, true).put("location", failingRepo.v2())) @@ -319,9 +317,7 @@ public class ShardSnapshotsServiceIT extends ESIntegTestCase { private void createRepository(String repositoryName, String type, Path location, boolean recoveryEnabledRepo) { assertAcked( - client().admin() - .cluster() - .preparePutRepository(repositoryName) + clusterAdmin().preparePutRepository(repositoryName) .setType(type) .setVerify(false) .setSettings( diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/settings/UpdateNumberOfReplicasIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/settings/UpdateNumberOfReplicasIT.java index d630ec469dca..bf8687dbde2f 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/indices/settings/UpdateNumberOfReplicasIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/settings/UpdateNumberOfReplicasIT.java @@ -180,9 +180,7 @@ public class UpdateNumberOfReplicasIT extends ESIntegTestCase { if (randomBoolean()) { assertAcked(indicesAdmin().prepareClose("test").setWaitForActiveShards(ActiveShardCount.ALL)); - clusterHealth = client().admin() - .cluster() - .prepareHealth() + clusterHealth = clusterAdmin().prepareHealth() .setWaitForEvents(Priority.LANGUID) .setWaitForGreenStatus() .setWaitForActiveShards(numShards.numPrimaries * 2) @@ -303,9 +301,7 @@ public class UpdateNumberOfReplicasIT extends ESIntegTestCase { if (randomBoolean()) { assertAcked(indicesAdmin().prepareClose("test").setWaitForActiveShards(ActiveShardCount.ALL)); - clusterHealth = client().admin() - .cluster() - .prepareHealth() + clusterHealth = clusterAdmin().prepareHealth() .setWaitForEvents(Priority.LANGUID) .setWaitForGreenStatus() .setWaitForActiveShards(numShards.numPrimaries * 2) @@ -439,7 +435,7 @@ public class UpdateNumberOfReplicasIT extends ESIntegTestCase { * time from the number of replicas changed by the allocation service. */ assertThat( - client().admin().cluster().prepareState().get().getState().metadata().index("test").getSettingsVersion(), + clusterAdmin().prepareState().get().getState().metadata().index("test").getSettingsVersion(), equalTo(1 + 1 + settingsVersion) ); } @@ -457,7 +453,7 @@ public class UpdateNumberOfReplicasIT extends ESIntegTestCase { } catch (IllegalArgumentException e) { assertEquals("Failed to parse value [" + value + "] for setting [index.number_of_replicas] must be >= 0", e.getMessage()); assertThat( - client().admin().cluster().prepareState().get().getState().metadata().index("test").getSettingsVersion(), + clusterAdmin().prepareState().get().getState().metadata().index("test").getSettingsVersion(), equalTo(settingsVersion) ); } diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/state/ReopenWhileClosingIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/state/ReopenWhileClosingIT.java index a152821edf72..9c12c00ae76c 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/indices/state/ReopenWhileClosingIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/state/ReopenWhileClosingIT.java @@ -162,7 +162,7 @@ public class ReopenWhileClosingIT extends ESIntegTestCase { } private static void assertIndexIsBlocked(final String... indices) { - final ClusterState clusterState = client().admin().cluster().prepareState().get().getState(); + final ClusterState clusterState = clusterAdmin().prepareState().get().getState(); for (String index : indices) { assertThat(clusterState.metadata().indices().get(index).getState(), is(IndexMetadata.State.OPEN)); assertThat(clusterState.routingTable().index(index), notNullValue()); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/ingest/IngestAsyncProcessorIT.java b/server/src/internalClusterTest/java/org/elasticsearch/ingest/IngestAsyncProcessorIT.java index eac5c092b7ef..9bf33fb5ebb9 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/ingest/IngestAsyncProcessorIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/ingest/IngestAsyncProcessorIT.java @@ -59,7 +59,7 @@ public class IngestAsyncProcessorIT extends ESSingleNodeTestCase { public void testAsyncProcessorImplementation() { // A pipeline with 2 processors: the test async processor and sync test processor. BytesReference pipelineBody = new BytesArray("{\"processors\": [{\"test-async\": {}, \"test\": {}}]}"); - client().admin().cluster().putPipeline(new PutPipelineRequest("_id", pipelineBody, XContentType.JSON)).actionGet(); + clusterAdmin().putPipeline(new PutPipelineRequest("_id", pipelineBody, XContentType.JSON)).actionGet(); BulkRequest bulkRequest = new BulkRequest(); int numDocs = randomIntBetween(8, 256); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/ingest/IngestStatsNamesAndTypesIT.java b/server/src/internalClusterTest/java/org/elasticsearch/ingest/IngestStatsNamesAndTypesIT.java index b96abc92863a..547da987dcb9 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/ingest/IngestStatsNamesAndTypesIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/ingest/IngestStatsNamesAndTypesIT.java @@ -97,7 +97,7 @@ public class IngestStatsNamesAndTypesIT extends ESIntegTestCase { } """, MockScriptEngine.NAME, MockScriptEngine.NAME); BytesReference pipeline1Reference = new BytesArray(pipeline1); - client().admin().cluster().putPipeline(new PutPipelineRequest("pipeline1", pipeline1Reference, XContentType.JSON)).actionGet(); + clusterAdmin().putPipeline(new PutPipelineRequest("pipeline1", pipeline1Reference, XContentType.JSON)).actionGet(); // index a single document through the pipeline BulkRequest bulkRequest = new BulkRequest(); @@ -143,7 +143,7 @@ public class IngestStatsNamesAndTypesIT extends ESIntegTestCase { { // the bits that we want to read from the cluster stats response aren't visible in java code (no getters, // non-public classes and methods), roundtrip through json so that we can read what we want - ClusterStatsResponse response = client().admin().cluster().prepareClusterStats().get(); + ClusterStatsResponse response = clusterAdmin().prepareClusterStats().get(); XContentBuilder builder = XContentFactory.jsonBuilder().prettyPrint(); builder.startObject(); response.toXContent(builder, new ToXContent.MapParams(Map.of())); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/plugins/IndexFoldersDeletionListenerIT.java b/server/src/internalClusterTest/java/org/elasticsearch/plugins/IndexFoldersDeletionListenerIT.java index 4efbec51329c..d3e4b230de28 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/plugins/IndexFoldersDeletionListenerIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/plugins/IndexFoldersDeletionListenerIT.java @@ -73,9 +73,7 @@ public class IndexFoldersDeletionListenerIT extends ESIntegTestCase { final NumShards numShards = getNumShards(indexName); assertFalse( - client().admin() - .cluster() - .prepareHealth() + clusterAdmin().prepareHealth() .setIndices(indexName) .setWaitForGreenStatus() .setWaitForEvents(Priority.LANGUID) @@ -142,9 +140,7 @@ public class IndexFoldersDeletionListenerIT extends ESIntegTestCase { final NumShards numShards = getNumShards(indexName); assertFalse( - client().admin() - .cluster() - .prepareHealth() + clusterAdmin().prepareHealth() .setIndices(indexName) .setWaitForGreenStatus() .setWaitForEvents(Priority.LANGUID) @@ -210,9 +206,7 @@ public class IndexFoldersDeletionListenerIT extends ESIntegTestCase { final NumShards numShards = getNumShards(indexName); assertFalse( - client().admin() - .cluster() - .prepareHealth() + clusterAdmin().prepareHealth() .setIndices(indexName) .setWaitForGreenStatus() .setWaitForEvents(Priority.LANGUID) diff --git a/server/src/internalClusterTest/java/org/elasticsearch/recovery/RestartInactiveAutoExpandReplicaNotStaleIT.java b/server/src/internalClusterTest/java/org/elasticsearch/recovery/RestartInactiveAutoExpandReplicaNotStaleIT.java index 74e3f2ea61af..0b56eb36c08e 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/recovery/RestartInactiveAutoExpandReplicaNotStaleIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/recovery/RestartInactiveAutoExpandReplicaNotStaleIT.java @@ -28,7 +28,7 @@ public class RestartInactiveAutoExpandReplicaNotStaleIT extends ESIntegTestCase ensureGreen(); - ClusterStateResponse clusterStateResponse = client().admin().cluster().prepareState().get(); + ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState().get(); IndexMetadata target = clusterStateResponse.getState().getMetadata().index("test"); internalCluster().restartNode(replica, new InternalTestCluster.RestartCallback() { diff --git a/server/src/internalClusterTest/java/org/elasticsearch/recovery/TruncatedRecoveryIT.java b/server/src/internalClusterTest/java/org/elasticsearch/recovery/TruncatedRecoveryIT.java index 16fad6832d36..1fbfdc44897f 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/recovery/TruncatedRecoveryIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/recovery/TruncatedRecoveryIT.java @@ -59,7 +59,7 @@ public class TruncatedRecoveryIT extends ESIntegTestCase { Settings.builder().put(CHUNK_SIZE_SETTING.getKey(), new ByteSizeValue(randomIntBetween(50, 300), ByteSizeUnit.BYTES)) ); - NodesStatsResponse nodeStats = client().admin().cluster().prepareNodesStats().get(); + NodesStatsResponse nodeStats = clusterAdmin().prepareNodesStats().get(); List dataNodeStats = new ArrayList<>(); for (NodeStats stat : nodeStats.getNodes()) { if (stat.getNode().canContainData()) { diff --git a/server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/ComponentTemplatesFileSettingsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/ComponentTemplatesFileSettingsIT.java index 174078819a00..895cd3d2a01e 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/ComponentTemplatesFileSettingsIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/ComponentTemplatesFileSettingsIT.java @@ -402,10 +402,9 @@ public class ComponentTemplatesFileSettingsIT extends ESIntegTestCase { boolean awaitSuccessful = savedClusterState.await(20, TimeUnit.SECONDS); assertTrue(awaitSuccessful); - final ClusterStateResponse clusterStateResponse = client().admin() - .cluster() - .state(new ClusterStateRequest().waitForMetadataVersion(metadataVersion.get())) - .actionGet(); + final ClusterStateResponse clusterStateResponse = clusterAdmin().state( + new ClusterStateRequest().waitForMetadataVersion(metadataVersion.get()) + ).actionGet(); Map allTemplates = clusterStateResponse.getState().metadata().templatesV2(); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/FileSettingsServiceIT.java b/server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/FileSettingsServiceIT.java index 1294f127b208..cf47fbe95da2 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/FileSettingsServiceIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/reservedstate/service/FileSettingsServiceIT.java @@ -168,10 +168,9 @@ public class FileSettingsServiceIT extends ESIntegTestCase { boolean awaitSuccessful = savedClusterState.await(20, TimeUnit.SECONDS); assertTrue(awaitSuccessful); - final ClusterStateResponse clusterStateResponse = client().admin() - .cluster() - .state(new ClusterStateRequest().waitForMetadataVersion(metadataVersion.get())) - .actionGet(); + final ClusterStateResponse clusterStateResponse = clusterAdmin().state( + new ClusterStateRequest().waitForMetadataVersion(metadataVersion.get()) + ).actionGet(); assertThat( clusterStateResponse.getState().metadata().persistentSettings().get(INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING.getKey()), @@ -185,7 +184,7 @@ public class FileSettingsServiceIT extends ESIntegTestCase { "java.lang.IllegalArgumentException: Failed to process request " + "[org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest/unset] " + "with errors: [[indices.recovery.max_bytes_per_sec] set as read-only by [file_settings]]", - expectThrows(ExecutionException.class, () -> client().admin().cluster().updateSettings(req).get()).getMessage() + expectThrows(ExecutionException.class, () -> clusterAdmin().updateSettings(req).get()).getMessage() ); } @@ -256,7 +255,7 @@ public class FileSettingsServiceIT extends ESIntegTestCase { logger.info("--> restart master"); internalCluster().restartNode(masterNode); - final ClusterStateResponse clusterStateResponse = client().admin().cluster().state(new ClusterStateRequest()).actionGet(); + final ClusterStateResponse clusterStateResponse = clusterAdmin().state(new ClusterStateRequest()).actionGet(); assertEquals( 1, clusterStateResponse.getState() @@ -299,10 +298,9 @@ public class FileSettingsServiceIT extends ESIntegTestCase { boolean awaitSuccessful = savedClusterState.await(20, TimeUnit.SECONDS); assertTrue(awaitSuccessful); - final ClusterStateResponse clusterStateResponse = client().admin() - .cluster() - .state(new ClusterStateRequest().waitForMetadataVersion(metadataVersion.get())) - .actionGet(); + final ClusterStateResponse clusterStateResponse = clusterAdmin().state( + new ClusterStateRequest().waitForMetadataVersion(metadataVersion.get()) + ).actionGet(); assertThat(clusterStateResponse.getState().metadata().persistentSettings().get("search.allow_expensive_queries"), nullValue()); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/rest/discovery/Zen2RestApiIT.java b/server/src/internalClusterTest/java/org/elasticsearch/rest/discovery/Zen2RestApiIT.java index a0b4eae6373e..502f02d9ce17 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/rest/discovery/Zen2RestApiIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/rest/discovery/Zen2RestApiIT.java @@ -51,7 +51,7 @@ public class Zen2RestApiIT extends ESIntegTestCase { ); ensureGreen("test"); - final DiscoveryNodes discoveryNodes = client().admin().cluster().prepareState().clear().setNodes(true).get().getState().nodes(); + final DiscoveryNodes discoveryNodes = clusterAdmin().prepareState().clear().setNodes(true).get().getState().nodes(); final Map nodeIdsByName = Maps.newMapWithExpectedSize(discoveryNodes.getSize()); discoveryNodes.forEach(n -> nodeIdsByName.put(n.getName(), n.getId())); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/routing/AliasResolveRoutingIT.java b/server/src/internalClusterTest/java/org/elasticsearch/routing/AliasResolveRoutingIT.java index 82e1b960eca5..9b1863a67d91 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/routing/AliasResolveRoutingIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/routing/AliasResolveRoutingIT.java @@ -55,7 +55,7 @@ public class AliasResolveRoutingIT extends ESIntegTestCase { public void testResolveIndexRouting() { createIndex("test1"); createIndex("test2"); - client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet(); + clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet(); indicesAdmin().prepareAliases() .addAliasAction(AliasActions.add().index("test1").alias("alias")) @@ -97,7 +97,7 @@ public class AliasResolveRoutingIT extends ESIntegTestCase { createIndex("test1"); createIndex("test2"); createIndex("test3"); - client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet(); + clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet(); indicesAdmin().prepareAliases() .addAliasAction(AliasActions.add().index("test1").alias("alias")) diff --git a/server/src/internalClusterTest/java/org/elasticsearch/routing/SimpleRoutingIT.java b/server/src/internalClusterTest/java/org/elasticsearch/routing/SimpleRoutingIT.java index 242d7b3eaa5a..f1417d2f230a 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/routing/SimpleRoutingIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/routing/SimpleRoutingIT.java @@ -48,7 +48,7 @@ public class SimpleRoutingIT extends ESIntegTestCase { } public String findNonMatchingRoutingValue(String index, String id) { - ClusterState state = client().admin().cluster().prepareState().all().get().getState(); + ClusterState state = clusterAdmin().prepareState().all().get().getState(); IndexMetadata metadata = state.metadata().index(index); IndexMetadata withoutRoutingRequired = IndexMetadata.builder(metadata).putMapping("{}").build(); IndexRouting indexRouting = IndexRouting.fromIndexMetadata(withoutRoutingRequired); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/GeoDistanceIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/GeoDistanceIT.java index b91c481f8e64..0ecb04fe579d 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/GeoDistanceIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/GeoDistanceIT.java @@ -228,7 +228,7 @@ public class GeoDistanceIT extends ESIntegTestCase { } public void testUnmapped() throws Exception { - client().admin().cluster().prepareHealth("idx_unmapped").setWaitForYellowStatus().get(); + clusterAdmin().prepareHealth("idx_unmapped").setWaitForYellowStatus().get(); SearchResponse response = client().prepareSearch("idx_unmapped") .addAggregation( diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/RangeIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/RangeIT.java index 6a09a10b3fac..a3a0f337aa42 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/RangeIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/RangeIT.java @@ -775,7 +775,7 @@ public class RangeIT extends ESIntegTestCase { } public void testPartiallyUnmapped() throws Exception { - client().admin().cluster().prepareHealth("idx_unmapped").setWaitForYellowStatus().get(); + clusterAdmin().prepareHealth("idx_unmapped").setWaitForYellowStatus().get(); SearchResponse response = client().prepareSearch("idx", "idx_unmapped") .addAggregation(range("range").field(SINGLE_VALUED_FIELD_NAME).addUnboundedTo(3).addRange(3, 6).addUnboundedFrom(6)) diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchWhileCreatingIndexIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchWhileCreatingIndexIT.java index f58cac722a8a..b5d1e3a356df 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchWhileCreatingIndexIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchWhileCreatingIndexIT.java @@ -61,7 +61,7 @@ public class SearchWhileCreatingIndexIT extends ESIntegTestCase { logger.info("using preference {}", preference); // we want to make sure that while recovery happens, and a replica gets recovered, its properly refreshed - ClusterHealthStatus status = client().admin().cluster().prepareHealth("test").get().getStatus(); + ClusterHealthStatus status = clusterAdmin().prepareHealth("test").get().getStatus(); while (status != ClusterHealthStatus.GREEN) { // first, verify that search normal search works SearchResponse searchResponse = client().prepareSearch("test").setQuery(QueryBuilders.termQuery("field", "test")).get(); @@ -93,7 +93,7 @@ public class SearchWhileCreatingIndexIT extends ESIntegTestCase { assertHitCount(searchResponse, 1); } assertHitCount(searchResponse, 1); - status = client().admin().cluster().prepareHealth("test").get().getStatus(); + status = clusterAdmin().prepareHealth("test").get().getStatus(); internalCluster().ensureAtLeastNumDataNodes(numberOfReplicas + 1); } cluster().wipeIndices("test"); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchWhileRelocatingIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchWhileRelocatingIT.java index 463e90bd6338..c5e73aeb69fc 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchWhileRelocatingIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/basic/SearchWhileRelocatingIT.java @@ -117,7 +117,7 @@ public class SearchWhileRelocatingIT extends ESIntegTestCase { threads[j].start(); } allowNodes("test", between(1, 3)); - client().admin().cluster().prepareReroute().get(); + clusterAdmin().prepareReroute().get(); stop.set(true); for (int j = 0; j < threads.length; j++) { threads[j].join(); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/functionscore/FunctionScorePluginIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/functionscore/FunctionScorePluginIT.java index 3efeae691ca1..1794ea8fbfab 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/search/functionscore/FunctionScorePluginIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/functionscore/FunctionScorePluginIT.java @@ -66,7 +66,7 @@ public class FunctionScorePluginIT extends ESIntegTestCase { .endObject() ) .get(); - client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().get(); + clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().get(); client().index( new IndexRequest("test").id("1") diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/nested/SimpleNestedIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/nested/SimpleNestedIT.java index 7f3fb961a74f..504f5265b4ba 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/search/nested/SimpleNestedIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/nested/SimpleNestedIT.java @@ -1560,7 +1560,7 @@ public class SimpleNestedIT extends ESIntegTestCase { ensureSearchable("test"); // No nested mapping yet, there shouldn't be anything in the fixed bit set cache - ClusterStatsResponse clusterStatsResponse = client().admin().cluster().prepareClusterStats().get(); + ClusterStatsResponse clusterStatsResponse = clusterAdmin().prepareClusterStats().get(); assertThat(clusterStatsResponse.getIndicesStats().getSegments().getBitsetMemoryInBytes(), equalTo(0L)); // Now add nested mapping @@ -1583,7 +1583,7 @@ public class SimpleNestedIT extends ESIntegTestCase { ensureSearchable("test"); if (loadFixedBitSeLazily) { - clusterStatsResponse = client().admin().cluster().prepareClusterStats().get(); + clusterStatsResponse = clusterAdmin().prepareClusterStats().get(); assertThat(clusterStatsResponse.getIndicesStats().getSegments().getBitsetMemoryInBytes(), equalTo(0L)); // only when querying with nested the fixed bitsets are loaded @@ -1593,11 +1593,11 @@ public class SimpleNestedIT extends ESIntegTestCase { assertNoFailures(searchResponse); assertThat(searchResponse.getHits().getTotalHits().value, equalTo(5L)); } - clusterStatsResponse = client().admin().cluster().prepareClusterStats().get(); + clusterStatsResponse = clusterAdmin().prepareClusterStats().get(); assertThat(clusterStatsResponse.getIndicesStats().getSegments().getBitsetMemoryInBytes(), greaterThan(0L)); assertAcked(indicesAdmin().prepareDelete("test")); - clusterStatsResponse = client().admin().cluster().prepareClusterStats().get(); + clusterStatsResponse = clusterAdmin().prepareClusterStats().get(); assertThat(clusterStatsResponse.getIndicesStats().getSegments().getBitsetMemoryInBytes(), equalTo(0L)); } diff --git a/server/src/internalClusterTest/java/org/elasticsearch/search/routing/SearchPreferenceIT.java b/server/src/internalClusterTest/java/org/elasticsearch/search/routing/SearchPreferenceIT.java index 8702c425687d..f1184dc0e01c 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/search/routing/SearchPreferenceIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/search/routing/SearchPreferenceIT.java @@ -59,7 +59,7 @@ public class SearchPreferenceIT extends ESIntegTestCase { } refresh(); internalCluster().stopRandomDataNode(); - client().admin().cluster().prepareHealth().setWaitForStatus(ClusterHealthStatus.RED).get(); + clusterAdmin().prepareHealth().setWaitForStatus(ClusterHealthStatus.RED).get(); String[] preferences = new String[] { "_local", "_prefer_nodes:somenode", @@ -156,7 +156,7 @@ public class SearchPreferenceIT extends ESIntegTestCase { ArrayList allNodeIds = new ArrayList<>(); ArrayList allNodeNames = new ArrayList<>(); ArrayList allNodeHosts = new ArrayList<>(); - NodesStatsResponse nodeStats = client().admin().cluster().prepareNodesStats().get(); + NodesStatsResponse nodeStats = clusterAdmin().prepareNodesStats().get(); for (NodeStats node : nodeStats.getNodes()) { allNodeIds.add(node.getNode().getId()); allNodeNames.add(node.getNode().getName()); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/MultiClusterRepoAccessIT.java b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/MultiClusterRepoAccessIT.java index 32b860d77d63..0a2f00b6e094 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/MultiClusterRepoAccessIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/MultiClusterRepoAccessIT.java @@ -127,12 +127,7 @@ public class MultiClusterRepoAccessIT extends AbstractSnapshotIntegTestCase { final SnapshotException sne = expectThrows( SnapshotException.class, - () -> client().admin() - .cluster() - .prepareCreateSnapshot(repoNameOnFirstCluster, "snap-4") - .setWaitForCompletion(true) - .execute() - .actionGet() + () -> clusterAdmin().prepareCreateSnapshot(repoNameOnFirstCluster, "snap-4").setWaitForCompletion(true).execute().actionGet() ); assertThat(sne.getMessage(), containsString("failed to update snapshot in repository")); final RepositoryException cause = (RepositoryException) sne.getCause(); @@ -147,7 +142,7 @@ public class MultiClusterRepoAccessIT extends AbstractSnapshotIntegTestCase { + "] at generation [4]." ) ); - assertAcked(client().admin().cluster().prepareDeleteRepository(repoNameOnFirstCluster).get()); + assertAcked(clusterAdmin().prepareDeleteRepository(repoNameOnFirstCluster).get()); createRepository(repoNameOnFirstCluster, "fs", repoPath); createFullSnapshot(repoNameOnFirstCluster, "snap-5"); } @@ -160,9 +155,7 @@ public class MultiClusterRepoAccessIT extends AbstractSnapshotIntegTestCase { createIndexWithRandomDocs("test-idx-1", randomIntBetween(1, 100)); createFullSnapshot(repoName, "snap-1"); - final String repoUuid = client().admin() - .cluster() - .prepareGetRepositories(repoName) + final String repoUuid = clusterAdmin().prepareGetRepositories(repoName) .get() .repositories() .stream() @@ -196,14 +189,12 @@ public class MultiClusterRepoAccessIT extends AbstractSnapshotIntegTestCase { equalTo(repoUuid) ); - assertAcked(client().admin().cluster().prepareDeleteRepository(repoName)); + assertAcked(clusterAdmin().prepareDeleteRepository(repoName)); IOUtils.rm(internalCluster().getCurrentMasterNodeInstance(Environment.class).resolveRepoFile(repoPath.toString())); createRepository(repoName, "fs", repoPath); createFullSnapshot(repoName, "snap-1"); - final String newRepoUuid = client().admin() - .cluster() - .prepareGetRepositories(repoName) + final String newRepoUuid = clusterAdmin().prepareGetRepositories(repoName) .get() .repositories() .stream() diff --git a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/RepositoryThrottlingStatsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/RepositoryThrottlingStatsIT.java index ea15c9200000..429c5c1a136c 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/RepositoryThrottlingStatsIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/RepositoryThrottlingStatsIT.java @@ -67,7 +67,7 @@ public class RepositoryThrottlingStatsIT extends AbstractSnapshotIntegTestCase { assertDocCount("test-idx", 100); logger.info("--> access repository throttling stats via _nodes/stats api"); - NodesStatsResponse response = client().admin().cluster().prepareNodesStats().setRepositoryStats(true).get(); + NodesStatsResponse response = clusterAdmin().prepareNodesStats().setRepositoryStats(true).get(); RepositoriesStats stats = response.getNodes().get(0).getRepositoriesStats(); assertTrue(stats.getRepositoryThrottlingStats().containsKey("test-repo")); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SnapshotStressTestsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SnapshotStressTestsIT.java index 59904a381761..cc425a8bb0fb 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SnapshotStressTestsIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SnapshotStressTestsIT.java @@ -369,9 +369,7 @@ public class SnapshotStressTestsIT extends AbstractSnapshotIntegTestCase { ); logger.info( "--> hot threads:\n{}", - client().admin() - .cluster() - .prepareNodesHotThreads() + clusterAdmin().prepareNodesHotThreads() .setThreads(99999) .setIgnoreIdleThreads(false) .get() diff --git a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SystemIndicesSnapshotIT.java b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SystemIndicesSnapshotIT.java index 1d23fca9b9c0..aef0c2324f16 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SystemIndicesSnapshotIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/SystemIndicesSnapshotIT.java @@ -720,9 +720,7 @@ public class SystemIndicesSnapshotIT extends AbstractSnapshotIntegTestCase { // Now get the snapshot and do our checks assertBusy(() -> { - GetSnapshotsResponse snapshotsStatusResponse = client().admin() - .cluster() - .prepareGetSnapshots(REPO_NAME) + GetSnapshotsResponse snapshotsStatusResponse = clusterAdmin().prepareGetSnapshots(REPO_NAME) .setSnapshots(partialSnapName) .get(); SnapshotInfo snapshotInfo = snapshotsStatusResponse.getSnapshots().get(0); diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/state/ClusterStateApiTests.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/state/ClusterStateApiTests.java index f4f35ff1252a..b726910f5d8c 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/state/ClusterStateApiTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/state/ClusterStateApiTests.java @@ -33,7 +33,7 @@ public class ClusterStateApiTests extends ESSingleNodeTestCase { public void testWaitForMetadataVersion() throws Exception { ClusterStateRequest clusterStateRequest = new ClusterStateRequest(); clusterStateRequest.waitForTimeout(TimeValue.timeValueHours(1)); - ClusterStateResponse response = client().admin().cluster().state(clusterStateRequest).get(10L, TimeUnit.SECONDS); + ClusterStateResponse response = clusterAdmin().state(clusterStateRequest).get(10L, TimeUnit.SECONDS); assertThat(response.isWaitForTimedOut(), is(false)); long metadataVersion = response.getState().getMetadata().version(); @@ -41,13 +41,13 @@ public class ClusterStateApiTests extends ESSingleNodeTestCase { clusterStateRequest = new ClusterStateRequest(); clusterStateRequest.waitForMetadataVersion(metadataVersion + 1); - ActionFuture future2 = client().admin().cluster().state(clusterStateRequest); + ActionFuture future2 = clusterAdmin().state(clusterStateRequest); assertThat(future2.isDone(), is(false)); ClusterUpdateSettingsRequest updateSettingsRequest = new ClusterUpdateSettingsRequest(); // Pick an arbitrary dynamic cluster setting and change it. Just to get metadata version incremented: updateSettingsRequest.transientSettings(Settings.builder().put("cluster.max_shards_per_node", 999)); - assertAcked(client().admin().cluster().updateSettings(updateSettingsRequest).actionGet()); + assertAcked(clusterAdmin().updateSettings(updateSettingsRequest).actionGet()); response = future2.get(10L, TimeUnit.SECONDS); assertThat(response.isWaitForTimedOut(), is(false)); @@ -57,7 +57,7 @@ public class ClusterStateApiTests extends ESSingleNodeTestCase { metadataVersion = response.getState().getMetadata().version(); clusterStateRequest.waitForMetadataVersion(metadataVersion + 1); clusterStateRequest.waitForTimeout(TimeValue.timeValueMillis(500)); // Fail fast - ActionFuture future3 = client().admin().cluster().state(clusterStateRequest); + ActionFuture future3 = clusterAdmin().state(clusterStateRequest); response = future3.get(10L, TimeUnit.SECONDS); assertThat(response.isWaitForTimedOut(), is(true)); assertThat(response.getState(), nullValue()); @@ -65,7 +65,7 @@ public class ClusterStateApiTests extends ESSingleNodeTestCase { // Remove transient setting, otherwise test fails with the reason that this test leaves state behind: updateSettingsRequest = new ClusterUpdateSettingsRequest(); updateSettingsRequest.transientSettings(Settings.builder().put("cluster.max_shards_per_node", (String) null)); - assertAcked(client().admin().cluster().updateSettings(updateSettingsRequest).actionGet()); + assertAcked(clusterAdmin().updateSettings(updateSettingsRequest).actionGet()); } } diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataIndexTemplateServiceTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataIndexTemplateServiceTests.java index e03ddb9e2585..d759952c73ed 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataIndexTemplateServiceTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataIndexTemplateServiceTests.java @@ -245,7 +245,7 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase { List errors = putTemplateDetail(request); assertThat(errors, is(empty())); - final Metadata metadata = client().admin().cluster().prepareState().get().getState().metadata(); + final Metadata metadata = clusterAdmin().prepareState().get().getState().metadata(); IndexTemplateMetadata template = metadata.templates().get(templateName); Map aliasMap = template.getAliases(); assertThat(aliasMap.size(), equalTo(1)); @@ -263,7 +263,7 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase { putTemplateDetail(new PutRequest("test", "foo-1").patterns(singletonList("foo-*")).order(1)); putTemplateDetail(new PutRequest("test", "foo-2").patterns(singletonList("foo-*")).order(2)); putTemplateDetail(new PutRequest("test", "bar").patterns(singletonList("bar-*")).order(between(0, 100))); - final ClusterState state = client().admin().cluster().prepareState().get().getState(); + final ClusterState state = clusterAdmin().prepareState().get().getState(); assertThat( MetadataIndexTemplateService.findV1Templates(state.metadata(), "foo-1234", randomBoolean()) .stream() @@ -293,7 +293,7 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase { new PutRequest("testFindTemplatesWithHiddenIndices", "sneaky-hidden").patterns(singletonList("sneaky*")) .settings(Settings.builder().put("index.hidden", true).build()) ); - final ClusterState state = client().admin().cluster().prepareState().get().getState(); + final ClusterState state = clusterAdmin().prepareState().get().getState(); // hidden assertThat( @@ -377,7 +377,7 @@ public class MetadataIndexTemplateServiceTests extends ESSingleNodeTestCase { public void testFindTemplatesWithDateMathIndex() throws Exception { client().admin().indices().prepareDeleteTemplate("*").get(); // Delete all existing templates putTemplateDetail(new PutRequest("testFindTemplatesWithDateMathIndex", "foo-1").patterns(singletonList("test-*")).order(1)); - final ClusterState state = client().admin().cluster().prepareState().get().getState(); + final ClusterState state = clusterAdmin().prepareState().get().getState(); assertThat( MetadataIndexTemplateService.findV1Templates(state.metadata(), "", false) diff --git a/server/src/test/java/org/elasticsearch/index/IndexServiceTests.java b/server/src/test/java/org/elasticsearch/index/IndexServiceTests.java index 82f0b4d87347..dba69e7db7ba 100644 --- a/server/src/test/java/org/elasticsearch/index/IndexServiceTests.java +++ b/server/src/test/java/org/elasticsearch/index/IndexServiceTests.java @@ -454,14 +454,14 @@ public class IndexServiceTests extends ESSingleNodeTestCase { assertNotNull(indexService.getFsyncTask()); assertTrue(indexService.getFsyncTask().mustReschedule()); - IndexMetadata indexMetadata = client().admin().cluster().prepareState().execute().actionGet().getState().metadata().index("test"); + IndexMetadata indexMetadata = clusterAdmin().prepareState().execute().actionGet().getState().metadata().index("test"); assertEquals("5s", indexMetadata.getSettings().get(IndexSettings.INDEX_TRANSLOG_SYNC_INTERVAL_SETTING.getKey())); indicesAdmin().prepareClose("test").get(); indicesAdmin().prepareUpdateSettings("test") .setSettings(Settings.builder().put(IndexSettings.INDEX_TRANSLOG_SYNC_INTERVAL_SETTING.getKey(), "20s")) .get(); - indexMetadata = client().admin().cluster().prepareState().execute().actionGet().getState().metadata().index("test"); + indexMetadata = clusterAdmin().prepareState().execute().actionGet().getState().metadata().index("test"); assertEquals("20s", indexMetadata.getSettings().get(IndexSettings.INDEX_TRANSLOG_SYNC_INTERVAL_SETTING.getKey())); } } diff --git a/server/src/test/java/org/elasticsearch/repositories/blobstore/BlobStoreRepositoryTests.java b/server/src/test/java/org/elasticsearch/repositories/blobstore/BlobStoreRepositoryTests.java index 532fe5fa2e67..1b44b7576b39 100644 --- a/server/src/test/java/org/elasticsearch/repositories/blobstore/BlobStoreRepositoryTests.java +++ b/server/src/test/java/org/elasticsearch/repositories/blobstore/BlobStoreRepositoryTests.java @@ -292,9 +292,7 @@ public class BlobStoreRepositoryTests extends ESSingleNodeTestCase { ); final long beforeStartTime = getInstanceFromNode(ThreadPool.class).absoluteTimeInMillis(); - final CreateSnapshotResponse createSnapshotResponse = client().admin() - .cluster() - .prepareCreateSnapshot(repositoryName, "test-snap-1") + final CreateSnapshotResponse createSnapshotResponse = clusterAdmin().prepareCreateSnapshot(repositoryName, "test-snap-1") .setWaitForCompletion(true) .setPartial(true) .get(); diff --git a/test/framework/src/main/java/org/elasticsearch/indices/recovery/AbstractIndexRecoveryIntegTestCase.java b/test/framework/src/main/java/org/elasticsearch/indices/recovery/AbstractIndexRecoveryIntegTestCase.java index 1d76f2d36559..05828a572418 100644 --- a/test/framework/src/main/java/org/elasticsearch/indices/recovery/AbstractIndexRecoveryIntegTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/indices/recovery/AbstractIndexRecoveryIntegTestCase.java @@ -105,7 +105,7 @@ public abstract class AbstractIndexRecoveryIntegTestCase extends ESIntegTestCase ); final String redNodeName = internalCluster().startNode(Settings.builder().put("node.attr.color", "red").put(nodeSettings).build()); - ClusterHealthResponse response = client().admin().cluster().prepareHealth().setWaitForNodes(">=3").get(); + ClusterHealthResponse response = clusterAdmin().prepareHealth().setWaitForNodes(">=3").get(); assertThat(response.isTimedOut(), is(false)); indicesAdmin().prepareCreate(indexName) @@ -135,7 +135,7 @@ public abstract class AbstractIndexRecoveryIntegTestCase extends ESIntegTestCase indexRandom(true, requests); ensureSearchable(indexName); - ClusterStateResponse stateResponse = client().admin().cluster().prepareState().get(); + ClusterStateResponse stateResponse = clusterAdmin().prepareState().get(); final String blueNodeId = internalCluster().getInstance(ClusterService.class, blueNodeName).localNode().getId(); assertFalse(stateResponse.getState().getRoutingNodes().node(blueNodeId).isEmpty()); @@ -219,7 +219,7 @@ public abstract class AbstractIndexRecoveryIntegTestCase extends ESIntegTestCase ); final String redNodeName = internalCluster().startNode(Settings.builder().put("node.attr.color", "red").put(nodeSettings).build()); - ClusterHealthResponse response = client().admin().cluster().prepareHealth().setWaitForNodes(">=3").get(); + ClusterHealthResponse response = clusterAdmin().prepareHealth().setWaitForNodes(">=3").get(); assertThat(response.isTimedOut(), is(false)); indicesAdmin().prepareCreate(indexName) @@ -239,7 +239,7 @@ public abstract class AbstractIndexRecoveryIntegTestCase extends ESIntegTestCase indexRandom(true, requests); ensureSearchable(indexName); - ClusterStateResponse stateResponse = client().admin().cluster().prepareState().get(); + ClusterStateResponse stateResponse = clusterAdmin().prepareState().get(); final String blueNodeId = internalCluster().getInstance(ClusterService.class, blueNodeName).localNode().getId(); assertFalse(stateResponse.getState().getRoutingNodes().node(blueNodeId).isEmpty()); @@ -497,9 +497,7 @@ public abstract class AbstractIndexRecoveryIntegTestCase extends ESIntegTestCase // create repo assertAcked( - client().admin() - .cluster() - .preparePutRepository(REPO_NAME) + clusterAdmin().preparePutRepository(REPO_NAME) .setType("fs") .setSettings( Settings.builder() @@ -511,9 +509,7 @@ public abstract class AbstractIndexRecoveryIntegTestCase extends ESIntegTestCase ); // create snapshot - CreateSnapshotResponse createSnapshotResponse = client().admin() - .cluster() - .prepareCreateSnapshot(REPO_NAME, SNAP_NAME) + CreateSnapshotResponse createSnapshotResponse = clusterAdmin().prepareCreateSnapshot(REPO_NAME, SNAP_NAME) .setWaitForCompletion(true) .setIndices(indexName) .get(); @@ -524,7 +520,7 @@ public abstract class AbstractIndexRecoveryIntegTestCase extends ESIntegTestCase ); assertThat( - client().admin().cluster().prepareGetSnapshots(REPO_NAME).setSnapshots(SNAP_NAME).get().getSnapshots().get(0).state(), + clusterAdmin().prepareGetSnapshots(REPO_NAME).setSnapshots(SNAP_NAME).get().getSnapshots().get(0).state(), equalTo(SnapshotState.SUCCESS) ); } diff --git a/test/framework/src/main/java/org/elasticsearch/repositories/AbstractThirdPartyRepositoryTestCase.java b/test/framework/src/main/java/org/elasticsearch/repositories/AbstractThirdPartyRepositoryTestCase.java index 8189c43439a0..68b9fdd95840 100644 --- a/test/framework/src/main/java/org/elasticsearch/repositories/AbstractThirdPartyRepositoryTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/repositories/AbstractThirdPartyRepositoryTestCase.java @@ -59,7 +59,7 @@ public abstract class AbstractThirdPartyRepositoryTestCase extends ESSingleNodeT @Override public void tearDown() throws Exception { deleteAndAssertEmpty(getRepository().basePath()); - client().admin().cluster().prepareDeleteRepository("test-repo").get(); + clusterAdmin().prepareDeleteRepository("test-repo").get(); super.tearDown(); } @@ -93,9 +93,7 @@ public abstract class AbstractThirdPartyRepositoryTestCase extends ESSingleNodeT final String snapshotName = "test-snap-" + System.currentTimeMillis(); logger.info("--> snapshot"); - CreateSnapshotResponse createSnapshotResponse = client().admin() - .cluster() - .prepareCreateSnapshot("test-repo", snapshotName) + CreateSnapshotResponse createSnapshotResponse = clusterAdmin().prepareCreateSnapshot("test-repo", snapshotName) .setWaitForCompletion(true) .setIndices("test-idx-*", "-test-idx-3") .get(); @@ -106,11 +104,11 @@ public abstract class AbstractThirdPartyRepositoryTestCase extends ESSingleNodeT ); assertThat( - client().admin().cluster().prepareGetSnapshots("test-repo").setSnapshots(snapshotName).get().getSnapshots().get(0).state(), + clusterAdmin().prepareGetSnapshots("test-repo").setSnapshots(snapshotName).get().getSnapshots().get(0).state(), equalTo(SnapshotState.SUCCESS) ); - assertTrue(client().admin().cluster().prepareDeleteSnapshot("test-repo", snapshotName).get().isAcknowledged()); + assertTrue(clusterAdmin().prepareDeleteSnapshot("test-repo", snapshotName).get().isAcknowledged()); } public void testListChildren() throws Exception { @@ -162,9 +160,7 @@ public abstract class AbstractThirdPartyRepositoryTestCase extends ESSingleNodeT final String snapshotName = "test-snap-" + System.currentTimeMillis(); logger.info("--> snapshot"); - CreateSnapshotResponse createSnapshotResponse = client().admin() - .cluster() - .prepareCreateSnapshot("test-repo", snapshotName) + CreateSnapshotResponse createSnapshotResponse = clusterAdmin().prepareCreateSnapshot("test-repo", snapshotName) .setWaitForCompletion(true) .setIndices("test-idx-*", "-test-idx-3") .get(); @@ -175,7 +171,7 @@ public abstract class AbstractThirdPartyRepositoryTestCase extends ESSingleNodeT ); assertThat( - client().admin().cluster().prepareGetSnapshots("test-repo").setSnapshots(snapshotName).get().getSnapshots().get(0).state(), + clusterAdmin().prepareGetSnapshots("test-repo").setSnapshots(snapshotName).get().getSnapshots().get(0).state(), equalTo(SnapshotState.SUCCESS) ); @@ -187,7 +183,7 @@ public abstract class AbstractThirdPartyRepositoryTestCase extends ESSingleNodeT createDanglingIndex(repo, genericExec); logger.info("--> deleting a snapshot to trigger repository cleanup"); - client().admin().cluster().prepareDeleteSnapshot("test-repo", snapshotName).get(); + clusterAdmin().prepareDeleteSnapshot("test-repo", snapshotName).get(); BlobStoreTestUtil.assertConsistency(repo); @@ -195,7 +191,7 @@ public abstract class AbstractThirdPartyRepositoryTestCase extends ESSingleNodeT createDanglingIndex(repo, genericExec); logger.info("--> Execute repository cleanup"); - final CleanupRepositoryResponse response = client().admin().cluster().prepareCleanupRepository("test-repo").get(); + final CleanupRepositoryResponse response = clusterAdmin().prepareCleanupRepository("test-repo").get(); assertCleanupResponse(response, 3L, 1L); } diff --git a/test/framework/src/main/java/org/elasticsearch/repositories/blobstore/ESBlobStoreRepositoryIntegTestCase.java b/test/framework/src/main/java/org/elasticsearch/repositories/blobstore/ESBlobStoreRepositoryIntegTestCase.java index fad23991729e..86ec7c77d14e 100644 --- a/test/framework/src/main/java/org/elasticsearch/repositories/blobstore/ESBlobStoreRepositoryIntegTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/repositories/blobstore/ESBlobStoreRepositoryIntegTestCase.java @@ -83,9 +83,7 @@ public abstract class ESBlobStoreRepositoryIntegTestCase extends ESIntegTestCase protected final String createRepository(final String name, final Settings settings, final boolean verify) { logger.info("--> creating repository [name: {}, verify: {}, settings: {}]", name, verify, settings); - assertAcked( - client().admin().cluster().preparePutRepository(name).setType(repositoryType()).setVerify(verify).setSettings(settings) - ); + assertAcked(clusterAdmin().preparePutRepository(name).setType(repositoryType()).setVerify(verify).setSettings(settings)); internalCluster().getDataOrMasterNodeInstances(RepositoriesService.class).forEach(repositories -> { assertThat(repositories.repository(name), notNullValue()); @@ -100,7 +98,7 @@ public abstract class ESBlobStoreRepositoryIntegTestCase extends ESIntegTestCase protected final void deleteRepository(final String name) { logger.debug("--> deleting repository [name: {}]", name); - assertAcked(client().admin().cluster().prepareDeleteRepository(name)); + assertAcked(clusterAdmin().prepareDeleteRepository(name)); internalCluster().getDataOrMasterNodeInstances(RepositoriesService.class).forEach(repositories -> { RepositoryMissingException e = expectThrows(RepositoryMissingException.class, () -> repositories.repository(name)); assertThat(e.repository(), equalTo(name)); @@ -298,7 +296,7 @@ public abstract class ESBlobStoreRepositoryIntegTestCase extends ESIntegTestCase final String snapshotName = randomName(); logger.info("--> create snapshot {}:{}", repoName, snapshotName); assertSuccessfulSnapshot( - client().admin().cluster().prepareCreateSnapshot(repoName, snapshotName).setWaitForCompletion(true).setIndices(indexNames) + clusterAdmin().prepareCreateSnapshot(repoName, snapshotName).setWaitForCompletion(true).setIndices(indexNames) ); List deleteIndices = randomSubsetOf(randomIntBetween(0, indexCount), indexNames); @@ -339,7 +337,7 @@ public abstract class ESBlobStoreRepositoryIntegTestCase extends ESIntegTestCase } logger.info("--> restore all indices from the snapshot"); - assertSuccessfulRestore(client().admin().cluster().prepareRestoreSnapshot(repoName, snapshotName).setWaitForCompletion(true)); + assertSuccessfulRestore(clusterAdmin().prepareRestoreSnapshot(repoName, snapshotName).setWaitForCompletion(true)); // higher timeout since we can have quite a few shards and a little more data here ensureGreen(TimeValue.timeValueSeconds(120)); @@ -349,18 +347,18 @@ public abstract class ESBlobStoreRepositoryIntegTestCase extends ESIntegTestCase } logger.info("--> delete snapshot {}:{}", repoName, snapshotName); - assertAcked(client().admin().cluster().prepareDeleteSnapshot(repoName, snapshotName).get()); + assertAcked(clusterAdmin().prepareDeleteSnapshot(repoName, snapshotName).get()); expectThrows( SnapshotMissingException.class, - () -> client().admin().cluster().prepareGetSnapshots(repoName).setSnapshots(snapshotName).execute().actionGet() + () -> clusterAdmin().prepareGetSnapshots(repoName).setSnapshots(snapshotName).execute().actionGet() ); - expectThrows(SnapshotMissingException.class, () -> client().admin().cluster().prepareDeleteSnapshot(repoName, snapshotName).get()); + expectThrows(SnapshotMissingException.class, () -> clusterAdmin().prepareDeleteSnapshot(repoName, snapshotName).get()); expectThrows( SnapshotRestoreException.class, - () -> client().admin().cluster().prepareRestoreSnapshot(repoName, snapshotName).setWaitForCompletion(randomBoolean()).get() + () -> clusterAdmin().prepareRestoreSnapshot(repoName, snapshotName).setWaitForCompletion(randomBoolean()).get() ); } @@ -392,11 +390,7 @@ public abstract class ESBlobStoreRepositoryIntegTestCase extends ESIntegTestCase docCounts[i] = (int) client().prepareSearch(indexName).setSize(0).get().getHits().getTotalHits().value; logger.info("--> create snapshot {}:{} with {} documents", repoName, snapshotName + "-" + i, docCounts[i]); assertSuccessfulSnapshot( - client().admin() - .cluster() - .prepareCreateSnapshot(repoName, snapshotName + "-" + i) - .setWaitForCompletion(true) - .setIndices(indexName) + clusterAdmin().prepareCreateSnapshot(repoName, snapshotName + "-" + i).setWaitForCompletion(true).setIndices(indexName) ); } @@ -412,10 +406,7 @@ public abstract class ESBlobStoreRepositoryIntegTestCase extends ESIntegTestCase logger.info("--> restore index from the snapshot"); assertSuccessfulRestore( - client().admin() - .cluster() - .prepareRestoreSnapshot(repoName, snapshotName + "-" + iterationToRestore) - .setWaitForCompletion(true) + clusterAdmin().prepareRestoreSnapshot(repoName, snapshotName + "-" + iterationToRestore).setWaitForCompletion(true) ); ensureGreen(); @@ -424,7 +415,7 @@ public abstract class ESBlobStoreRepositoryIntegTestCase extends ESIntegTestCase for (int i = 0; i < iterationCount; i++) { logger.info("--> delete snapshot {}:{}", repoName, snapshotName + "-" + i); - assertAcked(client().admin().cluster().prepareDeleteSnapshot(repoName, snapshotName + "-" + i).get()); + assertAcked(clusterAdmin().prepareDeleteSnapshot(repoName, snapshotName + "-" + i).get()); } } @@ -467,7 +458,7 @@ public abstract class ESBlobStoreRepositoryIntegTestCase extends ESIntegTestCase assertEquals(createSnapshotResponse.getSnapshotInfo().successfulShards(), createSnapshotResponse.getSnapshotInfo().totalShards()); logger.info("--> delete a snapshot"); - assertAcked(client().admin().cluster().prepareDeleteSnapshot(repoName, "test-snap").get()); + assertAcked(clusterAdmin().prepareDeleteSnapshot(repoName, "test-snap").get()); logger.info("--> verify index folder deleted from blob container"); RepositoriesService repositoriesSvc = internalCluster().getInstance(RepositoriesService.class, internalCluster().getMasterName()); @@ -487,7 +478,7 @@ public abstract class ESBlobStoreRepositoryIntegTestCase extends ESIntegTestCase } } - assertAcked(client().admin().cluster().prepareDeleteSnapshot(repoName, "test-snap2").get()); + assertAcked(clusterAdmin().prepareDeleteSnapshot(repoName, "test-snap2").get()); } protected void addRandomDocuments(String name, int numDocs) throws InterruptedException { diff --git a/test/framework/src/main/java/org/elasticsearch/repositories/blobstore/ESFsBasedRepositoryIntegTestCase.java b/test/framework/src/main/java/org/elasticsearch/repositories/blobstore/ESFsBasedRepositoryIntegTestCase.java index 41a312b86524..e0fd9d125134 100644 --- a/test/framework/src/main/java/org/elasticsearch/repositories/blobstore/ESFsBasedRepositoryIntegTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/repositories/blobstore/ESFsBasedRepositoryIntegTestCase.java @@ -50,11 +50,11 @@ public abstract class ESFsBasedRepositoryIntegTestCase extends ESBlobStoreReposi final String snapshotName = randomName(); logger.info("--> create snapshot {}:{}", repoName, snapshotName); assertSuccessfulSnapshot( - client().admin().cluster().prepareCreateSnapshot(repoName, snapshotName).setWaitForCompletion(true).setIndices(indexName) + clusterAdmin().prepareCreateSnapshot(repoName, snapshotName).setWaitForCompletion(true).setIndices(indexName) ); assertAcked(client().admin().indices().prepareDelete(indexName)); - assertAcked(client().admin().cluster().prepareDeleteRepository(repoName)); + assertAcked(clusterAdmin().prepareDeleteRepository(repoName)); final Path deletedPath; try (Stream contents = Files.list(repoPath.resolve("indices"))) { @@ -68,7 +68,7 @@ public abstract class ESFsBasedRepositoryIntegTestCase extends ESBlobStoreReposi final ElasticsearchException exception = expectThrows( ElasticsearchException.class, - () -> client().admin().cluster().prepareRestoreSnapshot(repoName, snapshotName).setWaitForCompletion(randomBoolean()).get() + () -> clusterAdmin().prepareRestoreSnapshot(repoName, snapshotName).setWaitForCompletion(randomBoolean()).get() ); assertThat(exception.getRootCause(), instanceOf(NoSuchFileException.class)); diff --git a/test/framework/src/main/java/org/elasticsearch/repositories/blobstore/ESMockAPIBasedRepositoryIntegTestCase.java b/test/framework/src/main/java/org/elasticsearch/repositories/blobstore/ESMockAPIBasedRepositoryIntegTestCase.java index 41fe11914c8a..a616e9138570 100644 --- a/test/framework/src/main/java/org/elasticsearch/repositories/blobstore/ESMockAPIBasedRepositoryIntegTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/repositories/blobstore/ESMockAPIBasedRepositoryIntegTestCase.java @@ -169,17 +169,15 @@ public abstract class ESMockAPIBasedRepositoryIntegTestCase extends ESBlobStoreR assertHitCount(client().prepareSearch(index).setSize(0).setTrackTotalHits(true).get(), nbDocs); final String snapshot = "snapshot"; - assertSuccessfulSnapshot( - client().admin().cluster().prepareCreateSnapshot(repository, snapshot).setWaitForCompletion(true).setIndices(index) - ); + assertSuccessfulSnapshot(clusterAdmin().prepareCreateSnapshot(repository, snapshot).setWaitForCompletion(true).setIndices(index)); assertAcked(client().admin().indices().prepareDelete(index)); - assertSuccessfulRestore(client().admin().cluster().prepareRestoreSnapshot(repository, snapshot).setWaitForCompletion(true)); + assertSuccessfulRestore(clusterAdmin().prepareRestoreSnapshot(repository, snapshot).setWaitForCompletion(true)); ensureGreen(index); assertHitCount(client().prepareSearch(index).setSize(0).setTrackTotalHits(true).get(), nbDocs); - assertAcked(client().admin().cluster().prepareDeleteSnapshot(repository, snapshot).get()); + assertAcked(clusterAdmin().prepareDeleteSnapshot(repository, snapshot).get()); } public void testRequestStats() throws Exception { @@ -198,17 +196,15 @@ public abstract class ESMockAPIBasedRepositoryIntegTestCase extends ESBlobStoreR assertHitCount(client().prepareSearch(index).setSize(0).setTrackTotalHits(true).get(), nbDocs); final String snapshot = "snapshot"; - assertSuccessfulSnapshot( - client().admin().cluster().prepareCreateSnapshot(repository, snapshot).setWaitForCompletion(true).setIndices(index) - ); + assertSuccessfulSnapshot(clusterAdmin().prepareCreateSnapshot(repository, snapshot).setWaitForCompletion(true).setIndices(index)); assertAcked(client().admin().indices().prepareDelete(index)); - assertSuccessfulRestore(client().admin().cluster().prepareRestoreSnapshot(repository, snapshot).setWaitForCompletion(true)); + assertSuccessfulRestore(clusterAdmin().prepareRestoreSnapshot(repository, snapshot).setWaitForCompletion(true)); ensureGreen(index); assertHitCount(client().prepareSearch(index).setSize(0).setTrackTotalHits(true).get(), nbDocs); - assertAcked(client().admin().cluster().prepareDeleteSnapshot(repository, snapshot).get()); + assertAcked(clusterAdmin().prepareDeleteSnapshot(repository, snapshot).get()); final RepositoryStats repositoryStats = StreamSupport.stream( internalCluster().getInstances(RepositoriesService.class).spliterator(), diff --git a/test/framework/src/main/java/org/elasticsearch/search/geo/BaseShapeIntegTestCase.java b/test/framework/src/main/java/org/elasticsearch/search/geo/BaseShapeIntegTestCase.java index b51b4c732363..7217c521e661 100644 --- a/test/framework/src/main/java/org/elasticsearch/search/geo/BaseShapeIntegTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/search/geo/BaseShapeIntegTestCase.java @@ -283,7 +283,7 @@ public abstract class BaseShapeIntegTestCase recreating repository to clear caches"); - assertAcked(client().admin().cluster().prepareDeleteRepository(repoName)); + assertAcked(clusterAdmin().prepareDeleteRepository(repoName)); createRepository(repoName, repoMetadata.type(), Settings.builder().put(repoMetadata.settings())); } return oldVersionSnapshot; @@ -450,9 +450,7 @@ public abstract class AbstractSnapshotIntegTestCase extends ESIntegTestCase { protected SnapshotInfo createSnapshot(String repositoryName, String snapshot, List indices, List featureStates) { logger.info("--> creating snapshot [{}] of {} in [{}]", snapshot, indices, repositoryName); - final CreateSnapshotResponse response = client().admin() - .cluster() - .prepareCreateSnapshot(repositoryName, snapshot) + final CreateSnapshotResponse response = clusterAdmin().prepareCreateSnapshot(repositoryName, snapshot) .setIndices(indices.toArray(Strings.EMPTY_ARRAY)) .setWaitForCompletion(true) .setFeatureStates(featureStates.toArray(Strings.EMPTY_ARRAY)) diff --git a/test/framework/src/main/java/org/elasticsearch/test/AbstractSearchCancellationTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/AbstractSearchCancellationTestCase.java index 8e7d895ee23d..479b81949a3f 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/AbstractSearchCancellationTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/AbstractSearchCancellationTestCase.java @@ -113,11 +113,7 @@ public class AbstractSearchCancellationTestCase extends ESIntegTestCase { TaskInfo searchTask = listTasksResponse.getTasks().get(0); logger.info("Cancelling search"); - CancelTasksResponse cancelTasksResponse = client().admin() - .cluster() - .prepareCancelTasks() - .setTargetTaskId(searchTask.taskId()) - .get(); + CancelTasksResponse cancelTasksResponse = clusterAdmin().prepareCancelTasks().setTargetTaskId(searchTask.taskId()).get(); assertThat(cancelTasksResponse.getTasks(), hasSize(1)); assertThat(cancelTasksResponse.getTasks().get(0).taskId(), equalTo(searchTask.taskId())); } diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java index 5e50147eab16..65d0b670e97f 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java @@ -564,7 +564,7 @@ public abstract class ESIntegTestCase extends ESTestCase { try { if (cluster() != null) { if (currentClusterScope != Scope.TEST) { - Metadata metadata = client().admin().cluster().prepareState().execute().actionGet().getState().getMetadata(); + Metadata metadata = clusterAdmin().prepareState().execute().actionGet().getState().getMetadata(); final Set persistentKeys = new HashSet<>(metadata.persistentSettings().keySet()); assertThat("test leaves persistent cluster metadata behind", persistentKeys, empty()); @@ -848,7 +848,7 @@ public abstract class ESIntegTestCase extends ESTestCase { * Waits until all nodes have no pending tasks. */ public void waitNoPendingTasksOnAll() throws Exception { - assertNoTimeout(client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).get()); + assertNoTimeout(clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).get()); assertBusy(() -> { for (Client client : clients()) { ClusterHealthResponse clusterHealth = client.admin().cluster().prepareHealth().setLocal(true).get(); @@ -863,7 +863,7 @@ public abstract class ESIntegTestCase extends ESTestCase { assertThat("client " + client + " still has in flight fetch", clusterHealth.getNumberOfInFlightFetch(), equalTo(0)); } }); - assertNoTimeout(client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).get()); + assertNoTimeout(clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).get()); } /** Ensures the result counts are as expected, and logs the results if different */ @@ -959,11 +959,9 @@ public abstract class ESIntegTestCase extends ESTestCase { // been removed by the master so that the health check applies to the set of nodes we expect to be part of the cluster. .waitForNodes(Integer.toString(cluster().size())); - ClusterHealthResponse actionGet = client().admin().cluster().health(healthRequest).actionGet(); + ClusterHealthResponse actionGet = clusterAdmin().health(healthRequest).actionGet(); if (actionGet.isTimedOut()) { - final String hotThreads = client().admin() - .cluster() - .prepareNodesHotThreads() + final String hotThreads = clusterAdmin().prepareNodesHotThreads() .setThreads(99999) .setIgnoreIdleThreads(false) .get() @@ -974,8 +972,8 @@ public abstract class ESIntegTestCase extends ESTestCase { logger.info( "{} timed out, cluster state:\n{}\npending tasks:\n{}\nhot threads:\n{}\n", method, - client().admin().cluster().prepareState().get().getState(), - client().admin().cluster().preparePendingClusterTasks().get(), + clusterAdmin().prepareState().get().getState(), + clusterAdmin().preparePendingClusterTasks().get(), hotThreads ); fail("timed out waiting for " + color + " state"); @@ -1006,13 +1004,13 @@ public abstract class ESIntegTestCase extends ESTestCase { if (status != null) { request.waitForStatus(status); } - ClusterHealthResponse actionGet = client().admin().cluster().health(request).actionGet(); + ClusterHealthResponse actionGet = clusterAdmin().health(request).actionGet(); if (actionGet.isTimedOut()) { logger.info( "waitForRelocation timed out (status={}), cluster state:\n{}\n{}", status, - client().admin().cluster().prepareState().get().getState(), - client().admin().cluster().preparePendingClusterTasks().get() + clusterAdmin().prepareState().get().getState(), + clusterAdmin().preparePendingClusterTasks().get() ); assertThat("timed out waiting for relocation", actionGet.isTimedOut(), equalTo(false)); } @@ -1121,15 +1119,15 @@ public abstract class ESIntegTestCase extends ESTestCase { public void logClusterState() { logger.debug( "cluster state:\n{}\n{}", - client().admin().cluster().prepareState().get().getState(), - client().admin().cluster().preparePendingClusterTasks().get() + clusterAdmin().prepareState().get().getState(), + clusterAdmin().preparePendingClusterTasks().get() ); } protected void ensureClusterSizeConsistency() { if (cluster() != null && cluster().size() > 0) { // if static init fails the cluster can be null logger.trace("Check consistency for [{}] nodes", cluster().size()); - assertNoTimeout(client().admin().cluster().prepareHealth().setWaitForNodes(Integer.toString(cluster().size())).get()); + assertNoTimeout(clusterAdmin().prepareHealth().setWaitForNodes(Integer.toString(cluster().size())).get()); } } @@ -1705,7 +1703,7 @@ public abstract class ESIntegTestCase extends ESTestCase { /** Sets cluster persistent settings **/ public static void updateClusterSettings(Settings.Builder persistentSettings) { - assertAcked(client().admin().cluster().prepareUpdateSettings().setPersistentSettings(persistentSettings).get()); + assertAcked(clusterAdmin().prepareUpdateSettings().setPersistentSettings(persistentSettings).get()); } private static CountDownLatch newLatch(List latches) { @@ -2196,7 +2194,7 @@ public abstract class ESIntegTestCase extends ESTestCase { } protected NumShards getNumShards(String index) { - Metadata metadata = client().admin().cluster().prepareState().get().getState().metadata(); + Metadata metadata = clusterAdmin().prepareState().get().getState().metadata(); assertThat(metadata.hasIndex(index), equalTo(true)); int numShards = Integer.valueOf(metadata.index(index).getSettings().get(SETTING_NUMBER_OF_SHARDS)); int numReplicas = Integer.valueOf(metadata.index(index).getSettings().get(SETTING_NUMBER_OF_REPLICAS)); @@ -2208,7 +2206,7 @@ public abstract class ESIntegTestCase extends ESTestCase { */ public Set assertAllShardsOnNodes(String index, String... pattern) { Set nodes = new HashSet<>(); - ClusterState clusterState = client().admin().cluster().prepareState().execute().actionGet().getState(); + ClusterState clusterState = clusterAdmin().prepareState().execute().actionGet().getState(); for (IndexRoutingTable indexRoutingTable : clusterState.routingTable()) { for (int shardId = 0; shardId < indexRoutingTable.size(); shardId++) { final IndexShardRoutingTable indexShard = indexRoutingTable.shard(shardId); @@ -2391,7 +2389,7 @@ public abstract class ESIntegTestCase extends ESTestCase { } protected static RestClient createRestClient(RestClientBuilder.HttpClientConfigCallback httpClientConfigCallback, String protocol) { - NodesInfoResponse nodesInfoResponse = client().admin().cluster().prepareNodesInfo().get(); + NodesInfoResponse nodesInfoResponse = clusterAdmin().prepareNodesInfo().get(); assertFalse(nodesInfoResponse.hasFailures()); return createRestClient(nodesInfoResponse.getNodes(), httpClientConfigCallback, protocol); } diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESSingleNodeTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESSingleNodeTestCase.java index 79f86e7e700c..39c8c1ce55fe 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESSingleNodeTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESSingleNodeTestCase.java @@ -20,6 +20,7 @@ import org.elasticsearch.action.support.DestructiveOperations; import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.client.internal.AdminClient; import org.elasticsearch.client.internal.Client; +import org.elasticsearch.client.internal.ClusterAdminClient; import org.elasticsearch.client.internal.IndicesAdminClient; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.health.ClusterHealthStatus; @@ -85,7 +86,7 @@ public abstract class ESSingleNodeTestCase extends ESTestCase { // we must wait for the node to actually be up and running. otherwise the node might have started, // elected itself master but might not yet have removed the // SERVICE_UNAVAILABLE/1/state not recovered / initialized block - ClusterHealthResponse clusterHealthResponse = client().admin().cluster().prepareHealth().setWaitForGreenStatus().get(); + ClusterHealthResponse clusterHealthResponse = clusterAdmin().prepareHealth().setWaitForGreenStatus().get(); assertFalse(clusterHealthResponse.isTimedOut()); indicesAdmin().preparePutTemplate("one_shard_index_template") .setPatterns(Collections.singletonList("*")) @@ -144,7 +145,7 @@ public abstract class ESSingleNodeTestCase extends ESTestCase { var deleteComponentTemplateRequest = new DeleteComponentTemplateAction.Request("*"); assertAcked(client().execute(DeleteComponentTemplateAction.INSTANCE, deleteComponentTemplateRequest).actionGet()); assertAcked(indicesAdmin().prepareDelete("*").setIndicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN_CLOSED_HIDDEN).get()); - Metadata metadata = client().admin().cluster().prepareState().get().getState().getMetadata(); + Metadata metadata = clusterAdmin().prepareState().get().getState().getMetadata(); assertThat( "test leaves persistent cluster metadata behind: " + metadata.persistentSettings().keySet(), metadata.persistentSettings().size(), @@ -290,6 +291,13 @@ public abstract class ESSingleNodeTestCase extends ESTestCase { return admin().indices(); } + /** + * Returns a cluster admin client. + */ + protected ClusterAdminClient clusterAdmin() { + return admin().cluster(); + } + public Client wrapClient(final Client client) { return client; } @@ -348,10 +356,9 @@ public abstract class ESSingleNodeTestCase extends ESTestCase { assertAcked(createIndexRequestBuilder.get()); // Wait for the index to be allocated so that cluster state updates don't override // changes that would have been done locally - ClusterHealthResponse health = client().admin() - .cluster() - .health(new ClusterHealthRequest(index).waitForYellowStatus().waitForEvents(Priority.LANGUID).waitForNoRelocatingShards(true)) - .actionGet(); + ClusterHealthResponse health = clusterAdmin().health( + new ClusterHealthRequest(index).waitForYellowStatus().waitForEvents(Priority.LANGUID).waitForNoRelocatingShards(true) + ).actionGet(); assertThat(health.getStatus(), lessThanOrEqualTo(ClusterHealthStatus.YELLOW)); assertThat("Cluster must be a single node cluster", health.getNumberOfDataNodes(), equalTo(1)); IndicesService instanceFromNode = getInstanceFromNode(IndicesService.class); @@ -389,20 +396,17 @@ public abstract class ESSingleNodeTestCase extends ESTestCase { * @param timeout time out value to set on {@link org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest} */ public ClusterHealthStatus ensureGreen(TimeValue timeout, String... indices) { - ClusterHealthResponse actionGet = client().admin() - .cluster() - .health( - new ClusterHealthRequest(indices).timeout(timeout) - .waitForGreenStatus() - .waitForEvents(Priority.LANGUID) - .waitForNoRelocatingShards(true) - ) - .actionGet(); + ClusterHealthResponse actionGet = clusterAdmin().health( + new ClusterHealthRequest(indices).timeout(timeout) + .waitForGreenStatus() + .waitForEvents(Priority.LANGUID) + .waitForNoRelocatingShards(true) + ).actionGet(); if (actionGet.isTimedOut()) { logger.info( "ensureGreen timed out, cluster state:\n{}\n{}", - client().admin().cluster().prepareState().get().getState(), - client().admin().cluster().preparePendingClusterTasks().get() + clusterAdmin().prepareState().get().getState(), + clusterAdmin().preparePendingClusterTasks().get() ); assertThat("timed out waiting for green state", actionGet.isTimedOut(), equalTo(false)); } @@ -426,9 +430,7 @@ public abstract class ESSingleNodeTestCase extends ESTestCase { * inspired by {@link ESRestTestCase} */ protected void ensureNoInitializingShards() { - ClusterHealthResponse actionGet = client().admin() - .cluster() - .health(new ClusterHealthRequest("_all").waitForNoInitializingShards(true)) + ClusterHealthResponse actionGet = clusterAdmin().health(new ClusterHealthRequest("_all").waitForNoInitializingShards(true)) .actionGet(); assertFalse("timed out waiting for shards to initialize", actionGet.isTimedOut()); diff --git a/x-pack/plugin/async-search/src/internalClusterTest/java/org/elasticsearch/xpack/search/AsyncSearchIntegTestCase.java b/x-pack/plugin/async-search/src/internalClusterTest/java/org/elasticsearch/xpack/search/AsyncSearchIntegTestCase.java index 013d8438ea75..3c28b839ac62 100644 --- a/x-pack/plugin/async-search/src/internalClusterTest/java/org/elasticsearch/xpack/search/AsyncSearchIntegTestCase.java +++ b/x-pack/plugin/async-search/src/internalClusterTest/java/org/elasticsearch/xpack/search/AsyncSearchIntegTestCase.java @@ -146,7 +146,7 @@ public abstract class AsyncSearchIntegTestCase extends ESIntegTestCase { */ protected void restartTaskNode(String id, String indexName) throws Exception { AsyncExecutionId searchId = AsyncExecutionId.decode(id); - final ClusterStateResponse clusterState = client().admin().cluster().prepareState().clear().setNodes(true).get(); + final ClusterStateResponse clusterState = clusterAdmin().prepareState().clear().setNodes(true).get(); DiscoveryNode node = clusterState.getState().nodes().get(searchId.getTaskId().getNodeId()); // Temporarily stop garbage collection, making sure to wait for any in-flight tasks to complete @@ -210,7 +210,7 @@ public abstract class AsyncSearchIntegTestCase extends ESIntegTestCase { assertBusy(() -> { TaskId taskId = AsyncExecutionId.decode(id).getTaskId(); try { - GetTaskResponse resp = client().admin().cluster().prepareGetTask(taskId).get(); + GetTaskResponse resp = clusterAdmin().prepareGetTask(taskId).get(); assertNull(resp.getTask()); } catch (Exception exc) { if (exc.getCause() instanceof ResourceNotFoundException == false) { diff --git a/x-pack/plugin/async-search/src/internalClusterTest/java/org/elasticsearch/xpack/search/SearchUsageStatsIT.java b/x-pack/plugin/async-search/src/internalClusterTest/java/org/elasticsearch/xpack/search/SearchUsageStatsIT.java index 22e1eea8eb5b..2e2cb147c5d9 100644 --- a/x-pack/plugin/async-search/src/internalClusterTest/java/org/elasticsearch/xpack/search/SearchUsageStatsIT.java +++ b/x-pack/plugin/async-search/src/internalClusterTest/java/org/elasticsearch/xpack/search/SearchUsageStatsIT.java @@ -36,7 +36,7 @@ public class SearchUsageStatsIT extends ESIntegTestCase { public void testSearchUsageStats() throws IOException { { - SearchUsageStats stats = client().admin().cluster().prepareClusterStats().get().getIndicesStats().getSearchUsageStats(); + SearchUsageStats stats = clusterAdmin().prepareClusterStats().get().getIndicesStats().getSearchUsageStats(); assertEquals(0, stats.getTotalSearchCount()); assertEquals(0, stats.getQueryUsage().size()); assertEquals(0, stats.getSectionsUsage().size()); @@ -63,7 +63,7 @@ public class SearchUsageStatsIT extends ESIntegTestCase { ResponseException responseException = expectThrows(ResponseException.class, () -> getRestClient().performRequest(request)); assertEquals(404, responseException.getResponse().getStatusLine().getStatusCode()); } - SearchUsageStats stats = client().admin().cluster().prepareClusterStats().get().getIndicesStats().getSearchUsageStats(); + SearchUsageStats stats = clusterAdmin().prepareClusterStats().get().getIndicesStats().getSearchUsageStats(); assertEquals(2, stats.getTotalSearchCount()); assertEquals(2, stats.getQueryUsage().size()); assertEquals(1, stats.getQueryUsage().get("match").longValue()); diff --git a/x-pack/plugin/autoscaling/src/internalClusterTest/java/org/elasticsearch/xpack/autoscaling/AutoscalingFileSettingsIT.java b/x-pack/plugin/autoscaling/src/internalClusterTest/java/org/elasticsearch/xpack/autoscaling/AutoscalingFileSettingsIT.java index 255b14330bad..4d4d1dc8045c 100644 --- a/x-pack/plugin/autoscaling/src/internalClusterTest/java/org/elasticsearch/xpack/autoscaling/AutoscalingFileSettingsIT.java +++ b/x-pack/plugin/autoscaling/src/internalClusterTest/java/org/elasticsearch/xpack/autoscaling/AutoscalingFileSettingsIT.java @@ -133,10 +133,9 @@ public class AutoscalingFileSettingsIT extends AutoscalingIntegTestCase { boolean awaitSuccessful = savedClusterState.await(20, TimeUnit.SECONDS); assertTrue(awaitSuccessful); - final ClusterStateResponse clusterStateResponse = client().admin() - .cluster() - .state(new ClusterStateRequest().waitForMetadataVersion(metadataVersion.get())) - .actionGet(); + final ClusterStateResponse clusterStateResponse = clusterAdmin().state( + new ClusterStateRequest().waitForMetadataVersion(metadataVersion.get()) + ).actionGet(); ReservedStateMetadata reservedState = clusterStateResponse.getState() .metadata() diff --git a/x-pack/plugin/autoscaling/src/internalClusterTest/java/org/elasticsearch/xpack/autoscaling/action/TransportDeleteAutoscalingPolicyActionIT.java b/x-pack/plugin/autoscaling/src/internalClusterTest/java/org/elasticsearch/xpack/autoscaling/action/TransportDeleteAutoscalingPolicyActionIT.java index 72b06a11f315..f65710cffe9f 100644 --- a/x-pack/plugin/autoscaling/src/internalClusterTest/java/org/elasticsearch/xpack/autoscaling/action/TransportDeleteAutoscalingPolicyActionIT.java +++ b/x-pack/plugin/autoscaling/src/internalClusterTest/java/org/elasticsearch/xpack/autoscaling/action/TransportDeleteAutoscalingPolicyActionIT.java @@ -35,7 +35,7 @@ public class TransportDeleteAutoscalingPolicyActionIT extends AutoscalingIntegTe final DeleteAutoscalingPolicyAction.Request deleteRequest = new DeleteAutoscalingPolicyAction.Request(deleteName); assertAcked(client().execute(DeleteAutoscalingPolicyAction.INSTANCE, deleteRequest).actionGet()); // now verify that the policy is not in the cluster state - final ClusterState state = client().admin().cluster().prepareState().get().getState(); + final ClusterState state = clusterAdmin().prepareState().get().getState(); final AutoscalingMetadata metadata = state.metadata().custom(AutoscalingMetadata.NAME); assertNotNull(metadata); assertThat(metadata.policies(), not(hasKey(policy.name()))); diff --git a/x-pack/plugin/autoscaling/src/internalClusterTest/java/org/elasticsearch/xpack/autoscaling/action/TransportPutAutoscalingPolicyActionIT.java b/x-pack/plugin/autoscaling/src/internalClusterTest/java/org/elasticsearch/xpack/autoscaling/action/TransportPutAutoscalingPolicyActionIT.java index 6d90df7c8a6c..54563acff679 100644 --- a/x-pack/plugin/autoscaling/src/internalClusterTest/java/org/elasticsearch/xpack/autoscaling/action/TransportPutAutoscalingPolicyActionIT.java +++ b/x-pack/plugin/autoscaling/src/internalClusterTest/java/org/elasticsearch/xpack/autoscaling/action/TransportPutAutoscalingPolicyActionIT.java @@ -32,7 +32,7 @@ public class TransportPutAutoscalingPolicyActionIT extends AutoscalingIntegTestC public void testAddPolicy() { final AutoscalingPolicy policy = putRandomAutoscalingPolicy(); - final ClusterState state = client().admin().cluster().prepareState().get().getState(); + final ClusterState state = clusterAdmin().prepareState().get().getState(); final AutoscalingMetadata metadata = state.metadata().custom(AutoscalingMetadata.NAME); assertNotNull(metadata); assertThat(metadata.policies(), hasKey(policy.name())); @@ -47,7 +47,7 @@ public class TransportPutAutoscalingPolicyActionIT extends AutoscalingIntegTestC mutateAutoscalingDeciders(policy.deciders()) ); putAutoscalingPolicy(updatedPolicy); - final ClusterState state = client().admin().cluster().prepareState().get().getState(); + final ClusterState state = clusterAdmin().prepareState().get().getState(); final AutoscalingMetadata metadata = state.metadata().custom(AutoscalingMetadata.NAME); assertNotNull(metadata); assertThat(metadata.policies(), hasKey(policy.name())); diff --git a/x-pack/plugin/autoscaling/src/internalClusterTest/java/org/elasticsearch/xpack/autoscaling/existence/FrozenExistenceDeciderIT.java b/x-pack/plugin/autoscaling/src/internalClusterTest/java/org/elasticsearch/xpack/autoscaling/existence/FrozenExistenceDeciderIT.java index c5c390ebca50..6e75e00c672a 100644 --- a/x-pack/plugin/autoscaling/src/internalClusterTest/java/org/elasticsearch/xpack/autoscaling/existence/FrozenExistenceDeciderIT.java +++ b/x-pack/plugin/autoscaling/src/internalClusterTest/java/org/elasticsearch/xpack/autoscaling/existence/FrozenExistenceDeciderIT.java @@ -109,7 +109,7 @@ public class FrozenExistenceDeciderIT extends AbstractFrozenAutoscalingIntegTest assertMinimumCapacity(capacity().results().get("frozen").requiredCapacity().node()); assertThat( - client().admin().cluster().prepareHealth().get().getStatus(), + clusterAdmin().prepareHealth().get().getStatus(), anyOf(equalTo(ClusterHealthStatus.YELLOW), equalTo(ClusterHealthStatus.GREEN)) ); diff --git a/x-pack/plugin/autoscaling/src/internalClusterTest/java/org/elasticsearch/xpack/autoscaling/storage/ReactiveStorageIT.java b/x-pack/plugin/autoscaling/src/internalClusterTest/java/org/elasticsearch/xpack/autoscaling/storage/ReactiveStorageIT.java index 4f841b8ba242..e2dd078b4a86 100644 --- a/x-pack/plugin/autoscaling/src/internalClusterTest/java/org/elasticsearch/xpack/autoscaling/storage/ReactiveStorageIT.java +++ b/x-pack/plugin/autoscaling/src/internalClusterTest/java/org/elasticsearch/xpack/autoscaling/storage/ReactiveStorageIT.java @@ -326,7 +326,7 @@ public class ReactiveStorageIT extends AutoscalingStorageIntegTestCase { long enoughSpaceForColocation = used + LOW_WATERMARK_BYTES; setTotalSpace(dataNode1Name, enoughSpaceForColocation); setTotalSpace(dataNode2Name, enoughSpaceForColocation); - assertAcked(client().admin().cluster().prepareReroute()); + assertAcked(clusterAdmin().prepareReroute()); waitForRelocation(); // Ensure that the relocated shard index files are removed from the data 2 node, @@ -372,7 +372,7 @@ public class ReactiveStorageIT extends AutoscalingStorageIntegTestCase { equalTo(requiredSpaceForShrink + ReactiveStorageDeciderService.NODE_DISK_OVERHEAD) ); - assertThat(client().admin().cluster().prepareHealth(shrinkName).get().getUnassignedShards(), equalTo(1)); + assertThat(clusterAdmin().prepareHealth(shrinkName).get().getUnassignedShards(), equalTo(1)); // test that the required amount is enough. // Adjust the amount since autoscaling calculates a node size to stay below low watermark though the shard can be @@ -380,10 +380,10 @@ public class ReactiveStorageIT extends AutoscalingStorageIntegTestCase { long tooLittleSpaceForShrink = requiredSpaceForShrink - Math.min(LOW_WATERMARK_BYTES - HIGH_WATERMARK_BYTES, used) - 1; assert tooLittleSpaceForShrink <= requiredSpaceForShrink; setTotalSpace(dataNode1Name, tooLittleSpaceForShrink); - assertAcked(client().admin().cluster().prepareReroute()); - assertThat(client().admin().cluster().prepareHealth(shrinkName).get().getUnassignedShards(), equalTo(1)); + assertAcked(clusterAdmin().prepareReroute()); + assertThat(clusterAdmin().prepareHealth(shrinkName).get().getUnassignedShards(), equalTo(1)); setTotalSpace(dataNode1Name, tooLittleSpaceForShrink + 1); - assertAcked(client().admin().cluster().prepareReroute()); + assertAcked(clusterAdmin().prepareReroute()); ensureGreen(); indicesAdmin().prepareDelete(indexName).get(); @@ -477,7 +477,7 @@ public class ReactiveStorageIT extends AutoscalingStorageIntegTestCase { equalTo(requiredSpaceForClone + ReactiveStorageDeciderService.NODE_DISK_OVERHEAD) ); - assertThat(client().admin().cluster().prepareHealth(cloneName).get().getUnassignedShards(), equalTo(resizedShardCount)); + assertThat(clusterAdmin().prepareHealth(cloneName).get().getUnassignedShards(), equalTo(resizedShardCount)); // test that the required amount is enough. // Adjust the amount since autoscaling calculates a node size to stay below low watermark though the shard can be @@ -485,10 +485,10 @@ public class ReactiveStorageIT extends AutoscalingStorageIntegTestCase { long tooLittleSpaceForClone = requiredSpaceForClone - Math.min(LOW_WATERMARK_BYTES - HIGH_WATERMARK_BYTES, used) - 1; assert tooLittleSpaceForClone <= requiredSpaceForClone; setTotalSpace(dataNode1Name, tooLittleSpaceForClone); - assertAcked(client().admin().cluster().prepareReroute()); - assertThat(client().admin().cluster().prepareHealth(cloneName).get().getUnassignedShards(), equalTo(resizedShardCount)); + assertAcked(clusterAdmin().prepareReroute()); + assertThat(clusterAdmin().prepareHealth(cloneName).get().getUnassignedShards(), equalTo(resizedShardCount)); setTotalSpace(dataNode1Name, requiredSpaceForClone); - assertAcked(client().admin().cluster().prepareReroute()); + assertAcked(clusterAdmin().prepareReroute()); ensureGreen(); indicesAdmin().prepareDelete(indexName).get(); diff --git a/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/snapshots/sourceonly/SourceOnlySnapshotIT.java b/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/snapshots/sourceonly/SourceOnlySnapshotIT.java index 9981fe3130ce..4385a294f598 100644 --- a/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/snapshots/sourceonly/SourceOnlySnapshotIT.java +++ b/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/snapshots/sourceonly/SourceOnlySnapshotIT.java @@ -355,16 +355,14 @@ public class SourceOnlySnapshotIT extends AbstractSnapshotIntegTestCase { logger.info("--> delete index and stop the data node"); assertAcked(client().admin().indices().prepareDelete(sourceIdx).get()); internalCluster().stopRandomDataNode(); - assertFalse(client().admin().cluster().prepareHealth().setTimeout("30s").setWaitForNodes("1").get().isTimedOut()); + assertFalse(clusterAdmin().prepareHealth().setTimeout("30s").setWaitForNodes("1").get().isTimedOut()); final String newDataNode = internalCluster().startDataOnlyNode(); logger.info("--> start a new data node " + newDataNode); - assertFalse(client().admin().cluster().prepareHealth().setTimeout("30s").setWaitForNodes("2").get().isTimedOut()); + assertFalse(clusterAdmin().prepareHealth().setTimeout("30s").setWaitForNodes("2").get().isTimedOut()); logger.info("--> restore the index and ensure all shards are allocated"); - RestoreSnapshotResponse restoreResponse = client().admin() - .cluster() - .prepareRestoreSnapshot(repo, snapshot) + RestoreSnapshotResponse restoreResponse = clusterAdmin().prepareRestoreSnapshot(repo, snapshot) .setWaitForCompletion(true) .setIndices(sourceIdx) .get(); diff --git a/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/xpack/cluster/routing/allocation/DataTierAllocationDeciderIT.java b/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/xpack/cluster/routing/allocation/DataTierAllocationDeciderIT.java index 6eb844c312e8..7124db6c1c72 100644 --- a/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/xpack/cluster/routing/allocation/DataTierAllocationDeciderIT.java +++ b/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/xpack/cluster/routing/allocation/DataTierAllocationDeciderIT.java @@ -75,10 +75,7 @@ public class DataTierAllocationDeciderIT extends ESIntegTestCase { assertThat(DataTier.TIER_PREFERENCE_SETTING.get(idxSettings), equalTo(DataTier.DATA_CONTENT)); // index should be red - assertThat( - client().admin().cluster().prepareHealth(index).get().getIndices().get(index).getStatus(), - equalTo(ClusterHealthStatus.RED) - ); + assertThat(clusterAdmin().prepareHealth(index).get().getIndices().get(index).getStatus(), equalTo(ClusterHealthStatus.RED)); if (randomBoolean()) { logger.info("--> starting content node"); @@ -537,7 +534,7 @@ public class DataTierAllocationDeciderIT extends ESIntegTestCase { } private DiscoveryNode getPrimaryShardAssignedNode(int shard) { - final var state = client().admin().cluster().prepareState().get().getState(); + final var state = clusterAdmin().prepareState().get().getState(); final var routingTable = state.routingTable().index(index).shard(shard); final var primaryShard = routingTable.primaryShard(); final var discoveryNode = state.nodes().get(primaryShard.currentNodeId()); @@ -547,7 +544,7 @@ public class DataTierAllocationDeciderIT extends ESIntegTestCase { private String explainAllocation(int shard) { return Strings.toString( - client().admin().cluster().prepareAllocationExplain().setIndex(index).setShard(shard).setPrimary(true).get().getExplanation(), + clusterAdmin().prepareAllocationExplain().setIndex(index).setShard(shard).setPrimary(true).get().getExplanation(), true, true ); diff --git a/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/xpack/cluster/routing/allocation/DataTierShardAvailabilityHealthIndicatorIT.java b/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/xpack/cluster/routing/allocation/DataTierShardAvailabilityHealthIndicatorIT.java index 12b327cfad37..00bcd6612035 100644 --- a/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/xpack/cluster/routing/allocation/DataTierShardAvailabilityHealthIndicatorIT.java +++ b/x-pack/plugin/core/src/internalClusterTest/java/org/elasticsearch/xpack/cluster/routing/allocation/DataTierShardAvailabilityHealthIndicatorIT.java @@ -109,9 +109,7 @@ public class DataTierShardAvailabilityHealthIndicatorIT extends ESIntegTestCase GetHealthAction.INSTANCE, new GetHealthAction.Request(ShardsAvailabilityHealthIndicatorService.NAME, true, 1000) ).get(); - ClusterAllocationExplanation explain = client().admin() - .cluster() - .prepareAllocationExplain() + ClusterAllocationExplanation explain = clusterAdmin().prepareAllocationExplain() .setIndex("test") .setShard(0) .setPrimary(false) @@ -189,7 +187,7 @@ public class DataTierShardAvailabilityHealthIndicatorIT extends ESIntegTestCase } private String findNodeWithShard(final String indexName, final int shard, final boolean primary) { - ClusterState state = client().admin().cluster().prepareState().get().getState(); + ClusterState state = clusterAdmin().prepareState().get().getState(); List startedShards = RoutingNodesHelper.shardsWithState(state.getRoutingNodes(), ShardRoutingState.STARTED); startedShards = startedShards.stream() .filter(shardRouting -> shardRouting.getIndexName().equals(indexName)) diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/license/LicensesTransportTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/license/LicensesTransportTests.java index 3de3fdc38fd9..effc92efe0f8 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/license/LicensesTransportTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/license/LicensesTransportTests.java @@ -59,7 +59,7 @@ public class LicensesTransportTests extends ESSingleNodeTestCase { assertBusy(() -> { try { final ActionFuture getLicenseFuture = new GetLicenseRequestBuilder( - client().admin().cluster(), + clusterAdmin(), GetLicenseAction.INSTANCE ).execute(); final GetLicenseResponse getLicenseResponse; @@ -76,16 +76,15 @@ public class LicensesTransportTests extends ESSingleNodeTestCase { License signedLicense = generateSignedLicense(TimeValue.timeValueMinutes(2)); // put license - PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder( - client().admin().cluster(), - PutLicenseAction.INSTANCE - ).setLicense(signedLicense).setAcknowledge(true); + PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(clusterAdmin(), PutLicenseAction.INSTANCE) + .setLicense(signedLicense) + .setAcknowledge(true); PutLicenseResponse putLicenseResponse = putLicenseRequestBuilder.get(); assertThat(putLicenseResponse.isAcknowledged(), equalTo(true)); assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID)); // get and check license - GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).get(); + GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(clusterAdmin(), GetLicenseAction.INSTANCE).get(); assertThat(getLicenseResponse.license(), equalTo(signedLicense)); } @@ -94,16 +93,15 @@ public class LicensesTransportTests extends ESSingleNodeTestCase { String licenseString = TestUtils.dumpLicense(signedLicense); // put license source - PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder( - client().admin().cluster(), - PutLicenseAction.INSTANCE - ).setLicense(new BytesArray(licenseString.getBytes(StandardCharsets.UTF_8)), XContentType.JSON).setAcknowledge(true); + PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(clusterAdmin(), PutLicenseAction.INSTANCE) + .setLicense(new BytesArray(licenseString.getBytes(StandardCharsets.UTF_8)), XContentType.JSON) + .setAcknowledge(true); PutLicenseResponse putLicenseResponse = putLicenseRequestBuilder.get(); assertThat(putLicenseResponse.isAcknowledged(), equalTo(true)); assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID)); // get and check license - GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).get(); + GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(clusterAdmin(), GetLicenseAction.INSTANCE).get(); assertThat(getLicenseResponse.license(), equalTo(signedLicense)); } @@ -117,7 +115,7 @@ public class LicensesTransportTests extends ESSingleNodeTestCase { .validate() .build(); - PutLicenseRequestBuilder builder = new PutLicenseRequestBuilder(client().admin().cluster(), PutLicenseAction.INSTANCE); + PutLicenseRequestBuilder builder = new PutLicenseRequestBuilder(clusterAdmin(), PutLicenseAction.INSTANCE); builder.setLicense(tamperedLicense); // try to put license (should be invalid) @@ -125,14 +123,14 @@ public class LicensesTransportTests extends ESSingleNodeTestCase { assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.INVALID)); // try to get invalid license - GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).get(); + GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(clusterAdmin(), GetLicenseAction.INSTANCE).get(); assertThat(getLicenseResponse.license(), not(tamperedLicense)); } public void testPutBasicLicenseIsInvalid() throws Exception { License signedLicense = generateSignedLicense("basic", License.VERSION_CURRENT, -1, TimeValue.timeValueMinutes(2)); - PutLicenseRequestBuilder builder = new PutLicenseRequestBuilder(client().admin().cluster(), PutLicenseAction.INSTANCE); + PutLicenseRequestBuilder builder = new PutLicenseRequestBuilder(clusterAdmin(), PutLicenseAction.INSTANCE); builder.setLicense(signedLicense); // try to put license (should be invalid) @@ -140,30 +138,29 @@ public class LicensesTransportTests extends ESSingleNodeTestCase { assertEquals(iae.getMessage(), "Registering basic licenses is not allowed."); // try to get invalid license - GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).get(); + GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(clusterAdmin(), GetLicenseAction.INSTANCE).get(); assertThat(getLicenseResponse.license(), not(signedLicense)); } public void testPutExpiredLicense() throws Exception { License expiredLicense = generateExpiredNonBasicLicense(); - PutLicenseRequestBuilder builder = new PutLicenseRequestBuilder(client().admin().cluster(), PutLicenseAction.INSTANCE); + PutLicenseRequestBuilder builder = new PutLicenseRequestBuilder(clusterAdmin(), PutLicenseAction.INSTANCE); builder.setLicense(expiredLicense); PutLicenseResponse putLicenseResponse = builder.get(); assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.EXPIRED)); // get license should not return the expired license - GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).get(); + GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(clusterAdmin(), GetLicenseAction.INSTANCE).get(); assertThat(getLicenseResponse.license(), not(expiredLicense)); } public void testPutLicensesSimple() throws Exception { License goldSignedLicense = generateSignedLicense("gold", TimeValue.timeValueMinutes(5)); - PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder( - client().admin().cluster(), - PutLicenseAction.INSTANCE - ).setLicense(goldSignedLicense).setAcknowledge(true); + PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(clusterAdmin(), PutLicenseAction.INSTANCE) + .setLicense(goldSignedLicense) + .setAcknowledge(true); PutLicenseResponse putLicenseResponse = putLicenseRequestBuilder.get(); assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID)); - GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).get(); + GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(clusterAdmin(), GetLicenseAction.INSTANCE).get(); assertThat(getLicenseResponse.license(), equalTo(goldSignedLicense)); License platinumSignedLicense = generateSignedLicense("platinum", TimeValue.timeValueMinutes(2)); @@ -171,30 +168,29 @@ public class LicensesTransportTests extends ESSingleNodeTestCase { putLicenseResponse = putLicenseRequestBuilder.get(); assertThat(putLicenseResponse.isAcknowledged(), equalTo(true)); assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID)); - getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).get(); + getLicenseResponse = new GetLicenseRequestBuilder(clusterAdmin(), GetLicenseAction.INSTANCE).get(); assertThat(getLicenseResponse.license(), equalTo(platinumSignedLicense)); } public void testRemoveLicensesSimple() throws Exception { License goldLicense = generateSignedLicense("gold", TimeValue.timeValueMinutes(5)); - PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder( - client().admin().cluster(), - PutLicenseAction.INSTANCE - ).setLicense(goldLicense).setAcknowledge(true); + PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(clusterAdmin(), PutLicenseAction.INSTANCE) + .setLicense(goldLicense) + .setAcknowledge(true); PutLicenseResponse putLicenseResponse = putLicenseRequestBuilder.get(); assertThat(putLicenseResponse.isAcknowledged(), equalTo(true)); assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID)); - GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).get(); + GetLicenseResponse getLicenseResponse = new GetLicenseRequestBuilder(clusterAdmin(), GetLicenseAction.INSTANCE).get(); assertThat(getLicenseResponse.license(), equalTo(goldLicense)); // delete all licenses DeleteLicenseRequestBuilder deleteLicenseRequestBuilder = new DeleteLicenseRequestBuilder( - client().admin().cluster(), + clusterAdmin(), DeleteLicenseAction.INSTANCE ); AcknowledgedResponse deleteLicenseResponse = deleteLicenseRequestBuilder.get(); assertThat(deleteLicenseResponse.isAcknowledged(), equalTo(true)); // get licenses (expected no licenses) - getLicenseResponse = new GetLicenseRequestBuilder(client().admin().cluster(), GetLicenseAction.INSTANCE).get(); + getLicenseResponse = new GetLicenseRequestBuilder(clusterAdmin(), GetLicenseAction.INSTANCE).get(); assertTrue(License.LicenseType.isBasic(getLicenseResponse.license().type())); } @@ -212,10 +208,9 @@ public class LicensesTransportTests extends ESSingleNodeTestCase { .maxNodes(5); License license = TestUtils.generateSignedLicense(builder); - PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder( - client().admin().cluster(), - PutLicenseAction.INSTANCE - ).setLicense(license).setAcknowledge(true); + PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(clusterAdmin(), PutLicenseAction.INSTANCE) + .setLicense(license) + .setAcknowledge(true); PutLicenseResponse putLicenseResponse = putLicenseRequestBuilder.get(); assertThat(putLicenseResponse.isAcknowledged(), equalTo(true)); assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.INVALID)); @@ -235,10 +230,9 @@ public class LicensesTransportTests extends ESSingleNodeTestCase { .maxNodes(5); License license = TestUtils.generateSignedLicense(builder); - PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder( - client().admin().cluster(), - PutLicenseAction.INSTANCE - ).setLicense(license).setAcknowledge(true); + PutLicenseRequestBuilder putLicenseRequestBuilder = new PutLicenseRequestBuilder(clusterAdmin(), PutLicenseAction.INSTANCE) + .setLicense(license) + .setAcknowledge(true); PutLicenseResponse putLicenseResponse = putLicenseRequestBuilder.get(); assertThat(putLicenseResponse.isAcknowledged(), equalTo(true)); assertThat(putLicenseResponse.status(), equalTo(LicensesStatus.VALID)); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/async/AsyncSearchIndexServiceTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/async/AsyncSearchIndexServiceTests.java index 5563fea7c05d..379530d72786 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/async/AsyncSearchIndexServiceTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/async/AsyncSearchIndexServiceTests.java @@ -345,7 +345,7 @@ public class AsyncSearchIndexServiceTests extends ESSingleNodeTestCase { int limit = randomIntBetween(1, 125); ClusterUpdateSettingsRequest updateSettingsRequest = new ClusterUpdateSettingsRequest(); updateSettingsRequest.transientSettings(Settings.builder().put("search.max_async_search_response_size", limit + "b")); - assertAcked(client().admin().cluster().updateSettings(updateSettingsRequest).actionGet()); + assertAcked(clusterAdmin().updateSettings(updateSettingsRequest).actionGet()); String expectedErrMsg = "Can't store an async search response larger than [" + limit + "] bytes. " @@ -378,7 +378,7 @@ public class AsyncSearchIndexServiceTests extends ESSingleNodeTestCase { // restoring limit ClusterUpdateSettingsRequest updateSettingsRequest = new ClusterUpdateSettingsRequest(); updateSettingsRequest.transientSettings(Settings.builder().put("search.max_async_search_response_size", (String) null)); - assertAcked(client().admin().cluster().updateSettings(updateSettingsRequest).actionGet()); + assertAcked(clusterAdmin().updateSettings(updateSettingsRequest).actionGet()); } } diff --git a/x-pack/plugin/enrich/src/internalClusterTest/java/org/elasticsearch/xpack/enrich/EnrichMultiNodeIT.java b/x-pack/plugin/enrich/src/internalClusterTest/java/org/elasticsearch/xpack/enrich/EnrichMultiNodeIT.java index 55e0ed54097b..389ccd380a59 100644 --- a/x-pack/plugin/enrich/src/internalClusterTest/java/org/elasticsearch/xpack/enrich/EnrichMultiNodeIT.java +++ b/x-pack/plugin/enrich/src/internalClusterTest/java/org/elasticsearch/xpack/enrich/EnrichMultiNodeIT.java @@ -178,9 +178,9 @@ public class EnrichMultiNodeIT extends ESIntegTestCase { assertThat(executePolicyResponse.getTaskId(), notNullValue()); var getTaskRequest = new GetTaskRequest().setTaskId(executePolicyResponse.getTaskId()).setWaitForCompletion(true); - client().admin().cluster().getTask(getTaskRequest).actionGet(); + clusterAdmin().getTask(getTaskRequest).actionGet(); - var discoNodes = client().admin().cluster().state(new ClusterStateRequest()).actionGet().getState().nodes(); + var discoNodes = clusterAdmin().state(new ClusterStateRequest()).actionGet().getState().nodes(); assertThat(discoNodes.get(executePolicyResponse.getTaskId().getNodeId()).isMasterNode(), is(false)); } @@ -205,9 +205,9 @@ public class EnrichMultiNodeIT extends ESIntegTestCase { assertThat(executePolicyResponse.getTaskId(), notNullValue()); var getTaskRequest = new GetTaskRequest().setTaskId(executePolicyResponse.getTaskId()).setWaitForCompletion(true); - client().admin().cluster().getTask(getTaskRequest).actionGet(); + clusterAdmin().getTask(getTaskRequest).actionGet(); - var discoNodes = client().admin().cluster().state(new ClusterStateRequest()).actionGet().getState().nodes(); + var discoNodes = clusterAdmin().state(new ClusterStateRequest()).actionGet().getState().nodes(); assertThat(executePolicyResponse.getTaskId().getNodeId(), not(equalTo(discoNodes.getMasterNodeId()))); } @@ -295,16 +295,11 @@ public class EnrichMultiNodeIT extends ESIntegTestCase { new ExecuteEnrichPolicyAction.Request(POLICY_NAME) ); // Make sure we can deserialize enrich policy execution task status - final List tasks = client().admin() - .cluster() - .prepareListTasks() - .setActions(EnrichPolicyExecutor.TASK_ACTION) - .get() - .getTasks(); + final List tasks = clusterAdmin().prepareListTasks().setActions(EnrichPolicyExecutor.TASK_ACTION).get().getTasks(); // Best effort, sometimes the enrich policy task will not be visible yet or will have already finished if (tasks.isEmpty() == false) { try { - final GetTaskResponse getTaskResponse = client().admin().cluster().prepareGetTask(tasks.get(0).taskId()).get(); + final GetTaskResponse getTaskResponse = clusterAdmin().prepareGetTask(tasks.get(0).taskId()).get(); assertEquals(getTaskResponse.getTask().getTask().action(), EnrichPolicyExecutor.TASK_ACTION); } catch (ResourceNotFoundException e) { // ignored, could be the task has already finished @@ -319,6 +314,6 @@ public class EnrichMultiNodeIT extends ESIntegTestCase { "processors": [ { "enrich": { "policy_name": "%s", "field": "%s", "target_field": "user" } } ] }""", POLICY_NAME, MATCH_FIELD); PutPipelineRequest request = new PutPipelineRequest(PIPELINE_NAME, new BytesArray(pipelineBody), XContentType.JSON); - client().admin().cluster().putPipeline(request).actionGet(); + clusterAdmin().putPipeline(request).actionGet(); } } diff --git a/x-pack/plugin/enrich/src/internalClusterTest/java/org/elasticsearch/xpack/enrich/EnrichProcessorIT.java b/x-pack/plugin/enrich/src/internalClusterTest/java/org/elasticsearch/xpack/enrich/EnrichProcessorIT.java index 0c736f9c9931..e93f1e9c2202 100644 --- a/x-pack/plugin/enrich/src/internalClusterTest/java/org/elasticsearch/xpack/enrich/EnrichProcessorIT.java +++ b/x-pack/plugin/enrich/src/internalClusterTest/java/org/elasticsearch/xpack/enrich/EnrichProcessorIT.java @@ -120,7 +120,7 @@ public class EnrichProcessorIT extends ESSingleNodeTestCase { ] } """), XContentType.JSON); - var response = client().admin().cluster().simulatePipeline(simulatePipelineRequest).actionGet(); + var response = clusterAdmin().simulatePipeline(simulatePipelineRequest).actionGet(); var result = (SimulateDocumentBaseResult) response.getResults().get(0); assertThat(result.getFailure(), nullValue()); assertThat(result.getIngestDocument().getFieldValue("device.name", String.class), equalTo("bla")); @@ -156,7 +156,7 @@ public class EnrichProcessorIT extends ESSingleNodeTestCase { ] } """), XContentType.JSON); - response = client().admin().cluster().simulatePipeline(simulatePipelineRequest).actionGet(); + response = clusterAdmin().simulatePipeline(simulatePipelineRequest).actionGet(); result = (SimulateDocumentBaseResult) response.getResults().get(0); assertThat(result.getFailure(), nullValue()); assertThat(result.getIngestDocument().getFieldValue("_tmp.device.name", String.class), equalTo("bla")); diff --git a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/BasicEnrichTests.java b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/BasicEnrichTests.java index da9102c20e04..10ec1f8fb6f7 100644 --- a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/BasicEnrichTests.java +++ b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/BasicEnrichTests.java @@ -112,7 +112,7 @@ public class BasicEnrichTests extends ESSingleNodeTestCase { ] }""", policyName, MATCH_FIELD, maxMatches); PutPipelineRequest putPipelineRequest = new PutPipelineRequest(pipelineName, new BytesArray(pipelineBody), XContentType.JSON); - client().admin().cluster().putPipeline(putPipelineRequest).actionGet(); + clusterAdmin().putPipeline(putPipelineRequest).actionGet(); BulkRequest bulkRequest = new BulkRequest("my-index"); for (int i = 0; i < numDocs; i++) { @@ -205,7 +205,7 @@ public class BasicEnrichTests extends ESSingleNodeTestCase { ] }""", policyName, matchField); PutPipelineRequest putPipelineRequest = new PutPipelineRequest(pipelineName, new BytesArray(pipelineBody), XContentType.JSON); - client().admin().cluster().putPipeline(putPipelineRequest).actionGet(); + clusterAdmin().putPipeline(putPipelineRequest).actionGet(); BulkRequest bulkRequest = new BulkRequest("my-index"); IndexRequest indexRequest = new IndexRequest(); @@ -256,7 +256,7 @@ public class BasicEnrichTests extends ESSingleNodeTestCase { "processors": [ { "enrich": { "policy_name": "%s", "field": "key", "target_field": "target" } } ] }""", policyName); PutPipelineRequest putPipelineRequest = new PutPipelineRequest(pipelineName, new BytesArray(pipelineBody), XContentType.JSON); - client().admin().cluster().putPipeline(putPipelineRequest).actionGet(); + clusterAdmin().putPipeline(putPipelineRequest).actionGet(); } BulkRequest bulkRequest = new BulkRequest("my-index"); @@ -314,7 +314,7 @@ public class BasicEnrichTests extends ESSingleNodeTestCase { "processors": [ { "enrich": { "policy_name": "%s", "field": "key", "target_field": "target" } } ] }""", policyName); PutPipelineRequest putPipelineRequest = new PutPipelineRequest(pipelineName, new BytesArray(pipelineBody), XContentType.JSON); - client().admin().cluster().putPipeline(putPipelineRequest).actionGet(); + clusterAdmin().putPipeline(putPipelineRequest).actionGet(); BulkRequest bulkRequest = new BulkRequest("my-index"); int numTestDocs = randomIntBetween(3, 10); @@ -357,7 +357,7 @@ public class BasicEnrichTests extends ESSingleNodeTestCase { policyName ); PutPipelineRequest putPipelineRequest = new PutPipelineRequest(pipelineName, new BytesArray(pipelineBody), XContentType.JSON); - client().admin().cluster().putPipeline(putPipelineRequest).actionGet(); + clusterAdmin().putPipeline(putPipelineRequest).actionGet(); IndexRequest indexRequest = new IndexRequest("my-index").id("1") .setPipeline(pipelineName) @@ -396,7 +396,7 @@ public class BasicEnrichTests extends ESSingleNodeTestCase { + "{ \"foreach\": {\"field\":\"users\", \"processor\":{\"append\":{\"field\":\"matched2\",\"value\":\"{{_ingest._value}}\"}}}}" + "]}"; PutPipelineRequest putPipelineRequest = new PutPipelineRequest(pipelineName, new BytesArray(pipelineBody), XContentType.JSON); - client().admin().cluster().putPipeline(putPipelineRequest).actionGet(); + clusterAdmin().putPipeline(putPipelineRequest).actionGet(); for (int i = 0; i < 5; i++) { IndexRequest indexRequest = new IndexRequest("my-index").id("1") diff --git a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyUpdateTests.java b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyUpdateTests.java index 5a31f70c9838..73c68b92ff30 100644 --- a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyUpdateTests.java +++ b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/EnrichPolicyUpdateTests.java @@ -66,7 +66,7 @@ public class EnrichPolicyUpdateTests extends ESSingleNodeTestCase { String pipelineConfig = """ {"processors":[{"enrich": {"policy_name": "my_policy", "field": "key", "target_field": "target"}}]}"""; PutPipelineRequest putPipelineRequest = new PutPipelineRequest("1", new BytesArray(pipelineConfig), XContentType.JSON); - assertAcked(client().admin().cluster().putPipeline(putPipelineRequest).actionGet()); + assertAcked(clusterAdmin().putPipeline(putPipelineRequest).actionGet()); Pipeline pipelineInstance1 = ingestService.getPipeline("1"); assertThat(pipelineInstance1.getProcessors().get(0), instanceOf(MatchProcessor.class)); diff --git a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/action/TransportDeleteEnrichPolicyActionTests.java b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/action/TransportDeleteEnrichPolicyActionTests.java index 6a6aa5622d75..d34fcf48aa68 100644 --- a/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/action/TransportDeleteEnrichPolicyActionTests.java +++ b/x-pack/plugin/enrich/src/test/java/org/elasticsearch/xpack/enrich/action/TransportDeleteEnrichPolicyActionTests.java @@ -126,7 +126,7 @@ public class TransportDeleteEnrichPolicyActionTests extends AbstractEnrichTestCa Settings settings = Settings.builder() .put(DestructiveOperations.REQUIRES_NAME_SETTING.getKey(), destructiveRequiresName) .build(); - assertAcked(client().admin().cluster().prepareUpdateSettings().setPersistentSettings(settings)); + assertAcked(clusterAdmin().prepareUpdateSettings().setPersistentSettings(settings)); } createIndex(EnrichPolicy.getIndexName(name, 1001)); @@ -161,7 +161,7 @@ public class TransportDeleteEnrichPolicyActionTests extends AbstractEnrichTestCa if (destructiveRequiresName) { Settings settings = Settings.builder().putNull(DestructiveOperations.REQUIRES_NAME_SETTING.getKey()).build(); - assertAcked(client().admin().cluster().prepareUpdateSettings().setPersistentSettings(settings)); + assertAcked(clusterAdmin().prepareUpdateSettings().setPersistentSettings(settings)); } EnrichPolicyLocks enrichPolicyLocks = getInstanceFromNode(EnrichPolicyLocks.class); diff --git a/x-pack/plugin/eql/src/internalClusterTest/java/org/elasticsearch/xpack/eql/action/AbstractEqlBlockingIntegTestCase.java b/x-pack/plugin/eql/src/internalClusterTest/java/org/elasticsearch/xpack/eql/action/AbstractEqlBlockingIntegTestCase.java index 23b16fdf1f06..3c25d872d914 100644 --- a/x-pack/plugin/eql/src/internalClusterTest/java/org/elasticsearch/xpack/eql/action/AbstractEqlBlockingIntegTestCase.java +++ b/x-pack/plugin/eql/src/internalClusterTest/java/org/elasticsearch/xpack/eql/action/AbstractEqlBlockingIntegTestCase.java @@ -245,7 +245,7 @@ public abstract class AbstractEqlBlockingIntegTestCase extends AbstractEqlIntegT } protected TaskInfo getTaskInfoWithXOpaqueId(String id, String action) { - ListTasksResponse tasks = client().admin().cluster().prepareListTasks().setActions(action).get(); + ListTasksResponse tasks = clusterAdmin().prepareListTasks().setActions(action).get(); for (TaskInfo task : tasks.getTasks()) { if (id.equals(task.headers().get(Task.X_OPAQUE_ID_HTTP_HEADER))) { return task; @@ -258,7 +258,7 @@ public abstract class AbstractEqlBlockingIntegTestCase extends AbstractEqlIntegT TaskId taskId = findTaskWithXOpaqueId(id, action); assertNotNull(taskId); logger.trace("Cancelling task " + taskId); - CancelTasksResponse response = client().admin().cluster().prepareCancelTasks().setTargetTaskId(taskId).get(); + CancelTasksResponse response = clusterAdmin().prepareCancelTasks().setTargetTaskId(taskId).get(); assertThat(response.getTasks(), hasSize(1)); assertThat(response.getTasks().get(0).action(), equalTo(action)); logger.trace("Task is cancelled " + taskId); diff --git a/x-pack/plugin/fleet/src/internalClusterTest/java/org/elasticsearch/xpack/fleet/action/SearchUsageStatsIT.java b/x-pack/plugin/fleet/src/internalClusterTest/java/org/elasticsearch/xpack/fleet/action/SearchUsageStatsIT.java index da15ee95cfb1..943854609ecb 100644 --- a/x-pack/plugin/fleet/src/internalClusterTest/java/org/elasticsearch/xpack/fleet/action/SearchUsageStatsIT.java +++ b/x-pack/plugin/fleet/src/internalClusterTest/java/org/elasticsearch/xpack/fleet/action/SearchUsageStatsIT.java @@ -40,7 +40,7 @@ public class SearchUsageStatsIT extends ESIntegTestCase { public void testSearchUsageStats() throws IOException { { - SearchUsageStats stats = client().admin().cluster().prepareClusterStats().get().getIndicesStats().getSearchUsageStats(); + SearchUsageStats stats = clusterAdmin().prepareClusterStats().get().getIndicesStats().getSearchUsageStats(); assertEquals(0, stats.getTotalSearchCount()); assertEquals(0, stats.getQueryUsage().size()); assertEquals(0, stats.getSectionsUsage().size()); @@ -91,7 +91,7 @@ public class SearchUsageStatsIT extends ESIntegTestCase { getRestClient().performRequest(request); } - SearchUsageStats stats = client().admin().cluster().prepareClusterStats().get().getIndicesStats().getSearchUsageStats(); + SearchUsageStats stats = clusterAdmin().prepareClusterStats().get().getIndicesStats().getSearchUsageStats(); assertEquals(5, stats.getTotalSearchCount()); assertEquals(4, stats.getQueryUsage().size()); assertEquals(1, stats.getQueryUsage().get("match").longValue()); diff --git a/x-pack/plugin/frozen-indices/src/internalClusterTest/java/org/elasticsearch/index/engine/frozen/FrozenIndexIT.java b/x-pack/plugin/frozen-indices/src/internalClusterTest/java/org/elasticsearch/index/engine/frozen/FrozenIndexIT.java index f5c3c13cd461..bb9379ec06a7 100644 --- a/x-pack/plugin/frozen-indices/src/internalClusterTest/java/org/elasticsearch/index/engine/frozen/FrozenIndexIT.java +++ b/x-pack/plugin/frozen-indices/src/internalClusterTest/java/org/elasticsearch/index/engine/frozen/FrozenIndexIT.java @@ -84,8 +84,8 @@ public class FrozenIndexIT extends ESIntegTestCase { final String excludeSetting = INDEX_ROUTING_EXCLUDE_GROUP_SETTING.getConcreteSettingForNamespace("_name").getKey(); updateIndexSettings(Settings.builder().put(excludeSetting, nodeNames.get(0)), "index"); - assertAcked(client().admin().cluster().prepareReroute().add(new CancelAllocationCommand("index", 0, nodeNames.get(0), true))); - assertThat(client().admin().cluster().prepareHealth("index").get().getUnassignedShards(), equalTo(1)); + assertAcked(clusterAdmin().prepareReroute().add(new CancelAllocationCommand("index", 0, nodeNames.get(0), true))); + assertThat(clusterAdmin().prepareHealth("index").get().getUnassignedShards(), equalTo(1)); assertThat(client().prepareDelete("index", indexResponse.getId()).get().status(), equalTo(RestStatus.OK)); @@ -94,24 +94,20 @@ public class FrozenIndexIT extends ESIntegTestCase { ); assertThat( - client().admin().cluster().prepareState().get().getState().metadata().index("index").getTimestampRange(), + clusterAdmin().prepareState().get().getState().metadata().index("index").getTimestampRange(), sameInstance(IndexLongFieldRange.EMPTY) ); internalCluster().stopNode(nodeNames.get(1)); - assertThat(client().admin().cluster().prepareHealth("index").get().getUnassignedShards(), equalTo(2)); + assertThat(clusterAdmin().prepareHealth("index").get().getUnassignedShards(), equalTo(2)); updateIndexSettings(Settings.builder().putNull(excludeSetting), "index"); - assertThat(client().admin().cluster().prepareHealth("index").get().getUnassignedShards(), equalTo(2)); + assertThat(clusterAdmin().prepareHealth("index").get().getUnassignedShards(), equalTo(2)); - assertAcked( - client().admin().cluster().prepareReroute().add(new AllocateStalePrimaryAllocationCommand("index", 0, nodeNames.get(0), true)) - ); + assertAcked(clusterAdmin().prepareReroute().add(new AllocateStalePrimaryAllocationCommand("index", 0, nodeNames.get(0), true))); ensureYellowAndNoInitializingShards("index"); - final IndexLongFieldRange timestampFieldRange = client().admin() - .cluster() - .prepareState() + final IndexLongFieldRange timestampFieldRange = clusterAdmin().prepareState() .get() .getState() .metadata() @@ -165,9 +161,7 @@ public class FrozenIndexIT extends ESIntegTestCase { ) ); - final Index index = client().admin() - .cluster() - .prepareState() + final Index index = clusterAdmin().prepareState() .clear() .setIndices("index") .setMetadata(true) diff --git a/x-pack/plugin/frozen-indices/src/internalClusterTest/java/org/elasticsearch/index/engine/frozen/FrozenIndexTests.java b/x-pack/plugin/frozen-indices/src/internalClusterTest/java/org/elasticsearch/index/engine/frozen/FrozenIndexTests.java index 8aabdbe9a7f4..67aba439ebe6 100644 --- a/x-pack/plugin/frozen-indices/src/internalClusterTest/java/org/elasticsearch/index/engine/frozen/FrozenIndexTests.java +++ b/x-pack/plugin/frozen-indices/src/internalClusterTest/java/org/elasticsearch/index/engine/frozen/FrozenIndexTests.java @@ -290,7 +290,7 @@ public class FrozenIndexTests extends ESSingleNodeTestCase { new FreezeRequest("idx*").setFreeze(false).indicesOptions(IndicesOptions.strictExpand()) ).actionGet() ); - ClusterStateResponse stateResponse = client().admin().cluster().prepareState().get(); + ClusterStateResponse stateResponse = clusterAdmin().prepareState().get(); assertEquals(IndexMetadata.State.CLOSE, stateResponse.getState().getMetadata().index("idx-closed").getState()); assertEquals(IndexMetadata.State.OPEN, stateResponse.getState().getMetadata().index("idx").getState()); assertHitCount(client().prepareSearch().get(), 1L); @@ -483,20 +483,14 @@ public class FrozenIndexTests extends ESSingleNodeTestCase { ).actionGet() ); assertIndexFrozen("idx"); - assertEquals( - IndexMetadata.State.CLOSE, - client().admin().cluster().prepareState().get().getState().metadata().index("idx-close").getState() - ); + assertEquals(IndexMetadata.State.CLOSE, clusterAdmin().prepareState().get().getState().metadata().index("idx-close").getState()); } public void testUnfreezeClosedIndex() { createIndex("idx", Settings.builder().put("index.number_of_shards", 1).build()); assertAcked(client().execute(FreezeIndexAction.INSTANCE, new FreezeRequest("idx")).actionGet()); assertAcked(indicesAdmin().prepareClose("idx")); - assertEquals( - IndexMetadata.State.CLOSE, - client().admin().cluster().prepareState().get().getState().metadata().index("idx").getState() - ); + assertEquals(IndexMetadata.State.CLOSE, clusterAdmin().prepareState().get().getState().metadata().index("idx").getState()); expectThrows( IndexNotFoundException.class, () -> client().execute( @@ -509,10 +503,7 @@ public class FrozenIndexTests extends ESSingleNodeTestCase { ); // we don't resolve to closed indices assertAcked(client().execute(FreezeIndexAction.INSTANCE, new FreezeRequest("idx").setFreeze(false)).actionGet()); - assertEquals( - IndexMetadata.State.OPEN, - client().admin().cluster().prepareState().get().getState().metadata().index("idx").getState() - ); + assertEquals(IndexMetadata.State.OPEN, clusterAdmin().prepareState().get().getState().metadata().index("idx").getState()); } public void testFreezeIndexIncreasesIndexSettingsVersion() { @@ -520,19 +511,12 @@ public class FrozenIndexTests extends ESSingleNodeTestCase { createIndex(index, indexSettings(1, 0).build()); client().prepareIndex(index).setSource("field", "value").execute().actionGet(); - final long settingsVersion = client().admin() - .cluster() - .prepareState() - .get() - .getState() - .metadata() - .index(index) - .getSettingsVersion(); + final long settingsVersion = clusterAdmin().prepareState().get().getState().metadata().index(index).getSettingsVersion(); assertAcked(client().execute(FreezeIndexAction.INSTANCE, new FreezeRequest(index)).actionGet()); assertIndexFrozen(index); assertThat( - client().admin().cluster().prepareState().get().getState().metadata().index(index).getSettingsVersion(), + clusterAdmin().prepareState().get().getState().metadata().index(index).getSettingsVersion(), greaterThan(settingsVersion) ); } @@ -549,7 +533,7 @@ public class FrozenIndexTests extends ESSingleNodeTestCase { final IndicesService indicesService = getInstanceFromNode(IndicesService.class); assertBusy(() -> { - final Index index = client().admin().cluster().prepareState().get().getState().metadata().index(indexName).getIndex(); + final Index index = clusterAdmin().prepareState().get().getState().metadata().index(indexName).getIndex(); final IndexService indexService = indicesService.indexService(index); assertThat(indexService.hasShard(0), is(true)); assertThat(indexService.getShard(0).getLastKnownGlobalCheckpoint(), greaterThanOrEqualTo(nbNoOps - 1L)); @@ -572,7 +556,7 @@ public class FrozenIndexTests extends ESSingleNodeTestCase { assertAcked(client().execute(FreezeIndexAction.INSTANCE, new FreezeRequest(indexName)).actionGet()); assertIndexFrozen(indexName); - final IndexMetadata indexMetadata = client().admin().cluster().prepareState().get().getState().metadata().index(indexName); + final IndexMetadata indexMetadata = clusterAdmin().prepareState().get().getState().metadata().index(indexName); final IndexService indexService = getInstanceFromNode(IndicesService.class).indexService(indexMetadata.getIndex()); for (int i = 0; i < indexMetadata.getNumberOfShards(); i++) { final IndexShard indexShard = indexService.getShardOrNull(i); @@ -635,9 +619,7 @@ public class FrozenIndexTests extends ESSingleNodeTestCase { assertAcked(client().execute(FreezeIndexAction.INSTANCE, new FreezeRequest("index")).actionGet()); - final IndexLongFieldRange timestampFieldRange = client().admin() - .cluster() - .prepareState() + final IndexLongFieldRange timestampFieldRange = clusterAdmin().prepareState() .get() .getState() .metadata() @@ -669,9 +651,7 @@ public class FrozenIndexTests extends ESSingleNodeTestCase { assertAcked(client().execute(FreezeIndexAction.INSTANCE, new FreezeRequest("index")).actionGet()); - final IndexLongFieldRange timestampFieldRange = client().admin() - .cluster() - .prepareState() + final IndexLongFieldRange timestampFieldRange = clusterAdmin().prepareState() .get() .getState() .metadata() diff --git a/x-pack/plugin/ilm/src/internalClusterTest/java/org/elasticsearch/xpack/ilm/DataTiersMigrationsTests.java b/x-pack/plugin/ilm/src/internalClusterTest/java/org/elasticsearch/xpack/ilm/DataTiersMigrationsTests.java index bb491822c920..d440e338b70b 100644 --- a/x-pack/plugin/ilm/src/internalClusterTest/java/org/elasticsearch/xpack/ilm/DataTiersMigrationsTests.java +++ b/x-pack/plugin/ilm/src/internalClusterTest/java/org/elasticsearch/xpack/ilm/DataTiersMigrationsTests.java @@ -230,7 +230,7 @@ public class DataTiersMigrationsTests extends ESIntegTestCase { ClusterAllocationExplainRequest explainReplicaShard = new ClusterAllocationExplainRequest().setIndex(managedIndex) .setPrimary(false) .setShard(0); - ClusterAllocationExplainResponse response = client().admin().cluster().allocationExplain(explainReplicaShard).actionGet(); + ClusterAllocationExplainResponse response = clusterAdmin().allocationExplain(explainReplicaShard).actionGet(); assertThat(response.getExplanation().getShardState(), is(ShardRoutingState.UNASSIGNED)); } } diff --git a/x-pack/plugin/ilm/src/internalClusterTest/java/org/elasticsearch/xpack/ilm/IndexLifecycleInitialisationTests.java b/x-pack/plugin/ilm/src/internalClusterTest/java/org/elasticsearch/xpack/ilm/IndexLifecycleInitialisationTests.java index 7bcc43d5e604..7e0329998084 100644 --- a/x-pack/plugin/ilm/src/internalClusterTest/java/org/elasticsearch/xpack/ilm/IndexLifecycleInitialisationTests.java +++ b/x-pack/plugin/ilm/src/internalClusterTest/java/org/elasticsearch/xpack/ilm/IndexLifecycleInitialisationTests.java @@ -180,7 +180,7 @@ public class IndexLifecycleInitialisationTests extends ESIntegTestCase { logger.info("Creating index [test]"); CreateIndexResponse createIndexResponse = indicesAdmin().create(new CreateIndexRequest("test").settings(settings)).actionGet(); assertAcked(createIndexResponse); - ClusterState clusterState = client().admin().cluster().prepareState().get().getState(); + ClusterState clusterState = clusterAdmin().prepareState().get().getState(); RoutingNode routingNodeEntry1 = clusterState.getRoutingNodes().node(node1); assertThat(routingNodeEntry1.numberOfShardsWithState(STARTED), equalTo(1)); assertBusy(() -> { assertTrue(indexExists("test")); }); @@ -188,9 +188,7 @@ public class IndexLifecycleInitialisationTests extends ESIntegTestCase { assertThat(indexLifecycleService.getScheduler().jobCount(), equalTo(1)); assertNotNull(indexLifecycleService.getScheduledJob()); assertBusy(() -> { - LifecycleExecutionState lifecycleState = client().admin() - .cluster() - .prepareState() + LifecycleExecutionState lifecycleState = clusterAdmin().prepareState() .execute() .actionGet() .getState() @@ -416,15 +414,13 @@ public class IndexLifecycleInitialisationTests extends ESIntegTestCase { CreateIndexResponse createIndexResponse = indicesAdmin().create(new CreateIndexRequest("test").settings(settings)).actionGet(); assertAcked(createIndexResponse); - ClusterState clusterState = client().admin().cluster().prepareState().get().getState(); + ClusterState clusterState = clusterAdmin().prepareState().get().getState(); RoutingNode routingNodeEntry1 = clusterState.getRoutingNodes().node(node2); assertThat(routingNodeEntry1.numberOfShardsWithState(STARTED), equalTo(1)); assertBusy(() -> assertTrue(indexExists("test"))); assertBusy(() -> { - LifecycleExecutionState lifecycleState = client().admin() - .cluster() - .prepareState() + LifecycleExecutionState lifecycleState = clusterAdmin().prepareState() .execute() .actionGet() .getState() diff --git a/x-pack/plugin/ilm/src/internalClusterTest/java/org/elasticsearch/xpack/slm/SLMFileSettingsIT.java b/x-pack/plugin/ilm/src/internalClusterTest/java/org/elasticsearch/xpack/slm/SLMFileSettingsIT.java index 9fdb0d943879..7abe99c85f3b 100644 --- a/x-pack/plugin/ilm/src/internalClusterTest/java/org/elasticsearch/xpack/slm/SLMFileSettingsIT.java +++ b/x-pack/plugin/ilm/src/internalClusterTest/java/org/elasticsearch/xpack/slm/SLMFileSettingsIT.java @@ -198,10 +198,9 @@ public class SLMFileSettingsIT extends AbstractSnapshotIntegTestCase { boolean awaitSuccessful = savedClusterState.await(20, TimeUnit.SECONDS); assertTrue(awaitSuccessful); - final ClusterStateResponse clusterStateResponse = client().admin() - .cluster() - .state(new ClusterStateRequest().waitForMetadataVersion(metadataVersion.get())) - .get(); + final ClusterStateResponse clusterStateResponse = clusterAdmin().state( + new ClusterStateRequest().waitForMetadataVersion(metadataVersion.get()) + ).get(); var reservedState = clusterStateResponse.getState().metadata().reservedStateMetadata().get(FileSettingsService.NAMESPACE); @@ -220,7 +219,7 @@ public class SLMFileSettingsIT extends AbstractSnapshotIntegTestCase { "java.lang.IllegalArgumentException: Failed to process request " + "[org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest/unset] " + "with errors: [[indices.recovery.max_bytes_per_sec] set as read-only by [file_settings]]", - expectThrows(ExecutionException.class, () -> client().admin().cluster().updateSettings(req).get()).getMessage() + expectThrows(ExecutionException.class, () -> clusterAdmin().updateSettings(req).get()).getMessage() ); assertTrue( @@ -256,7 +255,7 @@ public class SLMFileSettingsIT extends AbstractSnapshotIntegTestCase { logger.info("--> create snapshot manually"); var request = new CreateSnapshotRequest("repo", "file-snap").waitForCompletion(true); - var response = admin().cluster().createSnapshot(request).get(); + var response = clusterAdmin().createSnapshot(request).get(); RestStatus status = response.getSnapshotInfo().status(); assertEquals(RestStatus.OK, status); @@ -281,7 +280,7 @@ public class SLMFileSettingsIT extends AbstractSnapshotIntegTestCase { // Cancel/delete the snapshot try { - client().admin().cluster().prepareDeleteSnapshot(REPO, snapshotName).get(); + clusterAdmin().prepareDeleteSnapshot(REPO, snapshotName).get(); } catch (SnapshotMissingException e) { // ignore } @@ -313,10 +312,9 @@ public class SLMFileSettingsIT extends AbstractSnapshotIntegTestCase { boolean awaitSuccessful = savedClusterState.await(20, TimeUnit.SECONDS); assertTrue(awaitSuccessful); - final ClusterStateResponse clusterStateResponse = client().admin() - .cluster() - .state(new ClusterStateRequest().waitForMetadataVersion(metadataVersion.get())) - .actionGet(); + final ClusterStateResponse clusterStateResponse = clusterAdmin().state( + new ClusterStateRequest().waitForMetadataVersion(metadataVersion.get()) + ).actionGet(); assertThat(clusterStateResponse.getState().metadata().persistentSettings().get("search.allow_expensive_queries"), nullValue()); diff --git a/x-pack/plugin/ilm/src/internalClusterTest/java/org/elasticsearch/xpack/slm/SLMSnapshotBlockingIntegTests.java b/x-pack/plugin/ilm/src/internalClusterTest/java/org/elasticsearch/xpack/slm/SLMSnapshotBlockingIntegTests.java index 9663e57a9efd..0e045d09245c 100644 --- a/x-pack/plugin/ilm/src/internalClusterTest/java/org/elasticsearch/xpack/slm/SLMSnapshotBlockingIntegTests.java +++ b/x-pack/plugin/ilm/src/internalClusterTest/java/org/elasticsearch/xpack/slm/SLMSnapshotBlockingIntegTests.java @@ -148,7 +148,7 @@ public class SLMSnapshotBlockingIntegTests extends AbstractSnapshotIntegTestCase // Cancel/delete the snapshot try { - client().admin().cluster().prepareDeleteSnapshot(REPO, snapshotName).get(); + clusterAdmin().prepareDeleteSnapshot(REPO, snapshotName).get(); } catch (SnapshotMissingException e) { // ignore } @@ -246,7 +246,7 @@ public class SLMSnapshotBlockingIntegTests extends AbstractSnapshotIntegTestCase // Check that the snapshot created by the policy has been removed by retention assertBusy(() -> { // Trigger a cluster state update so that it re-checks for a snapshot in progress - client().admin().cluster().prepareReroute().get(); + clusterAdmin().prepareReroute().get(); logger.info("--> waiting for snapshot to be deleted"); try { SnapshotsStatusResponse s = getSnapshotStatus(completedSnapshotName); @@ -260,7 +260,7 @@ public class SLMSnapshotBlockingIntegTests extends AbstractSnapshotIntegTestCase assertBusy(() -> { try { logger.info("--> cancelling snapshot {}", secondSnapName); - client().admin().cluster().prepareDeleteSnapshot(REPO, secondSnapName).get(); + clusterAdmin().prepareDeleteSnapshot(REPO, secondSnapName).get(); } catch (ConcurrentSnapshotExecutionException e) { logger.info("--> attempted to stop second snapshot", e); // just wait and retry @@ -347,7 +347,7 @@ public class SLMSnapshotBlockingIntegTests extends AbstractSnapshotIntegTestCase logger.info("--> stopping random data node, which should cause shards to go missing"); internalCluster().stopRandomDataNode(); assertBusy( - () -> assertEquals(ClusterHealthStatus.RED, client().admin().cluster().prepareHealth().get().getStatus()), + () -> assertEquals(ClusterHealthStatus.RED, clusterAdmin().prepareHealth().get().getStatus()), 30, TimeUnit.SECONDS ); @@ -377,9 +377,7 @@ public class SLMSnapshotBlockingIntegTests extends AbstractSnapshotIntegTestCase logger.info("--> verify that snapshot [{}] is {}", failedSnapshotName.get(), expectedUnsuccessfulState); assertBusy(() -> { try { - GetSnapshotsResponse snapshotsStatusResponse = client().admin() - .cluster() - .prepareGetSnapshots(REPO) + GetSnapshotsResponse snapshotsStatusResponse = clusterAdmin().prepareGetSnapshots(REPO) .setSnapshots(failedSnapshotName.get()) .get(); SnapshotInfo snapshotInfo = snapshotsStatusResponse.getSnapshots().get(0); @@ -421,9 +419,7 @@ public class SLMSnapshotBlockingIntegTests extends AbstractSnapshotIntegTestCase assertBusy(() -> { final SnapshotInfo snapshotInfo; try { - GetSnapshotsResponse snapshotsStatusResponse = client().admin() - .cluster() - .prepareGetSnapshots(REPO) + GetSnapshotsResponse snapshotsStatusResponse = clusterAdmin().prepareGetSnapshots(REPO) .setSnapshots(successfulSnapshotName.get()) .execute() .actionGet(); @@ -438,9 +434,7 @@ public class SLMSnapshotBlockingIntegTests extends AbstractSnapshotIntegTestCase // Check that the failed snapshot from before still exists, now that retention has run { logger.info("--> verify that snapshot [{}] still exists", failedSnapshotName.get()); - GetSnapshotsResponse snapshotsStatusResponse = client().admin() - .cluster() - .prepareGetSnapshots(REPO) + GetSnapshotsResponse snapshotsStatusResponse = clusterAdmin().prepareGetSnapshots(REPO) .setSnapshots(failedSnapshotName.get()) .get(); SnapshotInfo snapshotInfo = snapshotsStatusResponse.getSnapshots().get(0); @@ -454,9 +448,7 @@ public class SLMSnapshotBlockingIntegTests extends AbstractSnapshotIntegTestCase logger.info("--> waiting for {} snapshot [{}] to be deleted", expectedUnsuccessfulState, failedSnapshotName.get()); assertBusy(() -> { try { - GetSnapshotsResponse snapshotsStatusResponse = client().admin() - .cluster() - .prepareGetSnapshots(REPO) + GetSnapshotsResponse snapshotsStatusResponse = clusterAdmin().prepareGetSnapshots(REPO) .setSnapshots(failedSnapshotName.get()) .get(); assertThat(snapshotsStatusResponse.getSnapshots(), empty()); @@ -469,9 +461,7 @@ public class SLMSnapshotBlockingIntegTests extends AbstractSnapshotIntegTestCase failedSnapshotName.get(), successfulSnapshotName.get() ); - GetSnapshotsResponse snapshotsStatusResponse = client().admin() - .cluster() - .prepareGetSnapshots(REPO) + GetSnapshotsResponse snapshotsStatusResponse = clusterAdmin().prepareGetSnapshots(REPO) .setSnapshots(successfulSnapshotName.get()) .get(); SnapshotInfo snapshotInfo = snapshotsStatusResponse.getSnapshots().get(0); @@ -530,11 +520,7 @@ public class SLMSnapshotBlockingIntegTests extends AbstractSnapshotIntegTestCase logger.info("--> waiting for {} snapshot to be deleted", snapshotName); assertBusy(() -> { try { - GetSnapshotsResponse snapshotsStatusResponse = client().admin() - .cluster() - .prepareGetSnapshots(REPO) - .setSnapshots(snapshotName) - .get(); + GetSnapshotsResponse snapshotsStatusResponse = clusterAdmin().prepareGetSnapshots(REPO).setSnapshots(snapshotName).get(); assertThat(snapshotsStatusResponse.getSnapshots(), empty()); } catch (SnapshotMissingException e) { // This is what we want to happen @@ -544,7 +530,7 @@ public class SLMSnapshotBlockingIntegTests extends AbstractSnapshotIntegTestCase } private SnapshotsStatusResponse getSnapshotStatus(String snapshotName) { - return client().admin().cluster().prepareSnapshotStatus(REPO).setSnapshots(snapshotName).get(); + return clusterAdmin().prepareSnapshotStatus(REPO).setSnapshots(snapshotName).get(); } private void createAndPopulateIndex(String indexName) throws InterruptedException { diff --git a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/LifecycleOperationSnapshotTests.java b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/LifecycleOperationSnapshotTests.java index a0c9517db409..62d1aefa306b 100644 --- a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/LifecycleOperationSnapshotTests.java +++ b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/LifecycleOperationSnapshotTests.java @@ -56,12 +56,7 @@ public class LifecycleOperationSnapshotTests extends ESSingleNodeTestCase { } public void testModeSnapshotRestore() throws Exception { - client().admin() - .cluster() - .preparePutRepository("repo") - .setType("fs") - .setSettings(Settings.builder().put("location", "repo").build()) - .get(); + clusterAdmin().preparePutRepository("repo").setType("fs").setSettings(Settings.builder().put("location", "repo").build()).get(); client().execute( PutSnapshotLifecycleAction.INSTANCE, diff --git a/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/DatafeedJobsIT.java b/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/DatafeedJobsIT.java index 5bd10bd2f035..bf9266157ae4 100644 --- a/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/DatafeedJobsIT.java +++ b/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/DatafeedJobsIT.java @@ -89,7 +89,7 @@ public class DatafeedJobsIT extends MlNativeAutodetectIntegTestCase { indexDocs(logger, "data-1", numDocs, twoWeeksAgo, oneWeekAgo); client().admin().indices().prepareCreate("data-2").setMapping("time", "type=date").get(); - client().admin().cluster().prepareHealth("data-1", "data-2").setWaitForYellowStatus().get(); + clusterAdmin().prepareHealth("data-1", "data-2").setWaitForYellowStatus().get(); long numDocs2 = randomIntBetween(32, 2048); indexDocs(logger, "data-2", numDocs2, oneWeekAgo, now); @@ -135,7 +135,7 @@ public class DatafeedJobsIT extends MlNativeAutodetectIntegTestCase { long twoWeeksAgo = oneWeekAgo - 604800000; indexDocs(logger, "datafeed_data_stream", numDocs, twoWeeksAgo, oneWeekAgo); - client().admin().cluster().prepareHealth("datafeed_data_stream").setWaitForYellowStatus().get(); + clusterAdmin().prepareHealth("datafeed_data_stream").setWaitForYellowStatus().get(); Job.Builder job = createScheduledJob("lookback-data-stream-job"); PutJobAction.Response putJobResponse = putJob(job); @@ -318,7 +318,7 @@ public class DatafeedJobsIT extends MlNativeAutodetectIntegTestCase { Intervals.alignToCeil(oneWeekAgo, intervalMillis), Intervals.alignToFloor(now, intervalMillis) ); - client().admin().cluster().prepareHealth(indexName).setWaitForYellowStatus().get(); + clusterAdmin().prepareHealth(indexName).setWaitForYellowStatus().get(); String scrollJobId = "stop-restart-scroll"; Job.Builder scrollJob = createScheduledJob(scrollJobId); @@ -468,7 +468,7 @@ public class DatafeedJobsIT extends MlNativeAutodetectIntegTestCase { StopDatafeedAction.Response stopJobResponse = stopDatafeed(datafeedId); assertTrue(stopJobResponse.isStopped()); } catch (Exception e) { - NodesHotThreadsResponse nodesHotThreadsResponse = client().admin().cluster().prepareNodesHotThreads().get(); + NodesHotThreadsResponse nodesHotThreadsResponse = clusterAdmin().prepareNodesHotThreads().get(); int i = 0; for (NodeHotThreads nodeHotThreads : nodesHotThreadsResponse.getNodes()) { logger.info(i++ + ":\n" + nodeHotThreads.getHotThreads()); @@ -491,7 +491,7 @@ public class DatafeedJobsIT extends MlNativeAutodetectIntegTestCase { CloseJobAction.Response closeJobResponse = closeJob(jobId); assertTrue(closeJobResponse.isClosed()); } catch (Exception e) { - NodesHotThreadsResponse nodesHotThreadsResponse = client().admin().cluster().prepareNodesHotThreads().get(); + NodesHotThreadsResponse nodesHotThreadsResponse = clusterAdmin().prepareNodesHotThreads().get(); int i = 0; for (NodeHotThreads nodeHotThreads : nodesHotThreadsResponse.getNodes()) { logger.info(i++ + ":\n" + nodeHotThreads.getHotThreads()); @@ -538,7 +538,7 @@ public class DatafeedJobsIT extends MlNativeAutodetectIntegTestCase { CloseJobAction.Response closeJobResponse = closeJob(jobId, useForce); assertTrue(closeJobResponse.isClosed()); } catch (Exception e) { - NodesHotThreadsResponse nodesHotThreadsResponse = client().admin().cluster().prepareNodesHotThreads().get(); + NodesHotThreadsResponse nodesHotThreadsResponse = clusterAdmin().prepareNodesHotThreads().get(); int i = 0; for (NodeHotThreads nodeHotThreads : nodesHotThreadsResponse.getNodes()) { logger.info(i++ + ":\n" + nodeHotThreads.getHotThreads()); diff --git a/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/JobAndDatafeedResilienceIT.java b/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/JobAndDatafeedResilienceIT.java index fd3360dae83f..d0188326ebdb 100644 --- a/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/JobAndDatafeedResilienceIT.java +++ b/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/JobAndDatafeedResilienceIT.java @@ -56,7 +56,7 @@ public class JobAndDatafeedResilienceIT extends MlNativeAutodetectIntegTestCase forceCloseJob(jobId); assertBusy( () -> assertThat( - client().admin().cluster().prepareListTasks().setActions(MlTasks.JOB_TASK_NAME + "[c]").get().getTasks().size(), + clusterAdmin().prepareListTasks().setActions(MlTasks.JOB_TASK_NAME + "[c]").get().getTasks().size(), equalTo(0) ) ); @@ -93,7 +93,7 @@ public class JobAndDatafeedResilienceIT extends MlNativeAutodetectIntegTestCase forceStopDatafeed(datafeedConfig.getId()); assertBusy( () -> assertThat( - client().admin().cluster().prepareListTasks().setActions(MlTasks.DATAFEED_TASK_NAME + "[c]").get().getTasks().size(), + clusterAdmin().prepareListTasks().setActions(MlTasks.DATAFEED_TASK_NAME + "[c]").get().getTasks().size(), equalTo(0) ) ); @@ -127,7 +127,7 @@ public class JobAndDatafeedResilienceIT extends MlNativeAutodetectIntegTestCase closeJob(jobId2); assertBusy( () -> assertThat( - client().admin().cluster().prepareListTasks().setActions(MlTasks.JOB_TASK_NAME + "[c]").get().getTasks().size(), + clusterAdmin().prepareListTasks().setActions(MlTasks.JOB_TASK_NAME + "[c]").get().getTasks().size(), equalTo(0) ) ); @@ -181,7 +181,7 @@ public class JobAndDatafeedResilienceIT extends MlNativeAutodetectIntegTestCase stopDatafeed(datafeedConfig2.getId()); assertBusy( () -> assertThat( - client().admin().cluster().prepareListTasks().setActions(MlTasks.DATAFEED_TASK_NAME + "[c]").get().getTasks().size(), + clusterAdmin().prepareListTasks().setActions(MlTasks.DATAFEED_TASK_NAME + "[c]").get().getTasks().size(), equalTo(0) ) ); diff --git a/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/MlNativeDataFrameAnalyticsIntegTestCase.java b/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/MlNativeDataFrameAnalyticsIntegTestCase.java index 045cd06195c6..3894c46e7a81 100644 --- a/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/MlNativeDataFrameAnalyticsIntegTestCase.java +++ b/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/MlNativeDataFrameAnalyticsIntegTestCase.java @@ -273,7 +273,7 @@ abstract class MlNativeDataFrameAnalyticsIntegTestCase extends MlNativeIntegTest } protected Collection> analyticsTaskList() { - ClusterState masterClusterState = client().admin().cluster().prepareState().all().get().getState(); + ClusterState masterClusterState = clusterAdmin().prepareState().all().get().getState(); PersistentTasksCustomMetadata persistentTasks = masterClusterState.getMetadata().custom(PersistentTasksCustomMetadata.TYPE); return persistentTasks != null ? persistentTasks.findTasks(MlTasks.DATA_FRAME_ANALYTICS_TASK_NAME, task -> true) @@ -281,7 +281,7 @@ abstract class MlNativeDataFrameAnalyticsIntegTestCase extends MlNativeIntegTest } protected List analyticsAssignedTaskList() { - return client().admin().cluster().prepareListTasks().setActions(MlTasks.DATA_FRAME_ANALYTICS_TASK_NAME + "[c]").get().getTasks(); + return clusterAdmin().prepareListTasks().setActions(MlTasks.DATA_FRAME_ANALYTICS_TASK_NAME + "[c]").get().getTasks(); } protected void waitUntilSomeProgressHasBeenMadeForPhase(String jobId, String phase) throws Exception { diff --git a/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/MlNativeIntegTestCase.java b/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/MlNativeIntegTestCase.java index cda03265fec2..e1bd0b4a38d4 100644 --- a/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/MlNativeIntegTestCase.java +++ b/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/MlNativeIntegTestCase.java @@ -237,7 +237,7 @@ abstract class MlNativeIntegTestCase extends ESIntegTestCase { } protected boolean upgradeMode() { - ClusterState masterClusterState = client().admin().cluster().prepareState().all().get().getState(); + ClusterState masterClusterState = clusterAdmin().prepareState().all().get().getState(); MlMetadata mlMetadata = MlMetadata.getMlMetadata(masterClusterState); return mlMetadata.isUpgradeMode(); } @@ -353,7 +353,7 @@ abstract class MlNativeIntegTestCase extends ESIntegTestCase { new NamedWriteableRegistry.Entry(AutoscalingDeciderResult.Reason.class, MlScalingReason.NAME, MlScalingReason::new) ); final NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(entries); - ClusterState masterClusterState = client().admin().cluster().prepareState().all().get().getState(); + ClusterState masterClusterState = clusterAdmin().prepareState().all().get().getState(); byte[] masterClusterStateBytes = ClusterState.Builder.toBytes(masterClusterState); // remove local node reference masterClusterState = ClusterState.Builder.fromBytes(masterClusterStateBytes, null, namedWriteableRegistry); diff --git a/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/SetUpgradeModeIT.java b/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/SetUpgradeModeIT.java index 093268e54b16..123300455202 100644 --- a/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/SetUpgradeModeIT.java +++ b/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/SetUpgradeModeIT.java @@ -55,16 +55,14 @@ public class SetUpgradeModeIT extends MlNativeAutodetectIntegTestCase { // Assert appropriate task state and assignment numbers assertThat( - client().admin() - .cluster() - .prepareListTasks() + clusterAdmin().prepareListTasks() .setActions(MlTasks.JOB_TASK_NAME + "[c]", MlTasks.DATAFEED_TASK_NAME + "[c]") .get() .getTasks(), hasSize(2) ); - ClusterState masterClusterState = client().admin().cluster().prepareState().all().get().getState(); + ClusterState masterClusterState = clusterAdmin().prepareState().all().get().getState(); PersistentTasksCustomMetadata persistentTasks = masterClusterState.getMetadata().custom(PersistentTasksCustomMetadata.TYPE); assertThat(persistentTasks.findTasks(MlTasks.DATAFEED_TASK_NAME, task -> true), hasSize(1)); @@ -73,7 +71,7 @@ public class SetUpgradeModeIT extends MlNativeAutodetectIntegTestCase { // Set the upgrade mode setting setUpgradeModeTo(true); - masterClusterState = client().admin().cluster().prepareState().all().get().getState(); + masterClusterState = clusterAdmin().prepareState().all().get().getState(); // Assert state for tasks still exists and that the upgrade setting is set persistentTasks = masterClusterState.getMetadata().custom(PersistentTasksCustomMetadata.TYPE); @@ -81,9 +79,7 @@ public class SetUpgradeModeIT extends MlNativeAutodetectIntegTestCase { assertThat(persistentTasks.findTasks(MlTasks.JOB_TASK_NAME, task -> true), hasSize(1)); assertThat( - client().admin() - .cluster() - .prepareListTasks() + clusterAdmin().prepareListTasks() .setActions(MlTasks.JOB_TASK_NAME + "[c]", MlTasks.DATAFEED_TASK_NAME + "[c]") .get() .getTasks(), @@ -103,7 +99,7 @@ public class SetUpgradeModeIT extends MlNativeAutodetectIntegTestCase { // Disable the setting setUpgradeModeTo(false); - masterClusterState = client().admin().cluster().prepareState().all().get().getState(); + masterClusterState = clusterAdmin().prepareState().all().get().getState(); persistentTasks = masterClusterState.getMetadata().custom(PersistentTasksCustomMetadata.TYPE); assertThat(persistentTasks.findTasks(MlTasks.DATAFEED_TASK_NAME, task -> true), hasSize(1)); @@ -111,9 +107,7 @@ public class SetUpgradeModeIT extends MlNativeAutodetectIntegTestCase { assertBusy( () -> assertThat( - client().admin() - .cluster() - .prepareListTasks() + clusterAdmin().prepareListTasks() .setActions(MlTasks.JOB_TASK_NAME + "[c]", MlTasks.DATAFEED_TASK_NAME + "[c]") .get() .getTasks(), diff --git a/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/TestFeatureResetIT.java b/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/TestFeatureResetIT.java index 7893b35f1fbc..b2ba93b818c4 100644 --- a/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/TestFeatureResetIT.java +++ b/x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/TestFeatureResetIT.java @@ -133,7 +133,7 @@ public class TestFeatureResetIT extends MlNativeAutodetectIntegTestCase { client().execute(DeletePipelineAction.INSTANCE, new DeletePipelineRequest("feature_reset_inference_pipeline")).actionGet(); createdPipelines.remove("feature_reset_inference_pipeline"); - assertBusy(() -> assertThat(countInferenceProcessors(client().admin().cluster().prepareState().get().getState()), equalTo(0))); + assertBusy(() -> assertThat(countInferenceProcessors(clusterAdmin().prepareState().get().getState()), equalTo(0))); client().execute(ResetFeatureStateAction.INSTANCE, new ResetFeatureStateRequest()).actionGet(); assertBusy(() -> { List indices = Arrays.asList(client().admin().indices().prepareGetIndex().addIndices(".ml*").get().indices()); @@ -171,9 +171,7 @@ public class TestFeatureResetIT extends MlNativeAutodetectIntegTestCase { assertThat(indices.toString(), indices, is(empty())); }); assertThat(isResetMode(), is(false)); - List tasksNames = client().admin() - .cluster() - .prepareListTasks() + List tasksNames = clusterAdmin().prepareListTasks() .setActions("xpack/ml/*") .get() .getTasks() @@ -223,7 +221,7 @@ public class TestFeatureResetIT extends MlNativeAutodetectIntegTestCase { } private boolean isResetMode() { - ClusterState state = client().admin().cluster().prepareState().get().getState(); + ClusterState state = clusterAdmin().prepareState().get().getState(); return MlMetadata.getMlMetadata(state).isResetMode(); } diff --git a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/license/MachineLearningLicensingIT.java b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/license/MachineLearningLicensingIT.java index 997aef561d51..9933daa4693c 100644 --- a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/license/MachineLearningLicensingIT.java +++ b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/license/MachineLearningLicensingIT.java @@ -251,7 +251,7 @@ public class MachineLearningLicensingIT extends BaseMlIntegTestCase { DatafeedState datafeedState = getDatafeedStats(datafeedId).getDatafeedState(); assertEquals(DatafeedState.STOPPED, datafeedState); - ClusterState state = client().admin().cluster().prepareState().get().getState(); + ClusterState state = clusterAdmin().prepareState().get().getState(); List> tasks = findTasks(state, RELATED_TASKS); assertEquals(0, tasks.size()); }); @@ -276,7 +276,7 @@ public class MachineLearningLicensingIT extends BaseMlIntegTestCase { DatafeedState datafeedState = getDatafeedStats(datafeedId).getDatafeedState(); assertEquals(DatafeedState.STARTED, datafeedState); - ClusterState state = client().admin().cluster().prepareState().get().getState(); + ClusterState state = clusterAdmin().prepareState().get().getState(); List> tasks = findTasks(state, RELATED_TASKS); assertEquals(2, tasks.size()); }); @@ -296,7 +296,7 @@ public class MachineLearningLicensingIT extends BaseMlIntegTestCase { DatafeedState datafeedState = getDatafeedStats(datafeedId).getDatafeedState(); assertEquals(DatafeedState.STOPPED, datafeedState); - ClusterState state = client().admin().cluster().prepareState().get().getState(); + ClusterState state = clusterAdmin().prepareState().get().getState(); List> tasks = findTasks(state, RELATED_TASKS); assertEquals(0, tasks.size()); }); @@ -336,7 +336,7 @@ public class MachineLearningLicensingIT extends BaseMlIntegTestCase { assertBusy(() -> { JobState jobState = getJobStats(jobId).getState(); assertEquals(JobState.CLOSED, jobState); - ClusterState state = client().admin().cluster().prepareState().get().getState(); + ClusterState state = clusterAdmin().prepareState().get().getState(); List> tasks = findTasks(state, RELATED_TASKS); assertEquals(0, tasks.size()); }); diff --git a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/BasicDistributedJobsIT.java b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/BasicDistributedJobsIT.java index 2ea95cee78c8..2d16f90ad422 100644 --- a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/BasicDistributedJobsIT.java +++ b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/BasicDistributedJobsIT.java @@ -225,7 +225,7 @@ public class BasicDistributedJobsIT extends BaseMlIntegTestCase { OpenJobAction.Request openJobRequest = new OpenJobAction.Request(job.getId()); client().execute(OpenJobAction.INSTANCE, openJobRequest).actionGet(); assertBusy(() -> { - ClusterState clusterState = client().admin().cluster().prepareState().get().getState(); + ClusterState clusterState = clusterAdmin().prepareState().get().getState(); PersistentTasksCustomMetadata tasks = clusterState.getMetadata().custom(PersistentTasksCustomMetadata.TYPE); PersistentTask task = tasks.getTask(MlTasks.jobTaskId(jobId)); @@ -405,7 +405,7 @@ public class BasicDistributedJobsIT extends BaseMlIntegTestCase { CloseJobAction.Request closeJobRequest = new CloseJobAction.Request(jobId); client().execute(CloseJobAction.INSTANCE, closeJobRequest).actionGet(); assertBusy(() -> { - ClusterState clusterState = client().admin().cluster().prepareState().get().getState(); + ClusterState clusterState = clusterAdmin().prepareState().get().getState(); List> tasks = findTasks(clusterState, MlTasks.JOB_TASK_NAME); assertEquals(0, tasks.size()); }); @@ -496,7 +496,7 @@ public class BasicDistributedJobsIT extends BaseMlIntegTestCase { } private void assertJobTask(String jobId, JobState expectedState, boolean hasExecutorNode) { - ClusterState clusterState = client().admin().cluster().prepareState().get().getState(); + ClusterState clusterState = clusterAdmin().prepareState().get().getState(); List> tasks = findTasks(clusterState, MlTasks.JOB_TASK_NAME); assertEquals(1, tasks.size()); PersistentTask task = tasks.get(0); @@ -518,7 +518,7 @@ public class BasicDistributedJobsIT extends BaseMlIntegTestCase { private CheckedRunnable checkAllJobsAreAssignedAndOpened(int numJobs) { return () -> { - ClusterState state = client().admin().cluster().prepareState().get().getState(); + ClusterState state = clusterAdmin().prepareState().get().getState(); List> tasks = findTasks(state, MlTasks.JOB_TASK_NAME); assertEquals(numJobs, tasks.size()); for (PersistentTask task : tasks) { diff --git a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/MlDistributedFailureIT.java b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/MlDistributedFailureIT.java index ba94d5571c92..826d8b5f23f7 100644 --- a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/MlDistributedFailureIT.java +++ b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/MlDistributedFailureIT.java @@ -717,7 +717,7 @@ public class MlDistributedFailureIT extends BaseMlIntegTestCase { // in a Lucene index it can take a while to update when there are many updates in quick // succession, like we see in internal cluster tests of node failure scenarios assertBusy(() -> { - ClusterState clusterState = client().admin().cluster().prepareState().get().getState(); + ClusterState clusterState = clusterAdmin().prepareState().get().getState(); List> tasks = findTasks(clusterState, Set.of(DATAFEED_TASK_NAME, JOB_TASK_NAME)); assertNotNull(tasks); assertEquals("Expected 2 tasks, but got [" + tasks + "]", 2, tasks.size()); diff --git a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/TooManyJobsIT.java b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/TooManyJobsIT.java index ede42cb47e81..b62a524245d8 100644 --- a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/TooManyJobsIT.java +++ b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/TooManyJobsIT.java @@ -63,7 +63,7 @@ public class TooManyJobsIT extends BaseMlIntegTestCase { new GetJobsStatsAction.Request("close-failed-job-2") ).actionGet(); assertEquals(statsResponse.getResponse().results().get(0).getState(), JobState.CLOSED); - ClusterState state = client().admin().cluster().prepareState().get().getState(); + ClusterState state = clusterAdmin().prepareState().get().getState(); List> tasks = findTasks(state, MlTasks.JOB_TASK_NAME); assertEquals(1, tasks.size()); // now just double check that the first job is still opened: diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/MlSingleNodeTestCase.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/MlSingleNodeTestCase.java index c5453aa3a1c7..2883a1c6fd01 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/MlSingleNodeTestCase.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/MlSingleNodeTestCase.java @@ -116,7 +116,7 @@ public abstract class MlSingleNodeTestCase extends ESSingleNodeTestCase { protected void waitForMlTemplates() throws Exception { // block until the templates are installed assertBusy(() -> { - ClusterState state = client().admin().cluster().prepareState().get().getState(); + ClusterState state = clusterAdmin().prepareState().get().getState(); assertTrue("Timed out waiting for the ML templates to be installed", MachineLearning.criticalTemplatesInstalled(state)); }); } diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java index 8987df1ece6b..c71f14ce6975 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java @@ -167,7 +167,7 @@ public abstract class BaseMlIntegTestCase extends ESIntegTestCase { @Before public void ensureTemplatesArePresent() throws Exception { assertBusy(() -> { - ClusterState state = client().admin().cluster().prepareState().get().getState(); + ClusterState state = clusterAdmin().prepareState().get().getState(); assertTrue("Timed out waiting for the ML templates to be installed", MachineLearning.criticalTemplatesInstalled(state)); }, 20, TimeUnit.SECONDS); } diff --git a/x-pack/plugin/monitoring/src/internalClusterTest/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterSslIT.java b/x-pack/plugin/monitoring/src/internalClusterTest/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterSslIT.java index 2f199fdeb090..db37b09095e6 100644 --- a/x-pack/plugin/monitoring/src/internalClusterTest/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterSslIT.java +++ b/x-pack/plugin/monitoring/src/internalClusterTest/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporterSslIT.java @@ -173,7 +173,7 @@ public class HttpExporterSslIT extends MonitoringIntegTestCase { .put("xpack.monitoring.exporters." + name + ".ssl.verification_mode", verificationModeName) .build(); updateSettings.persistentSettings(settings); - return client().admin().cluster().updateSettings(updateSettings); + return clusterAdmin().updateSettings(updateSettings); } private void clearPersistentSettings(String... names) { diff --git a/x-pack/plugin/monitoring/src/internalClusterTest/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java b/x-pack/plugin/monitoring/src/internalClusterTest/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java index 967e1b9cc02c..de35d8e0632b 100644 --- a/x-pack/plugin/monitoring/src/internalClusterTest/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java +++ b/x-pack/plugin/monitoring/src/internalClusterTest/java/org/elasticsearch/xpack/monitoring/integration/MonitoringIT.java @@ -196,7 +196,7 @@ public class MonitoringIT extends ESSingleNodeTestCase { ); final Settings settings = Settings.builder().put("cluster.metadata.display_name", "my cluster").build(); - assertAcked(client().admin().cluster().prepareUpdateSettings().setTransientSettings(settings)); + assertAcked(clusterAdmin().prepareUpdateSettings().setTransientSettings(settings)); whenExportersAreReady(() -> { final AtomicReference searchResponse = new AtomicReference<>(); @@ -264,7 +264,7 @@ public class MonitoringIT extends ESSingleNodeTestCase { private void assertMonitoringDocSourceNode(final Map sourceNode) { assertEquals(6, sourceNode.size()); - final NodesInfoResponse nodesResponse = client().admin().cluster().prepareNodesInfo().clear().get(); + final NodesInfoResponse nodesResponse = clusterAdmin().prepareNodesInfo().clear().get(); assertEquals(1, nodesResponse.getNodes().size()); @@ -365,7 +365,7 @@ public class MonitoringIT extends ESSingleNodeTestCase { .put("xpack.monitoring.exporters._local.enabled", true) .build(); - assertAcked(client().admin().cluster().prepareUpdateSettings().setTransientSettings(settings)); + assertAcked(clusterAdmin().prepareUpdateSettings().setTransientSettings(settings)); assertBusy(() -> assertThat("[_local] exporter not enabled yet", getMonitoringUsageExportersDefined(), is(true))); @@ -393,13 +393,13 @@ public class MonitoringIT extends ESSingleNodeTestCase { .putNull("cluster.metadata.display_name") .build(); - assertAcked(client().admin().cluster().prepareUpdateSettings().setTransientSettings(settings)); + assertAcked(clusterAdmin().prepareUpdateSettings().setTransientSettings(settings)); assertBusy(() -> assertThat("Exporters are not yet stopped", getMonitoringUsageExportersDefined(), is(false))); assertBusy(() -> { try { // now wait until Monitoring has actually stopped - final NodesStatsResponse response = client().admin().cluster().prepareNodesStats().clear().setThreadPool(true).get(); + final NodesStatsResponse response = clusterAdmin().prepareNodesStats().clear().setThreadPool(true).get(); for (final NodeStats nodeStats : response.getNodes()) { boolean foundBulkThreads = false; diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MultiNodesStatsTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MultiNodesStatsTests.java index 26eba6ffd2c6..29b044e81f7d 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MultiNodesStatsTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/MultiNodesStatsTests.java @@ -68,7 +68,7 @@ public class MultiNodesStatsTests extends MonitoringIntegTestCase { final int nbNodes = nodes; assertBusy(() -> { assertThat(cluster().size(), equalTo(nbNodes)); - assertNoTimeout(client().admin().cluster().prepareHealth().setWaitForNodes(Integer.toString(nbNodes)).get()); + assertNoTimeout(clusterAdmin().prepareHealth().setWaitForNodes(Integer.toString(nbNodes)).get()); }); enableMonitoringCollection(); diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTests.java index 6d29a2ad0fc5..503d83162df5 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/exporter/local/LocalExporterIntegTests.java @@ -258,7 +258,7 @@ public class LocalExporterIntegTests extends LocalExporterIntegTestCase { * fields and belongs to the right data or timestamped index. */ private void checkMonitoringDocs() { - ClusterStateResponse response = client().admin().cluster().prepareState().get(); + ClusterStateResponse response = clusterAdmin().prepareState().get(); String customTimeFormat = response.getState() .getMetadata() .persistentSettings() diff --git a/x-pack/plugin/old-lucene-versions/src/internalClusterTest/java/org/elasticsearch/xpack/lucene/bwc/ArchiveLicenseIntegTests.java b/x-pack/plugin/old-lucene-versions/src/internalClusterTest/java/org/elasticsearch/xpack/lucene/bwc/ArchiveLicenseIntegTests.java index a9976b6f8c9f..06883d88c50e 100644 --- a/x-pack/plugin/old-lucene-versions/src/internalClusterTest/java/org/elasticsearch/xpack/lucene/bwc/ArchiveLicenseIntegTests.java +++ b/x-pack/plugin/old-lucene-versions/src/internalClusterTest/java/org/elasticsearch/xpack/lucene/bwc/ArchiveLicenseIntegTests.java @@ -46,7 +46,7 @@ public class ArchiveLicenseIntegTests extends AbstractArchiveTestCase { final RestoreSnapshotRequest req = new RestoreSnapshotRequest(repoName, snapshotName).indices(indexName).waitForCompletion(true); - final RestoreSnapshotResponse restoreSnapshotResponse = client().admin().cluster().restoreSnapshot(req).get(); + final RestoreSnapshotResponse restoreSnapshotResponse = clusterAdmin().restoreSnapshot(req).get(); assertThat(restoreSnapshotResponse.getRestoreInfo().failedShards(), equalTo(0)); ensureGreen(indexName); @@ -66,7 +66,7 @@ public class ArchiveLicenseIntegTests extends AbstractArchiveTestCase { final RestoreSnapshotRequest req = new RestoreSnapshotRequest(repoName, snapshotName).indices(indexName).waitForCompletion(true); ElasticsearchSecurityException e = expectThrows( ElasticsearchSecurityException.class, - () -> client().admin().cluster().restoreSnapshot(req).actionGet() + () -> clusterAdmin().restoreSnapshot(req).actionGet() ); assertThat(e.getMessage(), containsString("current license is non-compliant for [archive]")); } @@ -78,10 +78,7 @@ public class ArchiveLicenseIntegTests extends AbstractArchiveTestCase { Settings.builder().put(getRepositoryOnMaster(repoName).getMetadata().settings()).put("version", Version.fromString("2.0.0").id) ); final RestoreSnapshotRequest req = new RestoreSnapshotRequest(repoName, snapshotName).indices(indexName).waitForCompletion(true); - SnapshotRestoreException e = expectThrows( - SnapshotRestoreException.class, - () -> client().admin().cluster().restoreSnapshot(req).actionGet() - ); + SnapshotRestoreException e = expectThrows(SnapshotRestoreException.class, () -> clusterAdmin().restoreSnapshot(req).actionGet()); assertThat( e.getMessage(), containsString( @@ -94,7 +91,7 @@ public class ArchiveLicenseIntegTests extends AbstractArchiveTestCase { public void testShardAllocationOnInvalidLicense() throws Exception { final RestoreSnapshotRequest req = new RestoreSnapshotRequest(repoName, snapshotName).indices(indexName).waitForCompletion(true); - final RestoreSnapshotResponse restoreSnapshotResponse = client().admin().cluster().restoreSnapshot(req).get(); + final RestoreSnapshotResponse restoreSnapshotResponse = clusterAdmin().restoreSnapshot(req).get(); assertThat(restoreSnapshotResponse.getRestoreInfo().failedShards(), equalTo(0)); ensureGreen(indexName); @@ -108,7 +105,7 @@ public class ArchiveLicenseIntegTests extends AbstractArchiveTestCase { assertBusy( () -> assertEquals( ClusterHealthStatus.RED, - client().admin().cluster().prepareHealth(indexName).get().getIndices().get(indexName).getStatus() + clusterAdmin().prepareHealth(indexName).get().getIndices().get(indexName).getStatus() ) ); diff --git a/x-pack/plugin/old-lucene-versions/src/internalClusterTest/java/org/elasticsearch/xpack/lucene/bwc/ArchiveSettingValidationIntegTests.java b/x-pack/plugin/old-lucene-versions/src/internalClusterTest/java/org/elasticsearch/xpack/lucene/bwc/ArchiveSettingValidationIntegTests.java index f6d14331d1be..3104c91f2e5f 100644 --- a/x-pack/plugin/old-lucene-versions/src/internalClusterTest/java/org/elasticsearch/xpack/lucene/bwc/ArchiveSettingValidationIntegTests.java +++ b/x-pack/plugin/old-lucene-versions/src/internalClusterTest/java/org/elasticsearch/xpack/lucene/bwc/ArchiveSettingValidationIntegTests.java @@ -21,7 +21,7 @@ public class ArchiveSettingValidationIntegTests extends AbstractArchiveTestCase public void testCannotRemoveWriteBlock() throws ExecutionException, InterruptedException { final RestoreSnapshotRequest req = new RestoreSnapshotRequest(repoName, snapshotName).indices(indexName).waitForCompletion(true); - final RestoreSnapshotResponse restoreSnapshotResponse = client().admin().cluster().restoreSnapshot(req).get(); + final RestoreSnapshotResponse restoreSnapshotResponse = clusterAdmin().restoreSnapshot(req).get(); assertThat(restoreSnapshotResponse.getRestoreInfo().failedShards(), equalTo(0)); ensureGreen(indexName); diff --git a/x-pack/plugin/profiler/src/internalClusterTest/java/org/elasticsearch/xpack/profiler/CancellationIT.java b/x-pack/plugin/profiler/src/internalClusterTest/java/org/elasticsearch/xpack/profiler/CancellationIT.java index d04289298a35..1fb9e2ffc23e 100644 --- a/x-pack/plugin/profiler/src/internalClusterTest/java/org/elasticsearch/xpack/profiler/CancellationIT.java +++ b/x-pack/plugin/profiler/src/internalClusterTest/java/org/elasticsearch/xpack/profiler/CancellationIT.java @@ -105,7 +105,7 @@ public class CancellationIT extends ProfilingTestCase { private static Map readNodesInfo() { Map nodeIdToName = new HashMap<>(); - NodesInfoResponse nodesInfoResponse = client().admin().cluster().prepareNodesInfo().get(); + NodesInfoResponse nodesInfoResponse = clusterAdmin().prepareNodesInfo().get(); assertFalse(nodesInfoResponse.hasFailures()); for (NodeInfo node : nodesInfoResponse.getNodes()) { nodeIdToName.put(node.getNode().getId(), node.getNode().getName()); @@ -116,7 +116,7 @@ public class CancellationIT extends ProfilingTestCase { private static Collection collectProfilingRelatedTasks(String transportAction) { SetOnce profilingTask = new SetOnce<>(); Map> taskToParent = new HashMap<>(); - ListTasksResponse listTasksResponse = client().admin().cluster().prepareListTasks().get(); + ListTasksResponse listTasksResponse = clusterAdmin().prepareListTasks().get(); for (TaskInfo task : listTasksResponse.getTasks()) { TaskId parentTaskId = task.parentTaskId(); if (parentTaskId != null) { diff --git a/x-pack/plugin/profiler/src/internalClusterTest/java/org/elasticsearch/xpack/profiler/ProfilingTestCase.java b/x-pack/plugin/profiler/src/internalClusterTest/java/org/elasticsearch/xpack/profiler/ProfilingTestCase.java index e37f5da1064e..d2b5abdcf37d 100644 --- a/x-pack/plugin/profiler/src/internalClusterTest/java/org/elasticsearch/xpack/profiler/ProfilingTestCase.java +++ b/x-pack/plugin/profiler/src/internalClusterTest/java/org/elasticsearch/xpack/profiler/ProfilingTestCase.java @@ -88,7 +88,7 @@ public abstract class ProfilingTestCase extends ESIntegTestCase { protected void waitForIndices() throws Exception { assertBusy(() -> { - ClusterState state = client().admin().cluster().prepareState().get().getState(); + ClusterState state = clusterAdmin().prepareState().get().getState(); assertTrue( "Timed out waiting for the indices to be created", state.metadata() @@ -104,7 +104,7 @@ public abstract class ProfilingTestCase extends ESIntegTestCase { protected void updateProfilingTemplatesEnabled(boolean newValue) { ClusterUpdateSettingsRequest request = new ClusterUpdateSettingsRequest(); request.persistentSettings(Settings.builder().put(ProfilingPlugin.PROFILING_TEMPLATES_ENABLED.getKey(), newValue).build()); - ClusterUpdateSettingsResponse response = client().admin().cluster().updateSettings(request).actionGet(); + ClusterUpdateSettingsResponse response = clusterAdmin().updateSettings(request).actionGet(); assertTrue("Update of profiling templates enabled setting is not acknowledged", response.isAcknowledged()); } diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/downsample/DownsampleActionSingleNodeTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/downsample/DownsampleActionSingleNodeTests.java index 035c2dc60616..4b39c34bca69 100644 --- a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/downsample/DownsampleActionSingleNodeTests.java +++ b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/downsample/DownsampleActionSingleNodeTests.java @@ -765,7 +765,7 @@ public class DownsampleActionSingleNodeTests extends ESSingleNodeTestCase { .map(mappingMetadata -> mappingMetadata.getValue().sourceAsMap()) .orElseThrow(() -> new IllegalArgumentException("No mapping found for rollup source index [" + sourceIndex + "]")); - final IndexMetadata indexMetadata = client().admin().cluster().prepareState().get().getState().getMetadata().index(sourceIndex); + final IndexMetadata indexMetadata = clusterAdmin().prepareState().get().getState().getMetadata().index(sourceIndex); final IndicesService indicesService = getInstanceFromNode(IndicesService.class); final MapperService mapperService = indicesService.createIndexMapperServiceForValidation(indexMetadata); final CompressedXContent sourceIndexCompressedXContent = new CompressedXContent(sourceIndexMappings); diff --git a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/BaseSearchableSnapshotsIntegTestCase.java b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/BaseSearchableSnapshotsIntegTestCase.java index f4477ebe7b3a..d6bd6ced4fcb 100644 --- a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/BaseSearchableSnapshotsIntegTestCase.java +++ b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/BaseSearchableSnapshotsIntegTestCase.java @@ -339,7 +339,7 @@ public abstract class BaseSearchableSnapshotsIntegTestCase extends AbstractSnaps } protected DiscoveryNodes getDiscoveryNodes() { - return client().admin().cluster().prepareState().clear().setNodes(true).get().getState().nodes(); + return clusterAdmin().prepareState().clear().setNodes(true).get().getState().nodes(); } protected void assertExecutorIsIdle(String executorName) throws Exception { diff --git a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/FrozenSearchableSnapshotsIntegTests.java b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/FrozenSearchableSnapshotsIntegTests.java index eac5f095188a..27613012d17c 100644 --- a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/FrozenSearchableSnapshotsIntegTests.java +++ b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/FrozenSearchableSnapshotsIntegTests.java @@ -132,9 +132,7 @@ public class FrozenSearchableSnapshotsIntegTests extends BaseFrozenSearchableSna assertShardFolders(indexName, false); assertThat( - client().admin() - .cluster() - .prepareState() + clusterAdmin().prepareState() .clear() .setMetadata(true) .setIndices(indexName) @@ -297,9 +295,7 @@ public class FrozenSearchableSnapshotsIntegTests extends BaseFrozenSearchableSna assertBusy(() -> assertShardFolders(restoredIndexName, true), 30, TimeUnit.SECONDS); assertThat( - client().admin() - .cluster() - .prepareState() + clusterAdmin().prepareState() .clear() .setMetadata(true) .setIndices(restoredIndexName) @@ -325,9 +321,7 @@ public class FrozenSearchableSnapshotsIntegTests extends BaseFrozenSearchableSna assertThat(indicesAdmin().prepareGetAliases(aliasName).get().getAliases().size(), equalTo(1)); assertTotalHits(aliasName, originalAllHits, originalBarHits); - final Decision diskDeciderDecision = client().admin() - .cluster() - .prepareAllocationExplain() + final Decision diskDeciderDecision = clusterAdmin().prepareAllocationExplain() .setIndex(restoredIndexName) .setShard(0) .setPrimary(true) @@ -357,9 +351,7 @@ public class FrozenSearchableSnapshotsIntegTests extends BaseFrozenSearchableSna internalCluster().ensureAtLeastNumDataNodes(2); - final DiscoveryNode dataNode = randomFrom( - client().admin().cluster().prepareState().get().getState().nodes().getDataNodes().values() - ); + final DiscoveryNode dataNode = randomFrom(clusterAdmin().prepareState().get().getState().nodes().getDataNodes().values()); updateIndexSettings( Settings.builder() @@ -372,9 +364,7 @@ public class FrozenSearchableSnapshotsIntegTests extends BaseFrozenSearchableSna ); assertFalse( - client().admin() - .cluster() - .prepareHealth(restoredIndexName) + clusterAdmin().prepareHealth(restoredIndexName) .setWaitForNoRelocatingShards(true) .setWaitForEvents(Priority.LANGUID) .get() diff --git a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/PrevalidateNodeRemovalWithSearchableSnapshotIntegTests.java b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/PrevalidateNodeRemovalWithSearchableSnapshotIntegTests.java index 10b7a2e0a1cb..a651c4b30fcb 100644 --- a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/PrevalidateNodeRemovalWithSearchableSnapshotIntegTests.java +++ b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/PrevalidateNodeRemovalWithSearchableSnapshotIntegTests.java @@ -52,9 +52,7 @@ public class PrevalidateNodeRemovalWithSearchableSnapshotIntegTests extends Base // Make sure the searchable snapshot index is red internalCluster().stopNode(node1); assertBusy(() -> { - ClusterHealthResponse healthResponse = client().admin() - .cluster() - .prepareHealth(restoredIndexName) + ClusterHealthResponse healthResponse = clusterAdmin().prepareHealth(restoredIndexName) .setWaitForStatus(ClusterHealthStatus.RED) .setWaitForEvents(Priority.LANGUID) .execute() diff --git a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsCanMatchOnCoordinatorIntegTests.java b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsCanMatchOnCoordinatorIntegTests.java index 2afbc940e277..8fe787c7d4cb 100644 --- a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsCanMatchOnCoordinatorIntegTests.java +++ b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsCanMatchOnCoordinatorIntegTests.java @@ -486,16 +486,7 @@ public class SearchableSnapshotsCanMatchOnCoordinatorIntegTests extends BaseFroz } private IndexMetadata getIndexMetadata(String indexName) { - return client().admin() - .cluster() - .prepareState() - .clear() - .setMetadata(true) - .setIndices(indexName) - .get() - .getState() - .metadata() - .index(indexName); + return clusterAdmin().prepareState().clear().setMetadata(true).setIndices(indexName).get().getState().metadata().index(indexName); } private void waitUntilRecoveryIsDone(String index) throws Exception { diff --git a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsIntegTests.java b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsIntegTests.java index 68da6f7e41aa..b8b51581bc0a 100644 --- a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsIntegTests.java +++ b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsIntegTests.java @@ -146,9 +146,7 @@ public class SearchableSnapshotsIntegTests extends BaseSearchableSnapshotsIntegT assertShardFolders(indexName, false); assertThat( - client().admin() - .cluster() - .prepareState() + clusterAdmin().prepareState() .clear() .setMetadata(true) .setIndices(indexName) @@ -224,12 +222,7 @@ public class SearchableSnapshotsIntegTests extends BaseSearchableSnapshotsIntegT final RestoreSnapshotResponse restoreSnapshotResponse = client().execute(MountSearchableSnapshotAction.INSTANCE, req).get(); assertThat(restoreSnapshotResponse.getRestoreInfo().failedShards(), equalTo(0)); - final RepositoryMetadata repositoryMetadata = client().admin() - .cluster() - .prepareGetRepositories(fsRepoName) - .get() - .repositories() - .get(0); + final RepositoryMetadata repositoryMetadata = clusterAdmin().prepareGetRepositories(fsRepoName).get().repositories().get(0); assertThat(repositoryMetadata.name(), equalTo(fsRepoName)); assertThat(repositoryMetadata.uuid(), not(equalTo(RepositoryData.MISSING_UUID))); @@ -256,9 +249,7 @@ public class SearchableSnapshotsIntegTests extends BaseSearchableSnapshotsIntegT assertBusy(() -> assertShardFolders(restoredIndexName, true), 30, TimeUnit.SECONDS); assertThat( - client().admin() - .cluster() - .prepareState() + clusterAdmin().prepareState() .clear() .setMetadata(true) .setIndices(restoredIndexName) @@ -292,9 +283,7 @@ public class SearchableSnapshotsIntegTests extends BaseSearchableSnapshotsIntegT internalCluster().ensureAtLeastNumDataNodes(2); - final DiscoveryNode dataNode = randomFrom( - client().admin().cluster().prepareState().get().getState().nodes().getDataNodes().values() - ); + final DiscoveryNode dataNode = randomFrom(clusterAdmin().prepareState().get().getState().nodes().getDataNodes().values()); updateIndexSettings( Settings.builder() @@ -307,9 +296,7 @@ public class SearchableSnapshotsIntegTests extends BaseSearchableSnapshotsIntegT ); assertFalse( - client().admin() - .cluster() - .prepareHealth(restoredIndexName) + clusterAdmin().prepareHealth(restoredIndexName) .setWaitForNoRelocatingShards(true) .setWaitForEvents(Priority.LANGUID) .get() @@ -644,7 +631,7 @@ public class SearchableSnapshotsIntegTests extends BaseSearchableSnapshotsIntegT assertThat(restoreSnapshotResponse.getRestoreInfo().failedShards(), equalTo(0)); ensureGreen(restoredIndexName); - final ClusterState state = client().admin().cluster().prepareState().clear().setRoutingTable(true).get().getState(); + final ClusterState state = clusterAdmin().prepareState().clear().setRoutingTable(true).get().getState(); assertThat( state.toString(), state.routingTable().index(restoredIndexName).shard(0).size(), @@ -668,9 +655,7 @@ public class SearchableSnapshotsIntegTests extends BaseSearchableSnapshotsIntegT final SnapshotId snapshotOne = createSnapshot(repositoryName, "snapshot-1", List.of(indexName)).snapshotId(); assertAcked(indicesAdmin().prepareDelete(indexName)); - final SnapshotStatus snapshotOneStatus = client().admin() - .cluster() - .prepareSnapshotStatus(repositoryName) + final SnapshotStatus snapshotOneStatus = clusterAdmin().prepareSnapshotStatus(repositoryName) .setSnapshots(snapshotOne.getName()) .get() .getSnapshots() @@ -682,9 +667,7 @@ public class SearchableSnapshotsIntegTests extends BaseSearchableSnapshotsIntegT ensureGreen(indexName); final SnapshotId snapshotTwo = createSnapshot(repositoryName, "snapshot-2", List.of(indexName)).snapshotId(); - final SnapshotStatus snapshotTwoStatus = client().admin() - .cluster() - .prepareSnapshotStatus(repositoryName) + final SnapshotStatus snapshotTwoStatus = clusterAdmin().prepareSnapshotStatus(repositoryName) .setSnapshots(snapshotTwo.getName()) .get() .getSnapshots() @@ -753,9 +736,7 @@ public class SearchableSnapshotsIntegTests extends BaseSearchableSnapshotsIntegT mountSnapshot(repositoryName, snapshotOne.getName(), indexName, indexName, Settings.EMPTY); ensureGreen(indexName); - final IndexLongFieldRange timestampRange = client().admin() - .cluster() - .prepareState() + final IndexLongFieldRange timestampRange = clusterAdmin().prepareState() .clear() .setMetadata(true) .setIndices(indexName) @@ -817,14 +798,7 @@ public class SearchableSnapshotsIntegTests extends BaseSearchableSnapshotsIntegT createRepositoryNoVerify(tmpRepositoryName, "fs"); final Path repoPath = internalCluster().getCurrentMasterNodeInstance(Environment.class) .resolveRepoFile( - client().admin() - .cluster() - .prepareGetRepositories(tmpRepositoryName) - .get() - .repositories() - .get(0) - .settings() - .get("location") + clusterAdmin().prepareGetRepositories(tmpRepositoryName).get().repositories().get(0).settings().get("location") ); initWithSnapshotVersion( tmpRepositoryName, @@ -835,14 +809,12 @@ public class SearchableSnapshotsIntegTests extends BaseSearchableSnapshotsIntegT SnapshotsService.INDEX_GEN_IN_REPO_DATA_VERSION ) ); - assertAcked(client().admin().cluster().prepareDeleteRepository(tmpRepositoryName)); + assertAcked(clusterAdmin().prepareDeleteRepository(tmpRepositoryName)); createRepository(repositoryName, "fs", repoPath); } final SnapshotId snapshotOne = createSnapshot(repositoryName, "snapshot-1", List.of(indexName)).snapshotId(); - for (final SnapshotStatus snapshotStatus : client().admin() - .cluster() - .prepareSnapshotStatus(repositoryName) + for (final SnapshotStatus snapshotStatus : clusterAdmin().prepareSnapshotStatus(repositoryName) .setSnapshots(snapshotOne.getName()) .get() .getSnapshots()) { @@ -856,7 +828,7 @@ public class SearchableSnapshotsIntegTests extends BaseSearchableSnapshotsIntegT assertAcked(indicesAdmin().prepareDelete(indexName)); assertThat( - client().admin().cluster().prepareGetRepositories(repositoryName).get().repositories().get(0).uuid(), + clusterAdmin().prepareGetRepositories(repositoryName).get().repositories().get(0).uuid(), hasRepositoryUuid ? not(equalTo(RepositoryData.MISSING_UUID)) : equalTo(RepositoryData.MISSING_UUID) ); @@ -881,9 +853,7 @@ public class SearchableSnapshotsIntegTests extends BaseSearchableSnapshotsIntegT logger.info("--> starting to take snapshot-2"); final SnapshotId snapshotTwo = createSnapshot(backupRepositoryName, "snapshot-2", List.of(restoredIndexName)).snapshotId(); logger.info("--> finished taking snapshot-2"); - for (final SnapshotStatus snapshotStatus : client().admin() - .cluster() - .prepareSnapshotStatus(backupRepositoryName) + for (final SnapshotStatus snapshotStatus : clusterAdmin().prepareSnapshotStatus(backupRepositoryName) .setSnapshots(snapshotTwo.getName()) .get() .getSnapshots()) { @@ -903,16 +873,11 @@ public class SearchableSnapshotsIntegTests extends BaseSearchableSnapshotsIntegT final String restoreRepositoryName; if (hasRepositoryUuid && randomBoolean()) { // Re-mount the repository containing the actual data under a different name - final RepositoryMetadata repositoryMetadata = client().admin() - .cluster() - .prepareGetRepositories(repositoryName) - .get() - .repositories() - .get(0); + final RepositoryMetadata repositoryMetadata = clusterAdmin().prepareGetRepositories(repositoryName).get().repositories().get(0); // Rename the repository containing the actual data. final String newRepositoryName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT); - assertAcked(client().admin().cluster().prepareDeleteRepository(repositoryName)); + assertAcked(clusterAdmin().prepareDeleteRepository(repositoryName)); final Settings.Builder settings = Settings.builder().put(repositoryMetadata.settings()); if (randomBoolean()) { settings.put(READONLY_SETTING_KEY, "true"); @@ -927,9 +892,7 @@ public class SearchableSnapshotsIntegTests extends BaseSearchableSnapshotsIntegT logger.info("--> starting to restore snapshot-2"); assertThat( - client().admin() - .cluster() - .prepareRestoreSnapshot(restoreRepositoryName, snapshotTwo.getName()) + clusterAdmin().prepareRestoreSnapshot(restoreRepositoryName, snapshotTwo.getName()) .setIndices(restoredIndexName) .get() .status(), @@ -1017,30 +980,18 @@ public class SearchableSnapshotsIntegTests extends BaseSearchableSnapshotsIntegT final SnapshotId backupSnapshot = createSnapshot(backupRepoName, "backup-snapshot", List.of(restoredIndexName)).snapshotId(); // Clear out data & the repo that contains it - final RepositoryMetadata dataRepoMetadata = client().admin() - .cluster() - .prepareGetRepositories(dataRepoName) - .get() - .repositories() - .get(0); + final RepositoryMetadata dataRepoMetadata = clusterAdmin().prepareGetRepositories(dataRepoName).get().repositories().get(0); assertAcked(indicesAdmin().prepareDelete(restoredIndexName)); - assertAcked(client().admin().cluster().prepareDeleteRepository(dataRepoName)); + assertAcked(clusterAdmin().prepareDeleteRepository(dataRepoName)); // Restore the backup snapshot assertThat( - client().admin() - .cluster() - .prepareRestoreSnapshot(backupRepoName, backupSnapshot.getName()) - .setIndices(restoredIndexName) - .get() - .status(), + clusterAdmin().prepareRestoreSnapshot(backupRepoName, backupSnapshot.getName()).setIndices(restoredIndexName).get().status(), equalTo(RestStatus.ACCEPTED) ); assertBusy(() -> { - final ClusterAllocationExplanation clusterAllocationExplanation = client().admin() - .cluster() - .prepareAllocationExplain() + final ClusterAllocationExplanation clusterAllocationExplanation = clusterAdmin().prepareAllocationExplain() .setIndex(restoredIndexName) .setShard(0) .setPrimary(true) @@ -1067,9 +1018,7 @@ public class SearchableSnapshotsIntegTests extends BaseSearchableSnapshotsIntegT }); assertBusy(() -> { - final RestoreInProgress restoreInProgress = client().admin() - .cluster() - .prepareState() + final RestoreInProgress restoreInProgress = clusterAdmin().prepareState() .clear() .setCustoms(true) .get() diff --git a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsLicenseIntegTests.java b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsLicenseIntegTests.java index 79d6867594e7..824114139a7e 100644 --- a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsLicenseIntegTests.java +++ b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsLicenseIntegTests.java @@ -141,7 +141,7 @@ public class SearchableSnapshotsLicenseIntegTests extends BaseFrozenSearchableSn assertBusy( () -> assertEquals( ClusterHealthStatus.RED, - client().admin().cluster().prepareHealth(indexName).get().getIndices().get(indexName).getStatus() + clusterAdmin().prepareHealth(indexName).get().getIndices().get(indexName).getStatus() ) ); diff --git a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsRepositoryIntegTests.java b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsRepositoryIntegTests.java index 6aad30cf1a82..474a0a15a960 100644 --- a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsRepositoryIntegTests.java +++ b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsRepositoryIntegTests.java @@ -297,9 +297,7 @@ public class SearchableSnapshotsRepositoryIntegTests extends BaseFrozenSearchabl logger.info("--> restoring snapshot of searchable snapshot index [{}] should be conflicting", mountedIndex); final SnapshotRestoreException exception = expectThrows( SnapshotRestoreException.class, - () -> client().admin() - .cluster() - .prepareRestoreSnapshot(repository, snapshotOfMountedIndex) + () -> clusterAdmin().prepareRestoreSnapshot(repository, snapshotOfMountedIndex) .setIndices(mountedIndex) .setWaitForCompletion(true) .get() @@ -360,9 +358,7 @@ public class SearchableSnapshotsRepositoryIntegTests extends BaseFrozenSearchabl : randomSubsetOf(randomIntBetween(1, nbMountedIndices), mountedIndices); final SnapshotRestoreException exception = expectThrows( SnapshotRestoreException.class, - () -> client().admin() - .cluster() - .prepareRestoreSnapshot(repository, snapshotOfMountedIndices) + () -> clusterAdmin().prepareRestoreSnapshot(repository, snapshotOfMountedIndices) .setIndices(restorables.toArray(String[]::new)) .setIndexSettings(deleteSnapshotIndexSettings(deleteSnapshot == false)) .setRenameReplacement("restored-with-different-setting-$1") @@ -382,9 +378,7 @@ public class SearchableSnapshotsRepositoryIntegTests extends BaseFrozenSearchabl ) ); - final RestoreSnapshotResponse restoreResponse = client().admin() - .cluster() - .prepareRestoreSnapshot(repository, snapshotOfMountedIndices) + final RestoreSnapshotResponse restoreResponse = clusterAdmin().prepareRestoreSnapshot(repository, snapshotOfMountedIndices) .setIndices(restorables.toArray(String[]::new)) .setIndexSettings(indexSettings) .setRenameReplacement("restored-with-same-setting-$1") diff --git a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsResizeIntegTests.java b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsResizeIntegTests.java index 59c35082de57..4f7c7f7aa0b7 100644 --- a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsResizeIntegTests.java +++ b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsResizeIntegTests.java @@ -55,8 +55,8 @@ public class SearchableSnapshotsResizeIntegTests extends BaseFrozenSearchableSna @Override public void tearDown() throws Exception { assertAcked(indicesAdmin().prepareDelete("mounted-*")); - assertAcked(client().admin().cluster().prepareDeleteSnapshot("repository", "snapshot").get()); - assertAcked(client().admin().cluster().prepareDeleteRepository("repository")); + assertAcked(clusterAdmin().prepareDeleteSnapshot("repository", "snapshot").get()); + assertAcked(clusterAdmin().prepareDeleteRepository("repository")); super.tearDown(); } diff --git a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsUuidValidationIntegTests.java b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsUuidValidationIntegTests.java index 02e1a350b42e..49400b357401 100644 --- a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsUuidValidationIntegTests.java +++ b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshotsUuidValidationIntegTests.java @@ -112,7 +112,7 @@ public class SearchableSnapshotsUuidValidationIntegTests extends BaseFrozenSearc final RestoreBlockingActionFilter restoreBlockingActionFilter = getBlockingActionFilter(); restoreBlockingActionFilter.awaitExecution(); - assertAcked(client().admin().cluster().prepareDeleteSnapshot(fsRepoName, snapshotName).get()); + assertAcked(clusterAdmin().prepareDeleteSnapshot(fsRepoName, snapshotName).get()); createFullSnapshot(fsRepoName, snapshotName); assertFalse(responseFuture.isDone()); diff --git a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/allocation/SearchableSnapshotAllocationIntegTests.java b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/allocation/SearchableSnapshotAllocationIntegTests.java index 88151d70f5da..6feccfc5ed11 100644 --- a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/allocation/SearchableSnapshotAllocationIntegTests.java +++ b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/allocation/SearchableSnapshotAllocationIntegTests.java @@ -50,7 +50,7 @@ public class SearchableSnapshotAllocationIntegTests extends BaseSearchableSnapsh setAllocation(EnableAllocationDecider.Allocation.ALL); ensureGreen(restoredIndex); - final ClusterState state = client().admin().cluster().prepareState().get().getState(); + final ClusterState state = clusterAdmin().prepareState().get().getState(); assertEquals( state.nodes().resolveNode(firstDataNode).getId(), state.routingTable().index(restoredIndex).shard(0).primaryShard().currentNodeId() @@ -88,7 +88,7 @@ public class SearchableSnapshotAllocationIntegTests extends BaseSearchableSnapsh setAllocation(EnableAllocationDecider.Allocation.ALL); ensureGreen(restoredIndex); - final ClusterState state = client().admin().cluster().prepareState().get().getState(); + final ClusterState state = clusterAdmin().prepareState().get().getState(); final Set nodesWithCache = Set.of( state.nodes().resolveNode(firstDataNode).getId(), state.nodes().resolveNode(secondDataNode).getId() diff --git a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/allocation/SearchableSnapshotDiskThresholdIntegTests.java b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/allocation/SearchableSnapshotDiskThresholdIntegTests.java index 1d2c9c25ee1d..91ddb112feee 100644 --- a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/allocation/SearchableSnapshotDiskThresholdIntegTests.java +++ b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/allocation/SearchableSnapshotDiskThresholdIntegTests.java @@ -148,18 +148,14 @@ public class SearchableSnapshotDiskThresholdIntegTests extends DiskUsageIntegTes private void createRepository(String name, String type) { assertAcked( - client().admin() - .cluster() - .preparePutRepository(name) + clusterAdmin().preparePutRepository(name) .setType(type) .setSettings(Settings.builder().put("location", randomRepoPath()).build()) ); } private void createSnapshot(String repository, String snapshot, int nbIndices) { - var snapshotInfo = client().admin() - .cluster() - .prepareCreateSnapshot(repository, snapshot) + var snapshotInfo = clusterAdmin().prepareCreateSnapshot(repository, snapshot) .setIndices("index-*") .setIncludeGlobalState(false) .setWaitForCompletion(true) @@ -244,7 +240,7 @@ public class SearchableSnapshotDiskThresholdIntegTests extends DiskUsageIntegTes // The cold/frozen data node has enough disk space to hold all the shards assertBusy(() -> { - var state = client().admin().cluster().prepareState().setRoutingTable(true).get().getState(); + var state = clusterAdmin().prepareState().setRoutingTable(true).get().getState(); assertThat( state.routingTable() .allShards() @@ -260,7 +256,7 @@ public class SearchableSnapshotDiskThresholdIntegTests extends DiskUsageIntegTes mountIndices(indicesStoresSizes.keySet(), "extra-", repositoryName, snapshot, storage); assertBusy(() -> { - var state = client().admin().cluster().prepareState().setRoutingTable(true).get().getState(); + var state = clusterAdmin().prepareState().setRoutingTable(true).get().getState(); assertThat( state.routingTable() .allShards() @@ -297,7 +293,7 @@ public class SearchableSnapshotDiskThresholdIntegTests extends DiskUsageIntegTes ); ensureStableCluster(3); - String coldNodeId = client().admin().cluster().prepareState().get().getState().nodes().resolveNode(coldNodeName).getId(); + String coldNodeId = clusterAdmin().prepareState().get().getState().nodes().resolveNode(coldNodeName).getId(); logger.info("--> reducing disk size of node [{}/{}] so that all shards except one can fit on the node", coldNodeName, coldNodeId); String indexToSkip = randomFrom(indicesStoresSizes.keySet()); Map indicesToBeMounted = indicesStoresSizes.entrySet() @@ -321,7 +317,7 @@ public class SearchableSnapshotDiskThresholdIntegTests extends DiskUsageIntegTes mountIndices(indicesToBeMounted.keySet(), prefix, repositoryName, snapshotName, FULL_COPY); assertBusy(() -> { - var state = client().admin().cluster().prepareState().setRoutingTable(true).get().getState(); + var state = clusterAdmin().prepareState().setRoutingTable(true).get().getState(); assertThat( state.routingTable() .allShards() @@ -338,7 +334,7 @@ public class SearchableSnapshotDiskThresholdIntegTests extends DiskUsageIntegTes mountIndices(List.of(indexToSkip), prefix, repositoryName, snapshotName, FULL_COPY); assertBusy(() -> { - var state = client().admin().cluster().prepareState().setRoutingTable(true).get().getState(); + var state = clusterAdmin().prepareState().setRoutingTable(true).get().getState(); assertThat(state.routingTable().index(prefix + indexToSkip).shardsWithState(ShardRoutingState.UNASSIGNED).size(), equalTo(1)); }); @@ -348,7 +344,7 @@ public class SearchableSnapshotDiskThresholdIntegTests extends DiskUsageIntegTes mockRepository.unlockRestore(); assertBusy(() -> { - var state = client().admin().cluster().prepareState().setRoutingTable(true).get().getState(); + var state = clusterAdmin().prepareState().setRoutingTable(true).get().getState(); assertThat(state.routingTable().index(prefix + indexToSkip).shardsWithState(ShardRoutingState.UNASSIGNED).size(), equalTo(1)); assertThat( state.routingTable() diff --git a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/allocation/SearchableSnapshotEnableAllocationDeciderIntegTests.java b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/allocation/SearchableSnapshotEnableAllocationDeciderIntegTests.java index 81ae44c7c869..d6291225f0c1 100644 --- a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/allocation/SearchableSnapshotEnableAllocationDeciderIntegTests.java +++ b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/allocation/SearchableSnapshotEnableAllocationDeciderIntegTests.java @@ -39,7 +39,7 @@ public class SearchableSnapshotEnableAllocationDeciderIntegTests extends BaseSea internalCluster().restartNode(indexNode); } - ClusterHealthResponse response = client().admin().cluster().health(new ClusterHealthRequest(restoredIndexName)).actionGet(); + ClusterHealthResponse response = clusterAdmin().health(new ClusterHealthRequest(restoredIndexName)).actionGet(); assertThat(response.getUnassignedShards(), Matchers.equalTo(numPrimaries)); setAllocateOnRollingRestart(true); diff --git a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/allocation/SearchableSnapshotShutdownIntegTests.java b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/allocation/SearchableSnapshotShutdownIntegTests.java index 04657320be87..4484d11ae47b 100644 --- a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/allocation/SearchableSnapshotShutdownIntegTests.java +++ b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/allocation/SearchableSnapshotShutdownIntegTests.java @@ -58,7 +58,7 @@ public class SearchableSnapshotShutdownIntegTests extends BaseSearchableSnapshot final Set indexNodes = restoredIndexNames.stream() .flatMap(index -> internalCluster().nodesInclude(index).stream()) .collect(Collectors.toSet()); - final ClusterState state = client().admin().cluster().prepareState().clear().setRoutingTable(true).setNodes(true).get().getState(); + final ClusterState state = clusterAdmin().prepareState().clear().setRoutingTable(true).setNodes(true).get().getState(); final Map nodeNameToId = state.getNodes() .stream() .collect(Collectors.toMap(DiscoveryNode::getName, DiscoveryNode::getId)); @@ -82,9 +82,7 @@ public class SearchableSnapshotShutdownIntegTests extends BaseSearchableSnapshot @Override public Settings onNodeStopped(String nodeName) throws Exception { assertBusy(() -> { - ClusterHealthResponse response = client().admin() - .cluster() - .health(new ClusterHealthRequest(restoredIndexNamesArray)) + ClusterHealthResponse response = clusterAdmin().health(new ClusterHealthRequest(restoredIndexNamesArray)) .actionGet(); assertThat(response.getUnassignedShards(), Matchers.equalTo(shards)); }); diff --git a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/allocation/SearchableSnapshotsRelocationIntegTests.java b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/allocation/SearchableSnapshotsRelocationIntegTests.java index c8c148ba0ab5..f72a429a62f2 100644 --- a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/allocation/SearchableSnapshotsRelocationIntegTests.java +++ b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/allocation/SearchableSnapshotsRelocationIntegTests.java @@ -82,7 +82,7 @@ public class SearchableSnapshotsRelocationIntegTests extends BaseSearchableSnaps final Index restoredIdx = clusterAdmin().prepareState().get().getState().metadata().index(restoredIndex).getIndex(); final IndicesService indicesService = internalCluster().getInstance(IndicesService.class, secondDataNode); assertEquals(1, indicesService.indexService(restoredIdx).getShard(0).outstandingCleanFilesConditions()); - final ClusterState state = client().admin().cluster().prepareState().get().getState(); + final ClusterState state = clusterAdmin().prepareState().get().getState(); final String primaryNodeId = state.routingTable().index(restoredIndex).shard(0).primaryShard().currentNodeId(); final DiscoveryNode primaryNode = state.nodes().resolveNode(primaryNodeId); assertEquals(firstDataNode, primaryNode.getName()); @@ -91,9 +91,7 @@ public class SearchableSnapshotsRelocationIntegTests extends BaseSearchableSnaps latch.countDown(); assertFalse( - client().admin() - .cluster() - .prepareHealth(restoredIndex) + clusterAdmin().prepareHealth(restoredIndex) .setWaitForNoRelocatingShards(true) .setWaitForEvents(Priority.LANGUID) .get() diff --git a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/blob/SearchableSnapshotsBlobStoreCacheMaintenanceIntegTests.java b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/blob/SearchableSnapshotsBlobStoreCacheMaintenanceIntegTests.java index 787b5000cf94..e29cbadf3e23 100644 --- a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/blob/SearchableSnapshotsBlobStoreCacheMaintenanceIntegTests.java +++ b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/blob/SearchableSnapshotsBlobStoreCacheMaintenanceIntegTests.java @@ -240,7 +240,7 @@ public class SearchableSnapshotsBlobStoreCacheMaintenanceIntegTests extends Base assertAcked(systemClient().admin().indices().prepareDelete(SNAPSHOT_BLOB_CACHE_INDEX)); assertAcked(indicesAdmin().prepareDelete(indicesToDelete.toArray(String[]::new))); - assertAcked(client().admin().cluster().prepareDeleteRepository("repo")); + assertAcked(clusterAdmin().prepareDeleteRepository("repo")); ensureClusterStateConsistency(); assertThat(numberOfEntriesInCache(), equalTo(0L)); @@ -251,9 +251,7 @@ public class SearchableSnapshotsBlobStoreCacheMaintenanceIntegTests extends Base ); try { // restores the .snapshot-blob-cache index with - now obsolete - documents - final RestoreSnapshotResponse restoreResponse = client().admin() - .cluster() - .prepareRestoreSnapshot("backup", "backup") + final RestoreSnapshotResponse restoreResponse = clusterAdmin().prepareRestoreSnapshot("backup", "backup") // We only want to restore the blob cache index. Since we can't do that by name, specify an index that doesn't exist and // allow no indices - this way, only the indices resolved from the feature state will be resolved. .setIndices("this-index-doesnt-exist-i-know-because-#-is-illegal-in-index-names") @@ -395,7 +393,7 @@ public class SearchableSnapshotsBlobStoreCacheMaintenanceIntegTests extends Base } else { logger.info("--> mounted index [{}] did not generate any entry in cache", mountedIndex); - assertAcked(client().admin().cluster().prepareDeleteSnapshot(repositoryName, snapshot).get()); + assertAcked(clusterAdmin().prepareDeleteSnapshot(repositoryName, snapshot).get()); assertAcked(indicesAdmin().prepareDelete(mountedIndex)); } } diff --git a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/full/SearchableSnapshotsPersistentCacheIntegTests.java b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/full/SearchableSnapshotsPersistentCacheIntegTests.java index c8da74919ba1..93d60f161e65 100644 --- a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/full/SearchableSnapshotsPersistentCacheIntegTests.java +++ b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/full/SearchableSnapshotsPersistentCacheIntegTests.java @@ -79,7 +79,7 @@ public class SearchableSnapshotsPersistentCacheIntegTests extends BaseSearchable assertThat(snapshotInfo.successfulShards(), equalTo(snapshotInfo.totalShards())); assertAcked(client().admin().indices().prepareDelete(indexName)); - final DiscoveryNodes discoveryNodes = client().admin().cluster().prepareState().clear().setNodes(true).get().getState().nodes(); + final DiscoveryNodes discoveryNodes = clusterAdmin().prepareState().clear().setNodes(true).get().getState().nodes(); final String dataNode = randomFrom(discoveryNodes.getDataNodes().values()).getName(); mountSnapshot( @@ -94,9 +94,7 @@ public class SearchableSnapshotsPersistentCacheIntegTests extends BaseSearchable assertExecutorIsIdle(SearchableSnapshots.CACHE_FETCH_ASYNC_THREAD_POOL_NAME); assertExecutorIsIdle(SearchableSnapshots.CACHE_PREWARMING_THREAD_POOL_NAME); - final Index restoredIndex = client().admin() - .cluster() - .prepareState() + final Index restoredIndex = clusterAdmin().prepareState() .clear() .setMetadata(true) .get() @@ -210,13 +208,7 @@ public class SearchableSnapshotsPersistentCacheIntegTests extends BaseSearchable .allMatch(recoveryState -> recoveryState.getStage() == RecoveryState.Stage.DONE) ); - final ClusterStateResponse state = client().admin() - .cluster() - .prepareState() - .clear() - .setMetadata(true) - .setIndices(mountedIndexName) - .get(); + final ClusterStateResponse state = clusterAdmin().prepareState().clear().setMetadata(true).setIndices(mountedIndexName).get(); final Index mountedIndex = state.getState().metadata().index(mountedIndexName).getIndex(); final Set dataNodes = new HashSet<>(); diff --git a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/full/SearchableSnapshotsPrewarmingIntegTests.java b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/full/SearchableSnapshotsPrewarmingIntegTests.java index 55b8cf264329..961118d0ab84 100644 --- a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/full/SearchableSnapshotsPrewarmingIntegTests.java +++ b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/full/SearchableSnapshotsPrewarmingIntegTests.java @@ -151,14 +151,10 @@ public class SearchableSnapshotsPrewarmingIntegTests extends ESSingleNodeTestCas } logger.debug("--> registering repository"); - assertAcked( - client().admin().cluster().preparePutRepository("repository").setType(FsRepository.TYPE).setSettings(repositorySettings.build()) - ); + assertAcked(clusterAdmin().preparePutRepository("repository").setType(FsRepository.TYPE).setSettings(repositorySettings.build())); logger.debug("--> snapshotting indices"); - final CreateSnapshotResponse createSnapshotResponse = client().admin() - .cluster() - .prepareCreateSnapshot("repository", "snapshot") + final CreateSnapshotResponse createSnapshotResponse = clusterAdmin().prepareCreateSnapshot("repository", "snapshot") .setIncludeGlobalState(false) .setIndices("index-*") .setWaitForCompletion(true) @@ -174,16 +170,11 @@ public class SearchableSnapshotsPrewarmingIntegTests extends ESSingleNodeTestCas assertAcked(indicesAdmin().prepareDelete("index-*")); logger.debug("--> deleting repository"); - assertAcked(client().admin().cluster().prepareDeleteRepository("repository")); + assertAcked(clusterAdmin().prepareDeleteRepository("repository")); logger.debug("--> registering tracking repository"); assertAcked( - client().admin() - .cluster() - .preparePutRepository("repository") - .setType("tracking") - .setVerify(false) - .setSettings(repositorySettings.build()) + clusterAdmin().preparePutRepository("repository").setType("tracking").setVerify(false).setSettings(repositorySettings.build()) ); TrackingRepositoryPlugin tracker = getTrackingRepositoryPlugin(); diff --git a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/shared/NodesCachesStatsIntegTests.java b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/shared/NodesCachesStatsIntegTests.java index 2dde350a1bc9..28a537c5da9e 100644 --- a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/shared/NodesCachesStatsIntegTests.java +++ b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/shared/NodesCachesStatsIntegTests.java @@ -81,9 +81,7 @@ public class NodesCachesStatsIntegTests extends BaseFrozenSearchableSnapshotsInt final String nodeName = nodeCachesStats.getNode().getName(); final ClusterService clusterService = internalCluster().getInstance(ClusterService.class, nodeName); - final long totalFsSize = client().admin() - .cluster() - .prepareNodesStats(nodeId) + final long totalFsSize = clusterAdmin().prepareNodesStats(nodeId) .clear() .setFs(true) .get() @@ -128,9 +126,7 @@ public class NodesCachesStatsIntegTests extends BaseFrozenSearchableSnapshotsInt assertThat(clearCacheResponse.getSuccessfulShards(), greaterThan(0)); assertThat(clearCacheResponse.getFailedShards(), equalTo(0)); - final String[] dataNodesWithFrozenShards = client().admin() - .cluster() - .prepareState() + final String[] dataNodesWithFrozenShards = clusterAdmin().prepareState() .get() .getState() .routingTable() diff --git a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/shared/PartiallyCachedShardAllocationIntegTests.java b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/shared/PartiallyCachedShardAllocationIntegTests.java index 55a6f89373e5..fd4b526eeadc 100644 --- a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/shared/PartiallyCachedShardAllocationIntegTests.java +++ b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/cache/shared/PartiallyCachedShardAllocationIntegTests.java @@ -108,12 +108,10 @@ public class PartiallyCachedShardAllocationIntegTests extends BaseFrozenSearchab final MountSearchableSnapshotRequest req = prepareMountRequest(); final RestoreSnapshotResponse restoreSnapshotResponse = client().execute(MountSearchableSnapshotAction.INSTANCE, req).get(); assertThat(restoreSnapshotResponse.getRestoreInfo().successfulShards(), equalTo(0)); - final ClusterState state = client().admin().cluster().prepareState().clear().setRoutingTable(true).get().getState(); + final ClusterState state = clusterAdmin().prepareState().clear().setRoutingTable(true).get().getState(); assertTrue(state.toString(), state.routingTable().index(req.mountedIndexName()).allPrimaryShardsUnassigned()); - final ClusterAllocationExplanation explanation = client().admin() - .cluster() - .prepareAllocationExplain() + final ClusterAllocationExplanation explanation = clusterAdmin().prepareAllocationExplain() .setPrimary(true) .setIndex(req.mountedIndexName()) .setShard(0) @@ -147,7 +145,7 @@ public class PartiallyCachedShardAllocationIntegTests extends BaseFrozenSearchab assertThat(restoreSnapshotResponse.getRestoreInfo().failedShards(), equalTo(0)); ensureGreen(req.mountedIndexName()); - final ClusterState state = client().admin().cluster().prepareState().clear().setNodes(true).setRoutingTable(true).get().getState(); + final ClusterState state = clusterAdmin().prepareState().clear().setNodes(true).setRoutingTable(true).get().getState(); final Set newNodeIds = newNodeNames.stream().map(n -> state.nodes().resolveNode(n).getId()).collect(Collectors.toSet()); for (ShardRouting shardRouting : state.routingTable().index(req.mountedIndexName()).shardsWithState(ShardRoutingState.STARTED)) { assertThat(state.toString(), newNodeIds, hasItem(shardRouting.currentNodeId())); @@ -168,9 +166,7 @@ public class PartiallyCachedShardAllocationIntegTests extends BaseFrozenSearchab createIndex("other-index", Settings.builder().putNull(TIER_PREFERENCE).build()); ensureGreen("other-index"); - final RoutingNodes routingNodes = client().admin() - .cluster() - .prepareState() + final RoutingNodes routingNodes = clusterAdmin().prepareState() .clear() .setRoutingTable(true) .setNodes(true) @@ -187,7 +183,7 @@ public class PartiallyCachedShardAllocationIntegTests extends BaseFrozenSearchab assertThat(restoreSnapshotResponse.getRestoreInfo().failedShards(), equalTo(0)); ensureGreen(req.mountedIndexName()); - final ClusterState state = client().admin().cluster().prepareState().clear().setNodes(true).setRoutingTable(true).get().getState(); + final ClusterState state = clusterAdmin().prepareState().clear().setNodes(true).setRoutingTable(true).get().getState(); final Set newNodeIds = newNodeNames.stream().map(n -> state.nodes().resolveNode(n).getId()).collect(Collectors.toSet()); for (ShardRouting shardRouting : state.routingTable().index(req.mountedIndexName()).shardsWithState(ShardRoutingState.STARTED)) { assertThat(state.toString(), newNodeIds, hasItem(shardRouting.currentNodeId())); @@ -250,9 +246,7 @@ public class PartiallyCachedShardAllocationIntegTests extends BaseFrozenSearchab assertBusy(() -> { try { - final ClusterAllocationExplanation explanation = client().admin() - .cluster() - .prepareAllocationExplain() + final ClusterAllocationExplanation explanation = clusterAdmin().prepareAllocationExplain() .setPrimary(true) .setIndex(req.mountedIndexName()) .setShard(0) @@ -277,9 +271,7 @@ public class PartiallyCachedShardAllocationIntegTests extends BaseFrozenSearchab // Still won't be allocated assertFalse(responseFuture.isDone()); - final ClusterAllocationExplanation explanation = client().admin() - .cluster() - .prepareAllocationExplain() + final ClusterAllocationExplanation explanation = clusterAdmin().prepareAllocationExplain() .setPrimary(true) .setIndex(req.mountedIndexName()) .setShard(0) @@ -313,7 +305,7 @@ public class PartiallyCachedShardAllocationIntegTests extends BaseFrozenSearchab assertFalse("should have failed before success", failurePermits.tryAcquire()); final Map shardCountsByNodeName = new HashMap<>(); - final ClusterState state = client().admin().cluster().prepareState().clear().setRoutingTable(true).setNodes(true).get().getState(); + final ClusterState state = clusterAdmin().prepareState().clear().setRoutingTable(true).setNodes(true).get().getState(); for (RoutingNode routingNode : state.getRoutingNodes()) { shardCountsByNodeName.put( routingNode.node().getName(), diff --git a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/recovery/SearchableSnapshotRecoveryStateIntegrationTests.java b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/recovery/SearchableSnapshotRecoveryStateIntegrationTests.java index 705e3b4c92c0..34b64da82ded 100644 --- a/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/recovery/SearchableSnapshotRecoveryStateIntegrationTests.java +++ b/x-pack/plugin/searchable-snapshots/src/internalClusterTest/java/org/elasticsearch/xpack/searchablesnapshots/recovery/SearchableSnapshotRecoveryStateIntegrationTests.java @@ -83,9 +83,7 @@ public class SearchableSnapshotRecoveryStateIntegrationTests extends BaseSearcha mountSnapshot(fsRepoName, snapshotName, indexName, restoredIndexName, Settings.EMPTY); ensureGreen(restoredIndexName); - final Index restoredIndex = client().admin() - .cluster() - .prepareState() + final Index restoredIndex = clusterAdmin().prepareState() .clear() .setMetadata(true) .get() @@ -147,9 +145,7 @@ public class SearchableSnapshotRecoveryStateIntegrationTests extends BaseSearcha internalCluster().restartRandomDataNode(); ensureGreen(restoredIndexName); - final Index restoredIndex = client().admin() - .cluster() - .prepareState() + final Index restoredIndex = clusterAdmin().prepareState() .clear() .setMetadata(true) .get() diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/ClusterPrivilegeIntegrationTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/ClusterPrivilegeIntegrationTests.java index 91861f054b0e..cd766f3fe941 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/ClusterPrivilegeIntegrationTests.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/ClusterPrivilegeIntegrationTests.java @@ -253,13 +253,11 @@ public class ClusterPrivilegeIntegrationTests extends AbstractPrivilegeTestCase private void waitForSnapshotToFinish(String repo, String snapshot) throws Exception { assertBusy(() -> { - SnapshotsStatusResponse response = client().admin().cluster().prepareSnapshotStatus(repo).setSnapshots(snapshot).get(); + SnapshotsStatusResponse response = clusterAdmin().prepareSnapshotStatus(repo).setSnapshots(snapshot).get(); assertThat(response.getSnapshots().get(0).getState(), is(SnapshotsInProgress.State.SUCCESS)); // The status of the snapshot in the repository can become SUCCESS before it is fully finalized in the cluster state so wait for // it to disappear from the cluster state as well - SnapshotsInProgress snapshotsInProgress = client().admin() - .cluster() - .state(new ClusterStateRequest()) + SnapshotsInProgress snapshotsInProgress = clusterAdmin().state(new ClusterStateRequest()) .get() .getState() .custom(SnapshotsInProgress.TYPE); diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/IndexPrivilegeIntegTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/IndexPrivilegeIntegTests.java index 10ea09285b2e..0baafc14d9ca 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/IndexPrivilegeIntegTests.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/IndexPrivilegeIntegTests.java @@ -559,7 +559,7 @@ public class IndexPrivilegeIntegTests extends AbstractPrivilegeTestCase { assertAccessIsAllowed(user, "DELETE", "/" + index); assertUserIsAllowed(user, "create_index", index); // wait until index ready, but as admin - assertNoTimeout(client().admin().cluster().prepareHealth(index).setWaitForGreenStatus().get()); + assertNoTimeout(clusterAdmin().prepareHealth(index).setWaitForGreenStatus().get()); assertAccessIsAllowed(user, "POST", "/" + index + "/_refresh"); assertAccessIsAllowed(user, "GET", "/" + index + "/_analyze", "{ \"text\" : \"test\" }"); assertAccessIsAllowed(user, "POST", "/" + index + "/_flush"); @@ -569,7 +569,7 @@ public class IndexPrivilegeIntegTests extends AbstractPrivilegeTestCase { assertAccessIsAllowed(user, "POST", "/" + index + "/_cache/clear"); // indexing a document to have the mapping available, and wait for green state to make sure index is created assertAccessIsAllowed("admin", "PUT", "/" + index + "/_doc/1", jsonDoc); - assertNoTimeout(client().admin().cluster().prepareHealth(index).setWaitForGreenStatus().get()); + assertNoTimeout(clusterAdmin().prepareHealth(index).setWaitForGreenStatus().get()); assertAccessIsAllowed(user, "GET", "/" + index + "/_mapping/field/name"); assertAccessIsAllowed(user, "GET", "/" + index + "/_settings"); assertAccessIsAllowed(user, randomFrom("GET", "POST"), "/" + index + "/_field_caps?fields=*"); diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/RoleMappingFileSettingsIT.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/RoleMappingFileSettingsIT.java index 168497696fc6..7c753692628c 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/RoleMappingFileSettingsIT.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/RoleMappingFileSettingsIT.java @@ -205,10 +205,9 @@ public class RoleMappingFileSettingsIT extends NativeRealmIntegTestCase { boolean awaitSuccessful = savedClusterState.await(20, TimeUnit.SECONDS); assertTrue(awaitSuccessful); - final ClusterStateResponse clusterStateResponse = client().admin() - .cluster() - .state(new ClusterStateRequest().waitForMetadataVersion(metadataVersion.get())) - .get(); + final ClusterStateResponse clusterStateResponse = clusterAdmin().state( + new ClusterStateRequest().waitForMetadataVersion(metadataVersion.get()) + ).get(); ReservedStateMetadata reservedState = clusterStateResponse.getState() .metadata() @@ -236,7 +235,7 @@ public class RoleMappingFileSettingsIT extends NativeRealmIntegTestCase { "java.lang.IllegalArgumentException: Failed to process request " + "[org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest/unset] " + "with errors: [[indices.recovery.max_bytes_per_sec] set as read-only by [file_settings]]", - expectThrows(ExecutionException.class, () -> client().admin().cluster().updateSettings(req).get()).getMessage() + expectThrows(ExecutionException.class, () -> clusterAdmin().updateSettings(req).get()).getMessage() ); var request = new GetRoleMappingsRequest(); @@ -285,10 +284,9 @@ public class RoleMappingFileSettingsIT extends NativeRealmIntegTestCase { boolean awaitSuccessful = savedClusterState.v1().await(20, TimeUnit.SECONDS); assertTrue(awaitSuccessful); - final ClusterStateResponse clusterStateResponse = client().admin() - .cluster() - .state(new ClusterStateRequest().waitForMetadataVersion(savedClusterState.v2().get())) - .get(); + final ClusterStateResponse clusterStateResponse = clusterAdmin().state( + new ClusterStateRequest().waitForMetadataVersion(savedClusterState.v2().get()) + ).get(); assertNull( clusterStateResponse.getState().metadata().persistentSettings().get(INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING.getKey()) @@ -346,10 +344,9 @@ public class RoleMappingFileSettingsIT extends NativeRealmIntegTestCase { boolean awaitSuccessful = savedClusterState.v1().await(20, TimeUnit.SECONDS); assertTrue(awaitSuccessful); - final ClusterStateResponse clusterStateResponse = client().admin() - .cluster() - .state(new ClusterStateRequest().waitForMetadataVersion(savedClusterState.v2().get())) - .get(); + final ClusterStateResponse clusterStateResponse = clusterAdmin().state( + new ClusterStateRequest().waitForMetadataVersion(savedClusterState.v2().get()) + ).get(); assertNull( clusterStateResponse.getState().metadata().persistentSettings().get(INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING.getKey()) @@ -404,10 +401,9 @@ public class RoleMappingFileSettingsIT extends NativeRealmIntegTestCase { var response = client().execute(GetRoleMappingsAction.INSTANCE, request).get(); assertFalse(response.hasMappings()); - final ClusterStateResponse clusterStateResponse = client().admin() - .cluster() - .state(new ClusterStateRequest().waitForMetadataVersion(savedClusterState.v2().get())) - .get(); + final ClusterStateResponse clusterStateResponse = clusterAdmin().state( + new ClusterStateRequest().waitForMetadataVersion(savedClusterState.v2().get()) + ).get(); assertNull( clusterStateResponse.getState().metadata().persistentSettings().get(INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING.getKey()) diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/SecurityFeatureStateIntegTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/SecurityFeatureStateIntegTests.java index 670ff9c4cfe7..ada76b8fd0fb 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/SecurityFeatureStateIntegTests.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/SecurityFeatureStateIntegTests.java @@ -68,9 +68,7 @@ public class SecurityFeatureStateIntegTests extends AbstractPrivilegeTestCase { public void testSecurityFeatureStateSnapshotAndRestore() throws Exception { // set up a snapshot repository final String repositoryName = "test-repo"; - client().admin() - .cluster() - .preparePutRepository(repositoryName) + clusterAdmin().preparePutRepository(repositoryName) .setType("fs") .setSettings(Settings.builder().put("location", repositoryLocation)) .get(); @@ -107,9 +105,7 @@ public class SecurityFeatureStateIntegTests extends AbstractPrivilegeTestCase { // snapshot state final String snapshotName = "security-state"; - client().admin() - .cluster() - .prepareCreateSnapshot(repositoryName, snapshotName) + clusterAdmin().prepareCreateSnapshot(repositoryName, snapshotName) .setIndices("test_index") .setFeatureStates("LocalStateSecurity") .get(); @@ -135,9 +131,7 @@ public class SecurityFeatureStateIntegTests extends AbstractPrivilegeTestCase { client().admin().indices().prepareClose("test_index").get(); // restore state - client().admin() - .cluster() - .prepareRestoreSnapshot(repositoryName, snapshotName) + clusterAdmin().prepareRestoreSnapshot(repositoryName, snapshotName) .setFeatureStates("LocalStateSecurity") .setIndices("test_index") .setWaitForCompletion(true) @@ -174,13 +168,11 @@ public class SecurityFeatureStateIntegTests extends AbstractPrivilegeTestCase { private void waitForSnapshotToFinish(String repo, String snapshot) throws Exception { assertBusy(() -> { - SnapshotsStatusResponse response = client().admin().cluster().prepareSnapshotStatus(repo).setSnapshots(snapshot).get(); + SnapshotsStatusResponse response = clusterAdmin().prepareSnapshotStatus(repo).setSnapshots(snapshot).get(); assertThat(response.getSnapshots().get(0).getState(), is(SnapshotsInProgress.State.SUCCESS)); // The status of the snapshot in the repository can become SUCCESS before it is fully finalized in the cluster state so wait for // it to disappear from the cluster state as well - SnapshotsInProgress snapshotsInProgress = client().admin() - .cluster() - .state(new ClusterStateRequest()) + SnapshotsInProgress snapshotsInProgress = clusterAdmin().state(new ClusterStateRequest()) .get() .getState() .custom(SnapshotsInProgress.TYPE); diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/ShrinkIndexWithSecurityTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/ShrinkIndexWithSecurityTests.java index 4f76951c19ee..b34967d88c1f 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/ShrinkIndexWithSecurityTests.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/ShrinkIndexWithSecurityTests.java @@ -39,7 +39,7 @@ public class ShrinkIndexWithSecurityTests extends SecurityIntegTestCase { client().prepareIndex("bigindex").setSource("foo", "bar").get(); } - Map dataNodes = client().admin().cluster().prepareState().get().getState().nodes().getDataNodes(); + Map dataNodes = clusterAdmin().prepareState().get().getState().nodes().getDataNodes(); DiscoveryNode[] discoveryNodes = dataNodes.values().toArray(DiscoveryNode[]::new); final String mergeNode = discoveryNodes[0].getName(); ensureGreen(); diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/test/SecuritySingleNodeTestCase.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/test/SecuritySingleNodeTestCase.java index 1d7326894f90..1daff64f57fc 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/test/SecuritySingleNodeTestCase.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/test/SecuritySingleNodeTestCase.java @@ -112,7 +112,7 @@ public abstract class SecuritySingleNodeTestCase extends ESSingleNodeTestCase { } private void doAssertXPackIsInstalled() { - NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().clear().setPlugins(true).get(); + NodesInfoResponse nodeInfos = clusterAdmin().prepareNodesInfo().clear().setPlugins(true).get(); for (NodeInfo nodeInfo : nodeInfos.getNodes()) { // TODO: disable this assertion for now, due to random runs with mock plugins. perhaps run without mock plugins? // assertThat(nodeInfo.getInfo(PluginsAndModules.class).getInfos(), hasSize(2)); diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/FileSettingsRoleMappingsRestartIT.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/FileSettingsRoleMappingsRestartIT.java index 082397b68e78..6e4e5fcc2a63 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/FileSettingsRoleMappingsRestartIT.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/FileSettingsRoleMappingsRestartIT.java @@ -130,7 +130,7 @@ public class FileSettingsRoleMappingsRestartIT extends SecurityIntegTestCase { ensureGreen(); - var clusterStateResponse = client().admin().cluster().state(new ClusterStateRequest()).actionGet(); + var clusterStateResponse = clusterAdmin().state(new ClusterStateRequest()).actionGet(); assertThat( clusterStateResponse.getState() .metadata() diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/audit/logfile/AuditTrailSettingsUpdateTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/audit/logfile/AuditTrailSettingsUpdateTests.java index 9c6dcc74703a..84a7f752d56a 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/audit/logfile/AuditTrailSettingsUpdateTests.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/audit/logfile/AuditTrailSettingsUpdateTests.java @@ -103,7 +103,7 @@ public class AuditTrailSettingsUpdateTests extends SecurityIntegTestCase { settingsBuilder.put(randomFrom(allSettingsKeys), invalidLuceneRegex); final IllegalArgumentException e = expectThrows( IllegalArgumentException.class, - () -> client().admin().cluster().prepareUpdateSettings().setPersistentSettings(settingsBuilder.build()).get() + () -> clusterAdmin().prepareUpdateSettings().setPersistentSettings(settingsBuilder.build()).get() ); assertThat(e.getMessage(), containsString("invalid pattern [/invalid]")); } diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/ApiKeyIntegTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/ApiKeyIntegTests.java index 08f4a894d814..ca34de08481c 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/ApiKeyIntegTests.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/ApiKeyIntegTests.java @@ -1739,9 +1739,7 @@ public class ApiKeyIntegTests extends SecurityIntegTestCase { // Clear the auth cache to force recompute the expensive hash which requires the crypto thread pool apiKeyService.getApiKeyAuthCache().invalidateAll(); - final List nodeInfos = client().admin() - .cluster() - .prepareNodesInfo() + final List nodeInfos = clusterAdmin().prepareNodesInfo() .get() .getNodes() .stream() diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/TokenAuthIntegTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/TokenAuthIntegTests.java index 655766eda836..45de9efa23f8 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/TokenAuthIntegTests.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/TokenAuthIntegTests.java @@ -653,7 +653,7 @@ public class TokenAuthIntegTests extends SecurityIntegTestCase { } public void testMetadataIsNotSentToClient() { - ClusterStateResponse clusterStateResponse = client().admin().cluster().prepareState().setCustoms(true).get(); + ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState().setCustoms(true).get(); assertFalse(clusterStateResponse.getState().customs().containsKey(TokenMetadata.TYPE)); } diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmIntegTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmIntegTests.java index 25bfdcb4b14b..230d0f89553e 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmIntegTests.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmIntegTests.java @@ -495,9 +495,7 @@ public class NativeRealmIntegTests extends NativeRealmIntegTestCase { ensureGreen(SECURITY_MAIN_ALIAS); logger.info("--> creating repository"); assertAcked( - client().admin() - .cluster() - .preparePutRepository("test-repo") + clusterAdmin().preparePutRepository("test-repo") .setType("fs") .setSettings( Settings.builder() @@ -534,9 +532,7 @@ public class NativeRealmIntegTests extends NativeRealmIntegTestCase { GetRolesResponse getRolesResponse = new GetRolesRequestBuilder(client()).names("test_role").get(); assertThat(getRolesResponse.roles().length, is(0)); // restore - RestoreSnapshotResponse response = client().admin() - .cluster() - .prepareRestoreSnapshot("test-repo", "test-snap-1") + RestoreSnapshotResponse response = clusterAdmin().prepareRestoreSnapshot("test-repo", "test-snap-1") .setWaitForCompletion(true) .setIncludeAliases(randomBoolean()) // Aliases are always restored for system indices .setFeatureStates(SECURITY_FEATURE_NAME) @@ -562,7 +558,7 @@ public class NativeRealmIntegTests extends NativeRealmIntegTestCase { .prepareCreate("idx") .get(); assertThat(createIndexResponse.isAcknowledged(), is(true)); - assertAcked(client().admin().cluster().prepareDeleteRepository("test-repo")); + assertAcked(clusterAdmin().prepareDeleteRepository("test-repo")); } public void testAuthenticateWithDeletedRole() { diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealmElasticAutoconfigIntegTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealmElasticAutoconfigIntegTests.java index 5217a1281384..1cd3cfa3a587 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealmElasticAutoconfigIntegTests.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealmElasticAutoconfigIntegTests.java @@ -69,7 +69,7 @@ public class ReservedRealmElasticAutoconfigIntegTests extends SecuritySingleNode // prevents the .security index from being created automatically (after elastic user authentication) ClusterUpdateSettingsRequest updateSettingsRequest = new ClusterUpdateSettingsRequest(); updateSettingsRequest.transientSettings(Settings.builder().put(Metadata.SETTING_READ_ONLY_ALLOW_DELETE_SETTING.getKey(), true)); - assertAcked(client().admin().cluster().updateSettings(updateSettingsRequest).actionGet()); + assertAcked(clusterAdmin().updateSettings(updateSettingsRequest).actionGet()); // delete the security index, if it exist GetIndexRequest getIndexRequest = new GetIndexRequest(); @@ -123,7 +123,7 @@ public class ReservedRealmElasticAutoconfigIntegTests extends SecuritySingleNode updateSettingsRequest.transientSettings( Settings.builder().put(Metadata.SETTING_READ_ONLY_ALLOW_DELETE_SETTING.getKey(), (String) null) ); - assertAcked(client().admin().cluster().updateSettings(updateSettingsRequest).actionGet()); + assertAcked(clusterAdmin().updateSettings(updateSettingsRequest).actionGet()); } } @@ -141,7 +141,7 @@ public class ReservedRealmElasticAutoconfigIntegTests extends SecuritySingleNode // but then make the cluster read-only ClusterUpdateSettingsRequest updateSettingsRequest = new ClusterUpdateSettingsRequest(); updateSettingsRequest.transientSettings(Settings.builder().put(Metadata.SETTING_READ_ONLY_ALLOW_DELETE_SETTING.getKey(), true)); - assertAcked(client().admin().cluster().updateSettings(updateSettingsRequest).actionGet()); + assertAcked(clusterAdmin().updateSettings(updateSettingsRequest).actionGet()); // elastic user now gets 503 for the good password Request restRequest = randomFrom( @@ -166,7 +166,7 @@ public class ReservedRealmElasticAutoconfigIntegTests extends SecuritySingleNode updateSettingsRequest.transientSettings( Settings.builder().put(Metadata.SETTING_READ_ONLY_ALLOW_DELETE_SETTING.getKey(), (String) null) ); - assertAcked(client().admin().cluster().updateSettings(updateSettingsRequest).actionGet()); + assertAcked(clusterAdmin().updateSettings(updateSettingsRequest).actionGet()); if (randomBoolean()) { Request restRequest2 = randomFrom( @@ -208,7 +208,7 @@ public class ReservedRealmElasticAutoconfigIntegTests extends SecuritySingleNode updateSettingsRequest.transientSettings( Settings.builder().put(Metadata.SETTING_READ_ONLY_ALLOW_DELETE_SETTING.getKey(), (String) null) ); - assertAcked(client().admin().cluster().updateSettings(updateSettingsRequest).actionGet()); + assertAcked(clusterAdmin().updateSettings(updateSettingsRequest).actionGet()); } } } diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authz/SnapshotUserRoleIntegTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authz/SnapshotUserRoleIntegTests.java index a419f9b90237..f0858c81ac1c 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authz/SnapshotUserRoleIntegTests.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authz/SnapshotUserRoleIntegTests.java @@ -46,11 +46,7 @@ public class SnapshotUserRoleIntegTests extends NativeRealmIntegTestCase { public void setupClusterBeforeSnapshot() throws IOException { logger.info("--> creating repository"); assertAcked( - client().admin() - .cluster() - .preparePutRepository("repo") - .setType("fs") - .setSettings(Settings.builder().put("location", randomRepoPath())) + clusterAdmin().preparePutRepository("repo").setType("fs").setSettings(Settings.builder().put("location", randomRepoPath())) ); logger.info("--> creating ordinary index"); diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/transport/filter/IpFilteringUpdateTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/transport/filter/IpFilteringUpdateTests.java index e639fb193bf8..1113b128b74e 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/transport/filter/IpFilteringUpdateTests.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/transport/filter/IpFilteringUpdateTests.java @@ -84,7 +84,7 @@ public class IpFilteringUpdateTests extends SecurityIntegTestCase { assertConnectionRejected("client", "127.0.0.8"); // check that all is in cluster state - ClusterState clusterState = client().admin().cluster().prepareState().get().getState(); + ClusterState clusterState = clusterAdmin().prepareState().get().getState(); assertThat(clusterState.metadata().settings().get("xpack.security.transport.filter.allow"), is("127.0.0.1")); assertThat(clusterState.metadata().settings().get("xpack.security.transport.filter.deny"), is("127.0.0.8")); assertEquals(Arrays.asList("127.0.0.1"), clusterState.metadata().settings().getAsList("xpack.security.http.filter.allow")); @@ -102,7 +102,7 @@ public class IpFilteringUpdateTests extends SecurityIntegTestCase { assertConnectionAccepted("client", "127.0.0.8"); // disabling should not have any effect on the cluster state settings - clusterState = client().admin().cluster().prepareState().get().getState(); + clusterState = clusterAdmin().prepareState().get().getState(); assertThat(clusterState.metadata().settings().get("xpack.security.transport.filter.allow"), is("127.0.0.1")); assertThat(clusterState.metadata().settings().get("xpack.security.transport.filter.deny"), is("127.0.0.8")); assertEquals(Arrays.asList("127.0.0.1"), clusterState.metadata().settings().getAsList("xpack.security.http.filter.allow")); @@ -145,7 +145,7 @@ public class IpFilteringUpdateTests extends SecurityIntegTestCase { expectThrows( IllegalArgumentException.class, settingName, - () -> client().admin().cluster().prepareUpdateSettings().setPersistentSettings(settings).execute().actionGet() + () -> clusterAdmin().prepareUpdateSettings().setPersistentSettings(settings).execute().actionGet() ).getMessage(), allOf(containsString("invalid IP filter"), containsString(invalidValue)) ); diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/transport/ssl/EllipticCurveSSLTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/transport/ssl/EllipticCurveSSLTests.java index 1707d2212487..e1d668635777 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/transport/ssl/EllipticCurveSSLTests.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/transport/ssl/EllipticCurveSSLTests.java @@ -70,7 +70,7 @@ public class EllipticCurveSSLTests extends SecurityIntegTestCase { SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(new X509ExtendedKeyManager[] { x509ExtendedKeyManager }, new TrustManager[] { trustManager }, new SecureRandom()); SSLSocketFactory socketFactory = sslContext.getSocketFactory(); - NodesInfoResponse response = client().admin().cluster().prepareNodesInfo().setTransport(true).get(); + NodesInfoResponse response = clusterAdmin().prepareNodesInfo().setTransport(true).get(); TransportAddress address = randomFrom(response.getNodes()).getInfo(TransportInfo.class).getAddress().publishAddress(); final CountDownLatch latch = new CountDownLatch(1); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/test/SecurityIntegTestCase.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/test/SecurityIntegTestCase.java index f25f8ffed54c..6057667fb575 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/test/SecurityIntegTestCase.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/test/SecurityIntegTestCase.java @@ -180,7 +180,7 @@ public abstract class SecurityIntegTestCase extends ESIntegTestCase { } protected void doAssertXPackIsInstalled() { - NodesInfoResponse nodeInfos = client().admin().cluster().prepareNodesInfo().clear().setPlugins(true).get(); + NodesInfoResponse nodeInfos = clusterAdmin().prepareNodesInfo().clear().setPlugins(true).get(); for (NodeInfo nodeInfo : nodeInfos.getNodes()) { // TODO: disable this assertion for now, due to random runs with mock plugins. perhaps run without mock plugins? // assertThat(nodeInfo.getPlugins().getInfos(), hasSize(2)); diff --git a/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownDelayedAllocationIT.java b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownDelayedAllocationIT.java index 47f6db172aa4..649e97e660e5 100644 --- a/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownDelayedAllocationIT.java +++ b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownDelayedAllocationIT.java @@ -62,9 +62,7 @@ public class NodeShutdownDelayedAllocationIT extends ESIntegTestCase { internalCluster().restartNode(nodeToRestartName, new InternalTestCluster.RestartCallback() { @Override public Settings onNodeStopped(String nodeName) throws Exception { - assertBusy( - () -> { assertThat(client().admin().cluster().prepareHealth().get().getDelayedUnassignedShards(), equalTo(1)); } - ); + assertBusy(() -> assertThat(clusterAdmin().prepareHealth().get().getDelayedUnassignedShards(), equalTo(1))); return super.onNodeStopped(nodeName); } }); @@ -131,9 +129,7 @@ public class NodeShutdownDelayedAllocationIT extends ESIntegTestCase { internalCluster().restartNode(nodeToRestartName, new InternalTestCluster.RestartCallback() { @Override public Settings onNodeStopped(String nodeName) throws Exception { - assertBusy( - () -> { assertThat(client().admin().cluster().prepareHealth().get().getDelayedUnassignedShards(), equalTo(1)); } - ); + assertBusy(() -> { assertThat(clusterAdmin().prepareHealth().get().getDelayedUnassignedShards(), equalTo(1)); }); return super.onNodeStopped(nodeName); } }); @@ -208,7 +204,7 @@ public class NodeShutdownDelayedAllocationIT extends ESIntegTestCase { internalCluster().stopNode(nodeToRestartName); // Verify that the shard's allocation is delayed - assertBusy(() -> { assertThat(client().admin().cluster().prepareHealth().get().getDelayedUnassignedShards(), equalTo(1)); }); + assertBusy(() -> { assertThat(clusterAdmin().prepareHealth().get().getDelayedUnassignedShards(), equalTo(1)); }); return nodeToRestartId; } @@ -223,13 +219,13 @@ public class NodeShutdownDelayedAllocationIT extends ESIntegTestCase { } private String findIdOfNodeWithShard() { - ClusterState state = client().admin().cluster().prepareState().get().getState(); + ClusterState state = clusterAdmin().prepareState().get().getState(); List startedShards = RoutingNodesHelper.shardsWithState(state.getRoutingNodes(), ShardRoutingState.STARTED); return randomFrom(startedShards).currentNodeId(); } private String findNodeNameFromId(String id) { - ClusterState state = client().admin().cluster().prepareState().get().getState(); + ClusterState state = clusterAdmin().prepareState().get().getState(); return state.nodes().get(id).getName(); } } diff --git a/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownPluginsIT.java b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownPluginsIT.java index 10f1c4d62adf..3a1280307b73 100644 --- a/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownPluginsIT.java +++ b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownPluginsIT.java @@ -44,7 +44,7 @@ public class NodeShutdownPluginsIT extends ESIntegTestCase { final String shutdownNode; final String remainNode; - NodesInfoResponse nodes = client().admin().cluster().prepareNodesInfo().clear().get(); + NodesInfoResponse nodes = clusterAdmin().prepareNodesInfo().clear().get(); final String node1Id = nodes.getNodes() .stream() .map(NodeInfo::getNode) diff --git a/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java index ba7f8cf047dd..280e9c7f3598 100644 --- a/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java +++ b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownShardsIT.java @@ -59,7 +59,7 @@ public class NodeShutdownShardsIT extends ESIntegTestCase { internalCluster().stopNode(nodeToRestartName); - NodesInfoResponse nodes = client().admin().cluster().prepareNodesInfo().clear().get(); + NodesInfoResponse nodes = clusterAdmin().prepareNodesInfo().clear().get(); assertThat(nodes.getNodes().size(), equalTo(1)); assertNodeShutdownStatus(nodeToRestartId, COMPLETE); @@ -88,7 +88,7 @@ public class NodeShutdownShardsIT extends ESIntegTestCase { internalCluster().stopNode(nodeToRestartName); - NodesInfoResponse nodes = client().admin().cluster().prepareNodesInfo().clear().get(); + NodesInfoResponse nodes = clusterAdmin().prepareNodesInfo().clear().get(); assertThat(nodes.getNodes().size(), equalTo(1)); assertNodeShutdownStatus(nodeToRestartId, COMPLETE); @@ -155,9 +155,7 @@ public class NodeShutdownShardsIT extends ESIntegTestCase { ensureYellow("other"); // Explain the replica for the "other" index - ClusterAllocationExplainResponse explainResponse = client().admin() - .cluster() - .prepareAllocationExplain() + ClusterAllocationExplainResponse explainResponse = clusterAdmin().prepareAllocationExplain() .setIndex("other") .setShard(0) .setPrimary(false) @@ -218,9 +216,7 @@ public class NodeShutdownShardsIT extends ESIntegTestCase { ensureYellow("other"); // Explain the replica for the "other" index - ClusterAllocationExplainResponse explainResponse = client().admin() - .cluster() - .prepareAllocationExplain() + ClusterAllocationExplainResponse explainResponse = clusterAdmin().prepareAllocationExplain() .setIndex("other") .setShard(0) .setPrimary(false) @@ -435,7 +431,7 @@ public class NodeShutdownShardsIT extends ESIntegTestCase { } private String findIdOfNodeWithPrimaryShard(String indexName) { - ClusterState state = client().admin().cluster().prepareState().get().getState(); + ClusterState state = clusterAdmin().prepareState().get().getState(); List startedShards = RoutingNodesHelper.shardsWithState(state.getRoutingNodes(), ShardRoutingState.STARTED); return startedShards.stream() .filter(ShardRouting::primary) @@ -450,7 +446,7 @@ public class NodeShutdownShardsIT extends ESIntegTestCase { } private String getNodeId(String nodeName) { - NodesInfoResponse nodes = client().admin().cluster().prepareNodesInfo().clear().get(); + NodesInfoResponse nodes = clusterAdmin().prepareNodesInfo().clear().get(); return nodes.getNodes() .stream() .map(NodeInfo::getNode) @@ -475,7 +471,7 @@ public class NodeShutdownShardsIT extends ESIntegTestCase { } private void assertIndexPrimaryShardsAreAllocatedOnNode(String indexName, String nodeId) { - var state = client().admin().cluster().prepareState().clear().setRoutingTable(true).get().getState(); + var state = clusterAdmin().prepareState().clear().setRoutingTable(true).get().getState(); var indexRoutingTable = state.routingTable().index(indexName); for (int p = 0; p < indexRoutingTable.size(); p++) { var primaryShard = indexRoutingTable.shard(p).primaryShard(); @@ -495,7 +491,7 @@ public class NodeShutdownShardsIT extends ESIntegTestCase { } private void assertIndexReplicaShardsAreNotAllocated(String indexName) { - var state = client().admin().cluster().prepareState().clear().setRoutingTable(true).get().getState(); + var state = clusterAdmin().prepareState().clear().setRoutingTable(true).get().getState(); var indexRoutingTable = state.routingTable().index(indexName); for (int p = 0; p < indexRoutingTable.size(); p++) { for (ShardRouting replicaShard : indexRoutingTable.shard(p).replicaShards()) { diff --git a/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownTasksIT.java b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownTasksIT.java index 63b786c61a0d..afd7b966b550 100644 --- a/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownTasksIT.java +++ b/x-pack/plugin/shutdown/src/internalClusterTest/java/org/elasticsearch/xpack/shutdown/NodeShutdownTasksIT.java @@ -86,7 +86,7 @@ public class NodeShutdownTasksIT extends ESIntegTestCase { final String shutdownNode; final String candidateNode; - NodesInfoResponse nodes = client().admin().cluster().prepareNodesInfo().clear().get(); + NodesInfoResponse nodes = clusterAdmin().prepareNodesInfo().clear().get(); final String node1Id = nodes.getNodes() .stream() .map(NodeInfo::getNode) @@ -120,7 +120,7 @@ public class NodeShutdownTasksIT extends ESIntegTestCase { // Tell the persistent task executor it can start allocating the task startTask.set(true); // Issue a new cluster state update to force task assignment - client().admin().cluster().prepareReroute().get(); + clusterAdmin().prepareReroute().get(); // Wait until the task has been assigned to a node assertBusy(() -> assertNotNull("expected to have candidate nodes chosen for task", candidates.get())); // Check that the node that is not shut down is the only candidate diff --git a/x-pack/plugin/snapshot-based-recoveries/src/internalClusterTest/java/org/elasticsearch/xpack/snapshotbasedrecoveries/recovery/SnapshotBasedIndexRecoveryIT.java b/x-pack/plugin/snapshot-based-recoveries/src/internalClusterTest/java/org/elasticsearch/xpack/snapshotbasedrecoveries/recovery/SnapshotBasedIndexRecoveryIT.java index 3a8658a6dcb8..68ca4a88d7db 100644 --- a/x-pack/plugin/snapshot-based-recoveries/src/internalClusterTest/java/org/elasticsearch/xpack/snapshotbasedrecoveries/recovery/SnapshotBasedIndexRecoveryIT.java +++ b/x-pack/plugin/snapshot-based-recoveries/src/internalClusterTest/java/org/elasticsearch/xpack/snapshotbasedrecoveries/recovery/SnapshotBasedIndexRecoveryIT.java @@ -447,9 +447,7 @@ public class SnapshotBasedIndexRecoveryIT extends AbstractSnapshotIntegTestCase assertDocumentsAreEqual(indexName, numDocs); - NodesStatsResponse statsResponse = client().admin() - .cluster() - .prepareNodesStats() + NodesStatsResponse statsResponse = clusterAdmin().prepareNodesStats() .clear() .setIndices(new CommonStatsFlags(CommonStatsFlags.Flag.Recovery)) .get(); @@ -582,7 +580,7 @@ public class SnapshotBasedIndexRecoveryIT extends AbstractSnapshotIntegTestCase final String targetNode; if (seqNoRecovery) { - ClusterState clusterState = client().admin().cluster().prepareState().get().getState(); + ClusterState clusterState = clusterAdmin().prepareState().get().getState(); IndexShardRoutingTable shardRoutingTable = clusterState.routingTable().index(indexName).shard(0); String primaryNodeName = clusterState.nodes().resolveNode(shardRoutingTable.primaryShard().currentNodeId()).getName(); String replicaNodeName = clusterState.nodes() @@ -617,7 +615,7 @@ public class SnapshotBasedIndexRecoveryIT extends AbstractSnapshotIntegTestCase ); if (seqNoRecovery) { - ClusterState clusterState = client().admin().cluster().prepareState().get().getState(); + ClusterState clusterState = clusterAdmin().prepareState().get().getState(); IndexShardRoutingTable shardRoutingTable = clusterState.routingTable().index(indexName).shard(0); String primaryNodeName = clusterState.nodes().resolveNode(shardRoutingTable.primaryShard().currentNodeId()).getName(); @@ -805,9 +803,7 @@ public class SnapshotBasedIndexRecoveryIT extends AbstractSnapshotIntegTestCase assertAcked(indicesAdmin().prepareDelete(indexName).get()); List restoredIndexDataNodes = internalCluster().startDataOnlyNodes(2); - RestoreSnapshotResponse restoreSnapshotResponse = client().admin() - .cluster() - .prepareRestoreSnapshot(repoName, "snap") + RestoreSnapshotResponse restoreSnapshotResponse = clusterAdmin().prepareRestoreSnapshot(repoName, "snap") .setIndices(indexName) .setIndexSettings( Settings.builder() @@ -1026,7 +1022,7 @@ public class SnapshotBasedIndexRecoveryIT extends AbstractSnapshotIntegTestCase createRepo(repoName, repoType); createSnapshot(repoName, "snap", Collections.singletonList(indexName)); - ClusterState clusterState = client().admin().cluster().prepareState().get().getState(); + ClusterState clusterState = clusterAdmin().prepareState().get().getState(); String primaryNodeId = clusterState.routingTable().index(indexName).shard(0).primaryShard().currentNodeId(); String primaryNodeName = clusterState.nodes().resolveNode(primaryNodeId).getName(); @@ -1036,7 +1032,7 @@ public class SnapshotBasedIndexRecoveryIT extends AbstractSnapshotIntegTestCase ensureGreen(indexName); - ClusterState clusterStateAfterPrimaryFailOver = client().admin().cluster().prepareState().get().getState(); + ClusterState clusterStateAfterPrimaryFailOver = clusterAdmin().prepareState().get().getState(); IndexShardRoutingTable shardRoutingTableAfterFailOver = clusterStateAfterPrimaryFailOver.routingTable().index(indexName).shard(0); String primaryNodeIdAfterFailOver = shardRoutingTableAfterFailOver.primaryShard().currentNodeId(); @@ -1349,7 +1345,7 @@ public class SnapshotBasedIndexRecoveryIT extends AbstractSnapshotIntegTestCase createRepo(repoName, TestRepositoryPlugin.FILTER_TYPE); createSnapshot(repoName, "snap", Collections.singletonList(indexName)); - ClusterState clusterState = client().admin().cluster().prepareState().get().getState(); + ClusterState clusterState = clusterAdmin().prepareState().get().getState(); String primaryNodeId = clusterState.routingTable().index(indexName).shard(0).primaryShard().currentNodeId(); String primaryNodeName = clusterState.nodes().resolveNode(primaryNodeId).getName(); String replicaNodeId = clusterState.routingTable().index(indexName).shard(0).replicaShards().get(0).currentNodeId(); @@ -1570,7 +1566,7 @@ public class SnapshotBasedIndexRecoveryIT extends AbstractSnapshotIntegTestCase } private Store.MetadataSnapshot getMetadataSnapshot(String nodeName, String indexName) throws IOException { - ClusterState clusterState = client().admin().cluster().prepareState().get().getState(); + ClusterState clusterState = clusterAdmin().prepareState().get().getState(); IndicesService indicesService = internalCluster().getInstance(IndicesService.class, nodeName); IndexService indexService = indicesService.indexService(clusterState.metadata().index(indexName).getIndex()); IndexShard shard = indexService.getShard(0); @@ -1582,7 +1578,7 @@ public class SnapshotBasedIndexRecoveryIT extends AbstractSnapshotIntegTestCase } private long getSnapshotSizeForIndex(String repository, String snapshot, String index) { - GetSnapshotsResponse getSnapshotsResponse = client().admin().cluster().prepareGetSnapshots(repository).addSnapshots(snapshot).get(); + GetSnapshotsResponse getSnapshotsResponse = clusterAdmin().prepareGetSnapshots(repository).addSnapshots(snapshot).get(); for (SnapshotInfo snapshotInfo : getSnapshotsResponse.getSnapshots()) { SnapshotInfo.IndexSnapshotDetails indexSnapshotDetails = snapshotInfo.indexSnapshotDetails().get(index); assertThat(indexSnapshotDetails, is(notNullValue())); diff --git a/x-pack/plugin/sql/src/internalClusterTest/java/org/elasticsearch/xpack/sql/action/AbstractSqlBlockingIntegTestCase.java b/x-pack/plugin/sql/src/internalClusterTest/java/org/elasticsearch/xpack/sql/action/AbstractSqlBlockingIntegTestCase.java index 4ac4827c9d52..c392b887c22e 100644 --- a/x-pack/plugin/sql/src/internalClusterTest/java/org/elasticsearch/xpack/sql/action/AbstractSqlBlockingIntegTestCase.java +++ b/x-pack/plugin/sql/src/internalClusterTest/java/org/elasticsearch/xpack/sql/action/AbstractSqlBlockingIntegTestCase.java @@ -258,7 +258,7 @@ public abstract class AbstractSqlBlockingIntegTestCase extends ESIntegTestCase { } protected TaskInfo getTaskInfoWithXOpaqueId(String id, String action) { - ListTasksResponse tasks = client().admin().cluster().prepareListTasks().setActions(action).get(); + ListTasksResponse tasks = clusterAdmin().prepareListTasks().setActions(action).get(); for (TaskInfo task : tasks.getTasks()) { if (id.equals(task.headers().get(Task.X_OPAQUE_ID_HTTP_HEADER))) { return task; @@ -271,7 +271,7 @@ public abstract class AbstractSqlBlockingIntegTestCase extends ESIntegTestCase { TaskId taskId = findTaskWithXOpaqueId(id, action); assertNotNull(taskId); logger.trace("Cancelling task " + taskId); - CancelTasksResponse response = client().admin().cluster().prepareCancelTasks().setTargetTaskId(taskId).get(); + CancelTasksResponse response = clusterAdmin().prepareCancelTasks().setTargetTaskId(taskId).get(); assertThat(response.getTasks(), hasSize(1)); assertThat(response.getTasks().get(0).action(), equalTo(action)); logger.trace("Task is cancelled " + taskId); diff --git a/x-pack/plugin/voting-only-node/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/votingonly/VotingOnlyNodePluginTests.java b/x-pack/plugin/voting-only-node/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/votingonly/VotingOnlyNodePluginTests.java index f1a44bd6afa0..3a6acd5ac9e9 100644 --- a/x-pack/plugin/voting-only-node/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/votingonly/VotingOnlyNodePluginTests.java +++ b/x-pack/plugin/voting-only-node/src/internalClusterTest/java/org/elasticsearch/cluster/coordination/votingonly/VotingOnlyNodePluginTests.java @@ -74,15 +74,10 @@ public class VotingOnlyNodePluginTests extends ESIntegTestCase { internalCluster().startNodes(2); internalCluster().startNode(addRoles(Set.of(DiscoveryNodeRole.VOTING_ONLY_NODE_ROLE))); assertBusy( - () -> assertThat( - client().admin().cluster().prepareState().get().getState().getLastCommittedConfiguration().getNodeIds(), - hasSize(3) - ) + () -> assertThat(clusterAdmin().prepareState().get().getState().getLastCommittedConfiguration().getNodeIds(), hasSize(3)) ); assertThat( - client().admin() - .cluster() - .prepareClusterStats() + clusterAdmin().prepareClusterStats() .get() .getNodesStats() .getCounts() @@ -91,8 +86,8 @@ public class VotingOnlyNodePluginTests extends ESIntegTestCase { .intValue(), equalTo(1) ); - assertThat(client().admin().cluster().prepareNodesStats("voting_only:true").get().getNodes(), hasSize(1)); - assertThat(client().admin().cluster().prepareNodesStats("master:true", "voting_only:false").get().getNodes(), hasSize(2)); + assertThat(clusterAdmin().prepareNodesStats("voting_only:true").get().getNodes(), hasSize(1)); + assertThat(clusterAdmin().prepareNodesStats("master:true", "voting_only:false").get().getNodes(), hasSize(2)); } public void testPreferFullMasterOverVotingOnlyNodes() throws Exception { @@ -101,18 +96,15 @@ public class VotingOnlyNodePluginTests extends ESIntegTestCase { internalCluster().startNode(addRoles(Set.of(DiscoveryNodeRole.VOTING_ONLY_NODE_ROLE))); internalCluster().startDataOnlyNodes(randomInt(2)); assertBusy( - () -> assertThat( - client().admin().cluster().prepareState().get().getState().getLastCommittedConfiguration().getNodeIds().size(), - equalTo(3) - ) + () -> assertThat(clusterAdmin().prepareState().get().getState().getLastCommittedConfiguration().getNodeIds().size(), equalTo(3)) ); final String originalMaster = internalCluster().getMasterName(); internalCluster().stopCurrentMasterNode(); - client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).get(); + clusterAdmin().prepareHealth().setWaitForEvents(Priority.LANGUID).get(); assertNotEquals(originalMaster, internalCluster().getMasterName()); assertThat( - VotingOnlyNodePlugin.isVotingOnlyNode(client().admin().cluster().prepareState().get().getState().nodes().getMasterNode()), + VotingOnlyNodePlugin.isVotingOnlyNode(clusterAdmin().prepareState().get().getState().nodes().getMasterNode()), equalTo(false) ); } @@ -121,13 +113,10 @@ public class VotingOnlyNodePluginTests extends ESIntegTestCase { internalCluster().setBootstrapMasterNodeIndex(0); internalCluster().startNodes(addRoles(Set.of(DiscoveryNodeRole.VOTING_ONLY_NODE_ROLE)), Settings.EMPTY, Settings.EMPTY); assertBusy( - () -> assertThat( - client().admin().cluster().prepareState().get().getState().getLastCommittedConfiguration().getNodeIds().size(), - equalTo(3) - ) + () -> assertThat(clusterAdmin().prepareState().get().getState().getLastCommittedConfiguration().getNodeIds().size(), equalTo(3)) ); assertThat( - VotingOnlyNodePlugin.isVotingOnlyNode(client().admin().cluster().prepareState().get().getState().nodes().getMasterNode()), + VotingOnlyNodePlugin.isVotingOnlyNode(clusterAdmin().prepareState().get().getState().nodes().getMasterNode()), equalTo(false) ); } @@ -141,9 +130,9 @@ public class VotingOnlyNodePluginTests extends ESIntegTestCase { .build() ); internalCluster().startNode(); - assertBusy(() -> assertThat(client().admin().cluster().prepareState().get().getState().getNodes().getSize(), equalTo(2))); + assertBusy(() -> assertThat(clusterAdmin().prepareState().get().getState().getNodes().getSize(), equalTo(2))); assertThat( - VotingOnlyNodePlugin.isVotingOnlyNode(client().admin().cluster().prepareState().get().getState().nodes().getMasterNode()), + VotingOnlyNodePlugin.isVotingOnlyNode(clusterAdmin().prepareState().get().getState().nodes().getMasterNode()), equalTo(false) ); } @@ -154,27 +143,16 @@ public class VotingOnlyNodePluginTests extends ESIntegTestCase { internalCluster().startNodes(2, addRoles(Set.of(DiscoveryNodeRole.VOTING_ONLY_NODE_ROLE))); internalCluster().startDataOnlyNodes(randomInt(2)); assertBusy( - () -> assertThat( - client().admin().cluster().prepareState().get().getState().getLastCommittedConfiguration().getNodeIds().size(), - equalTo(3) - ) + () -> assertThat(clusterAdmin().prepareState().get().getState().getLastCommittedConfiguration().getNodeIds().size(), equalTo(3)) ); - final String oldMasterId = client().admin().cluster().prepareState().get().getState().nodes().getMasterNodeId(); + final String oldMasterId = clusterAdmin().prepareState().get().getState().nodes().getMasterNodeId(); internalCluster().stopCurrentMasterNode(); expectThrows( MasterNotDiscoveredException.class, () -> assertThat( - client().admin() - .cluster() - .prepareState() - .setMasterNodeTimeout("100ms") - .execute() - .actionGet() - .getState() - .nodes() - .getMasterNodeId(), + clusterAdmin().prepareState().setMasterNodeTimeout("100ms").execute().actionGet().getState().nodes().getMasterNodeId(), nullValue() ) ); @@ -182,7 +160,7 @@ public class VotingOnlyNodePluginTests extends ESIntegTestCase { // start a fresh full master node, which will be brought into the cluster as master by the voting-only nodes final String newMaster = internalCluster().startNode(); assertEquals(newMaster, internalCluster().getMasterName()); - final String newMasterId = client().admin().cluster().prepareState().get().getState().nodes().getMasterNodeId(); + final String newMasterId = clusterAdmin().prepareState().get().getState().nodes().getMasterNodeId(); assertNotEquals(oldMasterId, newMasterId); } @@ -201,9 +179,7 @@ public class VotingOnlyNodePluginTests extends ESIntegTestCase { final String nonDedicatedVotingOnlyNode = internalCluster().startNode(dataContainingVotingOnlyNodeSettings); assertAcked( - client().admin() - .cluster() - .preparePutRepository("test-repo") + clusterAdmin().preparePutRepository("test-repo") .setType("verifyaccess-fs") .setSettings(Settings.builder().put("location", randomRepoPath()).put("compress", randomBoolean())) ); @@ -212,7 +188,7 @@ public class VotingOnlyNodePluginTests extends ESIntegTestCase { createIndex("test-idx-3"); ensureGreen(); - VerifyRepositoryResponse verifyResponse = client().admin().cluster().prepareVerifyRepository("test-repo").get(); + VerifyRepositoryResponse verifyResponse = clusterAdmin().prepareVerifyRepository("test-repo").get(); // only the da assertEquals(3, verifyResponse.getNodes().size()); assertTrue(verifyResponse.getNodes().stream().noneMatch(nw -> nw.getName().equals(dedicatedVotingOnlyNode))); diff --git a/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java b/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java index 8f14d0a71edf..12ae292f8da2 100644 --- a/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java +++ b/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java @@ -356,7 +356,7 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase final AtomicReference lastResponse = new AtomicReference<>(); try { assertBusy(() -> { - ClusterState state = client().admin().cluster().prepareState().get().getState(); + ClusterState state = clusterAdmin().prepareState().get().getState(); String[] watchHistoryIndices = indexNameExpressionResolver().concreteIndexNames( state, IndicesOptions.lenientExpandOpen(), @@ -424,7 +424,7 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase assertBusy(() -> { // The watch_history index gets created in the background when the first watch is triggered // so we to check first is this index is created and shards are started - ClusterState state = client().admin().cluster().prepareState().get().getState(); + ClusterState state = clusterAdmin().prepareState().get().getState(); String[] watchHistoryIndices = indexNameExpressionResolver().concreteIndexNames( state, IndicesOptions.lenientExpandOpen(), @@ -462,7 +462,7 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase protected void assertWatchWithMinimumActionsCount(final String watchName, final ExecutionState recordState, final long recordCount) throws Exception { assertBusy(() -> { - ClusterState state = client().admin().cluster().prepareState().get().getState(); + ClusterState state = clusterAdmin().prepareState().get().getState(); String[] watchHistoryIndices = indexNameExpressionResolver().concreteIndexNames( state, IndicesOptions.lenientExpandOpen(), diff --git a/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/test/integration/BasicWatcherTests.java b/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/test/integration/BasicWatcherTests.java index 834587d2635d..7ec2dd0bc71e 100644 --- a/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/test/integration/BasicWatcherTests.java +++ b/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/test/integration/BasicWatcherTests.java @@ -222,9 +222,7 @@ public class BasicWatcherTests extends AbstractWatcherIntegrationTestCase { public void testConditionSearchWithIndexedTemplate() throws Exception { SearchSourceBuilder searchSourceBuilder = searchSource().query(matchQuery("level", "a")); assertAcked( - client().admin() - .cluster() - .preparePutStoredScript() + clusterAdmin().preparePutStoredScript() .setId("my-template") .setContent( BytesReference.bytes( diff --git a/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/test/integration/SingleNodeTests.java b/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/test/integration/SingleNodeTests.java index 2d0a56c5b333..b6a87fe8c48e 100644 --- a/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/test/integration/SingleNodeTests.java +++ b/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/test/integration/SingleNodeTests.java @@ -42,7 +42,7 @@ public class SingleNodeTests extends AbstractWatcherIntegrationTestCase { // the watch should be executed properly, despite the index being created and the cluster state listener being reloaded public void testThatLoadingWithNonExistingIndexWorks() throws Exception { stopWatcher(); - ClusterStateResponse clusterStateResponse = client().admin().cluster().prepareState().get(); + ClusterStateResponse clusterStateResponse = clusterAdmin().prepareState().get(); IndexMetadata metadata = WatchStoreUtils.getConcreteIndex(Watch.INDEX, clusterStateResponse.getState().metadata()); String watchIndexName = metadata.getIndex().getName(); assertAcked(indicesAdmin().prepareDelete(watchIndexName)); diff --git a/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/transform/TransformIntegrationTests.java b/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/transform/TransformIntegrationTests.java index 19af70d76d9f..93d98b226496 100644 --- a/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/transform/TransformIntegrationTests.java +++ b/x-pack/plugin/watcher/src/internalClusterTest/java/org/elasticsearch/xpack/watcher/transform/TransformIntegrationTests.java @@ -108,7 +108,7 @@ public class TransformIntegrationTests extends AbstractWatcherIntegrationTestCas script = mockScript("['key3' : ctx.payload.key1 + ctx.payload.key2]"); } else { logger.info("testing script transform with an indexed script"); - assertAcked(client().admin().cluster().preparePutStoredScript().setId("my-script").setContent(new BytesArray(Strings.format(""" + assertAcked(clusterAdmin().preparePutStoredScript().setId("my-script").setContent(new BytesArray(Strings.format(""" { "script": { "lang": "%s",