Skip to content

Commit cc726cb

Browse files
authored
convert more admin requests to writeable (#26566)
1 parent 98f8bde commit cc726cb

File tree

37 files changed

+288
-209
lines changed

37 files changed

+288
-209
lines changed

core/src/main/java/org/elasticsearch/action/admin/cluster/repositories/get/GetRepositoriesRequest.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ public GetRepositoriesRequest(String[] repositories) {
5151
this.repositories = repositories;
5252
}
5353

54+
public GetRepositoriesRequest(StreamInput in) throws IOException {
55+
super(in);
56+
repositories = in.readStringArray();
57+
}
58+
59+
@Override
60+
public void writeTo(StreamOutput out) throws IOException {
61+
super.writeTo(out);
62+
out.writeStringArray(repositories);
63+
}
64+
5465
@Override
5566
public ActionRequestValidationException validate() {
5667
ActionRequestValidationException validationException = null;
@@ -85,13 +96,6 @@ public GetRepositoriesRequest repositories(String[] repositories) {
8596

8697
@Override
8798
public void readFrom(StreamInput in) throws IOException {
88-
super.readFrom(in);
89-
repositories = in.readStringArray();
90-
}
91-
92-
@Override
93-
public void writeTo(StreamOutput out) throws IOException {
94-
super.writeTo(out);
95-
out.writeStringArray(repositories);
99+
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
96100
}
97101
}

core/src/main/java/org/elasticsearch/action/admin/cluster/repositories/get/TransportGetRepositoriesAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class TransportGetRepositoriesAction extends TransportMasterNodeReadActio
5151
@Inject
5252
public TransportGetRepositoriesAction(Settings settings, TransportService transportService, ClusterService clusterService,
5353
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
54-
super(settings, GetRepositoriesAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, GetRepositoriesRequest::new);
54+
super(settings, GetRepositoriesAction.NAME, transportService, clusterService, threadPool, actionFilters, GetRepositoriesRequest::new, indexNameExpressionResolver);
5555
}
5656

5757
@Override

core/src/main/java/org/elasticsearch/action/admin/cluster/shards/ClusterSearchShardsRequest.java

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,42 @@ public ClusterSearchShardsRequest(String... indices) {
4949
indices(indices);
5050
}
5151

52+
public ClusterSearchShardsRequest(StreamInput in) throws IOException {
53+
super(in);
54+
indices = new String[in.readVInt()];
55+
for (int i = 0; i < indices.length; i++) {
56+
indices[i] = in.readString();
57+
}
58+
59+
routing = in.readOptionalString();
60+
preference = in.readOptionalString();
61+
62+
if (in.getVersion().onOrBefore(Version.V_5_1_1)) {
63+
//types
64+
in.readStringArray();
65+
}
66+
indicesOptions = IndicesOptions.readIndicesOptions(in);
67+
}
68+
69+
@Override
70+
public void writeTo(StreamOutput out) throws IOException {
71+
super.writeTo(out);
72+
73+
out.writeVInt(indices.length);
74+
for (String index : indices) {
75+
out.writeString(index);
76+
}
77+
78+
out.writeOptionalString(routing);
79+
out.writeOptionalString(preference);
80+
81+
if (out.getVersion().onOrBefore(Version.V_5_1_1)) {
82+
//types
83+
out.writeStringArray(Strings.EMPTY_ARRAY);
84+
}
85+
indicesOptions.writeIndicesOptions(out);
86+
}
87+
5288
@Override
5389
public ActionRequestValidationException validate() {
5490
return null;
@@ -124,40 +160,6 @@ public String preference() {
124160

125161
@Override
126162
public void readFrom(StreamInput in) throws IOException {
127-
super.readFrom(in);
128-
129-
indices = new String[in.readVInt()];
130-
for (int i = 0; i < indices.length; i++) {
131-
indices[i] = in.readString();
132-
}
133-
134-
routing = in.readOptionalString();
135-
preference = in.readOptionalString();
136-
137-
if (in.getVersion().onOrBefore(Version.V_5_1_1)) {
138-
//types
139-
in.readStringArray();
140-
}
141-
indicesOptions = IndicesOptions.readIndicesOptions(in);
142-
}
143-
144-
@Override
145-
public void writeTo(StreamOutput out) throws IOException {
146-
super.writeTo(out);
147-
148-
out.writeVInt(indices.length);
149-
for (String index : indices) {
150-
out.writeString(index);
151-
}
152-
153-
out.writeOptionalString(routing);
154-
out.writeOptionalString(preference);
155-
156-
if (out.getVersion().onOrBefore(Version.V_5_1_1)) {
157-
//types
158-
out.writeStringArray(Strings.EMPTY_ARRAY);
159-
}
160-
indicesOptions.writeIndicesOptions(out);
163+
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
161164
}
162-
163165
}

core/src/main/java/org/elasticsearch/action/admin/cluster/shards/TransportClusterSearchShardsAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public TransportClusterSearchShardsAction(Settings settings, TransportService tr
5454
IndicesService indicesService, ThreadPool threadPool, ActionFilters actionFilters,
5555
IndexNameExpressionResolver indexNameExpressionResolver) {
5656
super(settings, ClusterSearchShardsAction.NAME, transportService, clusterService, threadPool, actionFilters,
57-
indexNameExpressionResolver, ClusterSearchShardsRequest::new);
57+
ClusterSearchShardsRequest::new, indexNameExpressionResolver);
5858
this.indicesService = indicesService;
5959
}
6060

core/src/main/java/org/elasticsearch/action/admin/cluster/state/ClusterStateRequest.java

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,29 @@ public class ClusterStateRequest extends MasterNodeReadRequest<ClusterStateReque
4242
public ClusterStateRequest() {
4343
}
4444

45+
public ClusterStateRequest(StreamInput in) throws IOException {
46+
super(in);
47+
routingTable = in.readBoolean();
48+
nodes = in.readBoolean();
49+
metaData = in.readBoolean();
50+
blocks = in.readBoolean();
51+
customs = in.readBoolean();
52+
indices = in.readStringArray();
53+
indicesOptions = IndicesOptions.readIndicesOptions(in);
54+
}
55+
56+
@Override
57+
public void writeTo(StreamOutput out) throws IOException {
58+
super.writeTo(out);
59+
out.writeBoolean(routingTable);
60+
out.writeBoolean(nodes);
61+
out.writeBoolean(metaData);
62+
out.writeBoolean(blocks);
63+
out.writeBoolean(customs);
64+
out.writeStringArray(indices);
65+
indicesOptions.writeIndicesOptions(out);
66+
}
67+
4568
@Override
4669
public ActionRequestValidationException validate() {
4770
return null;
@@ -135,25 +158,6 @@ public boolean customs() {
135158

136159
@Override
137160
public void readFrom(StreamInput in) throws IOException {
138-
super.readFrom(in);
139-
routingTable = in.readBoolean();
140-
nodes = in.readBoolean();
141-
metaData = in.readBoolean();
142-
blocks = in.readBoolean();
143-
customs = in.readBoolean();
144-
indices = in.readStringArray();
145-
indicesOptions = IndicesOptions.readIndicesOptions(in);
146-
}
147-
148-
@Override
149-
public void writeTo(StreamOutput out) throws IOException {
150-
super.writeTo(out);
151-
out.writeBoolean(routingTable);
152-
out.writeBoolean(nodes);
153-
out.writeBoolean(metaData);
154-
out.writeBoolean(blocks);
155-
out.writeBoolean(customs);
156-
out.writeStringArray(indices);
157-
indicesOptions.writeIndicesOptions(out);
161+
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
158162
}
159163
}

core/src/main/java/org/elasticsearch/action/admin/cluster/state/TransportClusterStateAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class TransportClusterStateAction extends TransportMasterNodeReadAction<C
4747
@Inject
4848
public TransportClusterStateAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
4949
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
50-
super(settings, ClusterStateAction.NAME, false, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, ClusterStateRequest::new);
50+
super(settings, ClusterStateAction.NAME, false, transportService, clusterService, threadPool, actionFilters, ClusterStateRequest::new, indexNameExpressionResolver);
5151
}
5252

5353
@Override

core/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/GetStoredScriptRequest.java

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,26 @@ public GetStoredScriptRequest(String id) {
4343
this.id = id;
4444
}
4545

46+
public GetStoredScriptRequest(StreamInput in) throws IOException {
47+
super(in);
48+
if (in.getVersion().before(Version.V_6_0_0_alpha2)) {
49+
in.readString(); // read lang from previous versions
50+
}
51+
52+
id = in.readString();
53+
}
54+
55+
@Override
56+
public void writeTo(StreamOutput out) throws IOException {
57+
super.writeTo(out);
58+
59+
if (out.getVersion().before(Version.V_6_0_0_alpha2)) {
60+
out.writeString(""); // write an empty lang to previous versions
61+
}
62+
63+
out.writeString(id);
64+
}
65+
4666
@Override
4767
public ActionRequestValidationException validate() {
4868
ActionRequestValidationException validationException = null;
@@ -68,24 +88,7 @@ public GetStoredScriptRequest id(String id) {
6888

6989
@Override
7090
public void readFrom(StreamInput in) throws IOException {
71-
super.readFrom(in);
72-
73-
if (in.getVersion().before(Version.V_6_0_0_alpha2)) {
74-
in.readString(); // read lang from previous versions
75-
}
76-
77-
id = in.readString();
78-
}
79-
80-
@Override
81-
public void writeTo(StreamOutput out) throws IOException {
82-
super.writeTo(out);
83-
84-
if (out.getVersion().before(Version.V_6_0_0_alpha2)) {
85-
out.writeString(""); // write an empty lang to previous versions
86-
}
87-
88-
out.writeString(id);
91+
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
8992
}
9093

9194
@Override

core/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/TransportGetStoredScriptAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public TransportGetStoredScriptAction(Settings settings, TransportService transp
4343
ThreadPool threadPool, ActionFilters actionFilters,
4444
IndexNameExpressionResolver indexNameExpressionResolver, ScriptService scriptService) {
4545
super(settings, GetStoredScriptAction.NAME, transportService, clusterService, threadPool, actionFilters,
46-
indexNameExpressionResolver, GetStoredScriptRequest::new);
46+
GetStoredScriptRequest::new, indexNameExpressionResolver);
4747
this.scriptService = scriptService;
4848
}
4949

core/src/main/java/org/elasticsearch/action/admin/cluster/tasks/PendingClusterTasksRequest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,19 @@
2121

2222
import org.elasticsearch.action.ActionRequestValidationException;
2323
import org.elasticsearch.action.support.master.MasterNodeReadRequest;
24+
import org.elasticsearch.common.io.stream.StreamInput;
25+
26+
import java.io.IOException;
2427

2528
public class PendingClusterTasksRequest extends MasterNodeReadRequest<PendingClusterTasksRequest> {
2629

30+
public PendingClusterTasksRequest() {
31+
}
32+
33+
public PendingClusterTasksRequest(StreamInput in) throws IOException {
34+
super(in);
35+
}
36+
2737
@Override
2838
public ActionRequestValidationException validate() {
2939
return null;

core/src/main/java/org/elasticsearch/action/admin/cluster/tasks/TransportPendingClusterTasksAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public class TransportPendingClusterTasksAction extends TransportMasterNodeReadA
4242
@Inject
4343
public TransportPendingClusterTasksAction(Settings settings, TransportService transportService, ClusterService clusterService,
4444
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
45-
super(settings, PendingClusterTasksAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, PendingClusterTasksRequest::new);
45+
super(settings, PendingClusterTasksAction.NAME, transportService, clusterService, threadPool, actionFilters, PendingClusterTasksRequest::new, indexNameExpressionResolver);
4646
this.clusterService = clusterService;
4747
}
4848

0 commit comments

Comments
 (0)