Skip to content

Commit 2d6c462

Browse files
Remove Obsolete BwC Serialization Logic (#39883)
* Remove Obsolete BwC Serialization Logic * Same as #39879, all Bwc logic related to pre-7.0 versions is obsolete in master (8.0) now
1 parent 97562a8 commit 2d6c462

File tree

70 files changed

+201
-1070
lines changed

Some content is hidden

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

70 files changed

+201
-1070
lines changed

modules/reindex/src/test/java/org/elasticsearch/index/reindex/RoundTripTests.java

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,10 @@ public void testReindexRequest() throws IOException {
6868
ReindexRequest tripped = new ReindexRequest(toInputByteStream(reindex));
6969
assertRequestEquals(reindex, tripped);
7070

71-
// Try slices=auto with a version that doesn't support it, which should fail
72-
reindex.setSlices(AbstractBulkByScrollRequest.AUTO_SLICES);
73-
Exception e = expectThrows(IllegalArgumentException.class, () -> toInputByteStream(Version.V_6_0_0_alpha1, reindex));
74-
assertEquals("Slices set as \"auto\" are not supported before version [6.1.0]. Found version [6.0.0-alpha1]", e.getMessage());
75-
7671
// Try regular slices with a version that doesn't support slices=auto, which should succeed
7772
reindex.setSlices(between(1, Integer.MAX_VALUE));
7873
tripped = new ReindexRequest(toInputByteStream(reindex));
79-
assertRequestEquals(Version.V_6_0_0_alpha1, reindex, tripped);
74+
assertRequestEquals(reindex, tripped);
8075
}
8176

8277
public void testUpdateByQueryRequest() throws IOException {
@@ -89,11 +84,6 @@ public void testUpdateByQueryRequest() throws IOException {
8984
assertRequestEquals(update, tripped);
9085
assertEquals(update.getPipeline(), tripped.getPipeline());
9186

92-
// Try slices=auto with a version that doesn't support it, which should fail
93-
update.setSlices(AbstractBulkByScrollRequest.AUTO_SLICES);
94-
Exception e = expectThrows(IllegalArgumentException.class, () -> toInputByteStream(Version.V_6_0_0_alpha1, update));
95-
assertEquals("Slices set as \"auto\" are not supported before version [6.1.0]. Found version [6.0.0-alpha1]", e.getMessage());
96-
9787
// Try regular slices with a version that doesn't support slices=auto, which should succeed
9888
update.setSlices(between(1, Integer.MAX_VALUE));
9989
tripped = new UpdateByQueryRequest(toInputByteStream(update));
@@ -107,11 +97,6 @@ public void testDeleteByQueryRequest() throws IOException {
10797
DeleteByQueryRequest tripped = new DeleteByQueryRequest(toInputByteStream(delete));
10898
assertRequestEquals(delete, tripped);
10999

110-
// Try slices=auto with a version that doesn't support it, which should fail
111-
delete.setSlices(AbstractBulkByScrollRequest.AUTO_SLICES);
112-
Exception e = expectThrows(IllegalArgumentException.class, () -> toInputByteStream(Version.V_6_0_0_alpha1, delete));
113-
assertEquals("Slices set as \"auto\" are not supported before version [6.1.0]. Found version [6.0.0-alpha1]", e.getMessage());
114-
115100
// Try regular slices with a version that doesn't support slices=auto, which should succeed
116101
delete.setSlices(between(1, Integer.MAX_VALUE));
117102
tripped = new DeleteByQueryRequest(toInputByteStream(delete));
@@ -139,7 +124,7 @@ private void randomRequest(AbstractBulkIndexByScrollRequest<?> request) {
139124
request.setScript(random().nextBoolean() ? null : randomScript());
140125
}
141126

142-
private void assertRequestEquals(Version version, ReindexRequest request, ReindexRequest tripped) {
127+
private void assertRequestEquals(ReindexRequest request, ReindexRequest tripped) {
143128
assertRequestEquals((AbstractBulkIndexByScrollRequest<?>) request, (AbstractBulkIndexByScrollRequest<?>) tripped);
144129
assertEquals(request.getDestination().version(), tripped.getDestination().version());
145130
assertEquals(request.getDestination().index(), tripped.getDestination().index());

server/src/main/java/org/elasticsearch/action/DocWriteResponse.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
*/
1919
package org.elasticsearch.action;
2020

21-
import org.elasticsearch.Version;
2221
import org.elasticsearch.action.support.WriteRequest;
2322
import org.elasticsearch.action.support.WriteRequest.RefreshPolicy;
2423
import org.elasticsearch.action.support.WriteResponse;
@@ -264,13 +263,8 @@ public void readFrom(StreamInput in) throws IOException {
264263
type = in.readString();
265264
id = in.readString();
266265
version = in.readZLong();
267-
if (in.getVersion().onOrAfter(Version.V_6_0_0_alpha1)) {
268-
seqNo = in.readZLong();
269-
primaryTerm = in.readVLong();
270-
} else {
271-
seqNo = UNASSIGNED_SEQ_NO;
272-
primaryTerm = UNASSIGNED_PRIMARY_TERM;
273-
}
266+
seqNo = in.readZLong();
267+
primaryTerm = in.readVLong();
274268
forcedRefresh = in.readBoolean();
275269
result = Result.readFrom(in);
276270
}
@@ -282,10 +276,8 @@ public void writeTo(StreamOutput out) throws IOException {
282276
out.writeString(type);
283277
out.writeString(id);
284278
out.writeZLong(version);
285-
if (out.getVersion().onOrAfter(Version.V_6_0_0_alpha1)) {
286-
out.writeZLong(seqNo);
287-
out.writeVLong(primaryTerm);
288-
}
279+
out.writeZLong(seqNo);
280+
out.writeVLong(primaryTerm);
289281
out.writeBoolean(forcedRefresh);
290282
result.writeTo(out);
291283
}

server/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequest.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,7 @@ public ClusterHealthRequest(StreamInput in) throws IOException {
8181
if (in.readBoolean()) {
8282
waitForEvents = Priority.readFrom(in);
8383
}
84-
if (in.getVersion().onOrAfter(Version.V_6_2_0)) {
85-
waitForNoInitializingShards = in.readBoolean();
86-
}
84+
waitForNoInitializingShards = in.readBoolean();
8785
if (in.getVersion().onOrAfter(Version.V_7_1_0)) {
8886
indicesOptions = IndicesOptions.readIndicesOptions(in);
8987
} else {
@@ -118,9 +116,7 @@ public void writeTo(StreamOutput out) throws IOException {
118116
out.writeBoolean(true);
119117
Priority.writeTo(waitForEvents, out);
120118
}
121-
if (out.getVersion().onOrAfter(Version.V_6_2_0)) {
122-
out.writeBoolean(waitForNoInitializingShards);
123-
}
119+
out.writeBoolean(waitForNoInitializingShards);
124120
if (out.getVersion().onOrAfter(Version.V_7_1_0)) {
125121
indicesOptions.writeIndicesOptions(out);
126122
}

server/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStats.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@
1919

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

22-
import org.elasticsearch.Version;
2322
import org.elasticsearch.action.support.nodes.BaseNodeResponse;
2423
import org.elasticsearch.cluster.node.DiscoveryNode;
2524
import org.elasticsearch.common.Nullable;
2625
import org.elasticsearch.common.io.stream.StreamInput;
2726
import org.elasticsearch.common.io.stream.StreamOutput;
28-
import org.elasticsearch.common.xcontent.ToXContent.Params;
2927
import org.elasticsearch.common.xcontent.ToXContentFragment;
3028
import org.elasticsearch.common.xcontent.XContentBuilder;
3129
import org.elasticsearch.discovery.DiscoveryStats;
@@ -235,11 +233,7 @@ public void readFrom(StreamInput in) throws IOException {
235233
scriptStats = in.readOptionalWriteable(ScriptStats::new);
236234
discoveryStats = in.readOptionalWriteable(DiscoveryStats::new);
237235
ingestStats = in.readOptionalWriteable(IngestStats::new);
238-
if (in.getVersion().onOrAfter(Version.V_6_1_0)) {
239-
adaptiveSelectionStats = in.readOptionalWriteable(AdaptiveSelectionStats::new);
240-
} else {
241-
adaptiveSelectionStats = null;
242-
}
236+
adaptiveSelectionStats = in.readOptionalWriteable(AdaptiveSelectionStats::new);
243237
}
244238

245239
@Override
@@ -263,9 +257,7 @@ public void writeTo(StreamOutput out) throws IOException {
263257
out.writeOptionalWriteable(scriptStats);
264258
out.writeOptionalWriteable(discoveryStats);
265259
out.writeOptionalWriteable(ingestStats);
266-
if (out.getVersion().onOrAfter(Version.V_6_1_0)) {
267-
out.writeOptionalWriteable(adaptiveSelectionStats);
268-
}
260+
out.writeOptionalWriteable(adaptiveSelectionStats);
269261
}
270262

271263
@Override

server/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsRequest.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

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

22-
import org.elasticsearch.Version;
2322
import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags;
2423
import org.elasticsearch.action.support.nodes.BaseNodesRequest;
2524
import org.elasticsearch.common.io.stream.StreamInput;
@@ -296,11 +295,7 @@ public void readFrom(StreamInput in) throws IOException {
296295
script = in.readBoolean();
297296
discovery = in.readBoolean();
298297
ingest = in.readBoolean();
299-
if (in.getVersion().onOrAfter(Version.V_6_1_0)) {
300-
adaptiveSelection = in.readBoolean();
301-
} else {
302-
adaptiveSelection = false;
303-
}
298+
adaptiveSelection = in.readBoolean();
304299
}
305300

306301
@Override
@@ -318,8 +313,6 @@ public void writeTo(StreamOutput out) throws IOException {
318313
out.writeBoolean(script);
319314
out.writeBoolean(discovery);
320315
out.writeBoolean(ingest);
321-
if (out.getVersion().onOrAfter(Version.V_6_1_0)) {
322-
out.writeBoolean(adaptiveSelection);
323-
}
316+
out.writeBoolean(adaptiveSelection);
324317
}
325318
}

server/src/main/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteResponse.java

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919

2020
package org.elasticsearch.action.admin.cluster.reroute;
2121

22-
import org.elasticsearch.Version;
2322
import org.elasticsearch.action.support.master.AcknowledgedResponse;
24-
import org.elasticsearch.cluster.ClusterModule;
2523
import org.elasticsearch.cluster.ClusterState;
2624
import org.elasticsearch.cluster.routing.allocation.RoutingExplanations;
2725
import org.elasticsearch.common.io.stream.StreamInput;
@@ -63,32 +61,16 @@ public RoutingExplanations getExplanations() {
6361

6462
@Override
6563
public void readFrom(StreamInput in) throws IOException {
66-
if (in.getVersion().onOrAfter(Version.V_6_4_0)) {
67-
super.readFrom(in);
68-
state = ClusterState.readFrom(in, null);
69-
explanations = RoutingExplanations.readFrom(in);
70-
} else {
71-
state = ClusterState.readFrom(in, null);
72-
acknowledged = in.readBoolean();
73-
explanations = RoutingExplanations.readFrom(in);
74-
}
64+
super.readFrom(in);
65+
state = ClusterState.readFrom(in, null);
66+
explanations = RoutingExplanations.readFrom(in);
7567
}
7668

7769
@Override
7870
public void writeTo(StreamOutput out) throws IOException {
79-
if (out.getVersion().onOrAfter(Version.V_6_4_0)) {
80-
super.writeTo(out);
81-
state.writeTo(out);
82-
RoutingExplanations.writeTo(explanations, out);
83-
} else {
84-
if (out.getVersion().onOrAfter(Version.V_6_3_0)) {
85-
state.writeTo(out);
86-
} else {
87-
ClusterModule.filterCustomsForPre63Clients(state).writeTo(out);
88-
}
89-
out.writeBoolean(acknowledged);
90-
RoutingExplanations.writeTo(explanations, out);
91-
}
71+
super.writeTo(out);
72+
state.writeTo(out);
73+
RoutingExplanations.writeTo(explanations, out);
9274
}
9375

9476
@Override

server/src/main/java/org/elasticsearch/action/admin/cluster/settings/ClusterUpdateSettingsResponse.java

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
package org.elasticsearch.action.admin.cluster.settings;
2121

22-
import org.elasticsearch.Version;
2322
import org.elasticsearch.action.support.master.AcknowledgedResponse;
2423
import org.elasticsearch.common.ParseField;
2524
import org.elasticsearch.common.io.stream.StreamInput;
@@ -68,15 +67,9 @@ public class ClusterUpdateSettingsResponse extends AcknowledgedResponse {
6867

6968
@Override
7069
public void readFrom(StreamInput in) throws IOException {
71-
if (in.getVersion().onOrAfter(Version.V_6_4_0)) {
72-
super.readFrom(in);
73-
transientSettings = Settings.readSettingsFromStream(in);
74-
persistentSettings = Settings.readSettingsFromStream(in);
75-
} else {
76-
transientSettings = Settings.readSettingsFromStream(in);
77-
persistentSettings = Settings.readSettingsFromStream(in);
78-
acknowledged = in.readBoolean();
79-
}
70+
super.readFrom(in);
71+
transientSettings = Settings.readSettingsFromStream(in);
72+
persistentSettings = Settings.readSettingsFromStream(in);
8073
}
8174

8275
public Settings getTransientSettings() {
@@ -89,15 +82,9 @@ public Settings getPersistentSettings() {
8982

9083
@Override
9184
public void writeTo(StreamOutput out) throws IOException {
92-
if (out.getVersion().onOrAfter(Version.V_6_4_0)) {
93-
super.writeTo(out);
94-
Settings.writeSettingsToStream(transientSettings, out);
95-
Settings.writeSettingsToStream(persistentSettings, out);
96-
} else {
97-
Settings.writeSettingsToStream(transientSettings, out);
98-
Settings.writeSettingsToStream(persistentSettings, out);
99-
out.writeBoolean(acknowledged);
100-
}
85+
super.writeTo(out);
86+
Settings.writeSettingsToStream(transientSettings, out);
87+
Settings.writeSettingsToStream(persistentSettings, out);
10188
}
10289

10390
@Override

server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/SnapshotStats.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
package org.elasticsearch.action.admin.cluster.snapshots.status;
2121

22-
import org.elasticsearch.Version;
2322
import org.elasticsearch.common.io.stream.StreamInput;
2423
import org.elasticsearch.common.io.stream.StreamOutput;
2524
import org.elasticsearch.common.io.stream.Streamable;
@@ -134,10 +133,8 @@ public void writeTo(StreamOutput out) throws IOException {
134133
out.writeVLong(incrementalSize);
135134
out.writeVLong(processedSize);
136135

137-
if (out.getVersion().onOrAfter(Version.V_6_4_0)) {
138-
out.writeVInt(totalFileCount);
139-
out.writeVLong(totalSize);
140-
}
136+
out.writeVInt(totalFileCount);
137+
out.writeVLong(totalSize);
141138
}
142139

143140
@Override
@@ -151,13 +148,8 @@ public void readFrom(StreamInput in) throws IOException {
151148
incrementalSize = in.readVLong();
152149
processedSize = in.readVLong();
153150

154-
if (in.getVersion().onOrAfter(Version.V_6_4_0)) {
155-
totalFileCount = in.readVInt();
156-
totalSize = in.readVLong();
157-
} else {
158-
totalFileCount = incrementalFileCount;
159-
totalSize = incrementalSize;
160-
}
151+
totalFileCount = in.readVInt();
152+
totalSize = in.readVLong();
161153
}
162154

163155
static final class Fields {

server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/SnapshotStatus.java

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

2020
package org.elasticsearch.action.admin.cluster.snapshots.status;
2121

22-
import org.elasticsearch.Version;
2322
import org.elasticsearch.cluster.SnapshotsInProgress;
2423
import org.elasticsearch.cluster.SnapshotsInProgress.State;
2524
import org.elasticsearch.common.ParseField;
@@ -169,9 +168,7 @@ public void readFrom(StreamInput in) throws IOException {
169168
builder.add(SnapshotIndexShardStatus.readShardSnapshotStatus(in));
170169
}
171170
shards = Collections.unmodifiableList(builder);
172-
if (in.getVersion().onOrAfter(Version.V_6_2_0)) {
173-
includeGlobalState = in.readOptionalBoolean();
174-
}
171+
includeGlobalState = in.readOptionalBoolean();
175172
updateShardStats();
176173
}
177174

@@ -183,9 +180,7 @@ public void writeTo(StreamOutput out) throws IOException {
183180
for (SnapshotIndexShardStatus shard : shards) {
184181
shard.writeTo(out);
185182
}
186-
if (out.getVersion().onOrAfter(Version.V_6_2_0)) {
187-
out.writeOptionalBoolean(includeGlobalState);
188-
}
183+
out.writeOptionalBoolean(includeGlobalState);
189184
}
190185

191186
/**

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
package org.elasticsearch.action.admin.cluster.state;
2121

22-
import org.elasticsearch.Version;
2322
import org.elasticsearch.action.ActionRequestValidationException;
2423
import org.elasticsearch.action.IndicesRequest;
2524
import org.elasticsearch.action.support.IndicesOptions;
@@ -57,10 +56,8 @@ public ClusterStateRequest(StreamInput in) throws IOException {
5756
customs = in.readBoolean();
5857
indices = in.readStringArray();
5958
indicesOptions = IndicesOptions.readIndicesOptions(in);
60-
if (in.getVersion().onOrAfter(Version.V_6_6_0)) {
61-
waitForTimeout = in.readTimeValue();
62-
waitForMetaDataVersion = in.readOptionalLong();
63-
}
59+
waitForTimeout = in.readTimeValue();
60+
waitForMetaDataVersion = in.readOptionalLong();
6461
}
6562

6663
@Override
@@ -73,10 +70,8 @@ public void writeTo(StreamOutput out) throws IOException {
7370
out.writeBoolean(customs);
7471
out.writeStringArray(indices);
7572
indicesOptions.writeIndicesOptions(out);
76-
if (out.getVersion().onOrAfter(Version.V_6_6_0)) {
77-
out.writeTimeValue(waitForTimeout);
78-
out.writeOptionalLong(waitForMetaDataVersion);
79-
}
73+
out.writeTimeValue(waitForTimeout);
74+
out.writeOptionalLong(waitForMetaDataVersion);
8075
}
8176

8277
@Override

0 commit comments

Comments
 (0)