Skip to content

Commit d1d2977

Browse files
authored
Cleanup shutdown module bwc in v9 (#112793)
Removes a bunch of now-unnecessary bwc code in the shutdown module.
1 parent cd8d37b commit d1d2977

10 files changed

+15
-112
lines changed

x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/DeleteShutdownNodeAction.java

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,9 @@
1515
import org.elasticsearch.common.io.stream.StreamInput;
1616
import org.elasticsearch.common.io.stream.StreamOutput;
1717
import org.elasticsearch.core.TimeValue;
18-
import org.elasticsearch.core.UpdateForV9;
1918

2019
import java.io.IOException;
2120

22-
import static org.elasticsearch.xpack.shutdown.ShutdownPlugin.serializesWithParentTaskAndTimeouts;
23-
2421
public class DeleteShutdownNodeAction extends ActionType<AcknowledgedResponse> {
2522

2623
public static final DeleteShutdownNodeAction INSTANCE = new DeleteShutdownNodeAction();
@@ -39,32 +36,14 @@ public Request(TimeValue masterNodeTimeout, TimeValue ackTimeout, String nodeId)
3936
this.nodeId = nodeId;
4037
}
4138

42-
@UpdateForV9 // inline when bwc no longer needed
43-
public static Request readFrom(StreamInput in) throws IOException {
44-
if (serializesWithParentTaskAndTimeouts(in.getTransportVersion())) {
45-
return new Request(in);
46-
} else {
47-
return new Request(TimeValue.THIRTY_SECONDS, TimeValue.THIRTY_SECONDS, in);
48-
}
49-
}
50-
51-
private Request(StreamInput in) throws IOException {
39+
public Request(StreamInput in) throws IOException {
5240
super(in);
53-
assert serializesWithParentTaskAndTimeouts(in.getTransportVersion());
5441
this.nodeId = in.readString();
5542
}
5643

57-
@UpdateForV9 // remove when bwc no longer needed
58-
private Request(TimeValue masterNodeTimeout, TimeValue ackTimeout, StreamInput in) throws IOException {
59-
this(masterNodeTimeout, ackTimeout, in.readString());
60-
assert serializesWithParentTaskAndTimeouts(in.getTransportVersion()) == false;
61-
}
62-
6344
@Override
6445
public void writeTo(StreamOutput out) throws IOException {
65-
if (serializesWithParentTaskAndTimeouts(out.getTransportVersion())) {
66-
super.writeTo(out);
67-
}
46+
super.writeTo(out);
6847
out.writeString(this.nodeId);
6948
}
7049

x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/GetShutdownStatusAction.java

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
package org.elasticsearch.xpack.shutdown;
99

10-
import org.elasticsearch.TransportVersions;
1110
import org.elasticsearch.action.ActionRequestValidationException;
1211
import org.elasticsearch.action.ActionResponse;
1312
import org.elasticsearch.action.ActionType;
@@ -19,7 +18,6 @@
1918
import org.elasticsearch.common.xcontent.ChunkedToXContentHelper;
2019
import org.elasticsearch.common.xcontent.ChunkedToXContentObject;
2120
import org.elasticsearch.core.TimeValue;
22-
import org.elasticsearch.core.UpdateForV9;
2321
import org.elasticsearch.tasks.CancellableTask;
2422
import org.elasticsearch.tasks.Task;
2523
import org.elasticsearch.tasks.TaskId;
@@ -50,33 +48,14 @@ public Request(TimeValue masterNodeTimeout, String... nodeIds) {
5048
this.nodeIds = nodeIds;
5149
}
5250

53-
@UpdateForV9 // only needed for bwc, inline in v9
54-
public static Request readFrom(StreamInput in) throws IOException {
55-
if (in.getTransportVersion().onOrAfter(TransportVersions.GET_SHUTDOWN_STATUS_TIMEOUT)) {
56-
return new Request(in);
57-
} else {
58-
return new Request(TimeValue.THIRTY_SECONDS, in);
59-
}
60-
}
61-
62-
private Request(StreamInput in) throws IOException {
51+
public Request(StreamInput in) throws IOException {
6352
super(in);
64-
assert in.getTransportVersion().onOrAfter(TransportVersions.GET_SHUTDOWN_STATUS_TIMEOUT);
65-
nodeIds = in.readStringArray();
66-
}
67-
68-
@UpdateForV9 // only needed for bwc, remove in v9
69-
private Request(TimeValue masterNodeTimeout, StreamInput in) throws IOException {
70-
super(masterNodeTimeout);
71-
assert in.getTransportVersion().before(TransportVersions.GET_SHUTDOWN_STATUS_TIMEOUT);
7253
nodeIds = in.readStringArray();
7354
}
7455

7556
@Override
7657
public void writeTo(StreamOutput out) throws IOException {
77-
if (out.getTransportVersion().onOrAfter(TransportVersions.GET_SHUTDOWN_STATUS_TIMEOUT)) {
78-
super.writeTo(out);
79-
}
58+
super.writeTo(out);
8059
out.writeStringArray(this.nodeIds);
8160
}
8261

x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/PutShutdownNodeAction.java

Lines changed: 5 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,13 @@
1717
import org.elasticsearch.common.io.stream.StreamOutput;
1818
import org.elasticsearch.core.Nullable;
1919
import org.elasticsearch.core.TimeValue;
20-
import org.elasticsearch.core.UpdateForV9;
2120
import org.elasticsearch.xcontent.ConstructingObjectParser;
2221
import org.elasticsearch.xcontent.ParseField;
2322
import org.elasticsearch.xcontent.XContentParser;
2423

2524
import java.io.IOException;
2625

27-
import static org.elasticsearch.cluster.metadata.SingleNodeShutdownMetadata.GRACE_PERIOD_ADDED_VERSION;
28-
import static org.elasticsearch.cluster.metadata.SingleNodeShutdownMetadata.REPLACE_SHUTDOWN_TYPE_ADDED_VERSION;
2926
import static org.elasticsearch.core.Strings.format;
30-
import static org.elasticsearch.xpack.shutdown.ShutdownPlugin.serializesWithParentTaskAndTimeouts;
3127

3228
public class PutShutdownNodeAction extends ActionType<AcknowledgedResponse> {
3329

@@ -112,18 +108,8 @@ public Request(
112108
this.gracePeriod = gracePeriod;
113109
}
114110

115-
@UpdateForV9 // inline when bwc no longer needed
116-
public static Request readFrom(StreamInput in) throws IOException {
117-
if (serializesWithParentTaskAndTimeouts(in.getTransportVersion())) {
118-
return new Request(in);
119-
} else {
120-
return new Request(TimeValue.THIRTY_SECONDS, TimeValue.THIRTY_SECONDS, in);
121-
}
122-
}
123-
124-
private Request(StreamInput in) throws IOException {
111+
public Request(StreamInput in) throws IOException {
125112
super(in);
126-
assert serializesWithParentTaskAndTimeouts(in.getTransportVersion());
127113
this.nodeId = in.readString();
128114
this.type = in.readEnum(SingleNodeShutdownMetadata.Type.class);
129115
this.reason = in.readString();
@@ -132,46 +118,15 @@ private Request(StreamInput in) throws IOException {
132118
this.gracePeriod = in.readOptionalTimeValue();
133119
}
134120

135-
@UpdateForV9 // remove when bwc no longer needed
136-
private Request(TimeValue masterNodeTimeout, TimeValue ackTimeout, StreamInput in) throws IOException {
137-
super(masterNodeTimeout, ackTimeout);
138-
assert serializesWithParentTaskAndTimeouts(in.getTransportVersion()) == false;
139-
this.nodeId = in.readString();
140-
this.type = in.readEnum(SingleNodeShutdownMetadata.Type.class);
141-
this.reason = in.readString();
142-
this.allocationDelay = in.readOptionalTimeValue();
143-
if (in.getTransportVersion().onOrAfter(REPLACE_SHUTDOWN_TYPE_ADDED_VERSION)) {
144-
this.targetNodeName = in.readOptionalString();
145-
} else {
146-
this.targetNodeName = null;
147-
}
148-
if (in.getTransportVersion().onOrAfter(GRACE_PERIOD_ADDED_VERSION)) {
149-
this.gracePeriod = in.readOptionalTimeValue();
150-
} else {
151-
this.gracePeriod = null;
152-
}
153-
}
154-
155121
@Override
156122
public void writeTo(StreamOutput out) throws IOException {
157-
if (serializesWithParentTaskAndTimeouts(out.getTransportVersion())) {
158-
super.writeTo(out);
159-
}
123+
super.writeTo(out);
160124
out.writeString(nodeId);
161-
if (out.getTransportVersion().before(REPLACE_SHUTDOWN_TYPE_ADDED_VERSION)
162-
&& this.type == SingleNodeShutdownMetadata.Type.REPLACE) {
163-
out.writeEnum(SingleNodeShutdownMetadata.Type.REMOVE);
164-
} else {
165-
out.writeEnum(type);
166-
}
125+
out.writeEnum(type);
167126
out.writeString(reason);
168127
out.writeOptionalTimeValue(allocationDelay);
169-
if (out.getTransportVersion().onOrAfter(REPLACE_SHUTDOWN_TYPE_ADDED_VERSION)) {
170-
out.writeOptionalString(targetNodeName);
171-
}
172-
if (out.getTransportVersion().onOrAfter(GRACE_PERIOD_ADDED_VERSION)) {
173-
out.writeOptionalTimeValue(gracePeriod);
174-
}
128+
out.writeOptionalString(targetNodeName);
129+
out.writeOptionalTimeValue(gracePeriod);
175130
}
176131

177132
public String getNodeId() {

x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/ShutdownPlugin.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
*/
77
package org.elasticsearch.xpack.shutdown;
88

9-
import org.elasticsearch.TransportVersion;
10-
import org.elasticsearch.TransportVersions;
119
import org.elasticsearch.action.ActionRequest;
1210
import org.elasticsearch.action.ActionResponse;
1311
import org.elasticsearch.action.support.master.AcknowledgedResponse;
@@ -18,7 +16,6 @@
1816
import org.elasticsearch.common.settings.IndexScopedSettings;
1917
import org.elasticsearch.common.settings.Settings;
2018
import org.elasticsearch.common.settings.SettingsFilter;
21-
import org.elasticsearch.core.UpdateForV9;
2219
import org.elasticsearch.features.NodeFeature;
2320
import org.elasticsearch.plugins.ActionPlugin;
2421
import org.elasticsearch.plugins.Plugin;
@@ -72,11 +69,4 @@ public List<RestHandler> getRestHandlers(
7269
) {
7370
return Arrays.asList(new RestPutShutdownNodeAction(), new RestDeleteShutdownNodeAction(), new RestGetShutdownStatusAction());
7471
}
75-
76-
@UpdateForV9 // always true in v9 so can be removed
77-
static boolean serializesWithParentTaskAndTimeouts(TransportVersion transportVersion) {
78-
return transportVersion.isPatchFrom(TransportVersions.V_8_13_4)
79-
|| transportVersion.isPatchFrom(TransportVersions.V_8_14_0)
80-
|| transportVersion.onOrAfter(TransportVersions.SHUTDOWN_REQUEST_TIMEOUTS_FIX);
81-
}
8272
}

x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportDeleteShutdownNodeAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public TransportDeleteShutdownNodeAction(
120120
clusterService,
121121
threadPool,
122122
actionFilters,
123-
Request::readFrom,
123+
Request::new,
124124
indexNameExpressionResolver,
125125
EsExecutors.DIRECT_EXECUTOR_SERVICE
126126
);

x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public TransportGetShutdownStatusAction(
8888
clusterService,
8989
threadPool,
9090
actionFilters,
91-
GetShutdownStatusAction.Request::readFrom,
91+
GetShutdownStatusAction.Request::new,
9292
indexNameExpressionResolver,
9393
GetShutdownStatusAction.Response::new,
9494
threadPool.executor(ThreadPool.Names.MANAGEMENT)

x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/TransportPutShutdownNodeAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public TransportPutShutdownNodeAction(
156156
clusterService,
157157
threadPool,
158158
actionFilters,
159-
Request::readFrom,
159+
Request::new,
160160
indexNameExpressionResolver,
161161
EsExecutors.DIRECT_EXECUTOR_SERVICE
162162
);

x-pack/plugin/shutdown/src/test/java/org/elasticsearch/xpack/shutdown/DeleteShutdownRequestTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void writeTo(StreamOutput out) throws IOException {
3333
@Override
3434
protected Writeable.Reader<RequestWrapper> instanceReader() {
3535
return in -> {
36-
final var request = DeleteShutdownNodeAction.Request.readFrom(in);
36+
final var request = new DeleteShutdownNodeAction.Request(in);
3737
return new RequestWrapper(request.getNodeId(), request.getParentTask(), request.masterNodeTimeout(), request.ackTimeout());
3838
};
3939
}

x-pack/plugin/shutdown/src/test/java/org/elasticsearch/xpack/shutdown/GetShutdownStatusRequestTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class GetShutdownStatusRequestTests extends AbstractWireSerializingTestCa
1919

2020
@Override
2121
protected Writeable.Reader<GetShutdownStatusAction.Request> instanceReader() {
22-
return GetShutdownStatusAction.Request::readFrom;
22+
return GetShutdownStatusAction.Request::new;
2323
}
2424

2525
@Override

x-pack/plugin/shutdown/src/test/java/org/elasticsearch/xpack/shutdown/PutShutdownRequestTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public void writeTo(StreamOutput out) throws IOException {
5353
@Override
5454
protected Writeable.Reader<RequestWrapper> instanceReader() {
5555
return in -> {
56-
final var request = PutShutdownNodeAction.Request.readFrom(in);
56+
final var request = new PutShutdownNodeAction.Request(in);
5757
return new RequestWrapper(
5858
request.getNodeId(),
5959
request.getType(),

0 commit comments

Comments
 (0)