Skip to content
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

TransportNodesAction impls are local-only #100867

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 @@ -11,6 +11,7 @@
import org.elasticsearch.TransportVersions;
import org.elasticsearch.action.ActionType;
import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.action.support.TransportAction;
import org.elasticsearch.action.support.nodes.BaseNodeResponse;
import org.elasticsearch.action.support.nodes.BaseNodesRequest;
import org.elasticsearch.action.support.nodes.BaseNodesResponse;
Expand Down Expand Up @@ -44,10 +45,6 @@ public Request() {
super((String[]) null);
}

public Request(StreamInput in) throws IOException {
super(in);
}

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
Expand All @@ -71,16 +68,19 @@ public boolean equals(Object obj) {
}
return true;
}

@Override
public void writeTo(StreamOutput out) {
TransportAction.localOnly();
}
}

public static class NodeRequest extends TransportRequest {
public NodeRequest(StreamInput in) throws IOException {
super(in);
}

public NodeRequest(Request request) {

}
public NodeRequest() {}
}

public static class Response extends BaseNodesResponse<NodeResponse> implements Writeable, ToXContentObject {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@ public GeoIpDownloaderStatsTransportAction(
) {
super(
GeoIpDownloaderStatsAction.NAME,
threadPool,
clusterService,
transportService,
actionFilters,
Request::new,
NodeRequest::new,
threadPool.executor(ThreadPool.Names.MANAGEMENT)
);
Expand All @@ -66,7 +64,7 @@ protected Response newResponse(Request request, List<NodeResponse> nodeResponses

@Override
protected NodeRequest newNodeRequest(Request request) {
return new NodeRequest(request);
return new NodeRequest();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
package org.elasticsearch.action.admin.cluster.node.hotthreads;

import org.elasticsearch.action.ActionType;
import org.elasticsearch.common.io.stream.Writeable;

public class NodesHotThreadsAction extends ActionType<NodesHotThreadsResponse> {

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

private NodesHotThreadsAction() {
super(NAME, NodesHotThreadsResponse::new);
super(NAME, Writeable.Reader.localOnly());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package org.elasticsearch.action.admin.cluster.node.hotthreads;

import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.action.support.TransportAction;
import org.elasticsearch.action.support.nodes.BaseNodesResponse;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.common.collect.Iterators;
Expand All @@ -26,10 +27,6 @@

public class NodesHotThreadsResponse extends BaseNodesResponse<NodeHotThreads> {

public NodesHotThreadsResponse(StreamInput in) throws IOException {
super(in);
}

public NodesHotThreadsResponse(ClusterName clusterName, List<NodeHotThreads> nodes, List<FailedNodeException> failures) {
super(clusterName, nodes, failures);
}
Expand All @@ -52,7 +49,7 @@ protected List<NodeHotThreads> readNodesFrom(StreamInput in) throws IOException

@Override
protected void writeNodesTo(StreamOutput out, List<NodeHotThreads> nodes) throws IOException {
out.writeCollection(nodes);
TransportAction.localOnly();
}

private static class LinesIterator implements Iterator<String> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,9 @@ public TransportNodesHotThreadsAction(
) {
super(
NodesHotThreadsAction.NAME,
threadPool,
clusterService,
transportService,
actionFilters,
NodesHotThreadsRequest::new,
NodeRequest::new,
threadPool.executor(ThreadPool.Names.GENERIC)
);
Expand Down Expand Up @@ -87,6 +85,7 @@ protected NodeHotThreads nodeOperation(NodeRequest request, Task task) {

public static class NodeRequest extends TransportRequest {

// TODO don't wrap the whole top-level request, it contains heavy and irrelevant DiscoveryNode things; see #100878
NodesHotThreadsRequest request;

public NodeRequest(StreamInput in) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
package org.elasticsearch.action.admin.cluster.node.info;

import org.elasticsearch.action.ActionType;
import org.elasticsearch.common.io.stream.Writeable;

public class NodesInfoAction extends ActionType<NodesInfoResponse> {

public static final NodesInfoAction INSTANCE = new NodesInfoAction();
public static final String NAME = "cluster:monitor/nodes/info";

private NodesInfoAction() {
super(NAME, NodesInfoResponse::new);
super(NAME, Writeable.Reader.localOnly());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
public class NodesInfoRequest extends BaseNodesRequest<NodesInfoRequest> {

private NodesInfoMetrics nodesInfoMetrics;
private final NodesInfoMetrics nodesInfoMetrics;

/**
* Create a new NodeInfoRequest from a {@link StreamInput} object.
Expand Down Expand Up @@ -118,20 +118,6 @@ public void writeTo(StreamOutput out) throws IOException {
nodesInfoMetrics.writeTo(out);
}

/**
* Helper method for creating NodesInfoRequests with desired metrics
* @param metrics the metrics to include in the request
* @return
*/
public static NodesInfoRequest requestWithMetrics(NodesInfoMetrics.Metric... metrics) {
NodesInfoRequest nodesInfoRequest = new NodesInfoRequest();
nodesInfoRequest.clear();
for (var metric : metrics) {
nodesInfoRequest.addMetric(metric.metricName());
}
return nodesInfoRequest;
}

public NodesInfoMetrics getNodesInfoMetrics() {
return nodesInfoMetrics;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package org.elasticsearch.action.admin.cluster.node.info;

import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.action.support.TransportAction;
import org.elasticsearch.action.support.nodes.BaseNodesResponse;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.cluster.node.DiscoveryNodeRole;
Expand All @@ -34,22 +35,18 @@

public class NodesInfoResponse extends BaseNodesResponse<NodeInfo> implements ToXContentFragment {

public NodesInfoResponse(StreamInput in) throws IOException {
super(in);
}

public NodesInfoResponse(ClusterName clusterName, List<NodeInfo> nodes, List<FailedNodeException> failures) {
super(clusterName, nodes, failures);
}

@Override
protected List<NodeInfo> readNodesFrom(StreamInput in) throws IOException {
return in.readCollectionAsList(NodeInfo::new);
return TransportAction.localOnly();
}

@Override
protected void writeNodesTo(StreamOutput out, List<NodeInfo> nodes) throws IOException {
out.writeCollection(nodes);
TransportAction.localOnly();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,9 @@ public TransportNodesInfoAction(
) {
super(
NodesInfoAction.NAME,
threadPool,
clusterService,
transportService,
actionFilters,
NodesInfoRequest::new,
NodeInfoRequest::new,
threadPool.executor(ThreadPool.Names.MANAGEMENT)
);
Expand Down Expand Up @@ -97,7 +95,7 @@ protected NodeInfo nodeOperation(NodeInfoRequest nodeRequest, Task task) {

public static class NodeInfoRequest extends TransportRequest {

private NodesInfoMetrics nodesInfoMetrics;
private final NodesInfoMetrics nodesInfoMetrics;

public NodeInfoRequest(StreamInput in) throws IOException {
super(in);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
package org.elasticsearch.action.admin.cluster.node.reload;

import org.elasticsearch.action.ActionType;
import org.elasticsearch.common.io.stream.Writeable;

public class NodesReloadSecureSettingsAction extends ActionType<NodesReloadSecureSettingsResponse> {

public static final NodesReloadSecureSettingsAction INSTANCE = new NodesReloadSecureSettingsAction();
public static final String NAME = "cluster:admin/nodes/reload_secure_settings";

private NodesReloadSecureSettingsAction() {
super(NAME, NodesReloadSecureSettingsResponse::new);
super(NAME, Writeable.Reader.localOnly());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ public void close() {
}

public static class NodeRequest extends TransportRequest implements Releasable {

// TODO don't wrap the whole top-level request, it contains heavy and irrelevant DiscoveryNode things; see #100878
NodesReloadSecureSettingsRequest request;

NodeRequest(StreamInput in) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.action.support.TransportAction;
import org.elasticsearch.action.support.nodes.BaseNodeResponse;
import org.elasticsearch.action.support.nodes.BaseNodesResponse;
import org.elasticsearch.cluster.ClusterName;
Expand All @@ -30,22 +31,18 @@ public class NodesReloadSecureSettingsResponse extends BaseNodesResponse<NodesRe
implements
ToXContentFragment {

public NodesReloadSecureSettingsResponse(StreamInput in) throws IOException {
super(in);
}

public NodesReloadSecureSettingsResponse(ClusterName clusterName, List<NodeResponse> nodes, List<FailedNodeException> failures) {
super(clusterName, nodes, failures);
}

@Override
protected List<NodesReloadSecureSettingsResponse.NodeResponse> readNodesFrom(StreamInput in) throws IOException {
return in.readCollectionAsList(NodeResponse::new);
return TransportAction.localOnly();
}

@Override
protected void writeNodesTo(StreamOutput out, List<NodesReloadSecureSettingsResponse.NodeResponse> nodes) throws IOException {
out.writeCollection(nodes);
TransportAction.localOnly();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,9 @@ public TransportNodesReloadSecureSettingsAction(
) {
super(
NodesReloadSecureSettingsAction.NAME,
threadPool,
clusterService,
transportService,
actionFilters,
NodesReloadSecureSettingsRequest::new,
NodesReloadSecureSettingsRequest.NodeRequest::new,
threadPool.executor(ThreadPool.Names.GENERIC)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

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

import org.elasticsearch.action.support.TransportAction;
import org.elasticsearch.action.support.nodes.BaseNodesRequest;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.index.shard.ShardId;

Expand All @@ -27,15 +27,10 @@ public PrevalidateShardPathRequest(Set<ShardId> shardIds, String... nodeIds) {
this.shardIds = Set.copyOf(Objects.requireNonNull(shardIds));
}

public PrevalidateShardPathRequest(StreamInput in) throws IOException {
super(in);
this.shardIds = in.readCollectionAsImmutableSet(ShardId::new);
}

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeCollection(shardIds);
TransportAction.localOnly();
}

public Set<ShardId> getShardIds() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package org.elasticsearch.action.admin.cluster.node.shutdown;

import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.action.support.TransportAction;
import org.elasticsearch.action.support.nodes.BaseNodesResponse;
import org.elasticsearch.cluster.ClusterName;
import org.elasticsearch.common.io.stream.StreamInput;
Expand All @@ -27,17 +28,13 @@ public PrevalidateShardPathResponse(
super(clusterName, nodes, failures);
}

public PrevalidateShardPathResponse(StreamInput in) throws IOException {
super(in);
}

@Override
protected List<NodePrevalidateShardPathResponse> readNodesFrom(StreamInput in) throws IOException {
return in.readCollectionAsList(NodePrevalidateShardPathResponse::new);
return TransportAction.localOnly();
}

@Override
protected void writeNodesTo(StreamOutput out, List<NodePrevalidateShardPathResponse> nodes) throws IOException {
out.writeCollection(nodes);
TransportAction.localOnly();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.NodeEnvironment;
import org.elasticsearch.index.IndexSettings;
Expand Down Expand Up @@ -46,7 +47,7 @@ public class TransportPrevalidateShardPathAction extends TransportNodesAction<
NodePrevalidateShardPathResponse> {

public static final String ACTION_NAME = "internal:admin/indices/prevalidate_shard_path";
public static final ActionType<PrevalidateShardPathResponse> TYPE = new ActionType<>(ACTION_NAME, PrevalidateShardPathResponse::new);
public static final ActionType<PrevalidateShardPathResponse> TYPE = new ActionType<>(ACTION_NAME, Writeable.Reader.localOnly());
private static final Logger logger = LogManager.getLogger(TransportPrevalidateShardPathAction.class);

private final TransportService transportService;
Expand All @@ -64,11 +65,9 @@ public TransportPrevalidateShardPathAction(
) {
super(
ACTION_NAME,
threadPool,
clusterService,
transportService,
actionFilters,
PrevalidateShardPathRequest::new,
NodePrevalidateShardPathRequest::new,
threadPool.executor(ThreadPool.Names.MANAGEMENT)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
package org.elasticsearch.action.admin.cluster.node.stats;

import org.elasticsearch.action.ActionType;
import org.elasticsearch.common.io.stream.Writeable;

public class NodesStatsAction extends ActionType<NodesStatsResponse> {

public static final NodesStatsAction INSTANCE = new NodesStatsAction();
public static final String NAME = "cluster:monitor/nodes/stats";

private NodesStatsAction() {
super(NAME, NodesStatsResponse::new);
super(NAME, Writeable.Reader.localOnly());
}
}
Loading