Skip to content

Commit 6ce707c

Browse files
authored
Remove usages of 8_7_X transport versions (#136337)
1 parent 56b4cb5 commit 6ce707c

File tree

39 files changed

+78
-437
lines changed

39 files changed

+78
-437
lines changed

modules/aggregations/src/main/java/org/elasticsearch/aggregations/metric/MatrixStatsAggregationBuilder.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
package org.elasticsearch.aggregations.metric;
1010

1111
import org.elasticsearch.TransportVersion;
12-
import org.elasticsearch.TransportVersions;
1312
import org.elasticsearch.common.io.stream.StreamInput;
1413
import org.elasticsearch.common.io.stream.StreamOutput;
1514
import org.elasticsearch.search.MultiValueMode;
@@ -57,16 +56,12 @@ public boolean supportsSampling() {
5756
*/
5857
public MatrixStatsAggregationBuilder(StreamInput in) throws IOException {
5958
super(in);
60-
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
61-
multiValueMode = MultiValueMode.readMultiValueModeFrom(in);
62-
}
59+
multiValueMode = MultiValueMode.readMultiValueModeFrom(in);
6360
}
6461

6562
@Override
6663
protected void innerWriteTo(StreamOutput out) throws IOException {
67-
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
68-
multiValueMode.writeTo(out);
69-
}
64+
multiValueMode.writeTo(out);
7065
}
7166

7267
public MatrixStatsAggregationBuilder multiValueMode(MultiValueMode multiValueMode) {

server/src/main/java/org/elasticsearch/TransportVersions.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ static TransportVersion def(int id) {
6161
public static final TransportVersion V_7_9_0 = def(7_09_00_99);
6262
public static final TransportVersion V_7_10_0 = def(7_10_00_99);
6363
public static final TransportVersion V_8_0_0 = def(8_00_00_99);
64-
public static final TransportVersion V_8_7_0 = def(8_07_00_99);
65-
public static final TransportVersion V_8_7_1 = def(8_07_01_99);
6664
public static final TransportVersion V_8_8_0 = def(8_08_00_99);
6765
public static final TransportVersion V_8_8_1 = def(8_08_01_99);
6866
/*

server/src/main/java/org/elasticsearch/action/admin/cluster/node/shutdown/NodesRemovalPrevalidation.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

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

12-
import org.elasticsearch.TransportVersions;
1312
import org.elasticsearch.common.io.stream.StreamInput;
1413
import org.elasticsearch.common.io.stream.StreamOutput;
1514
import org.elasticsearch.common.io.stream.Writeable;
@@ -149,16 +148,11 @@ static <T> void configureParser(ConstructingObjectParser<T, Void> parser) {
149148
@Override
150149
public void writeTo(StreamOutput out) throws IOException {
151150
out.writeBoolean(isSafe);
152-
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
153-
reason.writeTo(out);
154-
}
151+
reason.writeTo(out);
155152
out.writeString(message);
156153
}
157154

158155
public static Result readFrom(final StreamInput in) throws IOException {
159-
if (in.getTransportVersion().before(TransportVersions.V_8_7_0)) {
160-
return new Result(in.readBoolean(), null, in.readString());
161-
}
162156
return new Result(in.readBoolean(), Reason.readFrom(in), in.readString());
163157
}
164158

server/src/main/java/org/elasticsearch/action/admin/cluster/node/shutdown/PrevalidateNodeRemovalRequest.java

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

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

12-
import org.elasticsearch.TransportVersions;
1312
import org.elasticsearch.action.ActionRequestValidationException;
1413
import org.elasticsearch.action.support.master.MasterNodeReadRequest;
1514
import org.elasticsearch.common.Strings;
@@ -46,9 +45,7 @@ public PrevalidateNodeRemovalRequest(final StreamInput in) throws IOException {
4645
names = in.readStringArray();
4746
ids = in.readStringArray();
4847
externalIds = in.readStringArray();
49-
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
50-
timeout = in.readTimeValue();
51-
}
48+
timeout = in.readTimeValue();
5249
}
5350

5451
@Override
@@ -57,9 +54,7 @@ public void writeTo(StreamOutput out) throws IOException {
5754
out.writeStringArray(names);
5855
out.writeStringArray(ids);
5956
out.writeStringArray(externalIds);
60-
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
61-
out.writeTimeValue(timeout);
62-
}
57+
out.writeTimeValue(timeout);
6358
}
6459

6560
@Override

server/src/main/java/org/elasticsearch/action/ingest/SimulateProcessorResult.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
package org.elasticsearch.action.ingest;
1010

1111
import org.elasticsearch.ElasticsearchException;
12-
import org.elasticsearch.TransportVersions;
1312
import org.elasticsearch.common.io.stream.StreamInput;
1413
import org.elasticsearch.common.io.stream.StreamOutput;
1514
import org.elasticsearch.common.io.stream.Writeable;
@@ -173,11 +172,7 @@ public SimulateProcessorResult(String type, String processorTag, String descript
173172
* Read from a stream.
174173
*/
175174
SimulateProcessorResult(StreamInput in) throws IOException {
176-
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
177-
this.processorTag = in.readOptionalString();
178-
} else {
179-
this.processorTag = in.readString();
180-
}
175+
this.processorTag = in.readOptionalString();
181176
this.ingestDocument = in.readOptionalWriteable(WriteableIngestDocument::new);
182177
this.failure = in.readException();
183178
this.description = in.readOptionalString();
@@ -192,11 +187,7 @@ public SimulateProcessorResult(String type, String processorTag, String descript
192187

193188
@Override
194189
public void writeTo(StreamOutput out) throws IOException {
195-
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
196-
out.writeOptionalString(processorTag);
197-
} else {
198-
out.writeString(processorTag);
199-
}
190+
out.writeOptionalString(processorTag);
200191
out.writeOptionalWriteable(ingestDocument);
201192
out.writeException(failure);
202193
out.writeOptionalString(description);

server/src/main/java/org/elasticsearch/cluster/metadata/ComposableIndexTemplate.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,7 @@ public ComposableIndexTemplate(StreamInput in) throws IOException {
174174
this.metadata = in.readGenericMap();
175175
this.dataStreamTemplate = in.readOptionalWriteable(DataStreamTemplate::new);
176176
this.allowAutoCreate = in.readOptionalBoolean();
177-
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
178-
this.ignoreMissingComponentTemplates = in.readOptionalStringCollectionAsList();
179-
} else {
180-
this.ignoreMissingComponentTemplates = null;
181-
}
177+
this.ignoreMissingComponentTemplates = in.readOptionalStringCollectionAsList();
182178
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_12_0)) {
183179
this.deprecated = in.readOptionalBoolean();
184180
} else {
@@ -295,9 +291,7 @@ public void writeTo(StreamOutput out) throws IOException {
295291
out.writeGenericMap(this.metadata);
296292
out.writeOptionalWriteable(dataStreamTemplate);
297293
out.writeOptionalBoolean(allowAutoCreate);
298-
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
299-
out.writeOptionalStringCollection(ignoreMissingComponentTemplates);
300-
}
294+
out.writeOptionalStringCollection(ignoreMissingComponentTemplates);
301295
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_12_0)) {
302296
out.writeOptionalBoolean(deprecated);
303297
}

