diff --git a/server/src/main/java/org/opensearch/LegacyESVersion.java b/server/src/main/java/org/opensearch/LegacyESVersion.java index 9fd782d3fe1..af5999699f7 100644 --- a/server/src/main/java/org/opensearch/LegacyESVersion.java +++ b/server/src/main/java/org/opensearch/LegacyESVersion.java @@ -46,9 +46,6 @@ import java.lang.reflect.Field; */ 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 22c3b85312d..91e01aa74f8 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 class ClusterStateRequest extends MasterNodeReadRequest 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 class ClusterStateResponse extends ActionResponse { @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 125601a822d..b6fda084e29 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 class DeleteRequest extends ReplicatedWriteRequest } 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 @@ public class DeleteRequest extends ReplicatedWriteRequest } 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 1cbf98b2658..ccbe48ab40a 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 class IndexRequest extends ReplicatedWriteRequest implement } 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 @@ public class IndexRequest extends ReplicatedWriteRequest implement } 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 f310f7528c4..09b691787df 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 class IndicesOptions implements ToXContentFragment { public void writeIndicesOptions(StreamOutput out) throws IOException { EnumSet