From 1a13022847d348b0775ce2b8985b03f2dffc6d81 Mon Sep 17 00:00:00 2001 From: javanna Date: Wed, 27 Jan 2016 13:29:02 +0100 Subject: [PATCH] Ingest: move also simulate to ClusterAdminClient --- .../java/org/elasticsearch/client/Client.java | 19 ------------ .../client/ClusterAdminClient.java | 18 +++++++++++ .../client/support/AbstractClient.java | 30 +++++++++---------- .../ingest/RestSimulatePipelineAction.java | 2 +- .../elasticsearch/ingest/IngestClientIT.java | 4 +-- 5 files changed, 36 insertions(+), 37 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/client/Client.java b/core/src/main/java/org/elasticsearch/client/Client.java index 9e05cd01371..e7461dabfe1 100644 --- a/core/src/main/java/org/elasticsearch/client/Client.java +++ b/core/src/main/java/org/elasticsearch/client/Client.java @@ -51,9 +51,6 @@ import org.elasticsearch.action.indexedscripts.get.GetIndexedScriptResponse; import org.elasticsearch.action.indexedscripts.put.PutIndexedScriptRequest; import org.elasticsearch.action.indexedscripts.put.PutIndexedScriptRequestBuilder; import org.elasticsearch.action.indexedscripts.put.PutIndexedScriptResponse; -import org.elasticsearch.action.ingest.SimulatePipelineRequest; -import org.elasticsearch.action.ingest.SimulatePipelineRequestBuilder; -import org.elasticsearch.action.ingest.SimulatePipelineResponse; import org.elasticsearch.action.percolate.MultiPercolateRequest; import org.elasticsearch.action.percolate.MultiPercolateRequestBuilder; import org.elasticsearch.action.percolate.MultiPercolateResponse; @@ -85,7 +82,6 @@ import org.elasticsearch.action.update.UpdateRequestBuilder; import org.elasticsearch.action.update.UpdateResponse; import org.elasticsearch.client.support.Headers; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.lease.Releasable; import org.elasticsearch.common.settings.Settings; @@ -596,21 +592,6 @@ public interface Client extends ElasticsearchClient, Releasable { void fieldStats(FieldStatsRequest request, ActionListener listener); - /** - * Simulates an ingest pipeline - */ - void simulatePipeline(SimulatePipelineRequest request, ActionListener listener); - - /** - * Simulates an ingest pipeline - */ - ActionFuture simulatePipeline(SimulatePipelineRequest request); - - /** - * Simulates an ingest pipeline - */ - SimulatePipelineRequestBuilder prepareSimulatePipeline(BytesReference source); - /** * Returns this clients settings */ diff --git a/core/src/main/java/org/elasticsearch/client/ClusterAdminClient.java b/core/src/main/java/org/elasticsearch/client/ClusterAdminClient.java index 761ab1a529c..c56fd087062 100644 --- a/core/src/main/java/org/elasticsearch/client/ClusterAdminClient.java +++ b/core/src/main/java/org/elasticsearch/client/ClusterAdminClient.java @@ -91,6 +91,9 @@ import org.elasticsearch.action.ingest.GetPipelineRequestBuilder; import org.elasticsearch.action.ingest.GetPipelineResponse; import org.elasticsearch.action.ingest.PutPipelineRequest; import org.elasticsearch.action.ingest.PutPipelineRequestBuilder; +import org.elasticsearch.action.ingest.SimulatePipelineRequest; +import org.elasticsearch.action.ingest.SimulatePipelineRequestBuilder; +import org.elasticsearch.action.ingest.SimulatePipelineResponse; import org.elasticsearch.action.ingest.WritePipelineResponse; import org.elasticsearch.common.bytes.BytesReference; @@ -528,4 +531,19 @@ public interface ClusterAdminClient extends ElasticsearchClient { * Returns a stored ingest pipeline */ GetPipelineRequestBuilder prepareGetPipeline(String... ids); + + /** + * Simulates an ingest pipeline + */ + void simulatePipeline(SimulatePipelineRequest request, ActionListener listener); + + /** + * Simulates an ingest pipeline + */ + ActionFuture simulatePipeline(SimulatePipelineRequest request); + + /** + * Simulates an ingest pipeline + */ + SimulatePipelineRequestBuilder prepareSimulatePipeline(BytesReference source); } diff --git a/core/src/main/java/org/elasticsearch/client/support/AbstractClient.java b/core/src/main/java/org/elasticsearch/client/support/AbstractClient.java index 08a57e68d60..f8badc3a8fb 100644 --- a/core/src/main/java/org/elasticsearch/client/support/AbstractClient.java +++ b/core/src/main/java/org/elasticsearch/client/support/AbstractClient.java @@ -810,21 +810,6 @@ public abstract class AbstractClient extends AbstractComponent implements Client return new FieldStatsRequestBuilder(this, FieldStatsAction.INSTANCE); } - @Override - public void simulatePipeline(SimulatePipelineRequest request, ActionListener listener) { - execute(SimulatePipelineAction.INSTANCE, request, listener); - } - - @Override - public ActionFuture simulatePipeline(SimulatePipelineRequest request) { - return execute(SimulatePipelineAction.INSTANCE, request); - } - - @Override - public SimulatePipelineRequestBuilder prepareSimulatePipeline(BytesReference source) { - return new SimulatePipelineRequestBuilder(this, SimulatePipelineAction.INSTANCE, source); - } - static class Admin implements AdminClient { private final ClusterAdmin clusterAdmin; @@ -1249,6 +1234,21 @@ public abstract class AbstractClient extends AbstractComponent implements Client public GetPipelineRequestBuilder prepareGetPipeline(String... ids) { return new GetPipelineRequestBuilder(this, GetPipelineAction.INSTANCE, ids); } + + @Override + public void simulatePipeline(SimulatePipelineRequest request, ActionListener listener) { + execute(SimulatePipelineAction.INSTANCE, request, listener); + } + + @Override + public ActionFuture simulatePipeline(SimulatePipelineRequest request) { + return execute(SimulatePipelineAction.INSTANCE, request); + } + + @Override + public SimulatePipelineRequestBuilder prepareSimulatePipeline(BytesReference source) { + return new SimulatePipelineRequestBuilder(this, SimulatePipelineAction.INSTANCE, source); + } } static class IndicesAdmin implements IndicesAdminClient { diff --git a/core/src/main/java/org/elasticsearch/rest/action/ingest/RestSimulatePipelineAction.java b/core/src/main/java/org/elasticsearch/rest/action/ingest/RestSimulatePipelineAction.java index 35cf43740a4..8e615505bb0 100644 --- a/core/src/main/java/org/elasticsearch/rest/action/ingest/RestSimulatePipelineAction.java +++ b/core/src/main/java/org/elasticsearch/rest/action/ingest/RestSimulatePipelineAction.java @@ -46,6 +46,6 @@ public class RestSimulatePipelineAction extends BaseRestHandler { SimulatePipelineRequest request = new SimulatePipelineRequest(RestActions.getRestContent(restRequest)); request.setId(restRequest.param("id")); request.setVerbose(restRequest.paramAsBoolean("verbose", false)); - client.simulatePipeline(request, new RestToXContentListener<>(channel)); + client.admin().cluster().simulatePipeline(request, new RestToXContentListener<>(channel)); } } diff --git a/core/src/test/java/org/elasticsearch/ingest/IngestClientIT.java b/core/src/test/java/org/elasticsearch/ingest/IngestClientIT.java index a645677a729..1a6e0c46df5 100644 --- a/core/src/test/java/org/elasticsearch/ingest/IngestClientIT.java +++ b/core/src/test/java/org/elasticsearch/ingest/IngestClientIT.java @@ -100,12 +100,12 @@ public class IngestClientIT extends ESIntegTestCase { .endObject().bytes(); SimulatePipelineResponse response; if (randomBoolean()) { - response = client().prepareSimulatePipeline(bytes) + response = client().admin().cluster().prepareSimulatePipeline(bytes) .setId("_id").get(); } else { SimulatePipelineRequest request = new SimulatePipelineRequest(bytes); request.setId("_id"); - response = client().simulatePipeline(request).get(); + response = client().admin().cluster().simulatePipeline(request).get(); } assertThat(response.isVerbose(), equalTo(false)); assertThat(response.getPipelineId(), equalTo("_id"));