diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/desirednodes/UpdateDesiredNodesRequest.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/desirednodes/UpdateDesiredNodesRequest.java index b4d7ffbc3d0d9..fa95c4a7df69e 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/desirednodes/UpdateDesiredNodesRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/desirednodes/UpdateDesiredNodesRequest.java @@ -8,6 +8,7 @@ package org.elasticsearch.action.admin.cluster.desirednodes; +import org.elasticsearch.TransportVersion; import org.elasticsearch.Version; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.ValidateActions; @@ -24,7 +25,7 @@ import java.util.Objects; public class UpdateDesiredNodesRequest extends AcknowledgedRequest { - private static final Version DRY_RUN_VERSION = Version.V_8_4_0; + private static final TransportVersion DRY_RUN_VERSION = TransportVersion.V_8_4_0; private final String historyID; private final long version; @@ -58,7 +59,7 @@ public UpdateDesiredNodesRequest(StreamInput in) throws IOException { this.historyID = in.readString(); this.version = in.readLong(); this.nodes = in.readList(DesiredNode::readFrom); - if (in.getVersion().onOrAfter(DRY_RUN_VERSION)) { + if (in.getTransportVersion().onOrAfter(DRY_RUN_VERSION)) { this.dryRun = in.readBoolean(); } else { this.dryRun = false; @@ -71,7 +72,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(historyID); out.writeLong(version); out.writeList(nodes); - if (out.getVersion().onOrAfter(DRY_RUN_VERSION)) { + if (out.getTransportVersion().onOrAfter(DRY_RUN_VERSION)) { out.writeBoolean(dryRun); } } diff --git a/server/src/main/java/org/elasticsearch/cluster/ClusterInfo.java b/server/src/main/java/org/elasticsearch/cluster/ClusterInfo.java index 500f0dcb5b9fa..c576389d72e2d 100644 --- a/server/src/main/java/org/elasticsearch/cluster/ClusterInfo.java +++ b/server/src/main/java/org/elasticsearch/cluster/ClusterInfo.java @@ -8,7 +8,7 @@ package org.elasticsearch.cluster; -import org.elasticsearch.Version; +import org.elasticsearch.TransportVersion; import org.elasticsearch.cluster.routing.RecoverySource; import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.cluster.routing.UnassignedInfo; @@ -42,8 +42,8 @@ public class ClusterInfo implements ToXContentFragment, Writeable { public static final ClusterInfo EMPTY = new ClusterInfo(); - public static final Version DATA_SET_SIZE_SIZE_VERSION = Version.V_7_13_0; - public static final Version DATA_PATH_NEW_KEY_VERSION = Version.V_8_6_0; + public static final TransportVersion DATA_SET_SIZE_SIZE_VERSION = TransportVersion.V_7_13_0; + public static final TransportVersion DATA_PATH_NEW_KEY_VERSION = TransportVersion.V_8_6_0; private final Map leastAvailableSpaceUsage; private final Map mostAvailableSpaceUsage; @@ -87,12 +87,12 @@ public ClusterInfo(StreamInput in) throws IOException { this.leastAvailableSpaceUsage = in.readImmutableMap(StreamInput::readString, DiskUsage::new); this.mostAvailableSpaceUsage = in.readImmutableMap(StreamInput::readString, DiskUsage::new); this.shardSizes = in.readImmutableMap(StreamInput::readString, StreamInput::readLong); - if (in.getVersion().onOrAfter(DATA_SET_SIZE_SIZE_VERSION)) { + if (in.getTransportVersion().onOrAfter(DATA_SET_SIZE_SIZE_VERSION)) { this.shardDataSetSizes = in.readImmutableMap(ShardId::new, StreamInput::readLong); } else { this.shardDataSetSizes = Map.of(); } - if (in.getVersion().onOrAfter(DATA_PATH_NEW_KEY_VERSION)) { + if (in.getTransportVersion().onOrAfter(DATA_PATH_NEW_KEY_VERSION)) { this.dataPath = in.readImmutableMap(NodeAndShard::new, StreamInput::readString); } else { this.dataPath = in.readImmutableMap(nested -> NodeAndShard.from(new ShardRouting(nested)), StreamInput::readString); @@ -109,10 +109,10 @@ public void writeTo(StreamOutput out) throws IOException { out.writeMap(this.leastAvailableSpaceUsage, StreamOutput::writeString, (o, v) -> v.writeTo(o)); out.writeMap(this.mostAvailableSpaceUsage, StreamOutput::writeString, (o, v) -> v.writeTo(o)); out.writeMap(this.shardSizes, StreamOutput::writeString, (o, v) -> o.writeLong(v == null ? -1 : v)); - if (out.getVersion().onOrAfter(DATA_SET_SIZE_SIZE_VERSION)) { + if (out.getTransportVersion().onOrAfter(DATA_SET_SIZE_SIZE_VERSION)) { out.writeMap(this.shardDataSetSizes, (o, s) -> s.writeTo(o), StreamOutput::writeLong); } - if (out.getVersion().onOrAfter(DATA_PATH_NEW_KEY_VERSION)) { + if (out.getTransportVersion().onOrAfter(DATA_PATH_NEW_KEY_VERSION)) { out.writeMap(this.dataPath, (o, k) -> k.writeTo(o), StreamOutput::writeString); } else { out.writeMap(this.dataPath, (o, k) -> createFakeShardRoutingFromNodeAndShard(k).writeTo(o), StreamOutput::writeString); diff --git a/server/src/main/java/org/elasticsearch/cluster/ClusterState.java b/server/src/main/java/org/elasticsearch/cluster/ClusterState.java index 3ed1e7e19aee4..165f2413f5f95 100644 --- a/server/src/main/java/org/elasticsearch/cluster/ClusterState.java +++ b/server/src/main/java/org/elasticsearch/cluster/ClusterState.java @@ -8,7 +8,7 @@ package org.elasticsearch.cluster; -import org.elasticsearch.Version; +import org.elasticsearch.TransportVersion; import org.elasticsearch.action.support.master.TransportMasterNodeAction; import org.elasticsearch.cluster.block.ClusterBlock; import org.elasticsearch.cluster.block.ClusterBlocks; @@ -841,7 +841,7 @@ public static ClusterState readFrom(StreamInput in, DiscoveryNode localNode) thr Custom customIndexMetadata = in.readNamedWriteable(Custom.class); builder.putCustom(customIndexMetadata.getWriteableName(), customIndexMetadata); } - if (in.getVersion().before(Version.V_8_0_0)) { + if (in.getTransportVersion().before(TransportVersion.V_8_0_0)) { in.readVInt(); // used to be minimumMasterNodesOnPublishingMaster, which was used in 7.x for BWC with 6.x } return builder.build(); @@ -857,7 +857,7 @@ public void writeTo(StreamOutput out) throws IOException { nodes.writeTo(out); blocks.writeTo(out); VersionedNamedWriteable.writeVersionedWritables(out, customs); - if (out.getVersion().before(Version.V_8_0_0)) { + if (out.getTransportVersion().before(TransportVersion.V_8_0_0)) { out.writeVInt(-1); // used to be minimumMasterNodesOnPublishingMaster, which was used in 7.x for BWC with 6.x } } @@ -904,7 +904,7 @@ private static class ClusterStateDiff implements Diff { metadata = Metadata.readDiffFrom(in); blocks = ClusterBlocks.readDiffFrom(in); customs = DiffableUtils.readJdkMapDiff(in, DiffableUtils.getStringKeySerializer(), CUSTOM_VALUE_SERIALIZER); - if (in.getVersion().before(Version.V_8_0_0)) { + if (in.getTransportVersion().before(TransportVersion.V_8_0_0)) { in.readVInt(); // used to be minimumMasterNodesOnPublishingMaster, which was used in 7.x for BWC with 6.x } } @@ -920,7 +920,7 @@ public void writeTo(StreamOutput out) throws IOException { metadata.writeTo(out); blocks.writeTo(out); customs.writeTo(out); - if (out.getVersion().before(Version.V_8_0_0)) { + if (out.getTransportVersion().before(TransportVersion.V_8_0_0)) { out.writeVInt(-1); // used to be minimumMasterNodesOnPublishingMaster, which was used in 7.x for BWC with 6.x } } diff --git a/server/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java b/server/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java index 32682a75f8b7b..e9736fcff52aa 100644 --- a/server/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java +++ b/server/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java @@ -190,10 +190,10 @@ public TransportVersion getMinimalSupportedVersion() { return TransportVersion.CURRENT.minimumCompatibilityVersion(); } - private static final Version DIFFABLE_VERSION = Version.V_8_5_0; + private static final TransportVersion DIFFABLE_VERSION = TransportVersion.V_8_5_0; public static NamedDiff readDiffFrom(StreamInput in) throws IOException { - if (in.getVersion().onOrAfter(DIFFABLE_VERSION)) { + if (in.getTransportVersion().onOrAfter(DIFFABLE_VERSION)) { return new SnapshotInProgressDiff(in); } return readDiffFrom(Custom.class, TYPE, in); @@ -1625,7 +1625,7 @@ public String getWriteableName() { @Override public void writeTo(StreamOutput out) throws IOException { assert after != null : "should only write instances that were diffed from this node's state"; - if (out.getVersion().onOrAfter(DIFFABLE_VERSION)) { + if (out.getTransportVersion().onOrAfter(DIFFABLE_VERSION)) { mapDiff.writeTo(out); } else { new SimpleDiffable.CompleteDiff<>(after).writeTo(out); diff --git a/server/src/main/java/org/elasticsearch/cluster/coordination/ValidateJoinRequest.java b/server/src/main/java/org/elasticsearch/cluster/coordination/ValidateJoinRequest.java index 464be6284d215..d2f9f18466aa1 100644 --- a/server/src/main/java/org/elasticsearch/cluster/coordination/ValidateJoinRequest.java +++ b/server/src/main/java/org/elasticsearch/cluster/coordination/ValidateJoinRequest.java @@ -7,7 +7,7 @@ */ package org.elasticsearch.cluster.coordination; -import org.elasticsearch.Version; +import org.elasticsearch.TransportVersion; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.common.CheckedSupplier; import org.elasticsearch.common.bytes.BytesReference; @@ -28,10 +28,10 @@ public class ValidateJoinRequest extends TransportRequest { public ValidateJoinRequest(StreamInput in) throws IOException { super(in); - if (in.getVersion().onOrAfter(Version.V_8_3_0)) { + if (in.getTransportVersion().onOrAfter(TransportVersion.V_8_3_0)) { // recent versions send a BytesTransportRequest containing a compressed representation of the state final var bytes = in.readReleasableBytesReference(); - final var version = in.getVersion(); + final var version = in.getTransportVersion(); final var namedWriteableRegistry = in.namedWriteableRegistry(); this.stateSupplier = () -> readCompressed(version, bytes, namedWriteableRegistry); this.refCounted = bytes; @@ -43,8 +43,11 @@ public ValidateJoinRequest(StreamInput in) throws IOException { } } - private static ClusterState readCompressed(Version version, BytesReference bytes, NamedWriteableRegistry namedWriteableRegistry) - throws IOException { + private static ClusterState readCompressed( + TransportVersion version, + BytesReference bytes, + NamedWriteableRegistry namedWriteableRegistry + ) throws IOException { try ( var bytesStreamInput = bytes.streamInput(); var in = new NamedWriteableAwareStreamInput( @@ -52,7 +55,7 @@ private static ClusterState readCompressed(Version version, BytesReference bytes namedWriteableRegistry ) ) { - in.setVersion(version); + in.setTransportVersion(version); return ClusterState.readFrom(in, null); } } @@ -64,7 +67,7 @@ public ValidateJoinRequest(ClusterState state) { @Override public void writeTo(StreamOutput out) throws IOException { - assert out.getVersion().before(Version.V_8_3_0); + assert out.getTransportVersion().before(TransportVersion.V_8_3_0); super.writeTo(out); stateSupplier.get().writeTo(out); } diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/ComposableIndexTemplate.java b/server/src/main/java/org/elasticsearch/cluster/metadata/ComposableIndexTemplate.java index 2a8ea2dc1b6bd..367b0f9f6f00d 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/ComposableIndexTemplate.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/ComposableIndexTemplate.java @@ -8,7 +8,7 @@ package org.elasticsearch.cluster.metadata; -import org.elasticsearch.Version; +import org.elasticsearch.TransportVersion; import org.elasticsearch.cluster.Diff; import org.elasticsearch.cluster.SimpleDiffable; import org.elasticsearch.common.Strings; @@ -331,12 +331,12 @@ public DataStreamTemplate(boolean hidden, boolean allowCustomRouting) { DataStreamTemplate(StreamInput in) throws IOException { hidden = in.readBoolean(); - if (in.getVersion().onOrAfter(Version.V_8_0_0)) { + if (in.getTransportVersion().onOrAfter(TransportVersion.V_8_0_0)) { allowCustomRouting = in.readBoolean(); } else { allowCustomRouting = false; } - if (in.getVersion().onOrAfter(Version.V_8_1_0) && in.getVersion().before(Version.V_8_3_0)) { + if (in.getTransportVersion().onOrAfter(TransportVersion.V_8_1_0) && in.getTransportVersion().before(TransportVersion.V_8_3_0)) { // Accidentally included index_mode to binary node to node protocol in previous releases. // (index_mode is removed and was part of code based when tsdb was behind a feature flag) // (index_mode was behind a feature in the xcontent parser, so it could never actually used) @@ -379,10 +379,11 @@ public boolean isAllowCustomRouting() { @Override public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(hidden); - if (out.getVersion().onOrAfter(Version.V_8_0_0)) { + if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_0_0)) { out.writeBoolean(allowCustomRouting); } - if (out.getVersion().onOrAfter(Version.V_8_1_0) && out.getVersion().before(Version.V_8_3_0)) { + if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_1_0) + && out.getTransportVersion().before(TransportVersion.V_8_3_0)) { // See comment in constructor. out.writeBoolean(false); } diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/DataStream.java b/server/src/main/java/org/elasticsearch/cluster/metadata/DataStream.java index 368274986f84e..8e66cecd19c41 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/DataStream.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/DataStream.java @@ -11,7 +11,7 @@ import org.apache.lucene.index.LeafReader; import org.apache.lucene.index.PointValues; import org.elasticsearch.ElasticsearchException; -import org.elasticsearch.Version; +import org.elasticsearch.TransportVersion; import org.elasticsearch.cluster.Diff; import org.elasticsearch.cluster.SimpleDiffable; import org.elasticsearch.common.Strings; @@ -529,8 +529,8 @@ public DataStream(StreamInput in) throws IOException { in.readBoolean(), in.readBoolean(), in.readBoolean(), - in.getVersion().onOrAfter(Version.V_8_0_0) ? in.readBoolean() : false, - in.getVersion().onOrAfter(Version.V_8_1_0) ? in.readOptionalEnum(IndexMode.class) : null + in.getTransportVersion().onOrAfter(TransportVersion.V_8_0_0) ? in.readBoolean() : false, + in.getTransportVersion().onOrAfter(TransportVersion.V_8_1_0) ? in.readOptionalEnum(IndexMode.class) : null ); } @@ -553,10 +553,10 @@ public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(hidden); out.writeBoolean(replicated); out.writeBoolean(system); - if (out.getVersion().onOrAfter(Version.V_8_0_0)) { + if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_0_0)) { out.writeBoolean(allowCustomRouting); } - if (out.getVersion().onOrAfter(Version.V_8_1_0)) { + if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_1_0)) { out.writeOptionalEnum(indexMode); } } diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/DataStreamAlias.java b/server/src/main/java/org/elasticsearch/cluster/metadata/DataStreamAlias.java index 40c2ac28faa92..7efba02dfe341 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/DataStreamAlias.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/DataStreamAlias.java @@ -7,7 +7,7 @@ */ package org.elasticsearch.cluster.metadata; -import org.elasticsearch.Version; +import org.elasticsearch.TransportVersion; import org.elasticsearch.cluster.Diff; import org.elasticsearch.cluster.SimpleDiffable; import org.elasticsearch.common.ParsingException; @@ -167,7 +167,7 @@ public DataStreamAlias(StreamInput in) throws IOException { this.name = in.readString(); this.dataStreams = in.readStringList(); this.writeDataStream = in.readOptionalString(); - if (in.getVersion().onOrAfter(Version.V_8_7_0)) { + if (in.getTransportVersion().onOrAfter(TransportVersion.V_8_7_0)) { this.dataStreamToFilterMap = in.readMap(StreamInput::readString, CompressedXContent::readCompressedString); } else { this.dataStreamToFilterMap = new HashMap<>(); @@ -398,16 +398,16 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(name); out.writeStringCollection(dataStreams); out.writeOptionalString(writeDataStream); - if (out.getVersion().onOrAfter(Version.V_8_7_0)) { + if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_7_0)) { out.writeMap(dataStreamToFilterMap, StreamOutput::writeString, (out1, filter) -> filter.writeTo(out1)); } else { if (dataStreamToFilterMap.isEmpty()) { out.writeBoolean(false); } else { /* - * Versions 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. + * 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); } diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/DesiredNode.java b/server/src/main/java/org/elasticsearch/cluster/metadata/DesiredNode.java index 8437ad0efcf36..32b060cc9682a 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/DesiredNode.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/DesiredNode.java @@ -173,7 +173,7 @@ public static DesiredNode readFrom(StreamInput in) throws IOException { final var settings = Settings.readSettingsFromStream(in); final Processors processors; final ProcessorsRange processorsRange; - if (in.getVersion().onOrAfter(RANGE_FLOAT_PROCESSORS_SUPPORT_VERSION)) { + if (in.getTransportVersion().onOrAfter(RANGE_FLOAT_PROCESSORS_SUPPORT_VERSION.transportVersion)) { processors = in.readOptionalWriteable(Processors::readFrom); processorsRange = in.readOptionalWriteable(ProcessorsRange::readFrom); } else { @@ -189,7 +189,7 @@ public static DesiredNode readFrom(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { settings.writeTo(out); - if (out.getVersion().onOrAfter(RANGE_FLOAT_PROCESSORS_SUPPORT_VERSION)) { + if (out.getTransportVersion().onOrAfter(RANGE_FLOAT_PROCESSORS_SUPPORT_VERSION.transportVersion)) { out.writeOptionalWriteable(processors); out.writeOptionalWriteable(processorsRange); } else { diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/DesiredNodeWithStatus.java b/server/src/main/java/org/elasticsearch/cluster/metadata/DesiredNodeWithStatus.java index 418bff501ec92..036b31fa65be5 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/DesiredNodeWithStatus.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/DesiredNodeWithStatus.java @@ -8,6 +8,7 @@ package org.elasticsearch.cluster.metadata; +import org.elasticsearch.TransportVersion; import org.elasticsearch.Version; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -30,7 +31,7 @@ public record DesiredNodeWithStatus(DesiredNode desiredNode, Status status) ToXContentObject, Comparable { - private static final Version STATUS_TRACKING_SUPPORT_VERSION = Version.V_8_4_0; + private static final TransportVersion STATUS_TRACKING_SUPPORT_VERSION = TransportVersion.V_8_4_0; private static final ParseField STATUS_FIELD = new ParseField("status"); public static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>( @@ -77,7 +78,7 @@ public String externalId() { public static DesiredNodeWithStatus readFrom(StreamInput in) throws IOException { final var desiredNode = DesiredNode.readFrom(in); final Status status; - if (in.getVersion().onOrAfter(STATUS_TRACKING_SUPPORT_VERSION)) { + if (in.getTransportVersion().onOrAfter(STATUS_TRACKING_SUPPORT_VERSION)) { status = Status.fromValue(in.readShort()); } else { // During upgrades, we consider all desired nodes as PENDING @@ -93,7 +94,7 @@ public static DesiredNodeWithStatus readFrom(StreamInput in) throws IOException @Override public void writeTo(StreamOutput out) throws IOException { desiredNode.writeTo(out); - if (out.getVersion().onOrAfter(STATUS_TRACKING_SUPPORT_VERSION)) { + if (out.getTransportVersion().onOrAfter(STATUS_TRACKING_SUPPORT_VERSION)) { out.writeShort(status.value); } } diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java b/server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java index c0e4b4962a796..436470b3ebda1 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetadata.java @@ -10,6 +10,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.elasticsearch.TransportVersion; import org.elasticsearch.Version; import org.elasticsearch.action.admin.indices.rollover.RolloverInfo; import org.elasticsearch.action.support.ActiveShardCount; @@ -534,9 +535,9 @@ public Iterator> settings() { public static final String INDEX_STATE_FILE_PREFIX = "state-"; - static final Version SYSTEM_INDEX_FLAG_ADDED = Version.V_7_10_0; + static final TransportVersion SYSTEM_INDEX_FLAG_ADDED = TransportVersion.V_7_10_0; - static final Version STATS_AND_FORECAST_ADDED = Version.V_8_6_0; + static final TransportVersion STATS_AND_FORECAST_ADDED = TransportVersion.V_8_6_0; private final int routingNumShards; private final int routingFactor; @@ -1406,7 +1407,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws return builder; } - private static final Version SETTING_DIFF_VERSION = Version.V_8_5_0; + private static final TransportVersion SETTING_DIFF_VERSION = TransportVersion.V_8_5_0; private static class IndexMetadataDiff implements Diff { @@ -1487,13 +1488,13 @@ private static class IndexMetadataDiff implements Diff { version = in.readLong(); mappingVersion = in.readVLong(); settingsVersion = in.readVLong(); - if (in.getVersion().onOrAfter(Version.V_7_2_0)) { + if (in.getTransportVersion().onOrAfter(TransportVersion.V_7_2_0)) { aliasesVersion = in.readVLong(); } else { aliasesVersion = 1; } state = State.fromId(in.readByte()); - if (in.getVersion().onOrAfter(SETTING_DIFF_VERSION)) { + if (in.getTransportVersion().onOrAfter(SETTING_DIFF_VERSION)) { settings = null; settingsDiff = Settings.readSettingsDiffFromStream(in); } else { @@ -1514,13 +1515,13 @@ private static class IndexMetadataDiff implements Diff { DiffableUtils.getStringKeySerializer(), ROLLOVER_INFO_DIFF_VALUE_READER ); - if (in.getVersion().onOrAfter(SYSTEM_INDEX_FLAG_ADDED)) { + if (in.getTransportVersion().onOrAfter(SYSTEM_INDEX_FLAG_ADDED)) { isSystem = in.readBoolean(); } else { isSystem = false; } timestampRange = IndexLongFieldRange.readFrom(in); - if (in.getVersion().onOrAfter(STATS_AND_FORECAST_ADDED)) { + if (in.getTransportVersion().onOrAfter(STATS_AND_FORECAST_ADDED)) { stats = in.readOptionalWriteable(IndexMetadataStats::new); indexWriteLoadForecast = in.readOptionalDouble(); shardSizeInBytesForecast = in.readOptionalLong(); @@ -1538,13 +1539,13 @@ public void writeTo(StreamOutput out) throws IOException { out.writeLong(version); out.writeVLong(mappingVersion); out.writeVLong(settingsVersion); - if (out.getVersion().onOrAfter(Version.V_7_2_0)) { + if (out.getTransportVersion().onOrAfter(TransportVersion.V_7_2_0)) { out.writeVLong(aliasesVersion); } out.writeByte(state.id); assert settings != null : "settings should always be non-null since this instance is not expected to have been read from another node"; - if (out.getVersion().onOrAfter(SETTING_DIFF_VERSION)) { + if (out.getTransportVersion().onOrAfter(SETTING_DIFF_VERSION)) { settingsDiff.writeTo(out); } else { settings.writeTo(out); @@ -1555,11 +1556,11 @@ public void writeTo(StreamOutput out) throws IOException { customData.writeTo(out); inSyncAllocationIds.writeTo(out); rolloverInfos.writeTo(out); - if (out.getVersion().onOrAfter(SYSTEM_INDEX_FLAG_ADDED)) { + if (out.getTransportVersion().onOrAfter(SYSTEM_INDEX_FLAG_ADDED)) { out.writeBoolean(isSystem); } timestampRange.writeTo(out); - if (out.getVersion().onOrAfter(STATS_AND_FORECAST_ADDED)) { + if (out.getTransportVersion().onOrAfter(STATS_AND_FORECAST_ADDED)) { out.writeOptionalWriteable(stats); out.writeOptionalDouble(indexWriteLoadForecast); out.writeOptionalLong(shardSizeInBytesForecast); @@ -1611,7 +1612,7 @@ public static IndexMetadata readFrom(StreamInput in, @Nullable Function DiffableUtils.StringSetValueSerializer.getInstance().write(v, o) ); out.writeCollection(rolloverInfos.values()); - if (out.getVersion().onOrAfter(SYSTEM_INDEX_FLAG_ADDED)) { + if (out.getTransportVersion().onOrAfter(SYSTEM_INDEX_FLAG_ADDED)) { out.writeBoolean(isSystem); } timestampRange.writeTo(out); - if (out.getVersion().onOrAfter(STATS_AND_FORECAST_ADDED)) { + if (out.getTransportVersion().onOrAfter(STATS_AND_FORECAST_ADDED)) { out.writeOptionalWriteable(stats); out.writeOptionalDouble(writeLoadForecast); out.writeOptionalLong(shardSizeInBytesForecast); diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/MappingMetadata.java b/server/src/main/java/org/elasticsearch/cluster/metadata/MappingMetadata.java index 17f1b75c2e541..d102624ccb06e 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/MappingMetadata.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/MappingMetadata.java @@ -9,7 +9,7 @@ package org.elasticsearch.cluster.metadata; import org.elasticsearch.ElasticsearchParseException; -import org.elasticsearch.Version; +import org.elasticsearch.TransportVersion; import org.elasticsearch.cluster.Diff; import org.elasticsearch.cluster.SimpleDiffable; import org.elasticsearch.common.compress.CompressedXContent; @@ -75,7 +75,7 @@ public MappingMetadata(String type, Map mapping) { } public static void writeMappingMetadata(StreamOutput out, Map mappings) throws IOException { - out.writeMap(mappings, StreamOutput::writeString, out.getVersion().before(Version.V_8_0_0) ? (o, v) -> { + out.writeMap(mappings, StreamOutput::writeString, out.getTransportVersion().before(TransportVersion.V_8_0_0) ? (o, v) -> { o.writeVInt(v == EMPTY_MAPPINGS ? 0 : 1); if (v != EMPTY_MAPPINGS) { o.writeString(MapperService.SINGLE_MAPPING_NAME); diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/Metadata.java b/server/src/main/java/org/elasticsearch/cluster/metadata/Metadata.java index 33657fbb583fa..06f4b29b681b3 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/Metadata.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/Metadata.java @@ -11,6 +11,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.lucene.util.CollectionUtil; +import org.elasticsearch.TransportVersion; import org.elasticsearch.Version; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.Diff; @@ -1375,7 +1376,7 @@ public Diff diff(Metadata previousState) { } public static Diff readDiffFrom(StreamInput in) throws IOException { - if (in.getVersion().onOrAfter(MetadataDiff.NOOP_METADATA_DIFF_VERSION) && in.readBoolean()) { + if (in.getTransportVersion().onOrAfter(MetadataDiff.NOOP_METADATA_DIFF_VERSION) && in.readBoolean()) { return SimpleDiffable.empty(); } return new MetadataDiff(in); @@ -1443,8 +1444,9 @@ public Map getMappingsByHash() { private static class MetadataDiff implements Diff { - private static final Version NOOP_METADATA_DIFF_VERSION = Version.V_8_5_0; - private static final Version NOOP_METADATA_DIFF_SAFE_VERSION = PublicationTransportHandler.INCLUDES_LAST_COMMITTED_DATA_VERSION; + private static final TransportVersion NOOP_METADATA_DIFF_VERSION = TransportVersion.V_8_5_0; + private static final TransportVersion NOOP_METADATA_DIFF_SAFE_VERSION = + PublicationTransportHandler.INCLUDES_LAST_COMMITTED_DATA_VERSION.transportVersion; private final long version; private final String clusterUUID; @@ -1510,7 +1512,7 @@ private MetadataDiff(StreamInput in) throws IOException { coordinationMetadata = new CoordinationMetadata(in); transientSettings = Settings.readSettingsFromStream(in); persistentSettings = Settings.readSettingsFromStream(in); - if (in.getVersion().onOrAfter(Version.V_7_3_0)) { + if (in.getTransportVersion().onOrAfter(TransportVersion.V_7_3_0)) { hashesOfConsistentSettings = DiffableStringMap.readDiffFrom(in); } else { hashesOfConsistentSettings = DiffableStringMap.DiffableStringMapDiff.EMPTY; @@ -1518,7 +1520,7 @@ private MetadataDiff(StreamInput in) throws IOException { indices = DiffableUtils.readImmutableOpenMapDiff(in, DiffableUtils.getStringKeySerializer(), INDEX_METADATA_DIFF_VALUE_READER); templates = DiffableUtils.readImmutableOpenMapDiff(in, DiffableUtils.getStringKeySerializer(), TEMPLATES_DIFF_VALUE_READER); customs = DiffableUtils.readImmutableOpenMapDiff(in, DiffableUtils.getStringKeySerializer(), CUSTOM_VALUE_SERIALIZER); - if (in.getVersion().onOrAfter(Version.V_8_4_0)) { + if (in.getTransportVersion().onOrAfter(TransportVersion.V_8_4_0)) { reservedStateMetadata = DiffableUtils.readJdkMapDiff( in, DiffableUtils.getStringKeySerializer(), @@ -1531,13 +1533,13 @@ private MetadataDiff(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { - if (out.getVersion().onOrAfter(NOOP_METADATA_DIFF_SAFE_VERSION)) { + if (out.getTransportVersion().onOrAfter(NOOP_METADATA_DIFF_SAFE_VERSION)) { out.writeBoolean(empty); if (empty) { // noop diff return; } - } else if (out.getVersion().onOrAfter(NOOP_METADATA_DIFF_VERSION)) { + } else if (out.getTransportVersion().onOrAfter(NOOP_METADATA_DIFF_VERSION)) { // noops are not safe with these versions, see #92259 out.writeBoolean(false); } @@ -1547,13 +1549,13 @@ public void writeTo(StreamOutput out) throws IOException { coordinationMetadata.writeTo(out); transientSettings.writeTo(out); persistentSettings.writeTo(out); - if (out.getVersion().onOrAfter(Version.V_7_3_0)) { + if (out.getTransportVersion().onOrAfter(TransportVersion.V_7_3_0)) { hashesOfConsistentSettings.writeTo(out); } indices.writeTo(out); templates.writeTo(out); customs.writeTo(out); - if (out.getVersion().onOrAfter(Version.V_8_4_0)) { + if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_4_0)) { reservedStateMetadata.writeTo(out); } } @@ -1586,7 +1588,7 @@ public Metadata apply(Metadata part) { } } - public static final Version MAPPINGS_AS_HASH_VERSION = Version.V_8_1_0; + public static final TransportVersion MAPPINGS_AS_HASH_VERSION = TransportVersion.V_8_1_0; public static Metadata readFrom(StreamInput in) throws IOException { Builder builder = new Builder(); @@ -1596,11 +1598,11 @@ public static Metadata readFrom(StreamInput in) throws IOException { builder.coordinationMetadata(new CoordinationMetadata(in)); builder.transientSettings(readSettingsFromStream(in)); builder.persistentSettings(readSettingsFromStream(in)); - if (in.getVersion().onOrAfter(Version.V_7_3_0)) { + if (in.getTransportVersion().onOrAfter(TransportVersion.V_7_3_0)) { builder.hashesOfConsistentSettings(DiffableStringMap.readFrom(in)); } final Function mappingLookup; - if (in.getVersion().onOrAfter(MAPPINGS_AS_HASH_VERSION)) { + if (in.getTransportVersion().onOrAfter(MAPPINGS_AS_HASH_VERSION)) { final Map mappingMetadataMap = in.readMapValues(MappingMetadata::new, MappingMetadata::getSha256); if (mappingMetadataMap.size() > 0) { mappingLookup = mappingMetadataMap::get; @@ -1623,7 +1625,7 @@ public static Metadata readFrom(StreamInput in) throws IOException { Custom customIndexMetadata = in.readNamedWriteable(Custom.class); builder.putCustom(customIndexMetadata.getWriteableName(), customIndexMetadata); } - if (in.getVersion().onOrAfter(Version.V_8_4_0)) { + if (in.getTransportVersion().onOrAfter(TransportVersion.V_8_4_0)) { int reservedStateSize = in.readVInt(); for (int i = 0; i < reservedStateSize; i++) { builder.put(ReservedStateMetadata.readFrom(in)); @@ -1640,22 +1642,22 @@ public void writeTo(StreamOutput out) throws IOException { coordinationMetadata.writeTo(out); transientSettings.writeTo(out); persistentSettings.writeTo(out); - if (out.getVersion().onOrAfter(Version.V_7_3_0)) { + if (out.getTransportVersion().onOrAfter(TransportVersion.V_7_3_0)) { hashesOfConsistentSettings.writeTo(out); } // Starting in #MAPPINGS_AS_HASH_VERSION we write the mapping metadata first and then write the indices without metadata so that // we avoid writing duplicate mappings twice - if (out.getVersion().onOrAfter(MAPPINGS_AS_HASH_VERSION)) { + if (out.getTransportVersion().onOrAfter(MAPPINGS_AS_HASH_VERSION)) { out.writeMapValues(mappingsByHash); } out.writeVInt(indices.size()); - final boolean writeMappingsHash = out.getVersion().onOrAfter(MAPPINGS_AS_HASH_VERSION); + final boolean writeMappingsHash = out.getTransportVersion().onOrAfter(MAPPINGS_AS_HASH_VERSION); for (IndexMetadata indexMetadata : this) { indexMetadata.writeTo(out, writeMappingsHash); } out.writeCollection(templates.values()); VersionedNamedWriteable.writeVersionedWritables(out, customs); - if (out.getVersion().onOrAfter(Version.V_8_4_0)) { + if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_4_0)) { out.writeCollection(reservedStateMetadata.values()); } } diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/ShutdownShardMigrationStatus.java b/server/src/main/java/org/elasticsearch/cluster/metadata/ShutdownShardMigrationStatus.java index dbde71aeef67c..7f7f8a87cbfb2 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/ShutdownShardMigrationStatus.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/ShutdownShardMigrationStatus.java @@ -8,7 +8,7 @@ package org.elasticsearch.cluster.metadata; -import org.elasticsearch.Version; +import org.elasticsearch.TransportVersion; import org.elasticsearch.cluster.routing.allocation.ShardAllocationDecision; import org.elasticsearch.common.Strings; import org.elasticsearch.common.io.stream.StreamInput; @@ -22,7 +22,7 @@ import java.util.Objects; public class ShutdownShardMigrationStatus implements Writeable, ToXContentObject { - private static final Version ALLOCATION_DECISION_ADDED_VERSION = Version.V_7_16_0; + private static final TransportVersion ALLOCATION_DECISION_ADDED_VERSION = TransportVersion.V_7_16_0; public static final String NODE_ALLOCATION_DECISION_KEY = "node_allocation_decision"; @@ -57,7 +57,7 @@ public ShutdownShardMigrationStatus(StreamInput in) throws IOException { this.status = in.readEnum(SingleNodeShutdownMetadata.Status.class); this.shardsRemaining = in.readLong(); this.explanation = in.readOptionalString(); - if (in.getVersion().onOrAfter(ALLOCATION_DECISION_ADDED_VERSION)) { + if (in.getTransportVersion().onOrAfter(ALLOCATION_DECISION_ADDED_VERSION)) { this.allocationDecision = in.readOptionalWriteable(ShardAllocationDecision::new); } else { this.allocationDecision = null; @@ -100,7 +100,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeEnum(status); out.writeLong(shardsRemaining); out.writeOptionalString(explanation); - if (out.getVersion().onOrAfter(ALLOCATION_DECISION_ADDED_VERSION)) { + if (out.getTransportVersion().onOrAfter(ALLOCATION_DECISION_ADDED_VERSION)) { out.writeOptionalWriteable(allocationDecision); } } diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/SingleNodeShutdownMetadata.java b/server/src/main/java/org/elasticsearch/cluster/metadata/SingleNodeShutdownMetadata.java index 489389b247695..69500c2e9b902 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/SingleNodeShutdownMetadata.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/SingleNodeShutdownMetadata.java @@ -8,7 +8,7 @@ package org.elasticsearch.cluster.metadata; -import org.elasticsearch.Version; +import org.elasticsearch.TransportVersion; import org.elasticsearch.cluster.SimpleDiffable; import org.elasticsearch.common.Strings; import org.elasticsearch.common.io.stream.StreamInput; @@ -33,7 +33,7 @@ */ public class SingleNodeShutdownMetadata implements SimpleDiffable, ToXContentObject { - public static final Version REPLACE_SHUTDOWN_TYPE_ADDED_VERSION = Version.V_7_16_0; + public static final TransportVersion REPLACE_SHUTDOWN_TYPE_ADDED_VERSION = TransportVersion.V_7_16_0; public static final ParseField NODE_ID_FIELD = new ParseField("node_id"); public static final ParseField TYPE_FIELD = new ParseField("type"); @@ -133,7 +133,7 @@ public SingleNodeShutdownMetadata(StreamInput in) throws IOException { this.startedAtMillis = in.readVLong(); this.nodeSeen = in.readBoolean(); this.allocationDelay = in.readOptionalTimeValue(); - if (in.getVersion().onOrAfter(REPLACE_SHUTDOWN_TYPE_ADDED_VERSION)) { + if (in.getTransportVersion().onOrAfter(REPLACE_SHUTDOWN_TYPE_ADDED_VERSION)) { this.targetNodeName = in.readOptionalString(); } else { this.targetNodeName = null; @@ -199,7 +199,7 @@ public TimeValue getAllocationDelay() { @Override public void writeTo(StreamOutput out) throws IOException { out.writeString(nodeId); - if (out.getVersion().before(REPLACE_SHUTDOWN_TYPE_ADDED_VERSION) && this.type == SingleNodeShutdownMetadata.Type.REPLACE) { + if (out.getTransportVersion().before(REPLACE_SHUTDOWN_TYPE_ADDED_VERSION) && this.type == SingleNodeShutdownMetadata.Type.REPLACE) { out.writeEnum(SingleNodeShutdownMetadata.Type.REMOVE); } else { out.writeEnum(type); @@ -208,7 +208,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeVLong(startedAtMillis); out.writeBoolean(nodeSeen); out.writeOptionalTimeValue(allocationDelay); - if (out.getVersion().onOrAfter(REPLACE_SHUTDOWN_TYPE_ADDED_VERSION)) { + if (out.getTransportVersion().onOrAfter(REPLACE_SHUTDOWN_TYPE_ADDED_VERSION)) { out.writeOptionalString(targetNodeName); } } diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/ShardRouting.java b/server/src/main/java/org/elasticsearch/cluster/routing/ShardRouting.java index 01bc1558cacda..2e993cc120c18 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/ShardRouting.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/ShardRouting.java @@ -8,7 +8,7 @@ package org.elasticsearch.cluster.routing; -import org.elasticsearch.Version; +import org.elasticsearch.TransportVersion; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.routing.RecoverySource.ExistingStoreRecoverySource; import org.elasticsearch.cluster.routing.RecoverySource.PeerRecoverySource; @@ -38,8 +38,8 @@ public final class ShardRouting implements Writeable, ToXContentObject { * Used if shard size is not available */ public static final long UNAVAILABLE_EXPECTED_SHARD_SIZE = -1; - private static final Version EXPECTED_SHARD_SIZE_FOR_STARTED_VERSION = Version.V_8_5_0; - private static final Version RELOCATION_FAILURE_INFO_VERSION = Version.V_8_6_0; + private static final TransportVersion EXPECTED_SHARD_SIZE_FOR_STARTED_VERSION = TransportVersion.V_8_5_0; + private static final TransportVersion RELOCATION_FAILURE_INFO_VERSION = TransportVersion.V_8_6_0; private final ShardId shardId; private final String currentNodeId; @@ -339,7 +339,7 @@ public ShardRouting(ShardId shardId, StreamInput in) throws IOException { recoverySource = null; } unassignedInfo = in.readOptionalWriteable(UnassignedInfo::new); - if (in.getVersion().onOrAfter(RELOCATION_FAILURE_INFO_VERSION)) { + if (in.getTransportVersion().onOrAfter(RELOCATION_FAILURE_INFO_VERSION)) { relocationFailureInfo = RelocationFailureInfo.readFrom(in); } else { relocationFailureInfo = RelocationFailureInfo.NO_FAILURES; @@ -347,12 +347,12 @@ public ShardRouting(ShardId shardId, StreamInput in) throws IOException { allocationId = in.readOptionalWriteable(AllocationId::new); if (state == ShardRoutingState.RELOCATING || state == ShardRoutingState.INITIALIZING - || (state == ShardRoutingState.STARTED && in.getVersion().onOrAfter(EXPECTED_SHARD_SIZE_FOR_STARTED_VERSION))) { + || (state == ShardRoutingState.STARTED && in.getTransportVersion().onOrAfter(EXPECTED_SHARD_SIZE_FOR_STARTED_VERSION))) { expectedShardSize = in.readLong(); } else { expectedShardSize = UNAVAILABLE_EXPECTED_SHARD_SIZE; } - if (in.getVersion().onOrAfter(Version.V_8_7_0)) { + if (in.getTransportVersion().onOrAfter(TransportVersion.V_8_7_0)) { role = Role.readFrom(in); } else { role = Role.DEFAULT; @@ -379,20 +379,22 @@ public void writeToThin(StreamOutput out) throws IOException { recoverySource.writeTo(out); } out.writeOptionalWriteable(unassignedInfo); - if (out.getVersion().onOrAfter(RELOCATION_FAILURE_INFO_VERSION)) { + if (out.getTransportVersion().onOrAfter(RELOCATION_FAILURE_INFO_VERSION)) { relocationFailureInfo.writeTo(out); } out.writeOptionalWriteable(allocationId); if (state == ShardRoutingState.RELOCATING || state == ShardRoutingState.INITIALIZING - || (state == ShardRoutingState.STARTED && out.getVersion().onOrAfter(EXPECTED_SHARD_SIZE_FOR_STARTED_VERSION))) { + || (state == ShardRoutingState.STARTED && out.getTransportVersion().onOrAfter(EXPECTED_SHARD_SIZE_FOR_STARTED_VERSION))) { out.writeLong(expectedShardSize); } - if (out.getVersion().onOrAfter(Version.V_8_7_0)) { + if (out.getTransportVersion().onOrAfter(TransportVersion.V_8_7_0)) { role.writeTo(out); } else if (role != Role.DEFAULT) { - throw new IllegalStateException(Strings.format("cannot send role [%s] to node of version [%s]", role, out.getVersion())); + throw new IllegalStateException( + Strings.format("cannot send role [%s] to node of version [%s]", role, out.getTransportVersion()) + ); } } diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/UnassignedInfo.java b/server/src/main/java/org/elasticsearch/cluster/routing/UnassignedInfo.java index 292a2c2d9113a..f20ef41342434 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/UnassignedInfo.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/UnassignedInfo.java @@ -9,7 +9,7 @@ package org.elasticsearch.cluster.routing; import org.elasticsearch.ExceptionsHelper; -import org.elasticsearch.Version; +import org.elasticsearch.TransportVersion; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.Metadata; import org.elasticsearch.cluster.metadata.SingleNodeShutdownMetadata; @@ -47,8 +47,8 @@ public final class UnassignedInfo implements ToXContentFragment, Writeable { * The version that the {@code lastAllocatedNode} field was added in. Used to adapt streaming of this class as appropriate for the * version of the node sending/receiving it. Should be removed once wire compatibility with this version is no longer necessary. */ - private static final Version VERSION_LAST_ALLOCATED_NODE_ADDED = Version.V_7_15_0; - private static final Version VERSION_UNPROMOTABLE_REPLICA_ADDED = Version.V_8_7_0; + private static final TransportVersion VERSION_LAST_ALLOCATED_NODE_ADDED = TransportVersion.V_7_15_0; + private static final TransportVersion VERSION_UNPROMOTABLE_REPLICA_ADDED = TransportVersion.V_8_7_0; public static final DateFormatter DATE_TIME_FORMATTER = DateFormatter.forPattern("date_optional_time").withZone(ZoneOffset.UTC); @@ -302,7 +302,7 @@ public UnassignedInfo(StreamInput in) throws IOException { this.failedAllocations = in.readVInt(); this.lastAllocationStatus = AllocationStatus.readFrom(in); this.failedNodeIds = Collections.unmodifiableSet(in.readSet(StreamInput::readString)); - if (in.getVersion().onOrAfter(VERSION_LAST_ALLOCATED_NODE_ADDED)) { + if (in.getTransportVersion().onOrAfter(VERSION_LAST_ALLOCATED_NODE_ADDED)) { this.lastAllocatedNodeId = in.readOptionalString(); } else { this.lastAllocatedNodeId = null; @@ -310,9 +310,9 @@ public UnassignedInfo(StreamInput in) throws IOException { } public void writeTo(StreamOutput out) throws IOException { - if (reason.equals(Reason.NODE_RESTARTING) && out.getVersion().before(VERSION_LAST_ALLOCATED_NODE_ADDED)) { + if (reason.equals(Reason.NODE_RESTARTING) && out.getTransportVersion().before(VERSION_LAST_ALLOCATED_NODE_ADDED)) { out.writeByte((byte) Reason.NODE_LEFT.ordinal()); - } else if (reason.equals(Reason.UNPROMOTABLE_REPLICA) && out.getVersion().before(VERSION_UNPROMOTABLE_REPLICA_ADDED)) { + } else if (reason.equals(Reason.UNPROMOTABLE_REPLICA) && out.getTransportVersion().before(VERSION_UNPROMOTABLE_REPLICA_ADDED)) { out.writeByte((byte) Reason.PRIMARY_FAILED.ordinal()); } else { out.writeByte((byte) reason.ordinal()); @@ -325,7 +325,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeVInt(failedAllocations); lastAllocationStatus.writeTo(out); out.writeCollection(failedNodeIds, StreamOutput::writeString); - if (out.getVersion().onOrAfter(VERSION_LAST_ALLOCATED_NODE_ADDED)) { + if (out.getTransportVersion().onOrAfter(VERSION_LAST_ALLOCATED_NODE_ADDED)) { out.writeOptionalString(lastAllocatedNodeId); } } diff --git a/server/src/main/java/org/elasticsearch/cluster/service/ClusterStateUpdateStats.java b/server/src/main/java/org/elasticsearch/cluster/service/ClusterStateUpdateStats.java index 96f9bd5c084e5..2efafb228bb54 100644 --- a/server/src/main/java/org/elasticsearch/cluster/service/ClusterStateUpdateStats.java +++ b/server/src/main/java/org/elasticsearch/cluster/service/ClusterStateUpdateStats.java @@ -8,7 +8,7 @@ package org.elasticsearch.cluster.service; -import org.elasticsearch.Version; +import org.elasticsearch.TransportVersion; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; @@ -117,7 +117,7 @@ public ClusterStateUpdateStats(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { - assert out.getVersion().onOrAfter(Version.V_7_16_0) : out.getVersion(); + assert out.getTransportVersion().onOrAfter(TransportVersion.V_7_16_0) : out.getTransportVersion(); out.writeVLong(unchangedTaskCount); out.writeVLong(publicationSuccessCount); out.writeVLong(publicationFailureCount); diff --git a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/PutShutdownNodeAction.java b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/PutShutdownNodeAction.java index 2a5ff0623ab80..d9232cc9ed5fd 100644 --- a/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/PutShutdownNodeAction.java +++ b/x-pack/plugin/shutdown/src/main/java/org/elasticsearch/xpack/shutdown/PutShutdownNodeAction.java @@ -92,7 +92,7 @@ public Request(StreamInput in) throws IOException { this.type = in.readEnum(SingleNodeShutdownMetadata.Type.class); this.reason = in.readString(); this.allocationDelay = in.readOptionalTimeValue(); - if (in.getVersion().onOrAfter(REPLACE_SHUTDOWN_TYPE_ADDED_VERSION)) { + if (in.getTransportVersion().onOrAfter(REPLACE_SHUTDOWN_TYPE_ADDED_VERSION)) { this.targetNodeName = in.readOptionalString(); } else { this.targetNodeName = null; @@ -102,14 +102,15 @@ public Request(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { out.writeString(nodeId); - if (out.getVersion().before(REPLACE_SHUTDOWN_TYPE_ADDED_VERSION) && this.type == SingleNodeShutdownMetadata.Type.REPLACE) { + if (out.getTransportVersion().before(REPLACE_SHUTDOWN_TYPE_ADDED_VERSION) + && this.type == SingleNodeShutdownMetadata.Type.REPLACE) { out.writeEnum(SingleNodeShutdownMetadata.Type.REMOVE); } else { out.writeEnum(type); } out.writeString(reason); out.writeOptionalTimeValue(allocationDelay); - if (out.getVersion().onOrAfter(REPLACE_SHUTDOWN_TYPE_ADDED_VERSION)) { + if (out.getTransportVersion().onOrAfter(REPLACE_SHUTDOWN_TYPE_ADDED_VERSION)) { out.writeOptionalString(targetNodeName); } }