Skip to content

Commit

Permalink
Remove unused client methods (#94300)
Browse files Browse the repository at this point in the history
We don't have to support the transport client API anymore.
-> remove all the unused APIs as well as a few that only had a single
usage in tests and replace those with another version
-> streamlines tests a little more + save 300LoC
  • Loading branch information
original-brownbear committed Mar 3, 2023
1 parent 2cd4520 commit 86b7dfc
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 291 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.elasticsearch.ESNetty4IntegTestCase;
import org.elasticsearch.action.admin.cluster.node.hotthreads.NodesHotThreadsRequest;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.MockLogAppender;
Expand Down Expand Up @@ -85,7 +84,7 @@ public void testLoggingHandler() {
appender.addExpectation(writeExpectation);
appender.addExpectation(flushExpectation);
appender.addExpectation(readExpectation);
client().admin().cluster().nodesHotThreads(new NodesHotThreadsRequest()).actionGet();
client().admin().cluster().prepareNodesHotThreads().get();
appender.assertAllExpectationsMatched();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.action.ingest.DeletePipelineRequest;
import org.elasticsearch.action.ingest.GetPipelineRequest;
import org.elasticsearch.action.ingest.GetPipelineResponse;
import org.elasticsearch.action.ingest.PutPipelineRequest;
import org.elasticsearch.action.search.SearchResponse;
Expand Down Expand Up @@ -71,8 +70,8 @@ public void cleanUpPipelines() {

final GetPipelineResponse response = client().admin()
.cluster()
.getPipeline(new GetPipelineRequest("default_pipeline", "final_pipeline", "request_pipeline"))
.actionGet();
.prepareGetPipeline("default_pipeline", "final_pipeline", "request_pipeline")
.get();
for (final PipelineConfiguration pipeline : response.pipelines()) {
client().admin().cluster().deletePipeline(new DeletePipelineRequest(pipeline.getId())).actionGet();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.action.ingest.DeletePipelineRequest;
import org.elasticsearch.action.ingest.GetPipelineRequest;
import org.elasticsearch.action.ingest.GetPipelineResponse;
import org.elasticsearch.action.ingest.PutPipelineRequest;
import org.elasticsearch.action.ingest.SimulateDocumentBaseResult;
Expand Down Expand Up @@ -226,8 +225,7 @@ public void test() throws Exception {
PutPipelineRequest putPipelineRequest = new PutPipelineRequest("_id", source, XContentType.JSON);
client().admin().cluster().putPipeline(putPipelineRequest).get();

GetPipelineRequest getPipelineRequest = new GetPipelineRequest("_id");
GetPipelineResponse getResponse = client().admin().cluster().getPipeline(getPipelineRequest).get();
GetPipelineResponse getResponse = client().admin().cluster().prepareGetPipeline("_id").get();
assertThat(getResponse.isFound(), is(true));
assertThat(getResponse.pipelines().size(), equalTo(1));
assertThat(getResponse.pipelines().get(0).getId(), equalTo("_id"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void testBasics() {
assertNotNull(script);
assertEquals("1", script);

assertAcked(client().admin().cluster().prepareDeleteStoredScript().setId("foobar"));
assertAcked(client().admin().cluster().prepareDeleteStoredScript("foobar"));
StoredScriptSource source = client().admin().cluster().prepareGetStoredScript("foobar").get().getSource();
assertNull(source);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotIndexShardStatus;
import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotStats;
import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotStatus;
import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotsStatusRequest;
import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotsStatusResponse;
import org.elasticsearch.action.support.GroupedActionListener;
import org.elasticsearch.action.support.PlainActionFuture;
Expand Down Expand Up @@ -90,9 +89,10 @@ public void testStatusApiConsistency() throws Exception {
assertThat(snapshotInfo.state(), equalTo(SnapshotState.SUCCESS));
assertThat(snapshotInfo.version(), equalTo(Version.CURRENT));

final List<SnapshotStatus> snapshotStatus = clusterAdmin().snapshotsStatus(
new SnapshotsStatusRequest("test-repo", new String[] { "test-snap" })
).get().getSnapshots();
final List<SnapshotStatus> snapshotStatus = clusterAdmin().prepareSnapshotStatus("test-repo")
.setSnapshots("test-snap")
.get()
.getSnapshots();
assertThat(snapshotStatus.size(), equalTo(1));
final SnapshotStatus snStatus = snapshotStatus.get(0);
assertEquals(snStatus.getStats().getStartTime(), snapshotInfo.startTime());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksRequestBuilder;
import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse;
import org.elasticsearch.action.admin.cluster.node.usage.NodesUsageRequest;
import org.elasticsearch.action.admin.cluster.node.usage.NodesUsageRequestBuilder;
import org.elasticsearch.action.admin.cluster.node.usage.NodesUsageResponse;
import org.elasticsearch.action.admin.cluster.repositories.cleanup.CleanupRepositoryRequest;
import org.elasticsearch.action.admin.cluster.repositories.cleanup.CleanupRepositoryRequestBuilder;
Expand Down Expand Up @@ -216,14 +215,6 @@ public interface ClusterAdminClient extends ElasticsearchClient {
*/
NodesInfoRequestBuilder prepareNodesInfo(String... nodesIds);

/**
* Cluster wide aggregated stats.
*
* @param request The cluster stats request
* @return The result future
*/
ActionFuture<ClusterStatsResponse> clusterStats(ClusterStatsRequest request);

/**
* Cluster wide aggregated stats
*
Expand Down Expand Up @@ -255,15 +246,6 @@ public interface ClusterAdminClient extends ElasticsearchClient {
*/
NodesStatsRequestBuilder prepareNodesStats(String... nodesIds);

/**
* Nodes usage of the cluster.
*
* @param request
* The nodes usage request
* @return The result future
*/
ActionFuture<NodesUsageResponse> nodesUsage(NodesUsageRequest request);

/**
* Nodes usage of the cluster.
*
Expand All @@ -274,18 +256,6 @@ public interface ClusterAdminClient extends ElasticsearchClient {
*/
void nodesUsage(NodesUsageRequest request, ActionListener<NodesUsageResponse> listener);

/**
* Nodes usage of the cluster.
*/
NodesUsageRequestBuilder prepareNodesUsage(String... nodesIds);

/**
* Returns top N hot-threads samples per node. The hot-threads are only
* sampled for the node ids specified in the request.
*
*/
ActionFuture<NodesHotThreadsResponse> nodesHotThreads(NodesHotThreadsRequest request);

/**
* Returns top N hot-threads samples per node. The hot-threads are only sampled
* for the node ids specified in the request.
Expand Down Expand Up @@ -366,31 +336,16 @@ public interface ClusterAdminClient extends ElasticsearchClient {
*/
CancelTasksRequestBuilder prepareCancelTasks(String... nodesIds);

/**
* Returns list of shards the given search would be executed on.
*/
ActionFuture<ClusterSearchShardsResponse> searchShards(ClusterSearchShardsRequest request);

/**
* Returns list of shards the given search would be executed on.
*/
void searchShards(ClusterSearchShardsRequest request, ActionListener<ClusterSearchShardsResponse> listener);

/**
* Returns list of shards the given search would be executed on.
*/
ClusterSearchShardsRequestBuilder prepareSearchShards();

/**
* Returns list of shards the given search would be executed on.
*/
ClusterSearchShardsRequestBuilder prepareSearchShards(String... indices);

/**
* Registers a snapshot repository.
*/
ActionFuture<AcknowledgedResponse> putRepository(PutRepositoryRequest request);

/**
* Registers a snapshot repository.
*/
Expand All @@ -401,11 +356,6 @@ public interface ClusterAdminClient extends ElasticsearchClient {
*/
PutRepositoryRequestBuilder preparePutRepository(String name);

/**
* Unregisters a repository.
*/
ActionFuture<AcknowledgedResponse> deleteRepository(DeleteRepositoryRequest request);

/**
* Unregisters a repository.
*/
Expand All @@ -416,11 +366,6 @@ public interface ClusterAdminClient extends ElasticsearchClient {
*/
DeleteRepositoryRequestBuilder prepareDeleteRepository(String name);

/**
* Gets repositories.
*/
ActionFuture<GetRepositoriesResponse> getRepositories(GetRepositoriesRequest request);

/**
* Gets repositories.
*/
Expand All @@ -436,21 +381,11 @@ public interface ClusterAdminClient extends ElasticsearchClient {
*/
CleanupRepositoryRequestBuilder prepareCleanupRepository(String repository);

/**
* Cleans up repository.
*/
ActionFuture<CleanupRepositoryResponse> cleanupRepository(CleanupRepositoryRequest repository);

/**
* Cleans up repository.
*/
void cleanupRepository(CleanupRepositoryRequest repository, ActionListener<CleanupRepositoryResponse> listener);

/**
* Verifies a repository.
*/
ActionFuture<VerifyRepositoryResponse> verifyRepository(VerifyRepositoryRequest request);

/**
* Verifies a repository.
*/
Expand Down Expand Up @@ -481,21 +416,11 @@ public interface ClusterAdminClient extends ElasticsearchClient {
*/
CloneSnapshotRequestBuilder prepareCloneSnapshot(String repository, String source, String target);

/**
* Clones a snapshot.
*/
ActionFuture<AcknowledgedResponse> cloneSnapshot(CloneSnapshotRequest request);

/**
* Clones a snapshot.
*/
void cloneSnapshot(CloneSnapshotRequest request, ActionListener<AcknowledgedResponse> listener);

/**
* Get snapshots.
*/
ActionFuture<GetSnapshotsResponse> getSnapshots(GetSnapshotsRequest request);

/**
* Get snapshots.
*/
Expand All @@ -506,11 +431,6 @@ public interface ClusterAdminClient extends ElasticsearchClient {
*/
GetSnapshotsRequestBuilder prepareGetSnapshots(String... repository);

/**
* Delete snapshot.
*/
ActionFuture<AcknowledgedResponse> deleteSnapshot(DeleteSnapshotRequest request);

/**
* Delete snapshot.
*/
Expand Down Expand Up @@ -542,23 +462,12 @@ public interface ClusterAdminClient extends ElasticsearchClient {
*/
void pendingClusterTasks(PendingClusterTasksRequest request, ActionListener<PendingClusterTasksResponse> listener);

/**
* Returns a list of the pending cluster tasks, that are scheduled to be executed. This includes operations
* that update the cluster state (for example, a create index operation)
*/
ActionFuture<PendingClusterTasksResponse> pendingClusterTasks(PendingClusterTasksRequest request);

/**
* Returns a list of the pending cluster tasks, that are scheduled to be executed. This includes operations
* that update the cluster state (for example, a create index operation)
*/
PendingClusterTasksRequestBuilder preparePendingClusterTasks();

/**
* Get snapshot status.
*/
ActionFuture<SnapshotsStatusResponse> snapshotsStatus(SnapshotsStatusRequest request);

/**
* Get snapshot status.
*/
Expand Down Expand Up @@ -599,11 +508,6 @@ public interface ClusterAdminClient extends ElasticsearchClient {
*/
ActionFuture<AcknowledgedResponse> deletePipeline(DeletePipelineRequest request);

/**
* Deletes a stored ingest pipeline
*/
DeletePipelineRequestBuilder prepareDeletePipeline();

/**
* Deletes a stored ingest pipeline
*/
Expand All @@ -614,11 +518,6 @@ public interface ClusterAdminClient extends ElasticsearchClient {
*/
void getPipeline(GetPipelineRequest request, ActionListener<GetPipelineResponse> listener);

/**
* Returns a stored ingest pipeline
*/
ActionFuture<GetPipelineResponse> getPipeline(GetPipelineRequest request);

/**
* Returns a stored ingest pipeline
*/
Expand Down Expand Up @@ -664,16 +563,6 @@ public interface ClusterAdminClient extends ElasticsearchClient {
*/
void deleteStoredScript(DeleteStoredScriptRequest request, ActionListener<AcknowledgedResponse> listener);

/**
* Delete a script from the cluster state
*/
ActionFuture<AcknowledgedResponse> deleteStoredScript(DeleteStoredScriptRequest request);

/**
* Delete a script from the cluster state
*/
DeleteStoredScriptRequestBuilder prepareDeleteStoredScript();

/**
* Delete a script from the cluster state
*/
Expand All @@ -684,16 +573,6 @@ public interface ClusterAdminClient extends ElasticsearchClient {
*/
void putStoredScript(PutStoredScriptRequest request, ActionListener<AcknowledgedResponse> listener);

/**
* Store a script in the cluster state
*/
ActionFuture<AcknowledgedResponse> putStoredScript(PutStoredScriptRequest request);

/**
* Get a script from the cluster state
*/
GetStoredScriptRequestBuilder prepareGetStoredScript();

/**
* Get a script from the cluster state
*/
Expand All @@ -704,11 +583,6 @@ public interface ClusterAdminClient extends ElasticsearchClient {
*/
void getStoredScript(GetStoredScriptRequest request, ActionListener<GetStoredScriptResponse> listener);

/**
* Get a script from the cluster state
*/
ActionFuture<GetStoredScriptResponse> getStoredScript(GetStoredScriptRequest request);

/**
* List dangling indices on all nodes.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,11 +544,6 @@ public interface IndicesAdminClient extends ElasticsearchClient {
*/
PutIndexTemplateRequestBuilder preparePutTemplate(String name);

/**
* Deletes index template.
*/
ActionFuture<AcknowledgedResponse> deleteTemplate(DeleteIndexTemplateRequest request);

/**
* Deletes an index template.
*/
Expand All @@ -561,11 +556,6 @@ public interface IndicesAdminClient extends ElasticsearchClient {
*/
DeleteIndexTemplateRequestBuilder prepareDeleteTemplate(String name);

/**
* Gets index template.
*/
ActionFuture<GetIndexTemplatesResponse> getTemplates(GetIndexTemplatesRequest request);

/**
* Gets an index template.
*/
Expand Down Expand Up @@ -622,11 +612,6 @@ public interface IndicesAdminClient extends ElasticsearchClient {
*/
ResizeRequestBuilder prepareResizeIndex(String sourceIndex, String targetIndex);

/**
* Resize an index using an explicit request allowing to specify the settings, mappings and aliases of the target index of the index.
*/
ActionFuture<ResizeResponse> resizeIndex(ResizeRequest request);

/**
* Shrinks an index using an explicit request allowing to specify the settings, mappings and aliases of the target index of the index.
*/
Expand Down

0 comments on commit 86b7dfc

Please sign in to comment.