Skip to content

Commit 0ea96e4

Browse files
authored
Convert BaseNode(s) Request/Response classes to Writeable (#44301)
This commit converts all BaseNodeResponse and BaseNodesResponse subclasses to implement Writeable.Reader instead of Streamable. relates #34389
1 parent 2316703 commit 0ea96e4

File tree

67 files changed

+522
-775
lines changed

Some content is hidden

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

67 files changed

+522
-775
lines changed

server/src/main/java/org/elasticsearch/action/admin/cluster/node/hotthreads/NodeHotThreads.java

+3-13
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ public class NodeHotThreads extends BaseNodeResponse {
3030

3131
private String hotThreads;
3232

33-
NodeHotThreads() {
33+
NodeHotThreads(StreamInput in) throws IOException {
34+
super(in);
35+
hotThreads = in.readString();
3436
}
3537

3638
public NodeHotThreads(DiscoveryNode node, String hotThreads) {
@@ -42,18 +44,6 @@ public String getHotThreads() {
4244
return this.hotThreads;
4345
}
4446

45-
public static NodeHotThreads readNodeHotThreads(StreamInput in) throws IOException {
46-
NodeHotThreads node = new NodeHotThreads();
47-
node.readFrom(in);
48-
return node;
49-
}
50-
51-
@Override
52-
public void readFrom(StreamInput in) throws IOException {
53-
super.readFrom(in);
54-
hotThreads = in.readString();
55-
}
56-
5747
@Override
5848
public void writeTo(StreamOutput out) throws IOException {
5949
super.writeTo(out);

server/src/main/java/org/elasticsearch/action/admin/cluster/node/hotthreads/NodesHotThreadsAction.java

+3-8
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,14 @@
1919

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

22-
import org.elasticsearch.action.StreamableResponseActionType;
22+
import org.elasticsearch.action.ActionType;
2323

24-
public class NodesHotThreadsAction extends StreamableResponseActionType<NodesHotThreadsResponse> {
24+
public class NodesHotThreadsAction extends ActionType<NodesHotThreadsResponse> {
2525

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

2929
private NodesHotThreadsAction() {
30-
super(NAME);
31-
}
32-
33-
@Override
34-
public NodesHotThreadsResponse newResponse() {
35-
return new NodesHotThreadsResponse();
30+
super(NAME, NodesHotThreadsResponse::new);
3631
}
3732
}

server/src/main/java/org/elasticsearch/action/admin/cluster/node/hotthreads/NodesHotThreadsRequest.java

+7-12
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,13 @@ public class NodesHotThreadsRequest extends BaseNodesRequest<NodesHotThreadsRequ
3636
boolean ignoreIdleThreads = true;
3737

3838
// for serialization
39-
public NodesHotThreadsRequest() {
40-
39+
public NodesHotThreadsRequest(StreamInput in) throws IOException {
40+
super(in);
41+
threads = in.readInt();
42+
ignoreIdleThreads = in.readBoolean();
43+
type = in.readString();
44+
interval = in.readTimeValue();
45+
snapshots = in.readInt();
4146
}
4247

4348
/**
@@ -93,16 +98,6 @@ public NodesHotThreadsRequest snapshots(int snapshots) {
9398
return this;
9499
}
95100

96-
@Override
97-
public void readFrom(StreamInput in) throws IOException {
98-
super.readFrom(in);
99-
threads = in.readInt();
100-
ignoreIdleThreads = in.readBoolean();
101-
type = in.readString();
102-
interval = in.readTimeValue();
103-
snapshots = in.readInt();
104-
}
105-
106101
@Override
107102
public void writeTo(StreamOutput out) throws IOException {
108103
super.writeTo(out);

server/src/main/java/org/elasticsearch/action/admin/cluster/node/hotthreads/NodesHotThreadsResponse.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030

3131
public class NodesHotThreadsResponse extends BaseNodesResponse<NodeHotThreads> {
3232

33-
NodesHotThreadsResponse() {
33+
public NodesHotThreadsResponse(StreamInput in) throws IOException {
34+
super(in);
3435
}
3536

3637
public NodesHotThreadsResponse(ClusterName clusterName, List<NodeHotThreads> nodes, List<FailedNodeException> failures) {
@@ -39,7 +40,7 @@ public NodesHotThreadsResponse(ClusterName clusterName, List<NodeHotThreads> nod
3940

4041
@Override
4142
protected List<NodeHotThreads> readNodesFrom(StreamInput in) throws IOException {
42-
return in.readList(NodeHotThreads::readNodeHotThreads);
43+
return in.readList(NodeHotThreads::new);
4344
}
4445

4546
@Override

server/src/main/java/org/elasticsearch/action/admin/cluster/node/hotthreads/TransportNodesHotThreadsAction.java

+5-10
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ protected NodeRequest newNodeRequest(NodesHotThreadsRequest request) {
6060
}
6161

6262
@Override
63-
protected NodeHotThreads newNodeResponse() {
64-
return new NodeHotThreads();
63+
protected NodeHotThreads newNodeResponse(StreamInput in) throws IOException {
64+
return new NodeHotThreads(in);
6565
}
6666

6767
@Override
@@ -83,20 +83,15 @@ public static class NodeRequest extends BaseNodeRequest {
8383

8484
NodesHotThreadsRequest request;
8585

86-
public NodeRequest() {
86+
public NodeRequest(StreamInput in) throws IOException {
87+
super(in);
88+
request = new NodesHotThreadsRequest(in);
8789
}
8890

8991
NodeRequest(NodesHotThreadsRequest request) {
9092
this.request = request;
9193
}
9294

93-
@Override
94-
public void readFrom(StreamInput in) throws IOException {
95-
super.readFrom(in);
96-
request = new NodesHotThreadsRequest();
97-
request.readFrom(in);
98-
}
99-
10095
@Override
10196
public void writeTo(StreamOutput out) throws IOException {
10297
super.writeTo(out);

server/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodeInfo.java

+20-30
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,26 @@ public class NodeInfo extends BaseNodeResponse {
7676
@Nullable
7777
private ByteSizeValue totalIndexingBuffer;
7878

79-
public NodeInfo() {
79+
public NodeInfo(StreamInput in) throws IOException {
80+
super(in);
81+
version = Version.readVersion(in);
82+
build = Build.readBuild(in);
83+
if (in.readBoolean()) {
84+
totalIndexingBuffer = new ByteSizeValue(in.readLong());
85+
} else {
86+
totalIndexingBuffer = null;
87+
}
88+
if (in.readBoolean()) {
89+
settings = Settings.readSettingsFromStream(in);
90+
}
91+
os = in.readOptionalWriteable(OsInfo::new);
92+
process = in.readOptionalWriteable(ProcessInfo::new);
93+
jvm = in.readOptionalWriteable(JvmInfo::new);
94+
threadPool = in.readOptionalWriteable(ThreadPoolInfo::new);
95+
transport = in.readOptionalWriteable(TransportInfo::new);
96+
http = in.readOptionalWriteable(HttpInfo::new);
97+
plugins = in.readOptionalWriteable(PluginsAndModules::new);
98+
ingest = in.readOptionalWriteable(IngestInfo::new);
8099
}
81100

82101
public NodeInfo(Version version, Build build, DiscoveryNode node, @Nullable Settings settings,
@@ -182,35 +201,6 @@ public ByteSizeValue getTotalIndexingBuffer() {
182201
return totalIndexingBuffer;
183202
}
184203

185-
public static NodeInfo readNodeInfo(StreamInput in) throws IOException {
186-
NodeInfo nodeInfo = new NodeInfo();
187-
nodeInfo.readFrom(in);
188-
return nodeInfo;
189-
}
190-
191-
@Override
192-
public void readFrom(StreamInput in) throws IOException {
193-
super.readFrom(in);
194-
version = Version.readVersion(in);
195-
build = Build.readBuild(in);
196-
if (in.readBoolean()) {
197-
totalIndexingBuffer = new ByteSizeValue(in.readLong());
198-
} else {
199-
totalIndexingBuffer = null;
200-
}
201-
if (in.readBoolean()) {
202-
settings = Settings.readSettingsFromStream(in);
203-
}
204-
os = in.readOptionalWriteable(OsInfo::new);
205-
process = in.readOptionalWriteable(ProcessInfo::new);
206-
jvm = in.readOptionalWriteable(JvmInfo::new);
207-
threadPool = in.readOptionalWriteable(ThreadPoolInfo::new);
208-
transport = in.readOptionalWriteable(TransportInfo::new);
209-
http = in.readOptionalWriteable(HttpInfo::new);
210-
plugins = in.readOptionalWriteable(PluginsAndModules::new);
211-
ingest = in.readOptionalWriteable(IngestInfo::new);
212-
}
213-
214204
@Override
215205
public void writeTo(StreamOutput out) throws IOException {
216206
super.writeTo(out);

server/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoAction.java

+3-8
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,14 @@
1919

2020
package org.elasticsearch.action.admin.cluster.node.info;
2121

22-
import org.elasticsearch.action.StreamableResponseActionType;
22+
import org.elasticsearch.action.ActionType;
2323

24-
public class NodesInfoAction extends StreamableResponseActionType<NodesInfoResponse> {
24+
public class NodesInfoAction extends ActionType<NodesInfoResponse> {
2525

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

2929
private NodesInfoAction() {
30-
super(NAME);
31-
}
32-
33-
@Override
34-
public NodesInfoResponse newResponse() {
35-
return new NodesInfoResponse();
30+
super(NAME, NodesInfoResponse::new);
3631
}
3732
}

server/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoRequest.java

+12-16
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,18 @@ public class NodesInfoRequest extends BaseNodesRequest<NodesInfoRequest> {
4141
private boolean ingest = true;
4242
private boolean indices = true;
4343

44-
public NodesInfoRequest() {
44+
public NodesInfoRequest(StreamInput in) throws IOException {
45+
super(in);
46+
settings = in.readBoolean();
47+
os = in.readBoolean();
48+
process = in.readBoolean();
49+
jvm = in.readBoolean();
50+
threadPool = in.readBoolean();
51+
transport = in.readBoolean();
52+
http = in.readBoolean();
53+
plugins = in.readBoolean();
54+
ingest = in.readBoolean();
55+
indices = in.readBoolean();
4556
}
4657

4758
/**
@@ -240,21 +251,6 @@ public boolean indices() {
240251
return indices;
241252
}
242253

243-
@Override
244-
public void readFrom(StreamInput in) throws IOException {
245-
super.readFrom(in);
246-
settings = in.readBoolean();
247-
os = in.readBoolean();
248-
process = in.readBoolean();
249-
jvm = in.readBoolean();
250-
threadPool = in.readBoolean();
251-
transport = in.readBoolean();
252-
http = in.readBoolean();
253-
plugins = in.readBoolean();
254-
ingest = in.readBoolean();
255-
indices = in.readBoolean();
256-
}
257-
258254
@Override
259255
public void writeTo(StreamOutput out) throws IOException {
260256
super.writeTo(out);

server/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoResponse.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737

3838
public class NodesInfoResponse extends BaseNodesResponse<NodeInfo> implements ToXContentFragment {
3939

40-
public NodesInfoResponse() {
40+
public NodesInfoResponse(StreamInput in) throws IOException {
41+
super(in);
4142
}
4243

4344
public NodesInfoResponse(ClusterName clusterName, List<NodeInfo> nodes, List<FailedNodeException> failures) {
@@ -46,7 +47,7 @@ public NodesInfoResponse(ClusterName clusterName, List<NodeInfo> nodes, List<Fai
4647

4748
@Override
4849
protected List<NodeInfo> readNodesFrom(StreamInput in) throws IOException {
49-
return in.readList(NodeInfo::readNodeInfo);
50+
return in.readList(NodeInfo::new);
5051
}
5152

5253
@Override

server/src/main/java/org/elasticsearch/action/admin/cluster/node/info/TransportNodesInfoAction.java

+5-10
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ protected NodeInfoRequest newNodeRequest(NodesInfoRequest request) {
6262
}
6363

6464
@Override
65-
protected NodeInfo newNodeResponse() {
66-
return new NodeInfo();
65+
protected NodeInfo newNodeResponse(StreamInput in) throws IOException {
66+
return new NodeInfo(in);
6767
}
6868

6969
@Override
@@ -77,20 +77,15 @@ public static class NodeInfoRequest extends BaseNodeRequest {
7777

7878
NodesInfoRequest request;
7979

80-
public NodeInfoRequest() {
80+
public NodeInfoRequest(StreamInput in) throws IOException {
81+
super(in);
82+
request = new NodesInfoRequest(in);
8183
}
8284

8385
public NodeInfoRequest(NodesInfoRequest request) {
8486
this.request = request;
8587
}
8688

87-
@Override
88-
public void readFrom(StreamInput in) throws IOException {
89-
super.readFrom(in);
90-
request = new NodesInfoRequest();
91-
request.readFrom(in);
92-
}
93-
9489
@Override
9590
public void writeTo(StreamOutput out) throws IOException {
9691
super.writeTo(out);

server/src/main/java/org/elasticsearch/action/admin/cluster/node/reload/NodesReloadSecureSettingsAction.java

+3-10
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,14 @@
1919

2020
package org.elasticsearch.action.admin.cluster.node.reload;
2121

22-
import org.elasticsearch.action.StreamableResponseActionType;
22+
import org.elasticsearch.action.ActionType;
2323

24-
public class NodesReloadSecureSettingsAction
25-
extends StreamableResponseActionType<NodesReloadSecureSettingsResponse> {
24+
public class NodesReloadSecureSettingsAction extends ActionType<NodesReloadSecureSettingsResponse> {
2625

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

3029
private NodesReloadSecureSettingsAction() {
31-
super(NAME);
30+
super(NAME, NodesReloadSecureSettingsResponse::new);
3231
}
33-
34-
@Override
35-
public NodesReloadSecureSettingsResponse newResponse() {
36-
return new NodesReloadSecureSettingsResponse();
37-
}
38-
3932
}

server/src/main/java/org/elasticsearch/action/admin/cluster/node/reload/NodesReloadSecureSettingsRequest.java

+8
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,21 @@
2020
package org.elasticsearch.action.admin.cluster.node.reload;
2121

2222
import org.elasticsearch.action.support.nodes.BaseNodesRequest;
23+
import org.elasticsearch.common.io.stream.StreamInput;
24+
25+
import java.io.IOException;
2326

2427
/**
2528
* Request for a reload secure settings action.
2629
*/
2730
public class NodesReloadSecureSettingsRequest extends BaseNodesRequest<NodesReloadSecureSettingsRequest> {
2831

2932
public NodesReloadSecureSettingsRequest() {
33+
super((String[]) null);
34+
}
35+
36+
public NodesReloadSecureSettingsRequest(StreamInput in) throws IOException {
37+
super(in);
3038
}
3139

3240
/**

0 commit comments

Comments
 (0)