diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/RoundTripTests.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/RoundTripTests.java index 57e7b2bf8221d..ab1968a2e3582 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/RoundTripTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/RoundTripTests.java @@ -68,15 +68,10 @@ public void testReindexRequest() throws IOException { ReindexRequest tripped = new ReindexRequest(toInputByteStream(reindex)); assertRequestEquals(reindex, tripped); - // Try slices=auto with a version that doesn't support it, which should fail - reindex.setSlices(AbstractBulkByScrollRequest.AUTO_SLICES); - Exception e = expectThrows(IllegalArgumentException.class, () -> toInputByteStream(Version.V_6_0_0_alpha1, reindex)); - assertEquals("Slices set as \"auto\" are not supported before version [6.1.0]. Found version [6.0.0-alpha1]", e.getMessage()); - // Try regular slices with a version that doesn't support slices=auto, which should succeed reindex.setSlices(between(1, Integer.MAX_VALUE)); tripped = new ReindexRequest(toInputByteStream(reindex)); - assertRequestEquals(Version.V_6_0_0_alpha1, reindex, tripped); + assertRequestEquals(reindex, tripped); } public void testUpdateByQueryRequest() throws IOException { @@ -89,11 +84,6 @@ public void testUpdateByQueryRequest() throws IOException { assertRequestEquals(update, tripped); assertEquals(update.getPipeline(), tripped.getPipeline()); - // Try slices=auto with a version that doesn't support it, which should fail - update.setSlices(AbstractBulkByScrollRequest.AUTO_SLICES); - Exception e = expectThrows(IllegalArgumentException.class, () -> toInputByteStream(Version.V_6_0_0_alpha1, update)); - assertEquals("Slices set as \"auto\" are not supported before version [6.1.0]. Found version [6.0.0-alpha1]", e.getMessage()); - // Try regular slices with a version that doesn't support slices=auto, which should succeed update.setSlices(between(1, Integer.MAX_VALUE)); tripped = new UpdateByQueryRequest(toInputByteStream(update)); @@ -107,11 +97,6 @@ public void testDeleteByQueryRequest() throws IOException { DeleteByQueryRequest tripped = new DeleteByQueryRequest(toInputByteStream(delete)); assertRequestEquals(delete, tripped); - // Try slices=auto with a version that doesn't support it, which should fail - delete.setSlices(AbstractBulkByScrollRequest.AUTO_SLICES); - Exception e = expectThrows(IllegalArgumentException.class, () -> toInputByteStream(Version.V_6_0_0_alpha1, delete)); - assertEquals("Slices set as \"auto\" are not supported before version [6.1.0]. Found version [6.0.0-alpha1]", e.getMessage()); - // Try regular slices with a version that doesn't support slices=auto, which should succeed delete.setSlices(between(1, Integer.MAX_VALUE)); tripped = new DeleteByQueryRequest(toInputByteStream(delete)); @@ -139,7 +124,7 @@ private void randomRequest(AbstractBulkIndexByScrollRequest request) { request.setScript(random().nextBoolean() ? null : randomScript()); } - private void assertRequestEquals(Version version, ReindexRequest request, ReindexRequest tripped) { + private void assertRequestEquals(ReindexRequest request, ReindexRequest tripped) { assertRequestEquals((AbstractBulkIndexByScrollRequest) request, (AbstractBulkIndexByScrollRequest) tripped); assertEquals(request.getDestination().version(), tripped.getDestination().version()); assertEquals(request.getDestination().index(), tripped.getDestination().index()); diff --git a/server/src/main/java/org/elasticsearch/action/DocWriteResponse.java b/server/src/main/java/org/elasticsearch/action/DocWriteResponse.java index 11ffad1c93deb..465a93914410b 100644 --- a/server/src/main/java/org/elasticsearch/action/DocWriteResponse.java +++ b/server/src/main/java/org/elasticsearch/action/DocWriteResponse.java @@ -18,7 +18,6 @@ */ package org.elasticsearch.action; -import org.elasticsearch.Version; import org.elasticsearch.action.support.WriteRequest; import org.elasticsearch.action.support.WriteRequest.RefreshPolicy; import org.elasticsearch.action.support.WriteResponse; @@ -264,13 +263,8 @@ public void readFrom(StreamInput in) throws IOException { type = in.readString(); id = in.readString(); version = in.readZLong(); - if (in.getVersion().onOrAfter(Version.V_6_0_0_alpha1)) { - seqNo = in.readZLong(); - primaryTerm = in.readVLong(); - } else { - seqNo = UNASSIGNED_SEQ_NO; - primaryTerm = UNASSIGNED_PRIMARY_TERM; - } + seqNo = in.readZLong(); + primaryTerm = in.readVLong(); forcedRefresh = in.readBoolean(); result = Result.readFrom(in); } @@ -282,10 +276,8 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(type); out.writeString(id); out.writeZLong(version); - if (out.getVersion().onOrAfter(Version.V_6_0_0_alpha1)) { - out.writeZLong(seqNo); - out.writeVLong(primaryTerm); - } + out.writeZLong(seqNo); + out.writeVLong(primaryTerm); out.writeBoolean(forcedRefresh); result.writeTo(out); } diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequest.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequest.java index aa85a4f4da87e..3663fa1b4aa08 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequest.java @@ -81,9 +81,7 @@ public ClusterHealthRequest(StreamInput in) throws IOException { if (in.readBoolean()) { waitForEvents = Priority.readFrom(in); } - if (in.getVersion().onOrAfter(Version.V_6_2_0)) { - waitForNoInitializingShards = in.readBoolean(); - } + waitForNoInitializingShards = in.readBoolean(); if (in.getVersion().onOrAfter(Version.V_7_1_0)) { indicesOptions = IndicesOptions.readIndicesOptions(in); } else { @@ -118,9 +116,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(true); Priority.writeTo(waitForEvents, out); } - if (out.getVersion().onOrAfter(Version.V_6_2_0)) { - out.writeBoolean(waitForNoInitializingShards); - } + out.writeBoolean(waitForNoInitializingShards); if (out.getVersion().onOrAfter(Version.V_7_1_0)) { indicesOptions.writeIndicesOptions(out); } diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStats.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStats.java index 750cf609dc67d..7a69bc0e506bd 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStats.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStats.java @@ -19,13 +19,11 @@ package org.elasticsearch.action.admin.cluster.node.stats; -import org.elasticsearch.Version; import org.elasticsearch.action.support.nodes.BaseNodeResponse; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.xcontent.ToXContent.Params; import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.discovery.DiscoveryStats; @@ -235,11 +233,7 @@ public void readFrom(StreamInput in) throws IOException { scriptStats = in.readOptionalWriteable(ScriptStats::new); discoveryStats = in.readOptionalWriteable(DiscoveryStats::new); ingestStats = in.readOptionalWriteable(IngestStats::new); - if (in.getVersion().onOrAfter(Version.V_6_1_0)) { - adaptiveSelectionStats = in.readOptionalWriteable(AdaptiveSelectionStats::new); - } else { - adaptiveSelectionStats = null; - } + adaptiveSelectionStats = in.readOptionalWriteable(AdaptiveSelectionStats::new); } @Override @@ -263,9 +257,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalWriteable(scriptStats); out.writeOptionalWriteable(discoveryStats); out.writeOptionalWriteable(ingestStats); - if (out.getVersion().onOrAfter(Version.V_6_1_0)) { - out.writeOptionalWriteable(adaptiveSelectionStats); - } + out.writeOptionalWriteable(adaptiveSelectionStats); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsRequest.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsRequest.java index 54ef5b65977a2..9cd3ff82c93da 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsRequest.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.admin.cluster.node.stats; -import org.elasticsearch.Version; import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags; import org.elasticsearch.action.support.nodes.BaseNodesRequest; import org.elasticsearch.common.io.stream.StreamInput; @@ -296,11 +295,7 @@ public void readFrom(StreamInput in) throws IOException { script = in.readBoolean(); discovery = in.readBoolean(); ingest = in.readBoolean(); - if (in.getVersion().onOrAfter(Version.V_6_1_0)) { - adaptiveSelection = in.readBoolean(); - } else { - adaptiveSelection = false; - } + adaptiveSelection = in.readBoolean(); } @Override @@ -318,8 +313,6 @@ public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(script); out.writeBoolean(discovery); out.writeBoolean(ingest); - if (out.getVersion().onOrAfter(Version.V_6_1_0)) { - out.writeBoolean(adaptiveSelection); - } + out.writeBoolean(adaptiveSelection); } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteResponse.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteResponse.java index 3c35b97702429..652a794e0f1cb 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteResponse.java @@ -19,9 +19,7 @@ package org.elasticsearch.action.admin.cluster.reroute; -import org.elasticsearch.Version; import org.elasticsearch.action.support.master.AcknowledgedResponse; -import org.elasticsearch.cluster.ClusterModule; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.routing.allocation.RoutingExplanations; import org.elasticsearch.common.io.stream.StreamInput; @@ -63,32 +61,16 @@ public RoutingExplanations getExplanations() { @Override public void readFrom(StreamInput in) throws IOException { - if (in.getVersion().onOrAfter(Version.V_6_4_0)) { - super.readFrom(in); - state = ClusterState.readFrom(in, null); - explanations = RoutingExplanations.readFrom(in); - } else { - state = ClusterState.readFrom(in, null); - acknowledged = in.readBoolean(); - explanations = RoutingExplanations.readFrom(in); - } + super.readFrom(in); + state = ClusterState.readFrom(in, null); + explanations = RoutingExplanations.readFrom(in); } @Override public void writeTo(StreamOutput out) throws IOException { - if (out.getVersion().onOrAfter(Version.V_6_4_0)) { - super.writeTo(out); - state.writeTo(out); - RoutingExplanations.writeTo(explanations, out); - } else { - if (out.getVersion().onOrAfter(Version.V_6_3_0)) { - state.writeTo(out); - } else { - ClusterModule.filterCustomsForPre63Clients(state).writeTo(out); - } - out.writeBoolean(acknowledged); - RoutingExplanations.writeTo(explanations, out); - } + super.writeTo(out); + state.writeTo(out); + RoutingExplanations.writeTo(explanations, out); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/settings/ClusterUpdateSettingsResponse.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/settings/ClusterUpdateSettingsResponse.java index cc29e60aa996f..4e925b398b6d5 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/settings/ClusterUpdateSettingsResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/settings/ClusterUpdateSettingsResponse.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.admin.cluster.settings; -import org.elasticsearch.Version; import org.elasticsearch.action.support.master.AcknowledgedResponse; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.io.stream.StreamInput; @@ -68,15 +67,9 @@ public class ClusterUpdateSettingsResponse extends AcknowledgedResponse { @Override public void readFrom(StreamInput in) throws IOException { - if (in.getVersion().onOrAfter(Version.V_6_4_0)) { - super.readFrom(in); - transientSettings = Settings.readSettingsFromStream(in); - persistentSettings = Settings.readSettingsFromStream(in); - } else { - transientSettings = Settings.readSettingsFromStream(in); - persistentSettings = Settings.readSettingsFromStream(in); - acknowledged = in.readBoolean(); - } + super.readFrom(in); + transientSettings = Settings.readSettingsFromStream(in); + persistentSettings = Settings.readSettingsFromStream(in); } public Settings getTransientSettings() { @@ -89,15 +82,9 @@ public Settings getPersistentSettings() { @Override public void writeTo(StreamOutput out) throws IOException { - if (out.getVersion().onOrAfter(Version.V_6_4_0)) { - super.writeTo(out); - Settings.writeSettingsToStream(transientSettings, out); - Settings.writeSettingsToStream(persistentSettings, out); - } else { - Settings.writeSettingsToStream(transientSettings, out); - Settings.writeSettingsToStream(persistentSettings, out); - out.writeBoolean(acknowledged); - } + super.writeTo(out); + Settings.writeSettingsToStream(transientSettings, out); + Settings.writeSettingsToStream(persistentSettings, out); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/SnapshotStats.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/SnapshotStats.java index 6cb56bd88dcd9..ba4028620aabd 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/SnapshotStats.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/SnapshotStats.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.admin.cluster.snapshots.status; -import org.elasticsearch.Version; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Streamable; @@ -134,10 +133,8 @@ public void writeTo(StreamOutput out) throws IOException { out.writeVLong(incrementalSize); out.writeVLong(processedSize); - if (out.getVersion().onOrAfter(Version.V_6_4_0)) { - out.writeVInt(totalFileCount); - out.writeVLong(totalSize); - } + out.writeVInt(totalFileCount); + out.writeVLong(totalSize); } @Override @@ -151,13 +148,8 @@ public void readFrom(StreamInput in) throws IOException { incrementalSize = in.readVLong(); processedSize = in.readVLong(); - if (in.getVersion().onOrAfter(Version.V_6_4_0)) { - totalFileCount = in.readVInt(); - totalSize = in.readVLong(); - } else { - totalFileCount = incrementalFileCount; - totalSize = incrementalSize; - } + totalFileCount = in.readVInt(); + totalSize = in.readVLong(); } static final class Fields { diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/SnapshotStatus.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/SnapshotStatus.java index 618bb54c9015d..b850330a9affa 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/SnapshotStatus.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/status/SnapshotStatus.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.admin.cluster.snapshots.status; -import org.elasticsearch.Version; import org.elasticsearch.cluster.SnapshotsInProgress; import org.elasticsearch.cluster.SnapshotsInProgress.State; import org.elasticsearch.common.ParseField; @@ -169,9 +168,7 @@ public void readFrom(StreamInput in) throws IOException { builder.add(SnapshotIndexShardStatus.readShardSnapshotStatus(in)); } shards = Collections.unmodifiableList(builder); - if (in.getVersion().onOrAfter(Version.V_6_2_0)) { - includeGlobalState = in.readOptionalBoolean(); - } + includeGlobalState = in.readOptionalBoolean(); updateShardStats(); } @@ -183,9 +180,7 @@ public void writeTo(StreamOutput out) throws IOException { for (SnapshotIndexShardStatus shard : shards) { shard.writeTo(out); } - if (out.getVersion().onOrAfter(Version.V_6_2_0)) { - out.writeOptionalBoolean(includeGlobalState); - } + out.writeOptionalBoolean(includeGlobalState); } /** diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/state/ClusterStateRequest.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/state/ClusterStateRequest.java index 2cca13c0b2461..7f07aeb364471 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/state/ClusterStateRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/state/ClusterStateRequest.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.admin.cluster.state; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.IndicesRequest; import org.elasticsearch.action.support.IndicesOptions; @@ -57,10 +56,8 @@ public ClusterStateRequest(StreamInput in) throws IOException { customs = in.readBoolean(); indices = in.readStringArray(); indicesOptions = IndicesOptions.readIndicesOptions(in); - if (in.getVersion().onOrAfter(Version.V_6_6_0)) { - waitForTimeout = in.readTimeValue(); - waitForMetaDataVersion = in.readOptionalLong(); - } + waitForTimeout = in.readTimeValue(); + waitForMetaDataVersion = in.readOptionalLong(); } @Override @@ -73,10 +70,8 @@ public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(customs); out.writeStringArray(indices); indicesOptions.writeIndicesOptions(out); - if (out.getVersion().onOrAfter(Version.V_6_6_0)) { - out.writeTimeValue(waitForTimeout); - out.writeOptionalLong(waitForMetaDataVersion); - } + out.writeTimeValue(waitForTimeout); + out.writeOptionalLong(waitForMetaDataVersion); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/state/ClusterStateResponse.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/state/ClusterStateResponse.java index fc4eb04fada99..39083cedfb077 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/state/ClusterStateResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/state/ClusterStateResponse.java @@ -19,9 +19,7 @@ package org.elasticsearch.action.admin.cluster.state; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionResponse; -import org.elasticsearch.cluster.ClusterModule; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.node.DiscoveryNodes; @@ -91,44 +89,18 @@ public boolean isWaitForTimedOut() { public void readFrom(StreamInput in) throws IOException { super.readFrom(in); clusterName = new ClusterName(in); - if (in.getVersion().onOrAfter(Version.V_6_6_0)) { - clusterState = in.readOptionalWriteable(innerIn -> ClusterState.readFrom(innerIn, null)); - } else { - clusterState = ClusterState.readFrom(in, null); - } - if (in.getVersion().onOrAfter(Version.V_6_0_0_alpha1)) { - totalCompressedSize = new ByteSizeValue(in); - } else { - // in a mixed cluster, if a pre 6.0 node processes the get cluster state - // request, then a compressed size won't be returned, so just return 0; - // its a temporary situation until all nodes in the cluster have been upgraded, - // at which point the correct cluster state size will always be reported - totalCompressedSize = new ByteSizeValue(0L); - } - if (in.getVersion().onOrAfter(Version.V_6_6_0)) { - waitForTimedOut = in.readBoolean(); - } + clusterState = in.readOptionalWriteable(innerIn -> ClusterState.readFrom(innerIn, null)); + totalCompressedSize = new ByteSizeValue(in); + waitForTimedOut = in.readBoolean(); } @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); clusterName.writeTo(out); - if (out.getVersion().onOrAfter(Version.V_6_6_0)) { - out.writeOptionalWriteable(clusterState); - } else { - if (out.getVersion().onOrAfter(Version.V_6_3_0)) { - clusterState.writeTo(out); - } else { - ClusterModule.filterCustomsForPre63Clients(clusterState).writeTo(out); - } - } - if (out.getVersion().onOrAfter(Version.V_6_0_0_alpha1)) { - totalCompressedSize.writeTo(out); - } - if (out.getVersion().onOrAfter(Version.V_6_6_0)) { - out.writeBoolean(waitForTimedOut); - } + out.writeOptionalWriteable(clusterState); + totalCompressedSize.writeTo(out); + out.writeBoolean(waitForTimedOut); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/DeleteStoredScriptRequest.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/DeleteStoredScriptRequest.java index ec6f68dd37f58..0d595cf92642d 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/DeleteStoredScriptRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/DeleteStoredScriptRequest.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.admin.cluster.storedscripts; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.support.master.AcknowledgedRequest; import org.elasticsearch.common.io.stream.StreamInput; @@ -69,22 +68,12 @@ public DeleteStoredScriptRequest id(String id) { @Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); - - if (in.getVersion().before(Version.V_6_0_0_alpha2)) { - in.readString(); // read lang from previous versions - } - id = in.readString(); } @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - - if (out.getVersion().before(Version.V_6_0_0_alpha2)) { - out.writeString(""); // write an empty lang to previous versions - } - out.writeString(id); } diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/GetStoredScriptRequest.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/GetStoredScriptRequest.java index 57f30699cc0f0..04991a8917526 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/GetStoredScriptRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/GetStoredScriptRequest.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.admin.cluster.storedscripts; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.support.master.MasterNodeReadRequest; import org.elasticsearch.common.io.stream.StreamInput; @@ -45,21 +44,12 @@ public GetStoredScriptRequest(String id) { public GetStoredScriptRequest(StreamInput in) throws IOException { super(in); - if (in.getVersion().before(Version.V_6_0_0_alpha2)) { - in.readString(); // read lang from previous versions - } - id = in.readString(); } @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - - if (out.getVersion().before(Version.V_6_0_0_alpha2)) { - out.writeString(""); // write an empty lang to previous versions - } - out.writeString(id); } diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/GetStoredScriptResponse.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/GetStoredScriptResponse.java index 742fb1a74eab4..4905c2e63382a 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/GetStoredScriptResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/GetStoredScriptResponse.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.admin.cluster.storedscripts; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.io.stream.StreamInput; @@ -118,10 +117,7 @@ public void readFrom(StreamInput in) throws IOException { } else { source = null; } - - if (in.getVersion().onOrAfter(Version.V_6_4_0)) { - id = in.readString(); - } + id = in.readString(); } @Override @@ -134,9 +130,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(true); source.writeTo(out); } - if (out.getVersion().onOrAfter(Version.V_6_4_0)) { - out.writeString(id); - } + out.writeString(id); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/PutStoredScriptRequest.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/PutStoredScriptRequest.java index e7c5a07f56874..29171f12a1859 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/PutStoredScriptRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/PutStoredScriptRequest.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.admin.cluster.storedscripts; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.support.master.AcknowledgedRequest; import org.elasticsearch.common.bytes.BytesReference; @@ -117,35 +116,21 @@ public PutStoredScriptRequest content(BytesReference content, XContentType xCont @Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); - - if (in.getVersion().before(Version.V_6_0_0_alpha2)) { - in.readString(); // read lang from previous versions - } id = in.readOptionalString(); content = in.readBytesReference(); xContentType = in.readEnum(XContentType.class); - if (in.getVersion().onOrAfter(Version.V_6_0_0_alpha2)) { - context = in.readOptionalString(); - source = new StoredScriptSource(in); - } else { - source = StoredScriptSource.parse(content, xContentType == null ? XContentType.JSON : xContentType); - } + context = in.readOptionalString(); + source = new StoredScriptSource(in); } @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - - if (out.getVersion().before(Version.V_6_0_0_alpha2)) { - out.writeString(source == null ? "" : source.getLang()); - } out.writeOptionalString(id); out.writeBytesReference(content); out.writeEnum(xContentType); - if (out.getVersion().onOrAfter(Version.V_6_0_0_alpha2)) { - out.writeOptionalString(context); - source.writeTo(out); - } + out.writeOptionalString(context); + source.writeTo(out); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/Alias.java b/server/src/main/java/org/elasticsearch/action/admin/indices/alias/Alias.java index 0f8439643b8f0..9d9f4c617265c 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/Alias.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/alias/Alias.java @@ -20,7 +20,6 @@ package org.elasticsearch.action.admin.indices.alias; import org.elasticsearch.ElasticsearchGenerationException; -import org.elasticsearch.Version; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.Strings; @@ -29,7 +28,6 @@ import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Streamable; import org.elasticsearch.common.xcontent.ToXContent; -import org.elasticsearch.common.xcontent.ToXContent.Params; import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; @@ -202,11 +200,7 @@ public void readFrom(StreamInput in) throws IOException { filter = in.readOptionalString(); indexRouting = in.readOptionalString(); searchRouting = in.readOptionalString(); - if (in.getVersion().onOrAfter(Version.V_6_4_0)) { - writeIndex = in.readOptionalBoolean(); - } else { - writeIndex = null; - } + writeIndex = in.readOptionalBoolean(); } @Override @@ -215,9 +209,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalString(filter); out.writeOptionalString(indexRouting); out.writeOptionalString(searchRouting); - if (out.getVersion().onOrAfter(Version.V_6_4_0)) { - out.writeOptionalBoolean(writeIndex); - } + out.writeOptionalBoolean(writeIndex); } /** diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesRequest.java b/server/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesRequest.java index 8ef16012cf308..20b01989285ad 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesRequest.java @@ -20,7 +20,6 @@ package org.elasticsearch.action.admin.indices.alias; import org.elasticsearch.ElasticsearchGenerationException; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.AliasesRequest; import org.elasticsearch.action.support.IndicesOptions; @@ -236,12 +235,8 @@ public AliasActions(StreamInput in) throws IOException { routing = in.readOptionalString(); searchRouting = in.readOptionalString(); indexRouting = in.readOptionalString(); - if (in.getVersion().onOrAfter(Version.V_6_4_0)) { - writeIndex = in.readOptionalBoolean(); - } - if (in.getVersion().onOrAfter(Version.V_7_0_0)) { - originalAliases = in.readStringArray(); - } + writeIndex = in.readOptionalBoolean(); + originalAliases = in.readStringArray(); } @Override @@ -253,12 +248,8 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalString(routing); out.writeOptionalString(searchRouting); out.writeOptionalString(indexRouting); - if (out.getVersion().onOrAfter(Version.V_6_4_0)) { - out.writeOptionalBoolean(writeIndex); - } - if (out.getVersion().onOrAfter(Version.V_7_0_0)) { - out.writeStringArray(originalAliases); - } + out.writeOptionalBoolean(writeIndex); + out.writeStringArray(originalAliases); } /** diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/get/GetAliasesRequest.java b/server/src/main/java/org/elasticsearch/action/admin/indices/alias/get/GetAliasesRequest.java index a40a3037acacd..40fae0d9543c6 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/get/GetAliasesRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/alias/get/GetAliasesRequest.java @@ -18,7 +18,6 @@ */ package org.elasticsearch.action.admin.indices.alias.get; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.AliasesRequest; import org.elasticsearch.action.support.IndicesOptions; @@ -49,9 +48,7 @@ public GetAliasesRequest(StreamInput in) throws IOException { indices = in.readStringArray(); aliases = in.readStringArray(); indicesOptions = IndicesOptions.readIndicesOptions(in); - if (in.getVersion().onOrAfter(Version.V_6_4_0)) { - originalAliases = in.readStringArray(); - } + originalAliases = in.readStringArray(); } @Override @@ -60,9 +57,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeStringArray(indices); out.writeStringArray(aliases); indicesOptions.writeIndicesOptions(out); - if (out.getVersion().onOrAfter(Version.V_6_4_0)) { - out.writeStringArray(originalAliases); - } + out.writeStringArray(originalAliases); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/open/OpenIndexResponse.java b/server/src/main/java/org/elasticsearch/action/admin/indices/open/OpenIndexResponse.java index 6ff03cb5291ea..91f27e8c0c3f7 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/open/OpenIndexResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/open/OpenIndexResponse.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.admin.indices.open; -import org.elasticsearch.Version; import org.elasticsearch.action.support.master.ShardsAcknowledgedResponse; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -50,17 +49,13 @@ public OpenIndexResponse(boolean acknowledged, boolean shardsAcknowledged) { @Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); - if (in.getVersion().onOrAfter(Version.V_6_1_0)) { - readShardsAcknowledged(in); - } + readShardsAcknowledged(in); } @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - if (out.getVersion().onOrAfter(Version.V_6_1_0)) { - writeShardsAcknowledged(out); - } + writeShardsAcknowledged(out); } public static OpenIndexResponse fromXContent(XContentParser parser) { diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/Condition.java b/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/Condition.java index 7e9ccda8f90b7..6f1b6a4240b32 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/Condition.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/Condition.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.admin.indices.rollover; -import org.elasticsearch.Version; import org.elasticsearch.common.io.stream.NamedWriteable; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.xcontent.ToXContentFragment; @@ -40,14 +39,6 @@ protected Condition(String name) { public abstract Result evaluate(Stats stats); - /** - * Checks if this condition is available in a specific version. - * This makes sure BWC when introducing a new condition which is not recognized by older versions. - */ - boolean includedInVersion(Version version) { - return true; - } - @Override public boolean equals(Object o) { if (this == o) { diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/MaxSizeCondition.java b/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/MaxSizeCondition.java index f1a121a87d41e..69f058ead8040 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/MaxSizeCondition.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/MaxSizeCondition.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.admin.indices.rollover; -import org.elasticsearch.Version; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.unit.ByteSizeUnit; @@ -51,11 +50,6 @@ public Result evaluate(Stats stats) { return new Result(this, stats.indexSize.getBytes() >= value.getBytes()); } - @Override - boolean includedInVersion(Version version) { - return version.onOrAfter(Version.V_6_1_0); - } - @Override public String getWriteableName() { return NAME; diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverRequest.java b/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverRequest.java index 1150a29b07766..082b81c1ccf51 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverRequest.java @@ -135,9 +135,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(dryRun); out.writeVInt(conditions.size()); for (Condition condition : conditions.values()) { - if (condition.includedInVersion(out.getVersion())) { - out.writeNamedWriteable(condition); - } + out.writeNamedWriteable(condition); } createIndexRequest.writeTo(out); } diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverResponse.java b/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverResponse.java index 52c5470618671..cd58253d5e7c2 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverResponse.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.admin.indices.rollover; -import org.elasticsearch.Version; import org.elasticsearch.action.support.master.ShardsAcknowledgedResponse; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.io.stream.StreamInput; @@ -122,60 +121,32 @@ public boolean isRolledOver() { @Override public void readFrom(StreamInput in) throws IOException { - if (in.getVersion().onOrAfter(Version.V_6_4_0)) { - super.readFrom(in); - oldIndex = in.readString(); - newIndex = in.readString(); - int conditionSize = in.readVInt(); - conditionStatus = new HashMap<>(conditionSize); - for (int i = 0; i < conditionSize; i++) { - conditionStatus.put(in.readString(), in.readBoolean()); - } - dryRun = in.readBoolean(); - rolledOver = in.readBoolean(); - readShardsAcknowledged(in); - } else { - oldIndex = in.readString(); - newIndex = in.readString(); - int conditionSize = in.readVInt(); - conditionStatus = new HashMap<>(conditionSize); - for (int i = 0; i < conditionSize; i++) { - conditionStatus.put(in.readString(), in.readBoolean()); - } - dryRun = in.readBoolean(); - rolledOver = in.readBoolean(); - acknowledged = in.readBoolean(); - readShardsAcknowledged(in); + super.readFrom(in); + oldIndex = in.readString(); + newIndex = in.readString(); + int conditionSize = in.readVInt(); + conditionStatus = new HashMap<>(conditionSize); + for (int i = 0; i < conditionSize; i++) { + conditionStatus.put(in.readString(), in.readBoolean()); } + dryRun = in.readBoolean(); + rolledOver = in.readBoolean(); + readShardsAcknowledged(in); } @Override public void writeTo(StreamOutput out) throws IOException { - if (out.getVersion().onOrAfter(Version.V_6_4_0)) { - super.writeTo(out); - out.writeString(oldIndex); - out.writeString(newIndex); - out.writeVInt(conditionStatus.size()); - for (Map.Entry entry : conditionStatus.entrySet()) { - out.writeString(entry.getKey()); - out.writeBoolean(entry.getValue()); - } - out.writeBoolean(dryRun); - out.writeBoolean(rolledOver); - writeShardsAcknowledged(out); - } else { - out.writeString(oldIndex); - out.writeString(newIndex); - out.writeVInt(conditionStatus.size()); - for (Map.Entry entry : conditionStatus.entrySet()) { - out.writeString(entry.getKey()); - out.writeBoolean(entry.getValue()); - } - out.writeBoolean(dryRun); - out.writeBoolean(rolledOver); - out.writeBoolean(acknowledged); - writeShardsAcknowledged(out); + super.writeTo(out); + out.writeString(oldIndex); + out.writeString(newIndex); + out.writeVInt(conditionStatus.size()); + for (Map.Entry entry : conditionStatus.entrySet()) { + out.writeString(entry.getKey()); + out.writeBoolean(entry.getValue()); } + out.writeBoolean(dryRun); + out.writeBoolean(rolledOver); + writeShardsAcknowledged(out); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/settings/get/GetSettingsRequest.java b/server/src/main/java/org/elasticsearch/action/admin/indices/settings/get/GetSettingsRequest.java index 1f4214dbdd7a4..dfcd0e33b3f43 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/settings/get/GetSettingsRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/settings/get/GetSettingsRequest.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.admin.indices.settings.get; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.IndicesRequest; import org.elasticsearch.action.ValidateActions; @@ -71,9 +70,7 @@ public GetSettingsRequest(StreamInput in) throws IOException { indicesOptions = IndicesOptions.readIndicesOptions(in); names = in.readStringArray(); humanReadable = in.readBoolean(); - if (in.getVersion().onOrAfter(Version.V_6_4_0)) { - includeDefaults = in.readBoolean(); - } + includeDefaults = in.readBoolean(); } @Override @@ -83,9 +80,7 @@ public void writeTo(StreamOutput out) throws IOException { indicesOptions.writeIndicesOptions(out); out.writeStringArray(names); out.writeBoolean(humanReadable); - if (out.getVersion().onOrAfter(Version.V_6_4_0)) { - out.writeBoolean(includeDefaults); - } + out.writeBoolean(includeDefaults); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/settings/get/GetSettingsResponse.java b/server/src/main/java/org/elasticsearch/action/admin/indices/settings/get/GetSettingsResponse.java index c5d931a69d29b..dc11ef6c9b22a 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/settings/get/GetSettingsResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/settings/get/GetSettingsResponse.java @@ -109,12 +109,9 @@ public void readFrom(StreamInput in) throws IOException { settingsBuilder.put(in.readString(), Settings.readSettingsFromStream(in)); } ImmutableOpenMap.Builder defaultSettingsBuilder = ImmutableOpenMap.builder(); - - if (in.getVersion().onOrAfter(org.elasticsearch.Version.V_6_4_0)) { - int defaultSettingsSize = in.readVInt(); - for (int i = 0; i < defaultSettingsSize ; i++) { - defaultSettingsBuilder.put(in.readString(), Settings.readSettingsFromStream(in)); - } + int defaultSettingsSize = in.readVInt(); + for (int i = 0; i < defaultSettingsSize; i++) { + defaultSettingsBuilder.put(in.readString(), Settings.readSettingsFromStream(in)); } indexToSettings = settingsBuilder.build(); indexToDefaultSettings = defaultSettingsBuilder.build(); @@ -128,12 +125,10 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(cursor.key); Settings.writeSettingsToStream(cursor.value, out); } - if (out.getVersion().onOrAfter(org.elasticsearch.Version.V_6_4_0)) { - out.writeVInt(indexToDefaultSettings.size()); - for (ObjectObjectCursor cursor : indexToDefaultSettings) { - out.writeString(cursor.key); - Settings.writeSettingsToStream(cursor.value, out); - } + out.writeVInt(indexToDefaultSettings.size()); + for (ObjectObjectCursor cursor : indexToDefaultSettings) { + out.writeString(cursor.key); + Settings.writeSettingsToStream(cursor.value, out); } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/stats/ShardStats.java b/server/src/main/java/org/elasticsearch/action/admin/indices/stats/ShardStats.java index 15173e581a738..76c18654321c7 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/stats/ShardStats.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/stats/ShardStats.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.admin.indices.stats; -import org.elasticsearch.Version; import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.io.stream.StreamInput; @@ -127,12 +126,8 @@ public void readFrom(StreamInput in) throws IOException { statePath = in.readString(); dataPath = in.readString(); isCustomDataPath = in.readBoolean(); - if (in.getVersion().onOrAfter(Version.V_6_0_0_alpha1)) { - seqNoStats = in.readOptionalWriteable(SeqNoStats::new); - } - if (in.getVersion().onOrAfter(Version.V_6_7_0)) { - retentionLeaseStats = in.readOptionalWriteable(RetentionLeaseStats::new); - } + seqNoStats = in.readOptionalWriteable(SeqNoStats::new); + retentionLeaseStats = in.readOptionalWriteable(RetentionLeaseStats::new); } @Override @@ -143,12 +138,8 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(statePath); out.writeString(dataPath); out.writeBoolean(isCustomDataPath); - if (out.getVersion().onOrAfter(Version.V_6_0_0_alpha1)) { - out.writeOptionalWriteable(seqNoStats); - } - if (out.getVersion().onOrAfter(Version.V_6_7_0)) { - out.writeOptionalWriteable(retentionLeaseStats); - } + out.writeOptionalWriteable(seqNoStats); + out.writeOptionalWriteable(retentionLeaseStats); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateRequest.java b/server/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateRequest.java index 0ff5785fcd358..7e3c549cfcf76 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateRequest.java @@ -21,7 +21,6 @@ import org.apache.logging.log4j.LogManager; import org.elasticsearch.ElasticsearchGenerationException; import org.elasticsearch.ElasticsearchParseException; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.IndicesRequest; import org.elasticsearch.action.admin.indices.alias.Alias; @@ -459,12 +458,7 @@ public void readFrom(StreamInput in) throws IOException { super.readFrom(in); cause = in.readString(); name = in.readString(); - - if (in.getVersion().onOrAfter(Version.V_6_0_0_alpha1)) { - indexPatterns = in.readStringList(); - } else { - indexPatterns = Collections.singletonList(in.readString()); - } + indexPatterns = in.readStringList(); order = in.readInt(); create = in.readBoolean(); settings = readSettingsFromStream(in); @@ -474,14 +468,6 @@ public void readFrom(StreamInput in) throws IOException { String mappingSource = in.readString(); mappings.put(type, mappingSource); } - if (in.getVersion().before(Version.V_6_5_0)) { - // Used to be used for custom index metadata - int customSize = in.readVInt(); - assert customSize == 0 : "expected not to have any custom metadata"; - if (customSize > 0) { - throw new IllegalStateException("unexpected custom metadata when none is supported"); - } - } int aliasesSize = in.readVInt(); for (int i = 0; i < aliasesSize; i++) { aliases.add(Alias.read(in)); @@ -494,11 +480,7 @@ public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeString(cause); out.writeString(name); - if (out.getVersion().onOrAfter(Version.V_6_0_0_alpha1)) { - out.writeStringCollection(indexPatterns); - } else { - out.writeString(indexPatterns.size() > 0 ? indexPatterns.get(0) : ""); - } + out.writeStringCollection(indexPatterns); out.writeInt(order); out.writeBoolean(create); writeSettingsToStream(settings, out); @@ -507,9 +489,6 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(entry.getKey()); out.writeString(entry.getValue()); } - if (out.getVersion().before(Version.V_6_5_0)) { - out.writeVInt(0); - } out.writeVInt(aliases.size()); for (Alias alias : aliases) { alias.writeTo(out); diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/validate/query/QueryExplanation.java b/server/src/main/java/org/elasticsearch/action/admin/indices/validate/query/QueryExplanation.java index b60bc407ce70c..3c796a061a90a 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/validate/query/QueryExplanation.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/validate/query/QueryExplanation.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.admin.indices.validate.query; -import org.elasticsearch.Version; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -115,11 +114,7 @@ public String getExplanation() { @Override public void readFrom(StreamInput in) throws IOException { - if (in.getVersion().onOrAfter(Version.V_6_4_0)) { - index = in.readOptionalString(); - } else { - index = in.readString(); - } + index = in.readOptionalString(); shard = in.readInt(); valid = in.readBoolean(); explanation = in.readOptionalString(); @@ -128,11 +123,7 @@ public void readFrom(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { - if (out.getVersion().onOrAfter(Version.V_6_4_0)) { - out.writeOptionalString(index); - } else { - out.writeString(index); - } + out.writeOptionalString(index); out.writeInt(shard); out.writeBoolean(valid); out.writeOptionalString(explanation); diff --git a/server/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java b/server/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java index 838293b8b1f65..dff7479d46219 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java @@ -21,7 +21,6 @@ import org.elasticsearch.ElasticsearchException; import org.elasticsearch.ExceptionsHelper; -import org.elasticsearch.Version; import org.elasticsearch.action.DocWriteRequest.OpType; import org.elasticsearch.action.DocWriteResponse; import org.elasticsearch.action.delete.DeleteResponse; @@ -238,16 +237,8 @@ public Failure(StreamInput in) throws IOException { id = in.readOptionalString(); cause = in.readException(); status = ExceptionsHelper.status(cause); - if (in.getVersion().onOrAfter(Version.V_6_0_0_alpha1)) { - seqNo = in.readZLong(); - } else { - seqNo = SequenceNumbers.UNASSIGNED_SEQ_NO; - } - if (supportsAbortedFlag(in.getVersion())) { - aborted = in.readBoolean(); - } else { - aborted = false; - } + seqNo = in.readZLong(); + aborted = in.readBoolean(); } @Override @@ -256,17 +247,8 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(getType()); out.writeOptionalString(getId()); out.writeException(getCause()); - if (out.getVersion().onOrAfter(Version.V_6_0_0_alpha1)) { - out.writeZLong(getSeqNo()); - } - if (supportsAbortedFlag(out.getVersion())) { - out.writeBoolean(aborted); - } - } - - private static boolean supportsAbortedFlag(Version version) { - // The "aborted" flag was not in 6.0.0-beta2 - return version.after(Version.V_6_0_0_beta2); + out.writeZLong(getSeqNo()); + out.writeBoolean(aborted); } /** diff --git a/server/src/main/java/org/elasticsearch/action/get/GetRequest.java b/server/src/main/java/org/elasticsearch/action/get/GetRequest.java index 2a4ba570d7011..390553fd8b55b 100644 --- a/server/src/main/java/org/elasticsearch/action/get/GetRequest.java +++ b/server/src/main/java/org/elasticsearch/action/get/GetRequest.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.get; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.RealtimeRequest; import org.elasticsearch.action.ValidateActions; @@ -268,9 +267,6 @@ public void readFrom(StreamInput in) throws IOException { type = in.readString(); id = in.readString(); routing = in.readOptionalString(); - if (in.getVersion().before(Version.V_7_0_0)) { - in.readOptionalString(); - } preference = in.readOptionalString(); refresh = in.readBoolean(); storedFields = in.readOptionalStringArray(); @@ -287,9 +283,6 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(type); out.writeString(id); out.writeOptionalString(routing); - if (out.getVersion().before(Version.V_7_0_0)) { - out.writeOptionalString(null); - } out.writeOptionalString(preference); out.writeBoolean(refresh); diff --git a/server/src/main/java/org/elasticsearch/action/resync/ResyncReplicationRequest.java b/server/src/main/java/org/elasticsearch/action/resync/ResyncReplicationRequest.java index 4680fc49dd82a..0450c165a236a 100644 --- a/server/src/main/java/org/elasticsearch/action/resync/ResyncReplicationRequest.java +++ b/server/src/main/java/org/elasticsearch/action/resync/ResyncReplicationRequest.java @@ -18,12 +18,9 @@ */ package org.elasticsearch.action.resync; -import org.elasticsearch.Version; -import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.support.replication.ReplicatedWriteRequest; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.index.seqno.SequenceNumbers; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.index.translog.Translog; @@ -69,28 +66,16 @@ public void readFrom(final StreamInput in) throws IOException { // TODO: https://github.com/elastic/elasticsearch/issues/38556 //assert Version.CURRENT.major <= 7; super.readFrom(in); - if (in.getVersion().onOrAfter(Version.V_6_4_0)) { - trimAboveSeqNo = in.readZLong(); - } else { - trimAboveSeqNo = SequenceNumbers.UNASSIGNED_SEQ_NO; - } - if (in.getVersion().onOrAfter(Version.V_6_5_0)) { - maxSeenAutoIdTimestampOnPrimary = in.readZLong(); - } else { - maxSeenAutoIdTimestampOnPrimary = IndexRequest.UNSET_AUTO_GENERATED_TIMESTAMP; - } + trimAboveSeqNo = in.readZLong(); + maxSeenAutoIdTimestampOnPrimary = in.readZLong(); operations = in.readArray(Translog.Operation::readOperation, Translog.Operation[]::new); } @Override public void writeTo(final StreamOutput out) throws IOException { super.writeTo(out); - if (out.getVersion().onOrAfter(Version.V_6_4_0)) { - out.writeZLong(trimAboveSeqNo); - } - if (out.getVersion().onOrAfter(Version.V_6_5_0)) { - out.writeZLong(maxSeenAutoIdTimestampOnPrimary); - } + out.writeZLong(trimAboveSeqNo); + out.writeZLong(maxSeenAutoIdTimestampOnPrimary); out.writeArray(Translog.Operation::writeOperation, operations); } diff --git a/server/src/main/java/org/elasticsearch/action/resync/TransportResyncReplicationAction.java b/server/src/main/java/org/elasticsearch/action/resync/TransportResyncReplicationAction.java index 2a219fcc5fd5a..c3aa39009ce8f 100644 --- a/server/src/main/java/org/elasticsearch/action/resync/TransportResyncReplicationAction.java +++ b/server/src/main/java/org/elasticsearch/action/resync/TransportResyncReplicationAction.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.resync; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.replication.ReplicationOperation; @@ -94,12 +93,7 @@ protected void sendReplicaRequest( final ConcreteReplicaRequest replicaRequest, final DiscoveryNode node, final ActionListener listener) { - if (node.getVersion().onOrAfter(Version.V_6_0_0_alpha1)) { - super.sendReplicaRequest(replicaRequest, node, listener); - } else { - final long pre60NodeCheckpoint = SequenceNumbers.PRE_60_NODE_CHECKPOINT; - listener.onResponse(new ReplicaResponse(pre60NodeCheckpoint, pre60NodeCheckpoint)); - } + super.sendReplicaRequest(replicaRequest, node, listener); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/search/SearchRequest.java b/server/src/main/java/org/elasticsearch/action/search/SearchRequest.java index ea5c442f5050c..18c2f529a711d 100644 --- a/server/src/main/java/org/elasticsearch/action/search/SearchRequest.java +++ b/server/src/main/java/org/elasticsearch/action/search/SearchRequest.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.search; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.IndicesRequest; @@ -198,26 +197,16 @@ public SearchRequest(StreamInput in) throws IOException { batchedReduceSize = in.readVInt(); maxConcurrentShardRequests = in.readVInt(); preFilterShardSize = in.readVInt(); - if (in.getVersion().onOrAfter(Version.V_6_3_0)) { - allowPartialSearchResults = in.readOptionalBoolean(); - } - if (in.getVersion().onOrAfter(Version.V_6_7_0)) { - localClusterAlias = in.readOptionalString(); - if (localClusterAlias != null) { - absoluteStartMillis = in.readVLong(); - finalReduce = in.readBoolean(); - } else { - absoluteStartMillis = DEFAULT_ABSOLUTE_START_MILLIS; - finalReduce = true; - } + allowPartialSearchResults = in.readOptionalBoolean(); + localClusterAlias = in.readOptionalString(); + if (localClusterAlias != null) { + absoluteStartMillis = in.readVLong(); + finalReduce = in.readBoolean(); } else { - localClusterAlias = null; absoluteStartMillis = DEFAULT_ABSOLUTE_START_MILLIS; finalReduce = true; } - if (in.getVersion().onOrAfter(Version.V_7_0_0)) { - ccsMinimizeRoundtrips = in.readBoolean(); - } + ccsMinimizeRoundtrips = in.readBoolean(); } @Override @@ -235,19 +224,14 @@ public void writeTo(StreamOutput out) throws IOException { out.writeVInt(batchedReduceSize); out.writeVInt(maxConcurrentShardRequests); out.writeVInt(preFilterShardSize); - if (out.getVersion().onOrAfter(Version.V_6_3_0)) { - out.writeOptionalBoolean(allowPartialSearchResults); - } - if (out.getVersion().onOrAfter(Version.V_6_7_0)) { - out.writeOptionalString(localClusterAlias); - if (localClusterAlias != null) { - out.writeVLong(absoluteStartMillis); - out.writeBoolean(finalReduce); - } - } - if (out.getVersion().onOrAfter(Version.V_7_0_0)) { - out.writeBoolean(ccsMinimizeRoundtrips); + out.writeOptionalBoolean(allowPartialSearchResults); + out.writeOptionalString(localClusterAlias); + if (localClusterAlias != null) { + out.writeVLong(absoluteStartMillis); + out.writeBoolean(finalReduce); } + out.writeBoolean(ccsMinimizeRoundtrips); + } @Override diff --git a/server/src/main/java/org/elasticsearch/action/search/SearchResponse.java b/server/src/main/java/org/elasticsearch/action/search/SearchResponse.java index 6ae5e1a553eb6..0e6773f5fbb43 100644 --- a/server/src/main/java/org/elasticsearch/action/search/SearchResponse.java +++ b/server/src/main/java/org/elasticsearch/action/search/SearchResponse.java @@ -20,7 +20,6 @@ package org.elasticsearch.action.search; import org.apache.lucene.search.TotalHits; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionResponse; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.ParseField; @@ -370,11 +369,7 @@ public void readFrom(StreamInput in) throws IOException { shardFailures[i] = readShardSearchFailure(in); } } - if (in.getVersion().onOrAfter(Version.V_6_1_0)) { - clusters = new Clusters(in); - } else { - clusters = Clusters.EMPTY; - } + clusters = new Clusters(in); scrollId = in.readOptionalString(); tookInMillis = in.readVLong(); skippedShards = in.readVInt(); @@ -391,9 +386,7 @@ public void writeTo(StreamOutput out) throws IOException { for (ShardSearchFailure shardSearchFailure : shardFailures) { shardSearchFailure.writeTo(out); } - if (out.getVersion().onOrAfter(Version.V_6_1_0)) { - clusters.writeTo(out); - } + clusters.writeTo(out); out.writeOptionalString(scrollId); out.writeVLong(tookInMillis); out.writeVInt(skippedShards); diff --git a/server/src/main/java/org/elasticsearch/action/support/IndicesOptions.java b/server/src/main/java/org/elasticsearch/action/support/IndicesOptions.java index 81364c31c9ed9..0644916d8f56a 100644 --- a/server/src/main/java/org/elasticsearch/action/support/IndicesOptions.java +++ b/server/src/main/java/org/elasticsearch/action/support/IndicesOptions.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.support; -import org.elasticsearch.Version; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.xcontent.ToXContent; @@ -259,30 +258,12 @@ public boolean ignoreThrottled() { } public void writeIndicesOptions(StreamOutput out) throws IOException { - EnumSet