Skip to content

Commit 26f2b1a

Browse files
authored
Add temporary LegacyActionRequest (#128107) (#128219)
* Add temporary LegacyActionRequest (#128107) In order to remove ActionType, ActionRequest will become strongly typed, referring to the ActionResponse type. As a precursor to that, this commit adds a LegacyActionRequest which all existing ActionRequest implementations now inherit from. This will allow adding the ActionResponse type to ActionRequest in a future commit without modifying every implementation at once. * fix oops * use list directly * more test compile
1 parent 603dc73 commit 26f2b1a

File tree

235 files changed

+661
-622
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

235 files changed

+661
-622
lines changed

modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/GrokProcessorGetAction.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
import org.elasticsearch.TransportVersions;
1212
import org.elasticsearch.action.ActionListener;
13-
import org.elasticsearch.action.ActionRequest;
1413
import org.elasticsearch.action.ActionRequestValidationException;
1514
import org.elasticsearch.action.ActionResponse;
1615
import org.elasticsearch.action.ActionType;
16+
import org.elasticsearch.action.LegacyActionRequest;
1717
import org.elasticsearch.action.support.ActionFilters;
1818
import org.elasticsearch.action.support.HandledTransportAction;
1919
import org.elasticsearch.client.internal.node.NodeClient;
@@ -43,11 +43,11 @@
4343

4444
public class GrokProcessorGetAction {
4545

46-
static final ActionType<GrokProcessorGetAction.Response> INSTANCE = new ActionType<>("cluster:admin/ingest/processor/grok/get");
46+
static final ActionType<Response> INSTANCE = new ActionType<>("cluster:admin/ingest/processor/grok/get");
4747

4848
private GrokProcessorGetAction() {/* no instances */}
4949

50-
public static class Request extends ActionRequest {
50+
public static class Request extends LegacyActionRequest {
5151

5252
private final boolean sorted;
5353
private final String ecsCompatibility;

modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/MultiSearchTemplateRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
package org.elasticsearch.script.mustache;
1111

12-
import org.elasticsearch.action.ActionRequest;
1312
import org.elasticsearch.action.ActionRequestValidationException;
1413
import org.elasticsearch.action.CompositeIndicesRequest;
14+
import org.elasticsearch.action.LegacyActionRequest;
1515
import org.elasticsearch.action.search.MultiSearchRequest;
1616
import org.elasticsearch.action.search.SearchRequest;
1717
import org.elasticsearch.action.support.IndicesOptions;
@@ -30,7 +30,7 @@
3030

3131
import static org.elasticsearch.action.ValidateActions.addValidationError;
3232

33-
public class MultiSearchTemplateRequest extends ActionRequest implements CompositeIndicesRequest {
33+
public class MultiSearchTemplateRequest extends LegacyActionRequest implements CompositeIndicesRequest {
3434

3535
private int maxConcurrentSearchRequests = 0;
3636
private List<SearchTemplateRequest> requests = new ArrayList<>();

modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/SearchTemplateRequest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
package org.elasticsearch.script.mustache;
1111

12-
import org.elasticsearch.action.ActionRequest;
1312
import org.elasticsearch.action.ActionRequestValidationException;
1413
import org.elasticsearch.action.CompositeIndicesRequest;
14+
import org.elasticsearch.action.LegacyActionRequest;
1515
import org.elasticsearch.action.search.SearchRequest;
1616
import org.elasticsearch.common.ParsingException;
1717
import org.elasticsearch.common.Strings;
@@ -34,7 +34,7 @@
3434
/**
3535
* A request to execute a search based on a search template.
3636
*/
37-
public class SearchTemplateRequest extends ActionRequest implements CompositeIndicesRequest, ToXContentObject {
37+
public class SearchTemplateRequest extends LegacyActionRequest implements CompositeIndicesRequest, ToXContentObject {
3838

3939
private SearchRequest request;
4040
private boolean simulate = false;
@@ -171,6 +171,7 @@ public ActionRequestValidationException validate() {
171171
private static final ParseField PROFILE_FIELD = new ParseField("profile");
172172

173173
private static final ObjectParser<SearchTemplateRequest, Void> PARSER;
174+
174175
static {
175176
PARSER = new ObjectParser<>("search_template");
176177
PARSER.declareField((parser, request, s) -> request.setScriptParams(parser.map()), PARAMS_FIELD, ObjectParser.ValueType.OBJECT);

modules/lang-painless/src/main/java/org/elasticsearch/painless/action/PainlessContextAction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
package org.elasticsearch.painless.action;
1111

1212
import org.elasticsearch.action.ActionListener;
13-
import org.elasticsearch.action.ActionRequest;
1413
import org.elasticsearch.action.ActionRequestValidationException;
1514
import org.elasticsearch.action.ActionResponse;
1615
import org.elasticsearch.action.ActionType;
16+
import org.elasticsearch.action.LegacyActionRequest;
1717
import org.elasticsearch.action.support.ActionFilters;
1818
import org.elasticsearch.action.support.HandledTransportAction;
1919
import org.elasticsearch.client.internal.node.NodeClient;
@@ -61,7 +61,7 @@ public class PainlessContextAction {
6161

6262
private PainlessContextAction() {/* no instances */}
6363

64-
public static class Request extends ActionRequest {
64+
public static class Request extends LegacyActionRequest {
6565

6666
private String scriptContextName;
6767

modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/RankEvalRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
package org.elasticsearch.index.rankeval;
1111

1212
import org.elasticsearch.TransportVersions;
13-
import org.elasticsearch.action.ActionRequest;
1413
import org.elasticsearch.action.ActionRequestValidationException;
1514
import org.elasticsearch.action.IndicesRequest;
15+
import org.elasticsearch.action.LegacyActionRequest;
1616
import org.elasticsearch.action.search.SearchRequest;
1717
import org.elasticsearch.action.search.SearchType;
1818
import org.elasticsearch.action.support.IndicesOptions;
@@ -27,7 +27,7 @@
2727
/**
2828
* Request to perform a search ranking evaluation.
2929
*/
30-
public final class RankEvalRequest extends ActionRequest implements IndicesRequest.Replaceable {
30+
public final class RankEvalRequest extends LegacyActionRequest implements IndicesRequest.Replaceable {
3131

3232
private RankEvalSpec rankingEvaluationSpec;
3333

modules/rest-root/src/main/java/org/elasticsearch/rest/root/MainRequest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99

1010
package org.elasticsearch.rest.root;
1111

12-
import org.elasticsearch.action.ActionRequest;
1312
import org.elasticsearch.action.ActionRequestValidationException;
13+
import org.elasticsearch.action.LegacyActionRequest;
1414
import org.elasticsearch.action.support.TransportAction;
1515
import org.elasticsearch.common.io.stream.StreamOutput;
1616

1717
import java.io.IOException;
1818

19-
public class MainRequest extends ActionRequest {
19+
public class MainRequest extends LegacyActionRequest {
2020
@Override
2121
public ActionRequestValidationException validate() {
2222
return null;

modules/transport-netty4/src/internalClusterTest/java/org/elasticsearch/http/netty4/Netty4ChunkedContinuationsIT.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.elasticsearch.action.ActionResponse;
2121
import org.elasticsearch.action.ActionRunnable;
2222
import org.elasticsearch.action.ActionType;
23+
import org.elasticsearch.action.LegacyActionRequest;
2324
import org.elasticsearch.action.support.ActionFilters;
2425
import org.elasticsearch.action.support.CountDownActionListener;
2526
import org.elasticsearch.action.support.SubscribableListener;
@@ -337,14 +338,14 @@ public static class YieldsContinuationsPlugin extends Plugin implements ActionPl
337338
static final String ROUTE = "/_test/yields_continuations";
338339
static final String FAIL_INDEX_PARAM = "fail_index";
339340

340-
private static final ActionType<YieldsContinuationsPlugin.Response> TYPE = new ActionType<>("test:yields_continuations");
341+
private static final ActionType<Response> TYPE = new ActionType<>("test:yields_continuations");
341342

342343
@Override
343344
public Collection<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() {
344345
return List.of(new ActionHandler<>(TYPE, TransportYieldsContinuationsAction.class));
345346
}
346347

347-
public static class Request extends ActionRequest {
348+
public static class Request extends LegacyActionRequest {
348349
final int failIndex;
349350

350351
public Request(int failIndex) {
@@ -525,7 +526,7 @@ public static class InfiniteContinuationsPlugin extends Plugin implements Action
525526
return List.of(new ActionHandler<>(TYPE, TransportInfiniteContinuationsAction.class));
526527
}
527528

528-
public static class Request extends ActionRequest {
529+
public static class Request extends LegacyActionRequest {
529530
@Override
530531
public ActionRequestValidationException validate() {
531532
return null;

server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/CancellableTasksIT.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.elasticsearch.action.ActionResponse;
2020
import org.elasticsearch.action.ActionType;
2121
import org.elasticsearch.action.LatchedActionListener;
22+
import org.elasticsearch.action.LegacyActionRequest;
2223
import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse;
2324
import org.elasticsearch.action.support.ActionFilters;
2425
import org.elasticsearch.action.support.GroupedActionListener;
@@ -118,6 +119,7 @@ static void randomDescendants(TestRequest request, Set<TestRequest> result) {
118119

119120
/**
120121
* Allow some parts of the request to be completed
122+
*
121123
* @return a pending child requests
122124
*/
123125
static Set<TestRequest> allowPartialRequest(TestRequest request) throws Exception {
@@ -418,7 +420,7 @@ static void waitForRootTask(ActionFuture<TestResponse> rootTask, boolean expectT
418420
}
419421
}
420422

421-
static class TestRequest extends ActionRequest {
423+
static class TestRequest extends LegacyActionRequest {
422424
final int id;
423425
final DiscoveryNode node;
424426
final List<TestRequest> subRequests;

server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/tasks/ListTasksIT.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.elasticsearch.action.ActionResponse;
1616
import org.elasticsearch.action.ActionRunnable;
1717
import org.elasticsearch.action.ActionType;
18+
import org.elasticsearch.action.LegacyActionRequest;
1819
import org.elasticsearch.action.support.ActionFilters;
1920
import org.elasticsearch.action.support.HandledTransportAction;
2021
import org.elasticsearch.action.support.PlainActionFuture;
@@ -142,7 +143,7 @@ public static class TestPlugin extends Plugin implements ActionPlugin {
142143
}
143144
}
144145

145-
public static class TestRequest extends ActionRequest {
146+
public static class TestRequest extends LegacyActionRequest {
146147
@Override
147148
public ActionRequestValidationException validate() {
148149
return null;

server/src/internalClusterTest/java/org/elasticsearch/search/rank/MockedRequestActionBasedRerankerIT.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.elasticsearch.action.ActionRequestValidationException;
2121
import org.elasticsearch.action.ActionResponse;
2222
import org.elasticsearch.action.ActionType;
23+
import org.elasticsearch.action.LegacyActionRequest;
2324
import org.elasticsearch.action.search.SearchPhaseController;
2425
import org.elasticsearch.action.support.ActionFilters;
2526
import org.elasticsearch.action.support.HandledTransportAction;
@@ -142,7 +143,7 @@ public static class TestRerankingActionType extends ActionType<TestRerankingActi
142143
}
143144
}
144145

145-
public static class TestRerankingActionRequest extends ActionRequest {
146+
public static class TestRerankingActionRequest extends LegacyActionRequest {
146147

147148
private final List<String> docFeatures;
148149

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.action;
11+
12+
import org.elasticsearch.common.io.stream.StreamInput;
13+
14+
import java.io.IOException;
15+
16+
/**
17+
* An action request with an unspecified response type.
18+
*
19+
* @deprecated Use {@link ActionRequest} with a specific {@link ActionResponse} type.
20+
*/
21+
@Deprecated
22+
public abstract class LegacyActionRequest extends ActionRequest {
23+
public LegacyActionRequest() {
24+
super();
25+
}
26+
27+
public LegacyActionRequest(StreamInput in) throws IOException {
28+
super(in);
29+
}
30+
}

server/src/main/java/org/elasticsearch/action/admin/cluster/coordination/ClusterFormationInfoAction.java

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
package org.elasticsearch.action.admin.cluster.coordination;
1111

1212
import org.elasticsearch.action.ActionListener;
13-
import org.elasticsearch.action.ActionRequest;
1413
import org.elasticsearch.action.ActionRequestValidationException;
1514
import org.elasticsearch.action.ActionResponse;
1615
import org.elasticsearch.action.ActionType;
16+
import org.elasticsearch.action.LegacyActionRequest;
1717
import org.elasticsearch.action.support.ActionFilters;
1818
import org.elasticsearch.action.support.HandledTransportAction;
1919
import org.elasticsearch.cluster.coordination.ClusterFormationFailureHelper;
@@ -41,7 +41,7 @@ private ClusterFormationInfoAction() {
4141
super(NAME);
4242
}
4343

44-
public static class Request extends ActionRequest {
44+
public static class Request extends LegacyActionRequest {
4545

4646
public Request() {}
4747

@@ -106,7 +106,7 @@ public boolean equals(Object o) {
106106
if (o == null || getClass() != o.getClass()) {
107107
return false;
108108
}
109-
ClusterFormationInfoAction.Response response = (ClusterFormationInfoAction.Response) o;
109+
Response response = (Response) o;
110110
return clusterFormationState.equals(response.clusterFormationState);
111111
}
112112

@@ -119,9 +119,7 @@ public int hashCode() {
119119
/**
120120
* This transport action fetches the ClusterFormationState from a remote node.
121121
*/
122-
public static class TransportAction extends HandledTransportAction<
123-
ClusterFormationInfoAction.Request,
124-
ClusterFormationInfoAction.Response> {
122+
public static class TransportAction extends HandledTransportAction<Request, Response> {
125123
private final Coordinator coordinator;
126124

127125
@Inject
@@ -130,19 +128,15 @@ public TransportAction(TransportService transportService, ActionFilters actionFi
130128
ClusterFormationInfoAction.NAME,
131129
transportService,
132130
actionFilters,
133-
ClusterFormationInfoAction.Request::new,
131+
Request::new,
134132
transportService.getThreadPool().executor(ThreadPool.Names.CLUSTER_COORDINATION)
135133
);
136134
this.coordinator = coordinator;
137135
}
138136

139137
@Override
140-
protected void doExecute(
141-
Task task,
142-
ClusterFormationInfoAction.Request request,
143-
ActionListener<ClusterFormationInfoAction.Response> listener
144-
) {
145-
listener.onResponse(new ClusterFormationInfoAction.Response(coordinator.getClusterFormationState()));
138+
protected void doExecute(Task task, Request request, ActionListener<Response> listener) {
139+
listener.onResponse(new Response(coordinator.getClusterFormationState()));
146140
}
147141
}
148142

server/src/main/java/org/elasticsearch/action/admin/cluster/coordination/CoordinationDiagnosticsAction.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
package org.elasticsearch.action.admin.cluster.coordination;
1111

1212
import org.elasticsearch.action.ActionListener;
13-
import org.elasticsearch.action.ActionRequest;
1413
import org.elasticsearch.action.ActionRequestValidationException;
1514
import org.elasticsearch.action.ActionResponse;
1615
import org.elasticsearch.action.ActionType;
16+
import org.elasticsearch.action.LegacyActionRequest;
1717
import org.elasticsearch.action.support.ActionFilters;
1818
import org.elasticsearch.action.support.HandledTransportAction;
1919
import org.elasticsearch.cluster.coordination.CoordinationDiagnosticsService;
@@ -42,7 +42,7 @@ private CoordinationDiagnosticsAction() {
4242
super(NAME);
4343
}
4444

45-
public static class Request extends ActionRequest {
45+
public static class Request extends LegacyActionRequest {
4646
final boolean explain; // Non-private for testing
4747

4848
public Request(boolean explain) {
@@ -105,7 +105,7 @@ public void writeTo(StreamOutput out) throws IOException {
105105
public boolean equals(Object o) {
106106
if (this == o) return true;
107107
if (o == null || getClass() != o.getClass()) return false;
108-
CoordinationDiagnosticsAction.Response response = (CoordinationDiagnosticsAction.Response) o;
108+
Response response = (Response) o;
109109
return result.equals(response.result);
110110
}
111111

@@ -131,14 +131,14 @@ public TransportAction(
131131
CoordinationDiagnosticsAction.NAME,
132132
transportService,
133133
actionFilters,
134-
CoordinationDiagnosticsAction.Request::new,
134+
Request::new,
135135
transportService.getThreadPool().executor(ThreadPool.Names.CLUSTER_COORDINATION)
136136
);
137137
this.coordinationDiagnosticsService = coordinationDiagnosticsService;
138138
}
139139

140140
@Override
141-
protected void doExecute(Task task, CoordinationDiagnosticsAction.Request request, ActionListener<Response> listener) {
141+
protected void doExecute(Task task, Request request, ActionListener<Response> listener) {
142142
listener.onResponse(new Response(coordinationDiagnosticsService.diagnoseMasterStability(request.explain)));
143143
}
144144
}

0 commit comments

Comments
 (0)