Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
package org.elasticsearch.aggregations.metric;

import org.elasticsearch.TransportVersion;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.search.MultiValueMode;
Expand Down Expand Up @@ -57,16 +56,12 @@ public boolean supportsSampling() {
*/
public MatrixStatsAggregationBuilder(StreamInput in) throws IOException {
super(in);
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
multiValueMode = MultiValueMode.readMultiValueModeFrom(in);
}
multiValueMode = MultiValueMode.readMultiValueModeFrom(in);
}

@Override
protected void innerWriteTo(StreamOutput out) throws IOException {
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
multiValueMode.writeTo(out);
}
multiValueMode.writeTo(out);
}

public MatrixStatsAggregationBuilder multiValueMode(MultiValueMode multiValueMode) {
Expand Down
2 changes: 0 additions & 2 deletions server/src/main/java/org/elasticsearch/TransportVersions.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ static TransportVersion def(int id) {
public static final TransportVersion V_7_9_0 = def(7_09_00_99);
public static final TransportVersion V_7_10_0 = def(7_10_00_99);
public static final TransportVersion V_8_0_0 = def(8_00_00_99);
public static final TransportVersion V_8_7_0 = def(8_07_00_99);
public static final TransportVersion V_8_7_1 = def(8_07_01_99);
public static final TransportVersion V_8_8_0 = def(8_08_00_99);
public static final TransportVersion V_8_8_1 = def(8_08_01_99);
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

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

import org.elasticsearch.TransportVersions;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
Expand Down Expand Up @@ -149,16 +148,11 @@ static <T> void configureParser(ConstructingObjectParser<T, Void> parser) {
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeBoolean(isSafe);
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
reason.writeTo(out);
}
reason.writeTo(out);
out.writeString(message);
}

public static Result readFrom(final StreamInput in) throws IOException {
if (in.getTransportVersion().before(TransportVersions.V_8_7_0)) {
return new Result(in.readBoolean(), null, in.readString());
}
return new Result(in.readBoolean(), Reason.readFrom(in), in.readString());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

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

import org.elasticsearch.TransportVersions;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.action.support.master.MasterNodeReadRequest;
import org.elasticsearch.common.Strings;
Expand Down Expand Up @@ -46,9 +45,7 @@ public PrevalidateNodeRemovalRequest(final StreamInput in) throws IOException {
names = in.readStringArray();
ids = in.readStringArray();
externalIds = in.readStringArray();
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
timeout = in.readTimeValue();
}
timeout = in.readTimeValue();
}

@Override
Expand All @@ -57,9 +54,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeStringArray(names);
out.writeStringArray(ids);
out.writeStringArray(externalIds);
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
out.writeTimeValue(timeout);
}
out.writeTimeValue(timeout);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
package org.elasticsearch.action.ingest;

import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
Expand Down Expand Up @@ -173,11 +172,7 @@ public SimulateProcessorResult(String type, String processorTag, String descript
* Read from a stream.
*/
SimulateProcessorResult(StreamInput in) throws IOException {
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
this.processorTag = in.readOptionalString();
} else {
this.processorTag = in.readString();
}
this.processorTag = in.readOptionalString();
this.ingestDocument = in.readOptionalWriteable(WriteableIngestDocument::new);
this.failure = in.readException();
this.description = in.readOptionalString();
Expand All @@ -192,11 +187,7 @@ public SimulateProcessorResult(String type, String processorTag, String descript

@Override
public void writeTo(StreamOutput out) throws IOException {
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
out.writeOptionalString(processorTag);
} else {
out.writeString(processorTag);
}
out.writeOptionalString(processorTag);
out.writeOptionalWriteable(ingestDocument);
out.writeException(failure);
out.writeOptionalString(description);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,7 @@ public ComposableIndexTemplate(StreamInput in) throws IOException {
this.metadata = in.readGenericMap();
this.dataStreamTemplate = in.readOptionalWriteable(DataStreamTemplate::new);
this.allowAutoCreate = in.readOptionalBoolean();
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
this.ignoreMissingComponentTemplates = in.readOptionalStringCollectionAsList();
} else {
this.ignoreMissingComponentTemplates = null;
}
this.ignoreMissingComponentTemplates = in.readOptionalStringCollectionAsList();
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_12_0)) {
this.deprecated = in.readOptionalBoolean();
} else {
Expand Down Expand Up @@ -295,9 +291,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeGenericMap(this.metadata);
out.writeOptionalWriteable(dataStreamTemplate);
out.writeOptionalBoolean(allowAutoCreate);
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
out.writeOptionalStringCollection(ignoreMissingComponentTemplates);
}
out.writeOptionalStringCollection(ignoreMissingComponentTemplates);
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_12_0)) {
out.writeOptionalBoolean(deprecated);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
*/
package org.elasticsearch.cluster.metadata;

import org.elasticsearch.TransportVersions;
import org.elasticsearch.cluster.Diff;
import org.elasticsearch.cluster.SimpleDiffable;
import org.elasticsearch.common.ParsingException;
Expand Down Expand Up @@ -168,21 +167,7 @@ public DataStreamAlias(StreamInput in) throws IOException {
this.name = in.readString();
this.dataStreams = in.readStringCollectionAsList();
this.writeDataStream = in.readOptionalString();
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
this.dataStreamToFilterMap = in.readMap(CompressedXContent::readCompressedString);
} else {
this.dataStreamToFilterMap = new HashMap<>();
CompressedXContent filter = in.readBoolean() ? CompressedXContent.readCompressedString(in) : null;
if (filter != null) {
/*
* Here we're reading in a DataStreamAlias from before 8.7.0, which did not correctly associate filters with DataStreams.
* So we associated the same filter with all DataStreams in the alias to replicate the old behavior.
*/
for (String dataStream : dataStreams) {
dataStreamToFilterMap.put(dataStream, filter);
}
}
}
this.dataStreamToFilterMap = in.readMap(CompressedXContent::readCompressedString);
}

