Skip to content

Commit

Permalink
Core: Remove RequestBuilder from Action (#30966)
Browse files Browse the repository at this point in the history
This commit removes the RequestBuilder generic type from Action. It was
needed to be used by the newRequest method, which in turn was used by
client.prepareExecute. Both of these methods are now removed, along with
the existing users of prepareExecute constructing the appropriate
builder directly.
  • Loading branch information
rjernst authored May 31, 2018
1 parent 0f5e570 commit 46e8d97
Show file tree
Hide file tree
Showing 318 changed files with 509 additions and 1,747 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private static final class TransportBulkRequestExecutor implements BulkRequestEx

@Override
public boolean bulkIndex(List<String> bulkData) {
NoopBulkRequestBuilder builder = NoopBulkAction.INSTANCE.newRequestBuilder(client);
NoopBulkRequestBuilder builder = new NoopBulkRequestBuilder(client,NoopBulkAction.INSTANCE);
for (String bulkItem : bulkData) {
builder.add(new IndexRequest(indexName, typeName).source(bulkItem.getBytes(StandardCharsets.UTF_8), XContentType.JSON));
}
Expand Down Expand Up @@ -108,7 +108,7 @@ private TransportSearchRequestExecutor(TransportClient client, String indexName)
@Override
public boolean search(String source) {
final SearchResponse response;
NoopSearchRequestBuilder builder = NoopSearchAction.INSTANCE.newRequestBuilder(client);
NoopSearchRequestBuilder builder = new NoopSearchRequestBuilder(client, NoopSearchAction.INSTANCE);
try {
builder.setIndices(indexName);
builder.setQuery(QueryBuilders.wrapperQuery(source));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
import org.elasticsearch.action.Action;
import org.elasticsearch.action.bulk.BulkRequest;
import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.client.ElasticsearchClient;

public class NoopBulkAction extends Action<BulkRequest, BulkResponse, NoopBulkRequestBuilder> {
public class NoopBulkAction extends Action<BulkRequest, BulkResponse> {
public static final String NAME = "mock:data/write/bulk";

public static final NoopBulkAction INSTANCE = new NoopBulkAction();
Expand All @@ -32,11 +31,6 @@ private NoopBulkAction() {
super(NAME);
}

@Override
public NoopBulkRequestBuilder newRequestBuilder(ElasticsearchClient client) {
return new NoopBulkRequestBuilder(client, this);
}

@Override
public BulkResponse newResponse() {
return new BulkResponse(null, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentType;

public class NoopBulkRequestBuilder extends ActionRequestBuilder<BulkRequest, BulkResponse, NoopBulkRequestBuilder>
public class NoopBulkRequestBuilder extends ActionRequestBuilder<BulkRequest, BulkResponse>
implements WriteRequestBuilder<NoopBulkRequestBuilder> {

public NoopBulkRequestBuilder(ElasticsearchClient client, NoopBulkAction action) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,15 @@
import org.elasticsearch.action.Action;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.ElasticsearchClient;

public class NoopSearchAction extends Action<SearchRequest, SearchResponse, NoopSearchRequestBuilder> {
public class NoopSearchAction extends Action<SearchRequest, SearchResponse> {
public static final NoopSearchAction INSTANCE = new NoopSearchAction();
public static final String NAME = "mock:data/read/search";

public NoopSearchAction() {
super(NAME);
}

@Override
public NoopSearchRequestBuilder newRequestBuilder(ElasticsearchClient client) {
return new NoopSearchRequestBuilder(client, this);
}

@Override
public SearchResponse newResponse() {
return new SearchResponse();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import java.util.Arrays;
import java.util.List;

public class NoopSearchRequestBuilder extends ActionRequestBuilder<SearchRequest, SearchResponse, NoopSearchRequestBuilder> {
public class NoopSearchRequestBuilder extends ActionRequestBuilder<SearchRequest, SearchResponse> {

public NoopSearchRequestBuilder(ElasticsearchClient client, NoopSearchAction action) {
super(client, action, new SearchRequest());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@
import static org.elasticsearch.rest.RestRequest.Method.GET;
import static org.elasticsearch.rest.RestStatus.OK;

public class GrokProcessorGetAction extends Action<GrokProcessorGetAction.Request,
GrokProcessorGetAction.Response, GrokProcessorGetAction.RequestBuilder> {
public class GrokProcessorGetAction extends Action<GrokProcessorGetAction.Request, GrokProcessorGetAction.Response> {

public static final GrokProcessorGetAction INSTANCE = new GrokProcessorGetAction();
public static final String NAME = "cluster:admin/ingest/processor/grok/get";
Expand All @@ -62,11 +61,6 @@ private GrokProcessorGetAction() {
super(NAME);
}

@Override
public RequestBuilder newRequestBuilder(ElasticsearchClient client) {
return new RequestBuilder(client);
}

@Override
public Response newResponse() {
return new Response(null);
Expand All @@ -79,7 +73,7 @@ public ActionRequestValidationException validate() {
}
}

public static class RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder> {
public static class RequestBuilder extends ActionRequestBuilder<Request, Response> {
public RequestBuilder(ElasticsearchClient client) {
super(client, GrokProcessorGetAction.INSTANCE, new Request());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
package org.elasticsearch.script.mustache;

import org.elasticsearch.action.Action;
import org.elasticsearch.client.ElasticsearchClient;

public class MultiSearchTemplateAction
extends Action<MultiSearchTemplateRequest, MultiSearchTemplateResponse, MultiSearchTemplateRequestBuilder> {
public class MultiSearchTemplateAction extends Action<MultiSearchTemplateRequest, MultiSearchTemplateResponse> {

public static final MultiSearchTemplateAction INSTANCE = new MultiSearchTemplateAction();
public static final String NAME = "indices:data/read/msearch/template";
Expand All @@ -36,9 +34,4 @@ private MultiSearchTemplateAction() {
public MultiSearchTemplateResponse newResponse() {
return new MultiSearchTemplateResponse();
}

@Override
public MultiSearchTemplateRequestBuilder newRequestBuilder(ElasticsearchClient client) {
return new MultiSearchTemplateRequestBuilder(client, this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.elasticsearch.client.ElasticsearchClient;

public class MultiSearchTemplateRequestBuilder
extends ActionRequestBuilder<MultiSearchTemplateRequest, MultiSearchTemplateResponse, MultiSearchTemplateRequestBuilder> {
extends ActionRequestBuilder<MultiSearchTemplateRequest, MultiSearchTemplateResponse> {

protected MultiSearchTemplateRequestBuilder(ElasticsearchClient client, MultiSearchTemplateAction action) {
super(client, action, new MultiSearchTemplateRequest());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
package org.elasticsearch.script.mustache;

import org.elasticsearch.action.Action;
import org.elasticsearch.client.ElasticsearchClient;

public class SearchTemplateAction extends Action<SearchTemplateRequest, SearchTemplateResponse, SearchTemplateRequestBuilder> {
public class SearchTemplateAction extends Action<SearchTemplateRequest, SearchTemplateResponse> {

public static final SearchTemplateAction INSTANCE = new SearchTemplateAction();
public static final String NAME = "indices:data/read/search/template";
Expand All @@ -31,11 +30,6 @@ private SearchTemplateAction() {
super(NAME);
}

@Override
public SearchTemplateRequestBuilder newRequestBuilder(ElasticsearchClient client) {
return new SearchTemplateRequestBuilder(client, this);
}

@Override
public SearchTemplateResponse newResponse() {
return new SearchTemplateResponse();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import java.util.Map;

public class SearchTemplateRequestBuilder
extends ActionRequestBuilder<SearchTemplateRequest, SearchTemplateResponse, SearchTemplateRequestBuilder> {
extends ActionRequestBuilder<SearchTemplateRequest, SearchTemplateResponse> {

SearchTemplateRequestBuilder(ElasticsearchClient client, SearchTemplateAction action) {
super(client, action, new SearchTemplateRequest());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@
import static org.elasticsearch.rest.RestRequest.Method.POST;
import static org.elasticsearch.rest.RestStatus.OK;

public class PainlessExecuteAction extends Action<PainlessExecuteAction.Request, PainlessExecuteAction.Response,
PainlessExecuteAction.RequestBuilder> {
public class PainlessExecuteAction extends Action<PainlessExecuteAction.Request, PainlessExecuteAction.Response> {

static final PainlessExecuteAction INSTANCE = new PainlessExecuteAction();
private static final String NAME = "cluster:admin/scripts/painless/execute";
Expand All @@ -72,11 +71,6 @@ private PainlessExecuteAction() {
super(NAME);
}

@Override
public RequestBuilder newRequestBuilder(ElasticsearchClient client) {
return new RequestBuilder(client);
}

@Override
public Response newResponse() {
return new Response();
Expand Down Expand Up @@ -201,7 +195,7 @@ public static SupportedContext fromId(byte id) {

}

public static class RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder> {
public static class RequestBuilder extends ActionRequestBuilder<Request, Response> {

RequestBuilder(ElasticsearchClient client) {
super(client, INSTANCE, new Request());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@
package org.elasticsearch.index.rankeval;

import org.elasticsearch.action.Action;
import org.elasticsearch.client.ElasticsearchClient;

/**
* Action for explaining evaluating search ranking results.
*/
public class RankEvalAction extends Action<RankEvalRequest, RankEvalResponse, RankEvalRequestBuilder> {
public class RankEvalAction extends Action<RankEvalRequest, RankEvalResponse> {

public static final RankEvalAction INSTANCE = new RankEvalAction();
public static final String NAME = "indices:data/read/rank_eval";
Expand All @@ -34,11 +33,6 @@ private RankEvalAction() {
super(NAME);
}

@Override
public RankEvalRequestBuilder newRequestBuilder(ElasticsearchClient client) {
return new RankEvalRequestBuilder(client, this, new RankEvalRequest());
}

@Override
public RankEvalResponse newResponse() {
return new RankEvalResponse();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
import org.elasticsearch.action.ActionRequestBuilder;
import org.elasticsearch.client.ElasticsearchClient;

public class RankEvalRequestBuilder extends ActionRequestBuilder<RankEvalRequest, RankEvalResponse, RankEvalRequestBuilder> {
public class RankEvalRequestBuilder extends ActionRequestBuilder<RankEvalRequest, RankEvalResponse> {

public RankEvalRequestBuilder(ElasticsearchClient client, Action<RankEvalRequest, RankEvalResponse, RankEvalRequestBuilder> action,
public RankEvalRequestBuilder(ElasticsearchClient client, Action<RankEvalRequest, RankEvalResponse> action,
RankEvalRequest request) {
super(client, action, request);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private BulkByScrollParallelizationHelper() {}
static <Request extends AbstractBulkByScrollRequest<Request>> void startSlicedAction(
Request request,
BulkByScrollTask task,
Action<Request, BulkByScrollResponse, ?> action,
Action<Request, BulkByScrollResponse> action,
ActionListener<BulkByScrollResponse> listener,
Client client,
DiscoveryNode node,
Expand All @@ -85,7 +85,7 @@ static <Request extends AbstractBulkByScrollRequest<Request>> void startSlicedAc
private static <Request extends AbstractBulkByScrollRequest<Request>> void sliceConditionally(
Request request,
BulkByScrollTask task,
Action<Request, BulkByScrollResponse, ?> action,
Action<Request, BulkByScrollResponse> action,
ActionListener<BulkByScrollResponse> listener,
Client client,
DiscoveryNode node,
Expand Down Expand Up @@ -118,7 +118,7 @@ private static int countSlicesBasedOnShards(ClusterSearchShardsResponse response

private static <Request extends AbstractBulkByScrollRequest<Request>> void sendSubRequests(
Client client,
Action<Request, BulkByScrollResponse, ?> action,
Action<Request, BulkByScrollResponse> action,
String localNodeId,
BulkByScrollTask task,
Request request,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,15 @@

import org.elasticsearch.action.Action;
import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse;
import org.elasticsearch.client.ElasticsearchClient;

public class RethrottleAction extends Action<RethrottleRequest, ListTasksResponse, RethrottleRequestBuilder> {
public class RethrottleAction extends Action<RethrottleRequest, ListTasksResponse> {
public static final RethrottleAction INSTANCE = new RethrottleAction();
public static final String NAME = "cluster:admin/reindex/rethrottle";

private RethrottleAction() {
super(NAME);
}

@Override
public RethrottleRequestBuilder newRequestBuilder(ElasticsearchClient client) {
return new RethrottleRequestBuilder(client, this);
}

@Override
public ListTasksResponse newResponse() {
return new ListTasksResponse();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/
public class RethrottleRequestBuilder extends TasksRequestBuilder<RethrottleRequest, ListTasksResponse, RethrottleRequestBuilder> {
public RethrottleRequestBuilder(ElasticsearchClient client,
Action<RethrottleRequest, ListTasksResponse, RethrottleRequestBuilder> action) {
Action<RethrottleRequest, ListTasksResponse> action) {
super(client, action, new RethrottleRequest());
}

Expand Down
Loading

0 comments on commit 46e8d97

Please sign in to comment.