From 5b8bdba12e4bae80e328402a4e2ec0eb819ae6d9 Mon Sep 17 00:00:00 2001 From: Luca Cavanna Date: Wed, 30 Nov 2016 15:03:58 +0100 Subject: [PATCH] Remove subrequests method from CompositeIndicesRequest (#21873) --- .../action/bulk/TransportNoopBulkAction.java | 2 +- .../action/CompositeIndicesRequest.java | 15 ++++-------- .../action/bulk/BulkRequest.java | 5 ---- .../action/get/MultiGetRequest.java | 5 ---- .../action/search/MultiSearchRequest.java | 6 ----- .../termvectors/MultiTermVectorsRequest.java | 6 ----- .../mustache/MultiSearchTemplateRequest.java | 10 -------- .../mustache/SearchTemplateRequest.java | 14 ----------- .../percolator/MultiPercolateRequest.java | 6 ----- .../index/reindex/ReindexRequest.java | 24 ------------------- 10 files changed, 5 insertions(+), 88 deletions(-) diff --git a/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/TransportNoopBulkAction.java b/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/TransportNoopBulkAction.java index 2a5efee1881..0ce008908cf 100644 --- a/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/TransportNoopBulkAction.java +++ b/client/client-benchmark-noop-api-plugin/src/main/java/org/elasticsearch/plugin/noop/action/bulk/TransportNoopBulkAction.java @@ -46,7 +46,7 @@ public class TransportNoopBulkAction extends HandledTransportAction listener) { - final int itemCount = request.subRequests().size(); + final int itemCount = request.requests().size(); // simulate at least a realistic amount of data that gets serialized BulkItemResponse[] bulkItemResponses = new BulkItemResponse[itemCount]; for (int idx = 0; idx < itemCount; idx++) { diff --git a/core/src/main/java/org/elasticsearch/action/CompositeIndicesRequest.java b/core/src/main/java/org/elasticsearch/action/CompositeIndicesRequest.java index 8d18df0c275..9c661e93be8 100644 --- a/core/src/main/java/org/elasticsearch/action/CompositeIndicesRequest.java +++ b/core/src/main/java/org/elasticsearch/action/CompositeIndicesRequest.java @@ -19,18 +19,11 @@ package org.elasticsearch.action; -import java.util.List; - /** - * Needs to be implemented by all {@link org.elasticsearch.action.ActionRequest} subclasses that are composed of multiple subrequests - * which relate to one or more indices. Allows to retrieve those subrequests and reason about them separately. A composite request is - * executed by its own transport action class (e.g. {@link org.elasticsearch.action.search.TransportMultiSearchAction}), which goes - * through all the subrequests and delegates their execution to the appropriate transport action (e.g. - * {@link org.elasticsearch.action.search.TransportSearchAction}) for each single item. + * Marker interface that needs to be implemented by all {@link org.elasticsearch.action.ActionRequest} subclasses that are composed of + * multiple sub-requests which relate to one or more indices. A composite request is executed by its own transport action class + * (e.g. {@link org.elasticsearch.action.search.TransportMultiSearchAction}), which goes through all sub-requests and delegates their + * execution to the appropriate transport action (e.g. {@link org.elasticsearch.action.search.TransportSearchAction}) for each single item. */ public interface CompositeIndicesRequest { - /** - * Returns the subrequests that a composite request is composed of - */ - List subRequests(); } diff --git a/core/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java b/core/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java index e26732c8df8..5351579278d 100644 --- a/core/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java +++ b/core/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java @@ -211,11 +211,6 @@ public class BulkRequest extends ActionRequest implements CompositeIndicesReques return this.requests; } - @Override - public List subRequests() { - return requests.stream().collect(Collectors.toList()); - } - /** * The list of optional payloads associated with requests in the same order as the requests. Note, elements within * it might be null if no payload has been provided. diff --git a/core/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java b/core/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java index ee4ce570df2..8772752639b 100644 --- a/core/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java +++ b/core/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java @@ -284,11 +284,6 @@ public class MultiGetRequest extends ActionRequest implements Iterable subRequests() { - return items; - } - /** * Sets the preference to execute the search. Defaults to randomize across shards. Can be set to * _local to prefer local shards, _primary to execute only on primary shards, or diff --git a/core/src/main/java/org/elasticsearch/action/search/MultiSearchRequest.java b/core/src/main/java/org/elasticsearch/action/search/MultiSearchRequest.java index b4f0f932eed..7ab97f9bc57 100644 --- a/core/src/main/java/org/elasticsearch/action/search/MultiSearchRequest.java +++ b/core/src/main/java/org/elasticsearch/action/search/MultiSearchRequest.java @@ -22,7 +22,6 @@ package org.elasticsearch.action.search; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.CompositeIndicesRequest; -import org.elasticsearch.action.IndicesRequest; import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -84,11 +83,6 @@ public class MultiSearchRequest extends ActionRequest implements CompositeIndice return this.requests; } - @Override - public List subRequests() { - return this.requests; - } - @Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; diff --git a/core/src/main/java/org/elasticsearch/action/termvectors/MultiTermVectorsRequest.java b/core/src/main/java/org/elasticsearch/action/termvectors/MultiTermVectorsRequest.java index da9dae6759d..d54448f1c8f 100644 --- a/core/src/main/java/org/elasticsearch/action/termvectors/MultiTermVectorsRequest.java +++ b/core/src/main/java/org/elasticsearch/action/termvectors/MultiTermVectorsRequest.java @@ -23,7 +23,6 @@ import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.CompositeIndicesRequest; -import org.elasticsearch.action.IndicesRequest; import org.elasticsearch.action.RealtimeRequest; import org.elasticsearch.action.ValidateActions; import org.elasticsearch.common.Nullable; @@ -76,11 +75,6 @@ public class MultiTermVectorsRequest extends ActionRequest implements Iterable subRequests() { - return requests; - } - @Override public Iterator iterator() { return Collections.unmodifiableCollection(requests).iterator(); diff --git a/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/MultiSearchTemplateRequest.java b/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/MultiSearchTemplateRequest.java index 8d8037fa10e..178eb3e290d 100644 --- a/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/MultiSearchTemplateRequest.java +++ b/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/MultiSearchTemplateRequest.java @@ -22,7 +22,6 @@ package org.elasticsearch.script.mustache; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.CompositeIndicesRequest; -import org.elasticsearch.action.IndicesRequest; import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -61,15 +60,6 @@ public class MultiSearchTemplateRequest extends ActionRequest implements Composi return this.requests; } - @Override - public List subRequests() { - List indicesRequests = new ArrayList<>(); - for (SearchTemplateRequest request : requests) { - indicesRequests.addAll(request.subRequests()); - } - return indicesRequests; - } - @Override public ActionRequestValidationException validate() { ActionRequestValidationException validationException = null; diff --git a/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/SearchTemplateRequest.java b/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/SearchTemplateRequest.java index 6b3c980be30..8ff30fb0e5b 100644 --- a/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/SearchTemplateRequest.java +++ b/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/SearchTemplateRequest.java @@ -22,15 +22,12 @@ package org.elasticsearch.script.mustache; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.CompositeIndicesRequest; -import org.elasticsearch.action.IndicesRequest; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.script.ScriptType; import java.io.IOException; -import java.util.Collections; -import java.util.List; import java.util.Map; import static org.elasticsearch.action.ValidateActions.addValidationError; @@ -166,15 +163,4 @@ public class SearchTemplateRequest extends ActionRequest implements CompositeInd out.writeMap(scriptParams); } } - - @Override - public List subRequests() { - //if we are simulating no index is involved in the request - if (simulate) { - assert request == null; - return Collections.emptyList(); - } - //composite request as it delegates to search, but it holds one single action (search itself) - return Collections.singletonList(request); - } } diff --git a/modules/percolator/src/main/java/org/elasticsearch/percolator/MultiPercolateRequest.java b/modules/percolator/src/main/java/org/elasticsearch/percolator/MultiPercolateRequest.java index 3ecf3c273ea..c95b767d42f 100644 --- a/modules/percolator/src/main/java/org/elasticsearch/percolator/MultiPercolateRequest.java +++ b/modules/percolator/src/main/java/org/elasticsearch/percolator/MultiPercolateRequest.java @@ -22,7 +22,6 @@ import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.CompositeIndicesRequest; -import org.elasticsearch.action.IndicesRequest; import org.elasticsearch.action.get.GetRequest; import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.common.bytes.BytesArray; @@ -164,11 +163,6 @@ public class MultiPercolateRequest extends ActionRequest implements CompositeInd return this; } - @Override - public List subRequests() { - return requests; - } - private void parsePercolateAction(XContentParser parser, PercolateRequest percolateRequest, boolean allowExplicitIndex) throws IOException { String globalIndex = indices != null && indices.length > 0 ? indices[0] : null; diff --git a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexRequest.java b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexRequest.java index d8388af755c..618db3dfa48 100644 --- a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexRequest.java +++ b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexRequest.java @@ -21,7 +21,6 @@ package org.elasticsearch.index.reindex; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.CompositeIndicesRequest; -import org.elasticsearch.action.IndicesRequest; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.common.io.stream.StreamInput; @@ -31,11 +30,7 @@ import org.elasticsearch.index.reindex.remote.RemoteInfo; import org.elasticsearch.tasks.TaskId; import java.io.IOException; -import java.util.Arrays; -import java.util.List; -import static java.util.Collections.singletonList; -import static java.util.Collections.unmodifiableList; import static org.elasticsearch.action.ValidateActions.addValidationError; import static org.elasticsearch.index.VersionType.INTERNAL; @@ -165,23 +160,4 @@ public class ReindexRequest extends AbstractBulkIndexByScrollRequestnot - * accurate since it returns a prototype {@link IndexRequest} and not the actual requests that will be issued as part of the - * execution of this request. Additionally, scripts can modify the underlying {@link IndexRequest} and change values such as the index, - * type, {@link org.elasticsearch.action.support.IndicesOptions}. In short - only use this for very course reasoning about the request. - * - * @return a list comprising of the {@link SearchRequest} and the prototype {@link IndexRequest} - */ - @Override - public List subRequests() { - assert getSearchRequest() != null; - assert getDestination() != null; - if (remoteInfo != null) { - return singletonList(getDestination()); - } - return unmodifiableList(Arrays.asList(getSearchRequest(), getDestination())); - } }