Skip to content

Commit

Permalink
Core: Replace Action class uses with GenericAction
Browse files Browse the repository at this point in the history
Since elastic#30966, Action no longer has anything but a call to the
GenericAction super constructor. This commit replaces all uses of Action
with GenericAction, and removes Action. It also removes Request as a
generic type of GenericAction, as it was unused.
  • Loading branch information
rjernst committed Jun 1, 2018
1 parent 7c74318 commit 194fee6
Show file tree
Hide file tree
Showing 272 changed files with 583 additions and 637 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
*/
package org.elasticsearch.plugin.noop.action.bulk;

import org.elasticsearch.action.Action;
import org.elasticsearch.action.bulk.BulkRequest;
import org.elasticsearch.action.GenericAction;
import org.elasticsearch.action.bulk.BulkResponse;

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

public static final NoopBulkAction INSTANCE = new NoopBulkAction();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
*/
package org.elasticsearch.plugin.noop.action.search;

import org.elasticsearch.action.Action;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.GenericAction;
import org.elasticsearch.action.search.SearchResponse;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.elasticsearch.ingest.common;

import org.elasticsearch.action.Action;
import org.elasticsearch.action.GenericAction;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestBuilder;
Expand Down Expand Up @@ -52,7 +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> {
public class GrokProcessorGetAction extends GenericAction<GrokProcessorGetAction.Response> {

public static final GrokProcessorGetAction INSTANCE = new GrokProcessorGetAction();
public static final String NAME = "cluster:admin/ingest/processor/grok/get";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

package org.elasticsearch.script.mustache;

import org.elasticsearch.action.Action;
import org.elasticsearch.action.GenericAction;

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

public static final MultiSearchTemplateAction INSTANCE = new MultiSearchTemplateAction();
public static final String NAME = "indices:data/read/msearch/template";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

package org.elasticsearch.script.mustache;

import org.elasticsearch.action.Action;
import org.elasticsearch.action.GenericAction;

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

public static final SearchTemplateAction INSTANCE = new SearchTemplateAction();
public static final String NAME = "indices:data/read/search/template";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.elasticsearch.painless;

import org.elasticsearch.action.Action;
import org.elasticsearch.action.GenericAction;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestBuilder;
Expand Down Expand Up @@ -62,7 +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> {
public class PainlessExecuteAction extends GenericAction<PainlessExecuteAction.Response> {

static final PainlessExecuteAction INSTANCE = new PainlessExecuteAction();
private static final String NAME = "cluster:admin/scripts/painless/execute";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@

package org.elasticsearch.index.rankeval;

import org.elasticsearch.action.Action;
import org.elasticsearch.action.GenericAction;

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

public static final RankEvalAction INSTANCE = new RankEvalAction();
public static final String NAME = "indices:data/read/rank_eval";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@

package org.elasticsearch.index.rankeval;

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

public class RankEvalRequestBuilder extends ActionRequestBuilder<RankEvalRequest, RankEvalResponse> {

public RankEvalRequestBuilder(ElasticsearchClient client, Action<RankEvalRequest, RankEvalResponse> action,
public RankEvalRequestBuilder(ElasticsearchClient client, GenericAction<RankEvalResponse> action,
RankEvalRequest request) {
super(client, action, request);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.elasticsearch.rest.BytesRestResponse;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.search.aggregations.AggregationBuilder;
import org.elasticsearch.tasks.LoggingTaskListener;
import org.elasticsearch.tasks.Task;

Expand All @@ -39,7 +38,7 @@

public abstract class AbstractBaseReindexRestHandler<
Request extends AbstractBulkByScrollRequest<Request>,
A extends GenericAction<Request, BulkByScrollResponse>
A extends GenericAction<BulkByScrollResponse>
> extends BaseRestHandler {

private final A action;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
*/
public abstract class AbstractBulkByQueryRestHandler<
Request extends AbstractBulkByScrollRequest<Request>,
A extends GenericAction<Request, BulkByScrollResponse>> extends AbstractBaseReindexRestHandler<Request, A> {
A extends GenericAction<BulkByScrollResponse>> extends AbstractBaseReindexRestHandler<Request, A> {

protected AbstractBulkByQueryRestHandler(Settings settings, A action) {
super(settings, action);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.elasticsearch.index.reindex;

import org.elasticsearch.action.Action;
import org.elasticsearch.action.GenericAction;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.admin.cluster.shards.ClusterSearchShardsRequest;
import org.elasticsearch.action.admin.cluster.shards.ClusterSearchShardsResponse;
Expand Down Expand Up @@ -61,7 +61,7 @@ private BulkByScrollParallelizationHelper() {}
static <Request extends AbstractBulkByScrollRequest<Request>> void startSlicedAction(
Request request,
BulkByScrollTask task,
Action<Request, BulkByScrollResponse> action,
GenericAction<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,
GenericAction<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,
GenericAction<BulkByScrollResponse> action,
String localNodeId,
BulkByScrollTask task,
Request request,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

package org.elasticsearch.index.reindex;

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.elasticsearch.index.reindex;

import org.elasticsearch.action.Action;
import org.elasticsearch.action.GenericAction;
import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse;
import org.elasticsearch.action.support.tasks.TasksRequestBuilder;
import org.elasticsearch.client.ElasticsearchClient;
Expand All @@ -29,7 +29,7 @@
*/
public class RethrottleRequestBuilder extends TasksRequestBuilder<RethrottleRequest, ListTasksResponse, RethrottleRequestBuilder> {
public RethrottleRequestBuilder(ElasticsearchClient client,
Action<RethrottleRequest, ListTasksResponse> action) {
GenericAction<ListTasksResponse> action) {
super(client, action, new RethrottleRequest());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.Version;
import org.elasticsearch.action.Action;
import org.elasticsearch.action.GenericAction;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestBuilder;
Expand Down Expand Up @@ -745,7 +745,7 @@ private class MyMockClient extends FilterClient {
@SuppressWarnings("unchecked")
protected <Request extends ActionRequest, Response extends ActionResponse,
RequestBuilder extends ActionRequestBuilder<Request, Response>> void doExecute(
Action<Request, Response> action, Request request, ActionListener<Response> listener) {
GenericAction<Response> action, Request request, ActionListener<Response> listener) {
if (false == expectedHeaders.equals(threadPool().getThreadContext().getHeaders())) {
listener.onFailure(
new RuntimeException("Expected " + expectedHeaders + " but got " + threadPool().getThreadContext().getHeaders()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public Collection<String> getRestHeaders() {
}

/**
* Action filter that will reject the request if it isn't authenticated.
* GenericAction filter that will reject the request if it isn't authenticated.
*/
public static class TestFilter implements ActionFilter {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public static void startHttpd() throws Exception {
headers.add("Content-Type", "text/xml; charset=UTF-8");
String action = null;
for (NameValuePair parse : URLEncodedUtils.parse(IOUtils.toString(s.getRequestBody()), StandardCharsets.UTF_8)) {
if ("Action".equals(parse.getName())) {
if ("GenericAction".equals(parse.getName())) {
action = parse.getValue();
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ private static PathTrie<RequestHandler> defaultHandlers(final String endpoint, f
(params, headers, body) -> {
final String action = params.get("action");
if ((action.equals("rewriteTo") == false) && (action.equals("copyTo") == false)) {
return newError(RestStatus.INTERNAL_SERVER_ERROR, "Action not implemented. None of \"rewriteTo\" or \"copyTo\".");
return newError(RestStatus.INTERNAL_SERVER_ERROR, "GenericAction not implemented. None of \"rewriteTo\" or \"copyTo\".");
}
final String source = params.get("src");
if (Strings.hasText(source) == false) {
Expand Down
31 changes: 0 additions & 31 deletions server/src/main/java/org/elasticsearch/action/Action.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,8 @@ public void register(ActionHandler<?, ?> handler) {
}

public <Request extends ActionRequest, Response extends ActionResponse> void register(
GenericAction<Request, Response> action, Class<? extends TransportAction<Request, Response>> transportAction,
Class<?>... supportTransportActions) {
GenericAction<Response> action, Class<? extends TransportAction<Request, Response>> transportAction,
Class<?>... supportTransportActions) {
register(new ActionHandler<>(action, transportAction, supportTransportActions));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@

public abstract class ActionRequestBuilder<Request extends ActionRequest, Response extends ActionResponse> {

protected final Action<Request, Response> action;
protected final GenericAction<Response> action;
protected final Request request;
protected final ElasticsearchClient client;

protected ActionRequestBuilder(ElasticsearchClient client, Action<Request, Response> action, Request request) {
protected ActionRequestBuilder(ElasticsearchClient client, GenericAction<Response> action, Request request) {
Objects.requireNonNull(action, "action must not be null");
this.action = action;
this.request = request;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

/**
* Generic interface to group ActionRequest, which perform writes to a single document
* Action requests implementing this can be part of {@link org.elasticsearch.action.bulk.BulkRequest}
* GenericAction requests implementing this can be part of {@link org.elasticsearch.action.bulk.BulkRequest}
*/
public interface DocWriteRequest<T> extends IndicesRequest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
/**
* A generic action. Should strive to make it a singleton.
*/
public abstract class GenericAction<Request extends ActionRequest, Response extends ActionResponse> {
public abstract class GenericAction<Response extends ActionResponse> {

private final String name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.transport.TransportRequestOptions;
import org.elasticsearch.transport.TransportService;
Expand All @@ -32,10 +31,10 @@
public class TransportActionNodeProxy<Request extends ActionRequest, Response extends ActionResponse> extends AbstractComponent {

private final TransportService transportService;
private final GenericAction<Request, Response> action;
private final GenericAction<Response> action;
private final TransportRequestOptions transportOptions;

public TransportActionNodeProxy(Settings settings, GenericAction<Request, Response> action, TransportService transportService) {
public TransportActionNodeProxy(Settings settings, GenericAction<Response> action, TransportService transportService) {
super(settings);
this.action = action;
this.transportService = transportService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@

package org.elasticsearch.action.admin.cluster.allocation;

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

/**
* Action for explaining shard allocation for a shard in the cluster
* GenericAction for explaining shard allocation for a shard in the cluster
*/
public class ClusterAllocationExplainAction extends Action<ClusterAllocationExplainRequest, ClusterAllocationExplainResponse> {
public class ClusterAllocationExplainAction extends GenericAction<ClusterAllocationExplainResponse> {

public static final ClusterAllocationExplainAction INSTANCE = new ClusterAllocationExplainAction();
public static final String NAME = "cluster:monitor/allocation/explain";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

package org.elasticsearch.action.admin.cluster.health;

import org.elasticsearch.action.Action;
import org.elasticsearch.action.GenericAction;

public class ClusterHealthAction extends Action<ClusterHealthRequest, ClusterHealthResponse> {
public class ClusterHealthAction extends GenericAction<ClusterHealthResponse> {

public static final ClusterHealthAction INSTANCE = new ClusterHealthAction();
public static final String NAME = "cluster:monitor/health";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

package org.elasticsearch.action.admin.cluster.node.hotthreads;

import org.elasticsearch.action.Action;
import org.elasticsearch.action.GenericAction;

public class NodesHotThreadsAction extends Action<NodesHotThreadsRequest, NodesHotThreadsResponse> {
public class NodesHotThreadsAction extends GenericAction<NodesHotThreadsResponse> {

public static final NodesHotThreadsAction INSTANCE = new NodesHotThreadsAction();
public static final String NAME = "cluster:monitor/nodes/hot_threads";
Expand Down
Loading

0 comments on commit 194fee6

Please sign in to comment.