/**
Expand Down Expand Up @@ -406,20 +391,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeString(name);
out.writeStringCollection(dataStreams);
out.writeOptionalString(writeDataStream);
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
out.writeMap(dataStreamToFilterMap, StreamOutput::writeWriteable);
} else {
if (dataStreamToFilterMap.isEmpty()) {
out.writeBoolean(false);
} else {
/*
* TransportVersions before 8.7 incorrectly only allowed a single filter for all datastreams,
* and randomly dropped all others. We replicate that buggy behavior here if we have to write
* to an older node because there is no way to send multipole filters to an older node.
*/
dataStreamToFilterMap.values().iterator().next().writeTo(out);
}
}
out.writeMap(dataStreamToFilterMap, StreamOutput::writeWriteable);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@

package org.elasticsearch.cluster.routing;

import org.elasticsearch.TransportVersions;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.routing.RecoverySource.ExistingStoreRecoverySource;
import org.elasticsearch.cluster.routing.RecoverySource.PeerRecoverySource;
import org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
Expand Down Expand Up @@ -347,11 +345,7 @@ public ShardRouting(ShardId shardId, StreamInput in) throws IOException {
} else {
expectedShardSize = UNAVAILABLE_EXPECTED_SHARD_SIZE;
}
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
role = Role.readFrom(in);
} else {
role = Role.DEFAULT;
}
role = Role.readFrom(in);
targetRelocatingShard = initializeTargetRelocatingShard();
}

Expand Down Expand Up @@ -380,13 +374,7 @@ public void writeToThin(StreamOutput out) throws IOException {
out.writeLong(expectedShardSize);
}

