diff --git a/server/src/main/java/org/opensearch/LegacyESVersion.java b/server/src/main/java/org/opensearch/LegacyESVersion.java index 9fd782d3fe172..af5999699f762 100644 --- a/server/src/main/java/org/opensearch/LegacyESVersion.java +++ b/server/src/main/java/org/opensearch/LegacyESVersion.java @@ -46,9 +46,6 @@ */ public class LegacyESVersion extends Version { - public static final LegacyESVersion V_6_6_0 = new LegacyESVersion(6060099, org.apache.lucene.util.Version.LUCENE_7_6_0); - public static final LegacyESVersion V_6_6_1 = new LegacyESVersion(6060199, org.apache.lucene.util.Version.LUCENE_7_6_0); - public static final LegacyESVersion V_6_6_2 = new LegacyESVersion(6060299, org.apache.lucene.util.Version.LUCENE_7_6_0); public static final LegacyESVersion V_6_7_0 = new LegacyESVersion(6070099, org.apache.lucene.util.Version.LUCENE_7_7_0); public static final LegacyESVersion V_6_7_1 = new LegacyESVersion(6070199, org.apache.lucene.util.Version.LUCENE_7_7_0); public static final LegacyESVersion V_6_7_2 = new LegacyESVersion(6070299, org.apache.lucene.util.Version.LUCENE_7_7_0); diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/state/ClusterStateRequest.java b/server/src/main/java/org/opensearch/action/admin/cluster/state/ClusterStateRequest.java index 22c3b85312d76..91e01aa74f8a5 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/state/ClusterStateRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/state/ClusterStateRequest.java @@ -32,7 +32,6 @@ package org.opensearch.action.admin.cluster.state; -import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.IndicesRequest; import org.opensearch.action.support.IndicesOptions; @@ -69,10 +68,8 @@ public ClusterStateRequest(StreamInput in) throws IOException { customs = in.readBoolean(); indices = in.readStringArray(); indicesOptions = IndicesOptions.readIndicesOptions(in); - if (in.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) { - waitForTimeout = in.readTimeValue(); - waitForMetadataVersion = in.readOptionalLong(); - } + waitForTimeout = in.readTimeValue(); + waitForMetadataVersion = in.readOptionalLong(); } @Override @@ -85,10 +82,8 @@ public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(customs); out.writeStringArray(indices); indicesOptions.writeIndicesOptions(out); - if (out.getVersion().onOrAfter(LegacyESVersion.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/opensearch/action/admin/cluster/state/ClusterStateResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/state/ClusterStateResponse.java index fc24ee45293f8..d2f053137e446 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/state/ClusterStateResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/state/ClusterStateResponse.java @@ -56,17 +56,11 @@ public class ClusterStateResponse extends ActionResponse { public ClusterStateResponse(StreamInput in) throws IOException { super(in); clusterName = new ClusterName(in); - if (in.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) { - clusterState = in.readOptionalWriteable(innerIn -> ClusterState.readFrom(innerIn, null)); - } else { - clusterState = ClusterState.readFrom(in, null); - } + clusterState = in.readOptionalWriteable(innerIn -> ClusterState.readFrom(innerIn, null)); if (in.getVersion().before(LegacyESVersion.V_7_0_0)) { new ByteSizeValue(in); } - if (in.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) { - waitForTimedOut = in.readBoolean(); - } + waitForTimedOut = in.readBoolean(); } public ClusterStateResponse(ClusterName clusterName, ClusterState clusterState, boolean waitForTimedOut) { @@ -101,17 +95,11 @@ public boolean isWaitForTimedOut() { @Override public void writeTo(StreamOutput out) throws IOException { clusterName.writeTo(out); - if (out.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) { - out.writeOptionalWriteable(clusterState); - } else { - clusterState.writeTo(out); - } + out.writeOptionalWriteable(clusterState); if (out.getVersion().before(LegacyESVersion.V_7_0_0)) { ByteSizeValue.ZERO.writeTo(out); } - if (out.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) { - out.writeBoolean(waitForTimedOut); - } + out.writeBoolean(waitForTimedOut); } @Override diff --git a/server/src/main/java/org/opensearch/action/delete/DeleteRequest.java b/server/src/main/java/org/opensearch/action/delete/DeleteRequest.java index 125601a822d45..b6fda084e2958 100644 --- a/server/src/main/java/org/opensearch/action/delete/DeleteRequest.java +++ b/server/src/main/java/org/opensearch/action/delete/DeleteRequest.java @@ -97,13 +97,8 @@ public DeleteRequest(@Nullable ShardId shardId, StreamInput in) throws IOExcepti } version = in.readLong(); versionType = VersionType.fromValue(in.readByte()); - if (in.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) { - ifSeqNo = in.readZLong(); - ifPrimaryTerm = in.readVLong(); - } else { - ifSeqNo = UNASSIGNED_SEQ_NO; - ifPrimaryTerm = UNASSIGNED_PRIMARY_TERM; - } + ifSeqNo = in.readZLong(); + ifPrimaryTerm = in.readVLong(); } public DeleteRequest() { @@ -348,18 +343,8 @@ private void writeBody(StreamOutput out) throws IOException { } out.writeLong(version); out.writeByte(versionType.getValue()); - if (out.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) { - out.writeZLong(ifSeqNo); - out.writeVLong(ifPrimaryTerm); - } else if (ifSeqNo != UNASSIGNED_SEQ_NO || ifPrimaryTerm != UNASSIGNED_PRIMARY_TERM) { - assert false : "setIfMatch [" + ifSeqNo + "], currentDocTem [" + ifPrimaryTerm + "]"; - throw new IllegalStateException( - "sequence number based compare and write is not supported until all nodes are on version 7.0 or higher. " - + "Stream version [" - + out.getVersion() - + "]" - ); - } + out.writeZLong(ifSeqNo); + out.writeVLong(ifPrimaryTerm); } @Override diff --git a/server/src/main/java/org/opensearch/action/index/IndexRequest.java b/server/src/main/java/org/opensearch/action/index/IndexRequest.java index 1cbf98b265822..ccbe48ab40a51 100644 --- a/server/src/main/java/org/opensearch/action/index/IndexRequest.java +++ b/server/src/main/java/org/opensearch/action/index/IndexRequest.java @@ -167,13 +167,8 @@ public IndexRequest(@Nullable ShardId shardId, StreamInput in) throws IOExceptio } else { contentType = null; } - if (in.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) { - ifSeqNo = in.readZLong(); - ifPrimaryTerm = in.readVLong(); - } else { - ifSeqNo = UNASSIGNED_SEQ_NO; - ifPrimaryTerm = UNASSIGNED_PRIMARY_TERM; - } + ifSeqNo = in.readZLong(); + ifPrimaryTerm = in.readVLong(); if (in.getVersion().onOrAfter(LegacyESVersion.V_7_10_0)) { requireAlias = in.readBoolean(); } else { @@ -765,18 +760,8 @@ private void writeBody(StreamOutput out) throws IOException { } else { out.writeBoolean(false); } - if (out.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) { - out.writeZLong(ifSeqNo); - out.writeVLong(ifPrimaryTerm); - } else if (ifSeqNo != UNASSIGNED_SEQ_NO || ifPrimaryTerm != UNASSIGNED_PRIMARY_TERM) { - assert false : "setIfMatch [" + ifSeqNo + "], currentDocTem [" + ifPrimaryTerm + "]"; - throw new IllegalStateException( - "sequence number based compare and write is not supported until all nodes are on version 7.0 or higher. " - + "Stream version [" - + out.getVersion() - + "]" - ); - } + out.writeZLong(ifSeqNo); + out.writeVLong(ifPrimaryTerm); if (out.getVersion().onOrAfter(LegacyESVersion.V_7_10_0)) { out.writeBoolean(requireAlias); } diff --git a/server/src/main/java/org/opensearch/action/support/IndicesOptions.java b/server/src/main/java/org/opensearch/action/support/IndicesOptions.java index f310f7528c4f5..09b691787dffe 100644 --- a/server/src/main/java/org/opensearch/action/support/IndicesOptions.java +++ b/server/src/main/java/org/opensearch/action/support/IndicesOptions.java @@ -263,11 +263,6 @@ public EnumSet getExpandWildcards() { public void writeIndicesOptions(StreamOutput out) throws IOException { EnumSet