server/src/main/java/org/elasticsearch/cluster/metadata/DataStreamAlias.java

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
*/
99
package org.elasticsearch.cluster.metadata;
1010

11-
import org.elasticsearch.TransportVersions;
1211
import org.elasticsearch.cluster.Diff;
1312
import org.elasticsearch.cluster.SimpleDiffable;
1413
import org.elasticsearch.common.ParsingException;
@@ -168,21 +167,7 @@ public DataStreamAlias(StreamInput in) throws IOException {
168167
this.name = in.readString();
169168
this.dataStreams = in.readStringCollectionAsList();
170169
this.writeDataStream = in.readOptionalString();
171-
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
172-
this.dataStreamToFilterMap = in.readMap(CompressedXContent::readCompressedString);
173-
} else {
174-
this.dataStreamToFilterMap = new HashMap<>();
175-
CompressedXContent filter = in.readBoolean() ? CompressedXContent.readCompressedString(in) : null;
176-
if (filter != null) {
177-
/*
178-
* Here we're reading in a DataStreamAlias from before 8.7.0, which did not correctly associate filters with DataStreams.
179-
* So we associated the same filter with all DataStreams in the alias to replicate the old behavior.
180-
*/
181-
for (String dataStream : dataStreams) {
182-
dataStreamToFilterMap.put(dataStream, filter);
183-
}
184-
}
185-
}
170+
this.dataStreamToFilterMap = in.readMap(CompressedXContent::readCompressedString);
186171
}
187172

188173
/**
@@ -406,20 +391,7 @@ public void writeTo(StreamOutput out) throws IOException {
406391
out.writeString(name);
407392
out.writeStringCollection(dataStreams);
408393
out.writeOptionalString(writeDataStream);
409-
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
410-
out.writeMap(dataStreamToFilterMap, StreamOutput::writeWriteable);
411-
} else {
412-
if (dataStreamToFilterMap.isEmpty()) {
413-
out.writeBoolean(false);
414-
} else {
415-
/*
416-
* TransportVersions before 8.7 incorrectly only allowed a single filter for all datastreams,
417-
* and randomly dropped all others. We replicate that buggy behavior here if we have to write
418-
* to an older node because there is no way to send multipole filters to an older node.
419-
*/
420-
dataStreamToFilterMap.values().iterator().next().writeTo(out);
421-
}
422-
}
394+
out.writeMap(dataStreamToFilterMap, StreamOutput::writeWriteable);
423395
}
424396

425397
@Override

