Skip to content

Make TransportRequest an interface #126733

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

Merged
merged 4 commits into from
Apr 14, 2025
Merged
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 @@ -18,7 +18,7 @@
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.transport.TransportRequest;
import org.elasticsearch.transport.AbstractTransportRequest;
import org.elasticsearch.xcontent.ToXContentObject;
import org.elasticsearch.xcontent.XContentBuilder;

Expand Down Expand Up @@ -187,7 +187,7 @@ private synchronized Map<String, NodeResponse> equalsHashCodeNodesMap() {
}
}

public static class NodeRequest extends TransportRequest {
public static class NodeRequest extends AbstractTransportRequest {

private final String[] databaseIds;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.transport.TransportRequest;
import org.elasticsearch.transport.AbstractTransportRequest;
import org.elasticsearch.xcontent.ToXContentObject;
import org.elasticsearch.xcontent.XContentBuilder;

Expand Down Expand Up @@ -68,7 +68,7 @@ public boolean equals(Object obj) {
}
}

public static class NodeRequest extends TransportRequest {
public static class NodeRequest extends AbstractTransportRequest {
public NodeRequest(StreamInput in) throws IOException {
super(in);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.transport.AbstractTransportRequest;
import org.elasticsearch.transport.TransportRequest;
import org.elasticsearch.xpack.core.security.authc.Authentication;
import org.elasticsearch.xpack.core.security.authc.Authentication.RealmRef;
Expand Down Expand Up @@ -47,7 +48,7 @@ public void testGetAuthorizationInfo() {

public void testAuthorizeRunAs() {
final String action = "cluster:monitor/foo";
final TransportRequest request = new TransportRequest() {
final TransportRequest request = new AbstractTransportRequest() {
};
CustomAuthorizationEngine engine = new CustomAuthorizationEngine();
// unauthorized
Expand Down Expand Up @@ -181,7 +182,7 @@ public void testAuthorizeIndexAction() {

private RequestInfo getRequestInfo() {
final String action = "cluster:monitor/foo";
final TransportRequest request = new TransportRequest() {
final TransportRequest request = new AbstractTransportRequest() {
};
final Authentication authentication = Authentication.newRealmAuthentication(
new User("joe", "custom_superuser"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.transport.TransportRequest;
import org.elasticsearch.transport.AbstractTransportRequest;

import java.io.IOException;

public abstract class ActionRequest extends TransportRequest {
public abstract class ActionRequest extends AbstractTransportRequest {

public ActionRequest() {
super();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportRequest;
import org.elasticsearch.transport.AbstractTransportRequest;
import org.elasticsearch.transport.TransportService;

import java.io.IOException;
Expand Down Expand Up @@ -110,7 +110,7 @@ protected NodeCapability nodeOperation(NodeCapabilitiesRequest request, Task tas
return new NodeCapability(supported, transportService.getLocalNode());
}

public static class NodeCapabilitiesRequest extends TransportRequest {
public static class NodeCapabilitiesRequest extends AbstractTransportRequest {
private final RestRequest.Method method;
private final String path;
private final Set<String> parameters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
import org.elasticsearch.injection.guice.Inject;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportRequest;
import org.elasticsearch.transport.AbstractTransportRequest;
import org.elasticsearch.transport.TransportService;

import java.io.IOException;
import java.util.List;

@UpdateForV10(owner = UpdateForV10.Owner.CORE_INFRA) // this can be removed in v10. It may be called by v8 nodes to v9 nodes.
@UpdateForV10(owner = UpdateForV10.Owner.CORE_INFRA)
// this can be removed in v10. It may be called by v8 nodes to v9 nodes.
public class TransportNodesFeaturesAction extends TransportNodesAction<
NodesFeaturesRequest,
NodesFeaturesResponse,
Expand Down Expand Up @@ -82,7 +83,7 @@ protected NodeFeatures nodeOperation(NodeFeaturesRequest request, Task task) {
return new NodeFeatures(featureService.getNodeFeatures().keySet(), transportService.getLocalNode());
}

public static class NodeFeaturesRequest extends TransportRequest {
public static class NodeFeaturesRequest extends AbstractTransportRequest {
public NodeFeaturesRequest(StreamInput in) throws IOException {
super(in);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import org.elasticsearch.monitor.jvm.HotThreads;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.AbstractTransportRequest;
import org.elasticsearch.transport.LeakTracker;
import org.elasticsearch.transport.TransportRequest;
import org.elasticsearch.transport.TransportService;

import java.io.IOException;
Expand Down Expand Up @@ -106,7 +106,7 @@ protected NodeHotThreads nodeOperation(NodeRequest request, Task task) {
}
}

public static class NodeRequest extends TransportRequest {
public static class NodeRequest extends AbstractTransportRequest {

final HotThreads.RequestOptions requestOptions;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.elasticsearch.node.NodeService;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportRequest;
import org.elasticsearch.transport.AbstractTransportRequest;
import org.elasticsearch.transport.TransportService;

import java.io.IOException;
Expand Down Expand Up @@ -95,7 +95,7 @@ protected NodeInfo nodeOperation(NodeInfoRequest nodeRequest, Task task) {
);
}

public static class NodeInfoRequest extends TransportRequest {
public static class NodeInfoRequest extends AbstractTransportRequest {

private final NodesInfoMetrics nodesInfoMetrics;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import org.elasticsearch.core.RefCounted;
import org.elasticsearch.core.Releasables;
import org.elasticsearch.tasks.TaskId;
import org.elasticsearch.transport.AbstractTransportRequest;
import org.elasticsearch.transport.LeakTracker;
import org.elasticsearch.transport.TransportRequest;

import java.io.IOException;
import java.util.Arrays;
Expand Down Expand Up @@ -82,7 +82,7 @@ NodeRequest newNodeRequest() {
return new NodeRequest(secureSettingsPassword, refs);
}

public static class NodeRequest extends TransportRequest {
public static class NodeRequest extends AbstractTransportRequest {

@Nullable
private final SecureString secureSettingsPassword;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.transport.TransportRequest;
import org.elasticsearch.transport.AbstractTransportRequest;

import java.io.IOException;
import java.util.Collection;
Expand All @@ -21,8 +21,8 @@

/**
* A node-specific request derived from the corresponding {@link PrevalidateShardPathRequest}.
*/
public class NodePrevalidateShardPathRequest extends TransportRequest {
*/
public class NodePrevalidateShardPathRequest extends AbstractTransportRequest {

private final Set<ShardId> shardIds;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import org.elasticsearch.tasks.Task;
import org.elasticsearch.tasks.TaskId;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportRequest;
import org.elasticsearch.transport.AbstractTransportRequest;
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.transport.Transports;

Expand Down Expand Up @@ -179,7 +179,7 @@ protected NodeStats nodeOperation(NodeStatsRequest request, Task task) {
);
}

public static class NodeStatsRequest extends TransportRequest {
public static class NodeStatsRequest extends AbstractTransportRequest {

private final NodesStatsRequestParameters nodesStatsRequestParameters;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.elasticsearch.search.aggregations.support.AggregationUsageService;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportRequest;
import org.elasticsearch.transport.AbstractTransportRequest;
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.usage.UsageService;

Expand Down Expand Up @@ -85,7 +85,7 @@ protected NodeUsage nodeOperation(NodeUsageRequest request, Task task) {
return new NodeUsage(clusterService.localNode(), System.currentTimeMillis(), sinceTime, restUsage, aggsUsage);
}

public static class NodeUsageRequest extends TransportRequest {
public static class NodeUsageRequest extends AbstractTransportRequest {

final boolean restActions;
final boolean aggregations;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.elasticsearch.snapshots.SnapshotShardsService;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportRequest;
import org.elasticsearch.transport.AbstractTransportRequest;
import org.elasticsearch.transport.TransportService;

import java.io.IOException;
Expand Down Expand Up @@ -148,7 +148,7 @@ protected void writeNodesTo(StreamOutput out, List<NodeSnapshotStatus> nodes) th
}
}

public static class NodeRequest extends TransportRequest {
public static class NodeRequest extends AbstractTransportRequest {

private final List<Snapshot> snapshots;

Expand All @@ -157,7 +157,7 @@ public NodeRequest(StreamInput in) throws IOException {
snapshots = in.readCollectionAsList(Snapshot::new);
}

NodeRequest(TransportNodesSnapshotsStatus.Request request) {
NodeRequest(Request request) {
snapshots = Arrays.asList(request.snapshots);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@
import org.elasticsearch.tasks.Task;
import org.elasticsearch.tasks.TaskId;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.AbstractTransportRequest;
import org.elasticsearch.transport.RemoteClusterConnection;
import org.elasticsearch.transport.RemoteClusterService;
import org.elasticsearch.transport.RemoteConnectionInfo;
import org.elasticsearch.transport.TransportRequest;
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.transport.Transports;
import org.elasticsearch.usage.SearchUsageHolder;
Expand Down Expand Up @@ -319,7 +319,7 @@ protected ClusterStatsNodeResponse nodeOperation(ClusterStatsNodeRequest nodeReq
);
}

public static class ClusterStatsNodeRequest extends TransportRequest {
public static class ClusterStatsNodeRequest extends AbstractTransportRequest {

ClusterStatsNodeRequest() {}

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

import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.transport.TransportRequest;
import org.elasticsearch.transport.AbstractTransportRequest;

import java.io.IOException;

/**
* Used when querying every node in the cluster for a specific dangling index.
*/
public class NodeFindDanglingIndexRequest extends TransportRequest {
public class NodeFindDanglingIndexRequest extends AbstractTransportRequest {
private final String indexUUID;

public NodeFindDanglingIndexRequest(String indexUUID) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.transport.TransportRequest;
import org.elasticsearch.transport.AbstractTransportRequest;

import java.io.IOException;

/**
* Used when querying every node in the cluster for dangling indices, in response to a list request.
*/
public class NodeListDanglingIndicesRequest extends TransportRequest {
public class NodeListDanglingIndicesRequest extends AbstractTransportRequest {
/**
* Filter the response by index UUID. Leave as null to find all indices.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import org.elasticsearch.injection.guice.Inject;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.AbstractTransportRequest;
import org.elasticsearch.transport.TransportChannel;
import org.elasticsearch.transport.TransportRequest;
import org.elasticsearch.transport.TransportRequestHandler;
import org.elasticsearch.transport.TransportService;

Expand Down Expand Up @@ -100,7 +100,7 @@ protected void shardOperationOnReplica(ShardFlushRequest request, IndexShard rep
// TODO: Remove this transition in 9.0
private static final String PRE_SYNCED_FLUSH_ACTION_NAME = "internal:indices/flush/synced/pre";

private static class PreShardSyncedFlushRequest extends TransportRequest {
private static class PreShardSyncedFlushRequest extends AbstractTransportRequest {
private final ShardId shardId;

private PreShardSyncedFlushRequest(StreamInput in) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.elasticsearch.search.internal.ShardSearchRequest;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.tasks.TaskId;
import org.elasticsearch.transport.TransportRequest;
import org.elasticsearch.transport.AbstractTransportRequest;

import java.io.IOException;
import java.util.ArrayList;
Expand All @@ -41,7 +41,7 @@
/**
* Node-level request used during can-match phase
*/
public class CanMatchNodeRequest extends TransportRequest implements IndicesRequest {
public class CanMatchNodeRequest extends AbstractTransportRequest implements IndicesRequest {

private final SearchSourceBuilder source;
private final List<Shard> shards;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@
import org.elasticsearch.tasks.TaskCancelledException;
import org.elasticsearch.tasks.TaskId;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.AbstractTransportRequest;
import org.elasticsearch.transport.LeakTracker;
import org.elasticsearch.transport.SendRequestTransportException;
import org.elasticsearch.transport.Transport;
import org.elasticsearch.transport.TransportActionProxy;
import org.elasticsearch.transport.TransportChannel;
import org.elasticsearch.transport.TransportException;
import org.elasticsearch.transport.TransportRequest;
import org.elasticsearch.transport.TransportResponse;
import org.elasticsearch.transport.TransportResponseHandler;

Expand Down Expand Up @@ -286,7 +286,7 @@ public boolean decRef() {
/**
* Request for starting the query phase for multiple shards.
*/
public static final class NodeQueryRequest extends TransportRequest implements IndicesRequest {
public static final class NodeQueryRequest extends AbstractTransportRequest implements IndicesRequest {
private final List<ShardToQuery> shards;
private final SearchRequest searchRequest;
private final Map<String, AliasFilter> aliasFilters;
Expand Down Expand Up @@ -368,7 +368,7 @@ public void writeTo(StreamOutput out) throws IOException {
* Check if, based on already collected results, a shard search can be updated with a lower search threshold than is current set.
* When the query executes via batched execution, data nodes this take into account the results of queries run against shards local
* to the datanode. On the coordinating node results received from all data nodes are taken into account.
*
* <p>
* See {@link BottomSortValuesCollector} for details.
*/
private static ShardSearchRequest tryRewriteWithUpdatedSortValue(
Expand Down
Loading