if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
role.writeTo(out);
} else if (role != Role.DEFAULT) {
throw new IllegalStateException(
Strings.format("cannot send role [%s] to node with version [%s]", role, out.getTransportVersion().toReleaseVersion())
);
}
role.writeTo(out);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.TransportVersion;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.Metadata;
import org.elasticsearch.cluster.metadata.NodesShutdownMetadata;
Expand Down Expand Up @@ -77,8 +76,6 @@ public record UnassignedInfo(
@Nullable String lastAllocatedNodeId
) implements ToXContentFragment, Writeable {

private static final TransportVersion VERSION_UNPROMOTABLE_REPLICA_ADDED = TransportVersions.V_8_7_0;

public static final DateFormatter DATE_TIME_FORMATTER = DateFormatter.forPattern("date_optional_time").withZone(ZoneOffset.UTC);

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

public void writeTo(StreamOutput out) throws IOException {
if (reason.equals(Reason.UNPROMOTABLE_REPLICA) && out.getTransportVersion().before(VERSION_UNPROMOTABLE_REPLICA_ADDED)) {
out.writeByte((byte) Reason.PRIMARY_FAILED.ordinal());
} else if (reason.equals(Reason.RESHARD_ADDED) && out.getTransportVersion().supports(UNASSIGENEDINFO_RESHARD_ADDED) == false) {
if (reason.equals(Reason.RESHARD_ADDED) && out.getTransportVersion().supports(UNASSIGENEDINFO_RESHARD_ADDED) == false) {
// We should have protection to ensure we do not reshard in mixed clusters
assert false;
out.writeByte((byte) Reason.FORCED_EMPTY_PRIMARY.ordinal());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -919,12 +919,8 @@ public Object readGenericValue() throws IOException {
case 6 -> readByteArray();
case 7 -> readCollection(StreamInput::readGenericValue, ArrayList::new, Collections.emptyList());
case 8 -> readArray();
case 9 -> getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)
? readOrderedMap(StreamInput::readGenericValue, StreamInput::readGenericValue)
: readOrderedMap(StreamInput::readString, StreamInput::readGenericValue);
case 10 -> getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)
? readMap(StreamInput::readGenericValue, StreamInput::readGenericValue)
: readMap(StreamInput::readGenericValue);
case 9 -> readOrderedMap(StreamInput::readGenericValue, StreamInput::readGenericValue);
case 10 -> readMap(StreamInput::readGenericValue, StreamInput::readGenericValue);
case 11 -> readByte();
case 12 -> readDate();
case 13 ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -613,11 +613,7 @@ public void writeMapWithConsistentOrder(@Nullable Map<String, ? extends Object>
Iterator<? extends Map.Entry<String, ?>> iterator = map.entrySet().stream().sorted(Map.Entry.comparingByKey()).iterator();
while (iterator.hasNext()) {
Map.Entry<String, ?> next = iterator.next();
if (this.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
this.writeGenericValue(next.getKey());
} else {
this.writeString(next.getKey());
}
this.writeGenericValue(next.getKey());
this.writeGenericValue(next.getValue());
}
}
Expand Down Expand Up @@ -751,14 +747,8 @@ public final void writeOptionalInstant(@Nullable Instant instant) throws IOExcep
} else {
o.writeByte((byte) 10);
}
if (o.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
final Map<?, ?> map = (Map<?, ?>) v;
o.writeMap(map, StreamOutput::writeGenericValue, StreamOutput::writeGenericValue);
} else {
@SuppressWarnings("unchecked")
final Map<String, ?> map = (Map<String, ?>) v;
o.writeMap(map, StreamOutput::writeGenericValue);
}
final Map<?, ?> map = (Map<?, ?>) v;
o.writeMap(map, StreamOutput::writeGenericValue, StreamOutput::writeGenericValue);
}),
entry(Byte.class, (o, v) -> {
o.writeByte((byte) 11);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
package org.elasticsearch.search.aggregations.metrics;

import org.HdrHistogram.DoubleHistogram;
import org.elasticsearch.TransportVersions;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.search.DocValueFormat;
Expand Down Expand Up @@ -59,14 +58,10 @@ abstract class AbstractInternalHDRPercentiles extends InternalNumericMetricsAggr
protected AbstractInternalHDRPercentiles(StreamInput in) throws IOException {
super(in);
keys = in.readDoubleArray();
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
if (in.readBoolean()) {
state = decode(in);
} else {
state = null;
}
} else {
if (in.readBoolean()) {
state = decode(in);
} else {
state = null;
}
keyed = in.readBoolean();
}
Expand All @@ -88,18 +83,11 @@ private DoubleHistogram decode(StreamInput in) throws IOException {
protected void doWriteTo(StreamOutput out) throws IOException {
out.writeNamedWriteable(format);
out.writeDoubleArray(keys);
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
if (this.state != null) {
out.writeBoolean(true);
encode(this.state, out);
} else {
out.writeBoolean(false);
}
if (this.state != null) {
out.writeBoolean(true);
encode(this.state, out);
} else {
DoubleHistogram state = this.state != null ? this.state
: out.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0) ? EMPTY_HISTOGRAM_ZERO_DIGITS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like it was unreachable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol, it sure seems that way.

: EMPTY_HISTOGRAM_THREE_DIGITS;
encode(state, out);
out.writeBoolean(false);
}
out.writeBoolean(keyed);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

package org.elasticsearch.search.aggregations.support;

import org.elasticsearch.TransportVersions;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
Expand Down Expand Up @@ -169,11 +168,7 @@ public MultiValuesSourceFieldConfig(StreamInput in) throws IOException {
this.filter = in.readOptionalNamedWriteable(QueryBuilder.class);
this.userValueTypeHint = in.readOptionalWriteable(ValueType::readFromStream);
this.format = in.readOptionalString();
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
this.includeExclude = in.readOptionalWriteable(IncludeExclude::new);
} else {
this.includeExclude = null;
}
this.includeExclude = in.readOptionalWriteable(IncludeExclude::new);
}

public Object getMissing() {
Expand Down Expand Up @@ -217,9 +212,7 @@ public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalNamedWriteable(filter);
out.writeOptionalWriteable(userValueTypeHint);
out.writeOptionalString(format);
if (out.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
out.writeOptionalWriteable(includeExclude);
}
out.writeOptionalWriteable(includeExclude);
}

@Override
Expand Down
Loading