Skip to content

Add temporary LegacyActionRequest #128107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

import org.elasticsearch.TransportVersions;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.ActionType;
import org.elasticsearch.action.LegacyActionRequest;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.HandledTransportAction;
import org.elasticsearch.client.internal.node.NodeClient;
Expand Down Expand Up @@ -43,11 +43,11 @@

public class GrokProcessorGetAction {

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

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

public static class Request extends ActionRequest {
public static class Request extends LegacyActionRequest {

private final boolean sorted;
private final String ecsCompatibility;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

package org.elasticsearch.script.mustache;

import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.CompositeIndicesRequest;
import org.elasticsearch.action.LegacyActionRequest;
import org.elasticsearch.action.search.MultiSearchRequest;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.support.IndicesOptions;
Expand All @@ -30,7 +30,7 @@

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

public class MultiSearchTemplateRequest extends ActionRequest implements CompositeIndicesRequest {
public class MultiSearchTemplateRequest extends LegacyActionRequest implements CompositeIndicesRequest {

private int maxConcurrentSearchRequests = 0;
private List<SearchTemplateRequest> requests = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

package org.elasticsearch.script.mustache;

import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.CompositeIndicesRequest;
import org.elasticsearch.action.LegacyActionRequest;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.common.ParsingException;
import org.elasticsearch.common.Strings;
Expand All @@ -34,7 +34,7 @@
/**
* A request to execute a search based on a search template.
*/
public class SearchTemplateRequest extends ActionRequest implements CompositeIndicesRequest, ToXContentObject {
public class SearchTemplateRequest extends LegacyActionRequest implements CompositeIndicesRequest, ToXContentObject {

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

private static final ObjectParser<SearchTemplateRequest, Void> PARSER;

static {
PARSER = new ObjectParser<>("search_template");
PARSER.declareField((parser, request, s) -> request.setScriptParams(parser.map()), PARAMS_FIELD, ObjectParser.ValueType.OBJECT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
package org.elasticsearch.painless.action;

import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.ActionType;
import org.elasticsearch.action.LegacyActionRequest;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.HandledTransportAction;
import org.elasticsearch.client.internal.node.NodeClient;
Expand Down Expand Up @@ -61,7 +61,7 @@ public class PainlessContextAction {

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

public static class Request extends ActionRequest {
public static class Request extends LegacyActionRequest {

private String scriptContextName;

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

package org.elasticsearch.index.rankeval;

import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.IndicesRequest;
import org.elasticsearch.action.LegacyActionRequest;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.action.support.IndicesOptions;
Expand All @@ -26,7 +26,7 @@
/**
* Request to perform a search ranking evaluation.
*/
public final class RankEvalRequest extends ActionRequest implements IndicesRequest.Replaceable {
public final class RankEvalRequest extends LegacyActionRequest implements IndicesRequest.Replaceable {

private RankEvalSpec rankingEvaluationSpec;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@

package org.elasticsearch.rest.root;

import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.LegacyActionRequest;
import org.elasticsearch.action.support.TransportAction;
import org.elasticsearch.common.io.stream.StreamOutput;

import java.io.IOException;

public class MainRequest extends ActionRequest {
public class MainRequest extends LegacyActionRequest {
@Override
public ActionRequestValidationException validate() {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
import org.elasticsearch.ESNetty4IntegTestCase;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.ActionRunnable;
import org.elasticsearch.action.ActionType;
import org.elasticsearch.action.LegacyActionRequest;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.CountDownActionListener;
import org.elasticsearch.action.support.SubscribableListener;
Expand Down Expand Up @@ -337,14 +337,14 @@ public static class YieldsContinuationsPlugin extends Plugin implements ActionPl
static final String ROUTE = "/_test/yields_continuations";
static final String FAIL_INDEX_PARAM = "fail_index";

private static final ActionType<YieldsContinuationsPlugin.Response> TYPE = new ActionType<>("test:yields_continuations");
private static final ActionType<Response> TYPE = new ActionType<>("test:yields_continuations");

@Override
public Collection<ActionHandler> getActions() {
return List.of(new ActionHandler(TYPE, TransportYieldsContinuationsAction.class));
}

public static class Request extends ActionRequest {
public static class Request extends LegacyActionRequest {
final int failIndex;

public Request(int failIndex) {
Expand Down Expand Up @@ -525,7 +525,7 @@ public Collection<ActionHandler> getActions() {
return List.of(new ActionHandler(TYPE, TransportInfiniteContinuationsAction.class));
}

public static class Request extends ActionRequest {
public static class Request extends LegacyActionRequest {
@Override
public ActionRequestValidationException validate() {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
import org.elasticsearch.action.ActionFuture;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionListenerResponseHandler;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.ActionType;
import org.elasticsearch.action.LatchedActionListener;
import org.elasticsearch.action.LegacyActionRequest;
import org.elasticsearch.action.admin.cluster.node.tasks.list.ListTasksResponse;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.GroupedActionListener;
Expand Down Expand Up @@ -118,6 +118,7 @@ static void randomDescendants(TestRequest request, Set<TestRequest> result) {

/**
* Allow some parts of the request to be completed
*
* @return a pending child requests
*/
static Set<TestRequest> allowPartialRequest(TestRequest request) throws Exception {
Expand Down Expand Up @@ -418,7 +419,7 @@ static void waitForRootTask(ActionFuture<TestResponse> rootTask, boolean expectT
}
}

static class TestRequest extends ActionRequest {
static class TestRequest extends LegacyActionRequest {
final int id;
final DiscoveryNode node;
final List<TestRequest> subRequests;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
package org.elasticsearch.action.admin.cluster.tasks;

import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.ActionRunnable;
import org.elasticsearch.action.ActionType;
import org.elasticsearch.action.LegacyActionRequest;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.HandledTransportAction;
import org.elasticsearch.action.support.PlainActionFuture;
Expand Down Expand Up @@ -142,7 +142,7 @@ public List<ActionHandler> getActions() {
}
}

public static class TestRequest extends ActionRequest {
public static class TestRequest extends LegacyActionRequest {
@Override
public ActionRequestValidationException validate() {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
import org.elasticsearch.TransportVersion;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.ActionType;
import org.elasticsearch.action.LegacyActionRequest;
import org.elasticsearch.action.search.SearchPhaseController;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.HandledTransportAction;
Expand Down Expand Up @@ -142,7 +142,7 @@ public static class TestRerankingActionType extends ActionType<TestRerankingActi
}
}

public static class TestRerankingActionRequest extends ActionRequest {
public static class TestRerankingActionRequest extends LegacyActionRequest {

private final List<String> docFeatures;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

package org.elasticsearch.action;

import org.elasticsearch.common.io.stream.StreamInput;

import java.io.IOException;

/**
* An action request with an unspecified response type.
*
* @deprecated Use {@link ActionRequest} with a specific {@link ActionResponse} type.
*/
@Deprecated
public abstract class LegacyActionRequest extends ActionRequest {
public LegacyActionRequest() {
super();
}

public LegacyActionRequest(StreamInput in) throws IOException {
super(in);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
package org.elasticsearch.action.admin.cluster.coordination;

import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.ActionType;
import org.elasticsearch.action.LegacyActionRequest;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.HandledTransportAction;
import org.elasticsearch.cluster.coordination.ClusterFormationFailureHelper;
Expand Down Expand Up @@ -41,7 +41,7 @@ private ClusterFormationInfoAction() {
super(NAME);
}

public static class Request extends ActionRequest {
public static class Request extends LegacyActionRequest {

public Request() {}

Expand Down Expand Up @@ -105,7 +105,7 @@ public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) {
return false;
}
ClusterFormationInfoAction.Response response = (ClusterFormationInfoAction.Response) o;
Response response = (Response) o;
return clusterFormationState.equals(response.clusterFormationState);
}

Expand All @@ -118,9 +118,7 @@ public int hashCode() {
/**
* This transport action fetches the ClusterFormationState from a remote node.
*/
public static class TransportAction extends HandledTransportAction<
ClusterFormationInfoAction.Request,
ClusterFormationInfoAction.Response> {
public static class TransportAction extends HandledTransportAction<Request, Response> {
private final Coordinator coordinator;

@Inject
Expand All @@ -129,19 +127,15 @@ public TransportAction(TransportService transportService, ActionFilters actionFi
ClusterFormationInfoAction.NAME,
transportService,
actionFilters,
ClusterFormationInfoAction.Request::new,
Request::new,
transportService.getThreadPool().executor(ThreadPool.Names.CLUSTER_COORDINATION)
);
this.coordinator = coordinator;
}

@Override
protected void doExecute(
Task task,
ClusterFormationInfoAction.Request request,
ActionListener<ClusterFormationInfoAction.Response> listener
) {
listener.onResponse(new ClusterFormationInfoAction.Response(coordinator.getClusterFormationState()));
protected void doExecute(Task task, Request request, ActionListener<Response> listener) {
listener.onResponse(new Response(coordinator.getClusterFormationState()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
package org.elasticsearch.action.admin.cluster.coordination;

import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.ActionType;
import org.elasticsearch.action.LegacyActionRequest;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.HandledTransportAction;
import org.elasticsearch.cluster.coordination.CoordinationDiagnosticsService;
Expand Down Expand Up @@ -42,7 +42,7 @@ private CoordinationDiagnosticsAction() {
super(NAME);
}

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

public Request(boolean explain) {
Expand Down Expand Up @@ -104,7 +104,7 @@ public void writeTo(StreamOutput out) throws IOException {
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
CoordinationDiagnosticsAction.Response response = (CoordinationDiagnosticsAction.Response) o;
Response response = (Response) o;
return result.equals(response.result);
}

Expand All @@ -130,14 +130,14 @@ public TransportAction(
CoordinationDiagnosticsAction.NAME,
transportService,
actionFilters,
CoordinationDiagnosticsAction.Request::new,
Request::new,
transportService.getThreadPool().executor(ThreadPool.Names.CLUSTER_COORDINATION)
);
this.coordinationDiagnosticsService = coordinationDiagnosticsService;
}

@Override
protected void doExecute(Task task, CoordinationDiagnosticsAction.Request request, ActionListener<Response> listener) {
protected void doExecute(Task task, Request request, ActionListener<Response> listener) {
listener.onResponse(new Response(coordinationDiagnosticsService.diagnoseMasterStability(request.explain)));
}
}
Expand Down
Loading