server/src/main/java/org/elasticsearch/cluster/routing/ShardRouting.java

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@
99

1010
package org.elasticsearch.cluster.routing;
1111

12-
import org.elasticsearch.TransportVersions;
1312
import org.elasticsearch.cluster.node.DiscoveryNode;
1413
import org.elasticsearch.cluster.routing.RecoverySource.ExistingStoreRecoverySource;
1514
import org.elasticsearch.cluster.routing.RecoverySource.PeerRecoverySource;
1615
import org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator;
17-
import org.elasticsearch.common.Strings;
1816
import org.elasticsearch.common.io.stream.StreamInput;
1917
import org.elasticsearch.common.io.stream.StreamOutput;
2018
import org.elasticsearch.common.io.stream.Writeable;
@@ -347,11 +345,7 @@ public ShardRouting(ShardId shardId, StreamInput in) throws IOException {
347345
} else {
348346
expectedShardSize = UNAVAILABLE_EXPECTED_SHARD_SIZE;
349347
}
350-
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
351-
role = Role.readFrom(in);
352-
} else {
353-
role = Role.DEFAULT;
354-
}
348+
role = Role.readFrom(in);
355349
targetRelocatingShard = initializeTargetRelocatingShard();
356350
}
357351

@@ -380,13 +374,7 @@ public void writeToThin(StreamOutput out) throws IOException {
380374
out.writeLong(expectedShardSize);
381375
}
382376

383-
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
384-
role.writeTo(out);
385-
} else if (role != Role.DEFAULT) {
386-
throw new IllegalStateException(
387-
Strings.format("cannot send role [%s] to node with version [%s]", role, out.getTransportVersion().toReleaseVersion())
388-
);
389-
}
377+
role.writeTo(out);
390378
}
391379

392380
@Override

server/src/main/java/org/elasticsearch/cluster/routing/UnassignedInfo.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
import org.elasticsearch.ExceptionsHelper;
1313
import org.elasticsearch.TransportVersion;
14-
import org.elasticsearch.TransportVersions;
1514
import org.elasticsearch.cluster.ClusterState;
1615
import org.elasticsearch.cluster.metadata.Metadata;
1716
import org.elasticsearch.cluster.metadata.NodesShutdownMetadata;
@@ -77,8 +76,6 @@ public record UnassignedInfo(
7776
@Nullable String lastAllocatedNodeId
7877
) implements ToXContentFragment, Writeable {
7978

80-
private static final TransportVersion VERSION_UNPROMOTABLE_REPLICA_ADDED = TransportVersions.V_8_7_0;
81-
8279
public static final DateFormatter DATE_TIME_FORMATTER = DateFormatter.forPattern("date_optional_time").withZone(ZoneOffset.UTC);
8380

8481
public static final Setting<TimeValue> INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING = Setting.timeSetting(
@@ -328,9 +325,7 @@ public static UnassignedInfo fromStreamInput(StreamInput in) throws IOException
328325
}
329326

330327
public void writeTo(StreamOutput out) throws IOException {
331-
if (reason.equals(Reason.UNPROMOTABLE_REPLICA) && out.getTransportVersion().before(VERSION_UNPROMOTABLE_REPLICA_ADDED)) {
332-
out.writeByte((byte) Reason.PRIMARY_FAILED.ordinal());
333-
} else if (reason.equals(Reason.RESHARD_ADDED) && out.getTransportVersion().supports(UNASSIGENEDINFO_RESHARD_ADDED) == false) {
328+
if (reason.equals(Reason.RESHARD_ADDED) && out.getTransportVersion().supports(UNASSIGENEDINFO_RESHARD_ADDED) == false) {
334329
// We should have protection to ensure we do not reshard in mixed clusters
335330
assert false;
336331
out.writeByte((byte) Reason.FORCED_EMPTY_PRIMARY.ordinal());

server/src/main/java/org/elasticsearch/common/io/stream/StreamInput.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -919,12 +919,8 @@ public Object readGenericValue() throws IOException {
919919
case 6 -> readByteArray();
920920
case 7 -> readCollection(StreamInput::readGenericValue, ArrayList::new, Collections.emptyList());
921921
case 8 -> readArray();
922-
case 9 -> getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)
923-
? readOrderedMap(StreamInput::readGenericValue, StreamInput::readGenericValue)
924-
: readOrderedMap(StreamInput::readString, StreamInput::readGenericValue);
925-
case 10 -> getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)
926-
? readMap(StreamInput::readGenericValue, StreamInput::readGenericValue)
927-
: readMap(StreamInput::readGenericValue);
922+
case 9 -> readOrderedMap(StreamInput::readGenericValue, StreamInput::readGenericValue);
923+
case 10 -> readMap(StreamInput::readGenericValue, StreamInput::readGenericValue);
928924
case 11 -> readByte();
929925
case 12 -> readDate();
930926
case 13 ->

0 commit comments

Comments
 (0)