diff --git a/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportUpdateByQueryAction.java b/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportUpdateByQueryAction.java index 382a732bc0649..25fd1a250d362 100644 --- a/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportUpdateByQueryAction.java +++ b/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportUpdateByQueryAction.java @@ -33,7 +33,6 @@ package org.opensearch.index.reindex; import org.apache.logging.log4j.Logger; -import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionListener; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.ActionFilters; @@ -113,8 +112,6 @@ protected void doExecute(Task task, UpdateByQueryRequest request, ActionListener */ static class AsyncIndexBySearchAction extends AbstractAsyncBulkByScrollAction { - private final boolean useSeqNoForCAS; - AsyncIndexBySearchAction( BulkByScrollTask task, Logger logger, @@ -125,21 +122,7 @@ static class AsyncIndexBySearchAction extends AbstractAsyncBulkByScrollAction listener ) { - super( - task, - // not all nodes support sequence number powered optimistic concurrency control, we fall back to version - clusterState.nodes().getMinNodeVersion().onOrAfter(LegacyESVersion.V_6_7_0) == false, - // all nodes support sequence number powered optimistic concurrency control and we can use it - clusterState.nodes().getMinNodeVersion().onOrAfter(LegacyESVersion.V_6_7_0), - logger, - client, - threadPool, - request, - listener, - scriptService, - null - ); - useSeqNoForCAS = clusterState.nodes().getMinNodeVersion().onOrAfter(LegacyESVersion.V_6_7_0); + super(task, false, true, logger, client, threadPool, request, listener, scriptService, null); } @Override diff --git a/qa/full-cluster-restart/src/test/java/org/opensearch/upgrades/FullClusterRestartIT.java b/qa/full-cluster-restart/src/test/java/org/opensearch/upgrades/FullClusterRestartIT.java index 4412b9d67ddd9..77bd7e443f7f7 100644 --- a/qa/full-cluster-restart/src/test/java/org/opensearch/upgrades/FullClusterRestartIT.java +++ b/qa/full-cluster-restart/src/test/java/org/opensearch/upgrades/FullClusterRestartIT.java @@ -51,7 +51,6 @@ import org.opensearch.common.xcontent.support.XContentMapValues; import org.opensearch.index.IndexSettings; import org.opensearch.rest.action.document.RestBulkAction; -import org.opensearch.rest.action.document.RestGetAction; import org.opensearch.rest.action.document.RestIndexAction; import org.opensearch.rest.action.document.RestUpdateAction; import org.opensearch.rest.action.search.RestExplainAction; @@ -109,7 +108,7 @@ public void setIndex() { @Before public void setType() { - type = getOldClusterVersion().before(LegacyESVersion.V_6_7_0) ? "doc" : "_doc"; + type = "_doc"; } public void testSearch() throws Exception { @@ -633,9 +632,6 @@ void assertRealtimeGetWorks(final String typeName) throws IOException { client().performRequest(updateRequest); Request getRequest = new Request("GET", "/" + index + "/" + typeName + "/" + docId); - if (getOldClusterVersion().before(LegacyESVersion.V_6_7_0)) { - getRequest.setOptions(expectWarnings(RestGetAction.TYPES_DEPRECATION_MESSAGE)); - } Map getRsp = entityAsMap(client().performRequest(getRequest)); Map source = (Map) getRsp.get("_source"); assertTrue("doc does not contain 'foo' key: " + source, source.containsKey("foo")); @@ -682,9 +678,6 @@ public void testSingleDoc() throws IOException { Request request = new Request("GET", docLocation); - if (getOldClusterVersion().before(LegacyESVersion.V_6_7_0)) { - request.setOptions(expectWarnings(RestGetAction.TYPES_DEPRECATION_MESSAGE)); - } assertThat(toStr(client().performRequest(request)), containsString(doc)); } @@ -1269,9 +1262,6 @@ private void saveInfoDocument(String type, String value) throws IOException { private String loadInfoDocument(String type) throws IOException { Request request = new Request("GET", "/info/" + this.type + "/" + index + "_" + type); request.addParameter("filter_path", "_source"); - if (getOldClusterVersion().before(LegacyESVersion.V_6_7_0)) { - request.setOptions(expectWarnings(RestGetAction.TYPES_DEPRECATION_MESSAGE)); - } String doc = toStr(client().performRequest(request)); Matcher m = Pattern.compile("\"value\":\"(.+)\"").matcher(doc); assertTrue(doc, m.find()); @@ -1352,9 +1342,7 @@ public void testOperationBasedRecovery() throws Exception { final Settings.Builder settings = Settings.builder() .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1); - if (getOldClusterVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { - settings.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), randomBoolean()); - } + settings.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), randomBoolean()); createIndex(index, settings.build()); ensureGreen(index); int committedDocs = randomIntBetween(100, 200); @@ -1383,7 +1371,6 @@ public void testOperationBasedRecovery() throws Exception { * Verifies that once all shard copies on the new version, we should turn off the translog retention for indices with soft-deletes. */ public void testTurnOffTranslogRetentionAfterUpgraded() throws Exception { - assumeTrue("requires soft-deletes and retention leases", getOldClusterVersion().onOrAfter(LegacyESVersion.V_6_7_0)); if (isRunningAgainstOldCluster()) { createIndex(index, Settings.builder() .put(IndexMetadata.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) @@ -1484,7 +1471,7 @@ public void testSystemIndexMetadataIsUpgraded() throws Exception { // make sure .tasks index exists Request getTasksIndex = new Request("GET", "/.tasks"); getTasksIndex.addParameter("allow_no_indices", "false"); - if (getOldClusterVersion().onOrAfter(LegacyESVersion.V_6_7_0) && getOldClusterVersion().before(LegacyESVersion.V_7_0_0)) { + if (getOldClusterVersion().before(LegacyESVersion.V_7_0_0)) { getTasksIndex.addParameter("include_type_name", "false"); } diff --git a/qa/translog-policy/src/test/java/org/opensearch/upgrades/TranslogPolicyIT.java b/qa/translog-policy/src/test/java/org/opensearch/upgrades/TranslogPolicyIT.java index 9ab58d1e758cd..72400a5705162 100644 --- a/qa/translog-policy/src/test/java/org/opensearch/upgrades/TranslogPolicyIT.java +++ b/qa/translog-policy/src/test/java/org/opensearch/upgrades/TranslogPolicyIT.java @@ -95,7 +95,7 @@ public void setIndex() { @Before public void setType() { - type = getOldClusterVersion().before(LegacyESVersion.V_6_7_0) ? "doc" : "_doc"; + type = "_doc"; } public void testEmptyIndex() throws Exception { diff --git a/server/src/main/java/org/opensearch/Build.java b/server/src/main/java/org/opensearch/Build.java index a4c5aad0b7b95..d9fe5fc577e14 100644 --- a/server/src/main/java/org/opensearch/Build.java +++ b/server/src/main/java/org/opensearch/Build.java @@ -246,12 +246,7 @@ public static void writeBuild(Build build, StreamOutput out) throws IOException if (out.getVersion().before(Version.V_2_0_0)) { out.writeString("oss"); } - final Type buildType; - if (out.getVersion().before(LegacyESVersion.V_6_7_0) && build.type() == Type.DOCKER) { - buildType = Type.TAR; - } else { - buildType = build.type(); - } + final Type buildType = build.type(); out.writeString(buildType.displayName()); out.writeString(build.hash()); out.writeString(build.date()); diff --git a/server/src/main/java/org/opensearch/LegacyESVersion.java b/server/src/main/java/org/opensearch/LegacyESVersion.java index af5999699f762..db0b7aaaa7097 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_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); public static final LegacyESVersion V_6_8_0 = new LegacyESVersion(6080099, org.apache.lucene.util.Version.LUCENE_7_7_0); public static final LegacyESVersion V_6_8_1 = new LegacyESVersion(6080199, org.apache.lucene.util.Version.LUCENE_7_7_0); public static final LegacyESVersion V_6_8_2 = new LegacyESVersion(6080299, org.apache.lucene.util.Version.LUCENE_7_7_0); diff --git a/server/src/main/java/org/opensearch/OpenSearchException.java b/server/src/main/java/org/opensearch/OpenSearchException.java index 9139f55b331c7..b6bc9b0157b64 100644 --- a/server/src/main/java/org/opensearch/OpenSearchException.java +++ b/server/src/main/java/org/opensearch/OpenSearchException.java @@ -1537,25 +1537,25 @@ private enum OpenSearchExceptionHandle { org.opensearch.snapshots.SnapshotInProgressException.class, org.opensearch.snapshots.SnapshotInProgressException::new, 151, - LegacyESVersion.V_6_7_0 + UNKNOWN_VERSION_ADDED ), NO_SUCH_REMOTE_CLUSTER_EXCEPTION( org.opensearch.transport.NoSuchRemoteClusterException.class, org.opensearch.transport.NoSuchRemoteClusterException::new, 152, - LegacyESVersion.V_6_7_0 + UNKNOWN_VERSION_ADDED ), RETENTION_LEASE_ALREADY_EXISTS_EXCEPTION( org.opensearch.index.seqno.RetentionLeaseAlreadyExistsException.class, org.opensearch.index.seqno.RetentionLeaseAlreadyExistsException::new, 153, - LegacyESVersion.V_6_7_0 + UNKNOWN_VERSION_ADDED ), RETENTION_LEASE_NOT_FOUND_EXCEPTION( org.opensearch.index.seqno.RetentionLeaseNotFoundException.class, org.opensearch.index.seqno.RetentionLeaseNotFoundException::new, 154, - LegacyESVersion.V_6_7_0 + UNKNOWN_VERSION_ADDED ), SHARD_NOT_IN_PRIMARY_MODE_EXCEPTION( org.opensearch.index.shard.ShardNotInPrimaryModeException.class, diff --git a/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequest.java index 1b665ff7a6dbb..d8b3b781b6787 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequest.java @@ -114,11 +114,7 @@ public PutMappingRequest(StreamInput in) throws IOException { in.readBoolean(); // updateAllTypes } concreteIndex = in.readOptionalWriteable(Index::new); - if (in.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { - origin = in.readOptionalString(); - } else { - origin = null; - } + origin = in.readOptionalString(); if (in.getVersion().onOrAfter(LegacyESVersion.V_7_9_0)) { writeIndexOnly = in.readBoolean(); } @@ -376,9 +372,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(true); // updateAllTypes } out.writeOptionalWriteable(concreteIndex); - if (out.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { - out.writeOptionalString(origin); - } + out.writeOptionalString(origin); if (out.getVersion().onOrAfter(LegacyESVersion.V_7_9_0)) { out.writeBoolean(writeIndexOnly); } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/stats/ShardStats.java b/server/src/main/java/org/opensearch/action/admin/indices/stats/ShardStats.java index c816fb4ad2153..c5d3fba2a5805 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/stats/ShardStats.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/stats/ShardStats.java @@ -32,7 +32,6 @@ package org.opensearch.action.admin.indices.stats; -import org.opensearch.LegacyESVersion; import org.opensearch.cluster.routing.ShardRouting; import org.opensearch.common.Nullable; import org.opensearch.common.io.stream.StreamInput; @@ -80,9 +79,7 @@ public ShardStats(StreamInput in) throws IOException { dataPath = in.readString(); isCustomDataPath = in.readBoolean(); seqNoStats = in.readOptionalWriteable(SeqNoStats::new); - if (in.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { - retentionLeaseStats = in.readOptionalWriteable(RetentionLeaseStats::new); - } + retentionLeaseStats = in.readOptionalWriteable(RetentionLeaseStats::new); } public ShardStats( @@ -145,9 +142,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(dataPath); out.writeBoolean(isCustomDataPath); out.writeOptionalWriteable(seqNoStats); - if (out.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { - out.writeOptionalWriteable(retentionLeaseStats); - } + out.writeOptionalWriteable(retentionLeaseStats); } @Override diff --git a/server/src/main/java/org/opensearch/action/search/SearchRequest.java b/server/src/main/java/org/opensearch/action/search/SearchRequest.java index 087c598ac0053..b753ec059b7af 100644 --- a/server/src/main/java/org/opensearch/action/search/SearchRequest.java +++ b/server/src/main/java/org/opensearch/action/search/SearchRequest.java @@ -236,17 +236,11 @@ public SearchRequest(StreamInput in) throws IOException { preFilterShardSize = in.readVInt(); } allowPartialSearchResults = in.readOptionalBoolean(); - if (in.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { - localClusterAlias = in.readOptionalString(); - if (localClusterAlias != null) { - absoluteStartMillis = in.readVLong(); - finalReduce = in.readBoolean(); - } else { - absoluteStartMillis = DEFAULT_ABSOLUTE_START_MILLIS; - finalReduce = true; - } + localClusterAlias = in.readOptionalString(); + if (localClusterAlias != null) { + absoluteStartMillis = in.readVLong(); + finalReduce = in.readBoolean(); } else { - localClusterAlias = null; absoluteStartMillis = DEFAULT_ABSOLUTE_START_MILLIS; finalReduce = true; } @@ -279,12 +273,10 @@ public void writeTo(StreamOutput out) throws IOException { out.writeVInt(preFilterShardSize == null ? DEFAULT_BATCHED_REDUCE_SIZE : preFilterShardSize); } out.writeOptionalBoolean(allowPartialSearchResults); - if (out.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { - out.writeOptionalString(localClusterAlias); - if (localClusterAlias != null) { - out.writeVLong(absoluteStartMillis); - out.writeBoolean(finalReduce); - } + out.writeOptionalString(localClusterAlias); + if (localClusterAlias != null) { + out.writeVLong(absoluteStartMillis); + out.writeBoolean(finalReduce); } if (out.getVersion().onOrAfter(LegacyESVersion.V_7_0_0)) { out.writeBoolean(ccsMinimizeRoundtrips); diff --git a/server/src/main/java/org/opensearch/cluster/ClusterState.java b/server/src/main/java/org/opensearch/cluster/ClusterState.java index e5a2f3f2fecb2..6e17be690dd9d 100644 --- a/server/src/main/java/org/opensearch/cluster/ClusterState.java +++ b/server/src/main/java/org/opensearch/cluster/ClusterState.java @@ -34,7 +34,6 @@ import com.carrotsearch.hppc.cursors.ObjectCursor; import com.carrotsearch.hppc.cursors.ObjectObjectCursor; -import org.opensearch.LegacyESVersion; import org.opensearch.cluster.block.ClusterBlock; import org.opensearch.cluster.block.ClusterBlocks; import org.opensearch.cluster.coordination.CoordinationMetadata; @@ -736,7 +735,7 @@ public static ClusterState readFrom(StreamInput in, DiscoveryNode localNode) thr Custom customIndexMetadata = in.readNamedWriteable(Custom.class); builder.putCustom(customIndexMetadata.getWriteableName(), customIndexMetadata); } - builder.minimumMasterNodesOnPublishingMaster = in.getVersion().onOrAfter(LegacyESVersion.V_6_7_0) ? in.readVInt() : -1; + builder.minimumMasterNodesOnPublishingMaster = in.readVInt(); return builder.build(); } @@ -762,9 +761,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeNamedWriteable(cursor.value); } } - if (out.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { - out.writeVInt(minimumMasterNodesOnPublishingMaster); - } + out.writeVInt(minimumMasterNodesOnPublishingMaster); } private static class ClusterStateDiff implements Diff { @@ -812,7 +809,7 @@ private static class ClusterStateDiff implements Diff { metadata = Metadata.readDiffFrom(in); blocks = ClusterBlocks.readDiffFrom(in); customs = DiffableUtils.readImmutableOpenMapDiff(in, DiffableUtils.getStringKeySerializer(), CUSTOM_VALUE_SERIALIZER); - minimumMasterNodesOnPublishingMaster = in.getVersion().onOrAfter(LegacyESVersion.V_6_7_0) ? in.readVInt() : -1; + minimumMasterNodesOnPublishingMaster = in.readVInt(); } @Override @@ -826,9 +823,7 @@ public void writeTo(StreamOutput out) throws IOException { metadata.writeTo(out); blocks.writeTo(out); customs.writeTo(out); - if (out.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { - out.writeVInt(minimumMasterNodesOnPublishingMaster); - } + out.writeVInt(minimumMasterNodesOnPublishingMaster); } @Override diff --git a/server/src/main/java/org/opensearch/cluster/action/shard/ShardStateAction.java b/server/src/main/java/org/opensearch/cluster/action/shard/ShardStateAction.java index ec95c35ddbcb7..300067587b78b 100644 --- a/server/src/main/java/org/opensearch/cluster/action/shard/ShardStateAction.java +++ b/server/src/main/java/org/opensearch/cluster/action/shard/ShardStateAction.java @@ -35,7 +35,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.LegacyESVersion; import org.opensearch.OpenSearchException; import org.opensearch.ExceptionsHelper; import org.opensearch.action.ActionListener; @@ -88,8 +87,6 @@ import java.util.function.Predicate; import java.util.function.Supplier; -import static org.opensearch.index.seqno.SequenceNumbers.UNASSIGNED_PRIMARY_TERM; - public class ShardStateAction { private static final Logger logger = LogManager.getLogger(ShardStateAction.class); @@ -819,11 +816,7 @@ public static class StartedShardEntry extends TransportRequest { super(in); shardId = new ShardId(in); allocationId = in.readString(); - if (in.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { - primaryTerm = in.readVLong(); - } else { - primaryTerm = UNASSIGNED_PRIMARY_TERM; - } + primaryTerm = in.readVLong(); this.message = in.readString(); } @@ -839,9 +832,7 @@ public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); shardId.writeTo(out); out.writeString(allocationId); - if (out.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { - out.writeVLong(primaryTerm); - } + out.writeVLong(primaryTerm); out.writeString(message); } diff --git a/server/src/main/java/org/opensearch/cluster/block/ClusterBlock.java b/server/src/main/java/org/opensearch/cluster/block/ClusterBlock.java index c95915788bb1a..9da2bdeaabd8e 100644 --- a/server/src/main/java/org/opensearch/cluster/block/ClusterBlock.java +++ b/server/src/main/java/org/opensearch/cluster/block/ClusterBlock.java @@ -32,7 +32,6 @@ package org.opensearch.cluster.block; -import org.opensearch.LegacyESVersion; import org.opensearch.common.Nullable; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; @@ -60,11 +59,7 @@ public class ClusterBlock implements Writeable, ToXContentFragment { public ClusterBlock(StreamInput in) throws IOException { id = in.readVInt(); - if (in.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { - uuid = in.readOptionalString(); - } else { - uuid = null; - } + uuid = in.readOptionalString(); description = in.readString(); this.levels = in.readEnumSet(ClusterBlockLevel.class); retryable = in.readBoolean(); @@ -173,9 +168,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws @Override public void writeTo(StreamOutput out) throws IOException { out.writeVInt(id); - if (out.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { - out.writeOptionalString(uuid); - } + out.writeOptionalString(uuid); out.writeString(description); out.writeEnumSet(levels); out.writeBoolean(retryable); diff --git a/server/src/main/java/org/opensearch/index/engine/ReadOnlyEngine.java b/server/src/main/java/org/opensearch/index/engine/ReadOnlyEngine.java index 4b6000d1ca7a8..b0c05701ae0c6 100644 --- a/server/src/main/java/org/opensearch/index/engine/ReadOnlyEngine.java +++ b/server/src/main/java/org/opensearch/index/engine/ReadOnlyEngine.java @@ -167,8 +167,7 @@ protected void ensureMaxSeqNoEqualsToGlobalCheckpoint(final SeqNoStats seqNoStat // that guarantee that all operations have been flushed to Lucene. final Version indexVersionCreated = engineConfig.getIndexSettings().getIndexVersionCreated(); if (indexVersionCreated.onOrAfter(LegacyESVersion.V_7_2_0) - || (seqNoStats.getGlobalCheckpoint() != SequenceNumbers.UNASSIGNED_SEQ_NO - && indexVersionCreated.onOrAfter(LegacyESVersion.V_6_7_0))) { + || (seqNoStats.getGlobalCheckpoint() != SequenceNumbers.UNASSIGNED_SEQ_NO)) { assert assertMaxSeqNoEqualsToGlobalCheckpoint(seqNoStats.getMaxSeqNo(), seqNoStats.getGlobalCheckpoint()); if (seqNoStats.getMaxSeqNo() != seqNoStats.getGlobalCheckpoint()) { throw new IllegalStateException( diff --git a/server/src/main/java/org/opensearch/index/query/InnerHitBuilder.java b/server/src/main/java/org/opensearch/index/query/InnerHitBuilder.java index b747b7faa0cb2..a1e041ba24080 100644 --- a/server/src/main/java/org/opensearch/index/query/InnerHitBuilder.java +++ b/server/src/main/java/org/opensearch/index/query/InnerHitBuilder.java @@ -183,11 +183,7 @@ public InnerHitBuilder(StreamInput in) throws IOException { size = in.readVInt(); explain = in.readBoolean(); version = in.readBoolean(); - if (in.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { - seqNoAndPrimaryTerm = in.readBoolean(); - } else { - seqNoAndPrimaryTerm = false; - } + seqNoAndPrimaryTerm = in.readBoolean(); trackScores = in.readBoolean(); storedFieldsContext = in.readOptionalWriteable(StoredFieldsContext::new); docValueFields = in.readBoolean() ? in.readList(FieldAndFormat::new) : null; @@ -224,9 +220,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeVInt(size); out.writeBoolean(explain); out.writeBoolean(version); - if (out.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { - out.writeBoolean(seqNoAndPrimaryTerm); - } + out.writeBoolean(seqNoAndPrimaryTerm); out.writeBoolean(trackScores); out.writeOptionalWriteable(storedFieldsContext); diff --git a/server/src/main/java/org/opensearch/indices/recovery/RecoverySourceHandler.java b/server/src/main/java/org/opensearch/indices/recovery/RecoverySourceHandler.java index 21dc53413655b..1bd659853e10e 100644 --- a/server/src/main/java/org/opensearch/indices/recovery/RecoverySourceHandler.java +++ b/server/src/main/java/org/opensearch/indices/recovery/RecoverySourceHandler.java @@ -150,7 +150,7 @@ public RecoverySourceHandler( this.logger = Loggers.getLogger(getClass(), request.shardId(), "recover to " + request.targetNode().getName()); this.chunkSizeInBytes = fileChunkSizeInBytes; // if the target is on an old version, it won't be able to handle out-of-order file chunks. - this.maxConcurrentFileChunks = request.targetNode().getVersion().onOrAfter(LegacyESVersion.V_6_7_0) ? maxConcurrentFileChunks : 1; + this.maxConcurrentFileChunks = maxConcurrentFileChunks; this.maxConcurrentOperations = maxConcurrentOperations; } diff --git a/server/src/main/java/org/opensearch/indices/recovery/RecoveryTranslogOperationsRequest.java b/server/src/main/java/org/opensearch/indices/recovery/RecoveryTranslogOperationsRequest.java index 7e365e1bdf2f5..94ac53f77a1d1 100644 --- a/server/src/main/java/org/opensearch/indices/recovery/RecoveryTranslogOperationsRequest.java +++ b/server/src/main/java/org/opensearch/indices/recovery/RecoveryTranslogOperationsRequest.java @@ -120,16 +120,8 @@ long mappingVersionOnPrimary() { totalTranslogOps = in.readVInt(); maxSeenAutoIdTimestampOnPrimary = in.readZLong(); maxSeqNoOfUpdatesOrDeletesOnPrimary = in.readZLong(); - if (in.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { - retentionLeases = new RetentionLeases(in); - } else { - retentionLeases = RetentionLeases.EMPTY; - } - if (in.getVersion().onOrAfter(LegacyESVersion.V_7_2_0)) { - mappingVersionOnPrimary = in.readVLong(); - } else { - mappingVersionOnPrimary = Long.MAX_VALUE; - } + retentionLeases = new RetentionLeases(in); + mappingVersionOnPrimary = in.readVLong(); } @Override @@ -141,9 +133,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeVInt(totalTranslogOps); out.writeZLong(maxSeenAutoIdTimestampOnPrimary); out.writeZLong(maxSeqNoOfUpdatesOrDeletesOnPrimary); - if (out.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { - retentionLeases.writeTo(out); - } + retentionLeases.writeTo(out); if (out.getVersion().onOrAfter(LegacyESVersion.V_7_2_0)) { out.writeVLong(mappingVersionOnPrimary); } diff --git a/server/src/main/java/org/opensearch/search/SearchHit.java b/server/src/main/java/org/opensearch/search/SearchHit.java index cfb67c7c985f9..80ed3268780c3 100644 --- a/server/src/main/java/org/opensearch/search/SearchHit.java +++ b/server/src/main/java/org/opensearch/search/SearchHit.java @@ -168,10 +168,8 @@ public SearchHit(StreamInput in) throws IOException { type = in.readOptionalText(); nestedIdentity = in.readOptionalWriteable(NestedIdentity::new); version = in.readLong(); - if (in.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { - seqNo = in.readZLong(); - primaryTerm = in.readVLong(); - } + seqNo = in.readZLong(); + primaryTerm = in.readVLong(); source = in.readBytesReference(); if (source.length() == 0) { source = null; @@ -270,10 +268,8 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalText(type); out.writeOptionalWriteable(nestedIdentity); out.writeLong(version); - if (out.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { - out.writeZLong(seqNo); - out.writeVLong(primaryTerm); - } + out.writeZLong(seqNo); + out.writeVLong(primaryTerm); out.writeBytesReference(source); if (explanation == null) { out.writeBoolean(false); diff --git a/server/src/main/java/org/opensearch/search/aggregations/InternalAggregations.java b/server/src/main/java/org/opensearch/search/aggregations/InternalAggregations.java index 3a9116c9bb9db..371a2b04ae019 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/InternalAggregations.java +++ b/server/src/main/java/org/opensearch/search/aggregations/InternalAggregations.java @@ -108,7 +108,7 @@ public static InternalAggregations from(List aggregations) public static InternalAggregations readFrom(StreamInput in) throws IOException { final InternalAggregations res = from(in.readList(stream -> in.readNamedWriteable(InternalAggregation.class))); - if (in.getVersion().before(LegacyESVersion.V_7_8_0) && in.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { + if (in.getVersion().before(LegacyESVersion.V_7_8_0)) { /* * Setting the pipeline tree source to null is here is correct but * only because we don't immediately pass the InternalAggregations @@ -127,16 +127,12 @@ public void writeTo(StreamOutput out) throws IOException { if (pipelineTreeForBwcSerialization == null) { mergePipelineTreeForBWCSerialization(PipelineTree.EMPTY); out.writeNamedWriteableList(getInternalAggregations()); - if (out.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { - out.writeNamedWriteableList(emptyList()); - } + out.writeNamedWriteableList(emptyList()); } else { PipelineAggregator.PipelineTree pipelineTree = pipelineTreeForBwcSerialization.get(); mergePipelineTreeForBWCSerialization(pipelineTree); out.writeNamedWriteableList(getInternalAggregations()); - if (out.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { - out.writeNamedWriteableList(pipelineTree.aggregators()); - } + out.writeNamedWriteableList(pipelineTree.aggregators()); } } else { out.writeNamedWriteableList(getInternalAggregations()); diff --git a/server/src/main/java/org/opensearch/search/aggregations/metrics/TopHitsAggregationBuilder.java b/server/src/main/java/org/opensearch/search/aggregations/metrics/TopHitsAggregationBuilder.java index cefe9d0372493..d1097aaa20612 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/metrics/TopHitsAggregationBuilder.java +++ b/server/src/main/java/org/opensearch/search/aggregations/metrics/TopHitsAggregationBuilder.java @@ -157,9 +157,7 @@ public TopHitsAggregationBuilder(StreamInput in) throws IOException { } trackScores = in.readBoolean(); version = in.readBoolean(); - if (in.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { - seqNoAndPrimaryTerm = in.readBoolean(); - } + seqNoAndPrimaryTerm = in.readBoolean(); if (in.getVersion().onOrAfter(LegacyESVersion.V_7_10_0)) { if (in.readBoolean()) { @@ -193,9 +191,7 @@ protected void doWriteTo(StreamOutput out) throws IOException { } out.writeBoolean(trackScores); out.writeBoolean(version); - if (out.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { - out.writeBoolean(seqNoAndPrimaryTerm); - } + out.writeBoolean(seqNoAndPrimaryTerm); if (out.getVersion().onOrAfter(LegacyESVersion.V_7_10_0)) { out.writeBoolean(fetchFields != null); diff --git a/server/src/main/java/org/opensearch/search/builder/SearchSourceBuilder.java b/server/src/main/java/org/opensearch/search/builder/SearchSourceBuilder.java index 034cf1e9cc79e..8c162e1fa4a33 100644 --- a/server/src/main/java/org/opensearch/search/builder/SearchSourceBuilder.java +++ b/server/src/main/java/org/opensearch/search/builder/SearchSourceBuilder.java @@ -252,11 +252,7 @@ public SearchSourceBuilder(StreamInput in) throws IOException { timeout = in.readOptionalTimeValue(); trackScores = in.readBoolean(); version = in.readOptionalBoolean(); - if (in.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { - seqNoAndPrimaryTerm = in.readOptionalBoolean(); - } else { - seqNoAndPrimaryTerm = null; - } + seqNoAndPrimaryTerm = in.readOptionalBoolean(); extBuilders = in.readNamedWriteableList(SearchExtBuilder.class); profile = in.readBoolean(); searchAfterBuilder = in.readOptionalWriteable(SearchAfterBuilder::new); @@ -322,9 +318,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalTimeValue(timeout); out.writeBoolean(trackScores); out.writeOptionalBoolean(version); - if (out.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { - out.writeOptionalBoolean(seqNoAndPrimaryTerm); - } + out.writeOptionalBoolean(seqNoAndPrimaryTerm); out.writeNamedWriteableList(extBuilders); out.writeBoolean(profile); out.writeOptionalWriteable(searchAfterBuilder); diff --git a/server/src/test/java/org/opensearch/BuildTests.java b/server/src/test/java/org/opensearch/BuildTests.java index aaca336ecec27..eeb6890699fdc 100644 --- a/server/src/test/java/org/opensearch/BuildTests.java +++ b/server/src/test/java/org/opensearch/BuildTests.java @@ -300,12 +300,6 @@ public void testSerializationBWC() throws IOException { ); final List versions = Version.getDeclaredVersions(LegacyESVersion.class); - - final Version post67Pre70Version = randomFrom( - versions.stream() - .filter(v -> v.onOrAfter(LegacyESVersion.V_6_7_0) && v.before(LegacyESVersion.V_7_0_0)) - .collect(Collectors.toList()) - ); final Version post70Version = randomFrom( versions.stream().filter(v -> v.onOrAfter(LegacyESVersion.V_7_0_0)).collect(Collectors.toList()) ); @@ -313,7 +307,6 @@ public void testSerializationBWC() throws IOException { versions.stream().filter(v -> v.onOrAfter(Version.V_1_0_0)).collect(Collectors.toList()) ); - final WriteableBuild post67pre70 = copyWriteable(dockerBuild, writableRegistry(), WriteableBuild::new, post67Pre70Version); final WriteableBuild post70 = copyWriteable(dockerBuild, writableRegistry(), WriteableBuild::new, post70Version); final WriteableBuild post10OpenSearch = copyWriteable( dockerBuild, @@ -322,10 +315,8 @@ public void testSerializationBWC() throws IOException { post10OpenSearchVersion ); - assertThat(post67pre70.build.type(), equalTo(dockerBuild.build.type())); assertThat(post70.build.type(), equalTo(dockerBuild.build.type())); - assertThat(post67pre70.build.getQualifiedVersion(), equalTo(post67Pre70Version.toString())); assertThat(post70.build.getQualifiedVersion(), equalTo(dockerBuild.build.getQualifiedVersion())); assertThat(post70.build.getDistribution(), equalTo(dockerBuild.build.getDistribution())); assertThat(post10OpenSearch.build.getQualifiedVersion(), equalTo(dockerBuild.build.getQualifiedVersion())); diff --git a/server/src/test/java/org/opensearch/ExceptionSerializationTests.java b/server/src/test/java/org/opensearch/ExceptionSerializationTests.java index 37c5462a8a1a4..a1455a715e461 100644 --- a/server/src/test/java/org/opensearch/ExceptionSerializationTests.java +++ b/server/src/test/java/org/opensearch/ExceptionSerializationTests.java @@ -921,7 +921,7 @@ public void testShardLockObtainFailedException() throws IOException { public void testSnapshotInProgressException() throws IOException { SnapshotInProgressException orig = new SnapshotInProgressException("boom"); - Version version = VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_6_7_0, Version.CURRENT); + Version version = VersionUtils.randomIndexCompatibleVersion(random()); SnapshotInProgressException ex = serialize(orig, version); assertEquals(orig.getMessage(), ex.getMessage()); } diff --git a/server/src/test/java/org/opensearch/LegacyESVersionTests.java b/server/src/test/java/org/opensearch/LegacyESVersionTests.java index 5c7fa3d1aa04c..51ce64b4aa9da 100644 --- a/server/src/test/java/org/opensearch/LegacyESVersionTests.java +++ b/server/src/test/java/org/opensearch/LegacyESVersionTests.java @@ -282,7 +282,7 @@ public void testAllVersionsMatchId() throws Exception { public void testIsCompatible() { assertTrue(isCompatible(LegacyESVersion.V_6_8_0, LegacyESVersion.V_7_0_0)); assertFalse(isCompatible(LegacyESVersion.fromString("6.6.0"), LegacyESVersion.V_7_0_0)); - assertFalse(isCompatible(LegacyESVersion.V_6_7_0, LegacyESVersion.V_7_0_0)); + assertFalse(isCompatible(LegacyESVersion.fromString("6.7.0"), LegacyESVersion.V_7_0_0)); assertFalse(isCompatible(LegacyESVersion.fromId(5000099), LegacyESVersion.fromString("6.0.0"))); assertFalse(isCompatible(LegacyESVersion.fromId(5000099), LegacyESVersion.fromString("7.0.0"))); diff --git a/server/src/test/java/org/opensearch/action/search/SearchRequestTests.java b/server/src/test/java/org/opensearch/action/search/SearchRequestTests.java index 1cad4e2aa34e0..8fe4e89a58f38 100644 --- a/server/src/test/java/org/opensearch/action/search/SearchRequestTests.java +++ b/server/src/test/java/org/opensearch/action/search/SearchRequestTests.java @@ -55,10 +55,7 @@ import static java.util.Collections.emptyMap; import static org.opensearch.test.EqualsHashCodeTestUtils.checkEqualsAndHashCode; -import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.greaterThanOrEqualTo; -import static org.hamcrest.Matchers.lessThanOrEqualTo; public class SearchRequestTests extends AbstractSearchTestCase { @@ -115,15 +112,9 @@ public void testRandomVersionSerialization() throws IOException { } else { assertEquals(searchRequest.isCcsMinimizeRoundtrips(), deserializedRequest.isCcsMinimizeRoundtrips()); } - if (version.before(LegacyESVersion.V_6_7_0)) { - assertNull(deserializedRequest.getLocalClusterAlias()); - assertAbsoluteStartMillisIsCurrentTime(deserializedRequest); - assertTrue(deserializedRequest.isFinalReduce()); - } else { - assertEquals(searchRequest.getLocalClusterAlias(), deserializedRequest.getLocalClusterAlias()); - assertEquals(searchRequest.getAbsoluteStartMillis(), deserializedRequest.getAbsoluteStartMillis()); - assertEquals(searchRequest.isFinalReduce(), deserializedRequest.isFinalReduce()); - } + assertEquals(searchRequest.getLocalClusterAlias(), deserializedRequest.getLocalClusterAlias()); + assertEquals(searchRequest.getAbsoluteStartMillis(), deserializedRequest.getAbsoluteStartMillis()); + assertEquals(searchRequest.isFinalReduce(), deserializedRequest.isFinalReduce()); if (version.onOrAfter(Version.V_1_1_0)) { assertEquals(searchRequest.getCancelAfterTimeInterval(), deserializedRequest.getCancelAfterTimeInterval()); @@ -132,13 +123,6 @@ public void testRandomVersionSerialization() throws IOException { } } - private static void assertAbsoluteStartMillisIsCurrentTime(SearchRequest searchRequest) { - long before = System.currentTimeMillis(); - long absoluteStartMillis = searchRequest.getOrCreateAbsoluteStartMillis(); - long after = System.currentTimeMillis(); - assertThat(absoluteStartMillis, allOf(greaterThanOrEqualTo(before), lessThanOrEqualTo(after))); - } - public void testIllegalArguments() { SearchRequest searchRequest = new SearchRequest(); assertNotNull(searchRequest.indices()); diff --git a/server/src/test/java/org/opensearch/cluster/action/shard/ShardStateActionTests.java b/server/src/test/java/org/opensearch/cluster/action/shard/ShardStateActionTests.java index 5e7b5dfa52284..43bee8c7bc6bd 100644 --- a/server/src/test/java/org/opensearch/cluster/action/shard/ShardStateActionTests.java +++ b/server/src/test/java/org/opensearch/cluster/action/shard/ShardStateActionTests.java @@ -34,7 +34,6 @@ import org.apache.lucene.index.CorruptIndexException; import org.apache.lucene.util.SetOnce; -import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.action.ActionListener; import org.opensearch.action.support.replication.ClusterStateCreationUtils; @@ -570,11 +569,7 @@ public void testStartedShardEntrySerialization() throws Exception { final StartedShardEntry deserialized = new StartedShardEntry(in); assertThat(deserialized.shardId, equalTo(shardId)); assertThat(deserialized.allocationId, equalTo(allocationId)); - if (version.onOrAfter(LegacyESVersion.V_6_7_0)) { - assertThat(deserialized.primaryTerm, equalTo(primaryTerm)); - } else { - assertThat(deserialized.primaryTerm, equalTo(0L)); - } + assertThat(deserialized.primaryTerm, equalTo(primaryTerm)); assertThat(deserialized.message, equalTo(message)); } } diff --git a/server/src/test/java/org/opensearch/cluster/block/ClusterBlockTests.java b/server/src/test/java/org/opensearch/cluster/block/ClusterBlockTests.java index e6468011f2a2c..af82e143faa37 100644 --- a/server/src/test/java/org/opensearch/cluster/block/ClusterBlockTests.java +++ b/server/src/test/java/org/opensearch/cluster/block/ClusterBlockTests.java @@ -32,7 +32,6 @@ package org.opensearch.cluster.block; -import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.common.UUIDs; import org.opensearch.common.collect.ImmutableOpenMap; @@ -60,7 +59,7 @@ public void testSerialization() throws Exception { int iterations = randomIntBetween(5, 20); for (int i = 0; i < iterations; i++) { Version version = randomVersion(random()); - ClusterBlock clusterBlock = randomClusterBlock(version); + ClusterBlock clusterBlock = randomClusterBlock(); BytesStreamOutput out = new BytesStreamOutput(); out.setVersion(version); @@ -138,11 +137,7 @@ public void testGetIndexBlockWithId() { } private ClusterBlock randomClusterBlock() { - return randomClusterBlock(randomVersion(random())); - } - - private ClusterBlock randomClusterBlock(final Version version) { - final String uuid = (version.onOrAfter(LegacyESVersion.V_6_7_0) && randomBoolean()) ? UUIDs.randomBase64UUID() : null; + final String uuid = randomBoolean() ? UUIDs.randomBase64UUID() : null; final List levels = Arrays.asList(ClusterBlockLevel.values()); return new ClusterBlock( randomInt(), diff --git a/server/src/test/java/org/opensearch/cluster/coordination/JoinTaskExecutorTests.java b/server/src/test/java/org/opensearch/cluster/coordination/JoinTaskExecutorTests.java index 3e4cfd7f100f9..8cea1a709f0bc 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/JoinTaskExecutorTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/JoinTaskExecutorTests.java @@ -54,7 +54,6 @@ import java.util.Map; import static org.mockito.Matchers.anyBoolean; -import static org.opensearch.test.VersionUtils.getPreviousVersion; import static org.opensearch.test.VersionUtils.maxCompatibleVersion; import static org.opensearch.test.VersionUtils.randomCompatibleVersion; import static org.opensearch.test.VersionUtils.randomVersion; @@ -108,7 +107,7 @@ public void testPreventJoinClusterWithUnsupportedNodeVersions() { final Version maxNodeVersion = nodes.getMaxNodeVersion(); final Version minNodeVersion = nodes.getMinNodeVersion(); if (maxNodeVersion.onOrAfter(LegacyESVersion.V_7_0_0)) { - final Version tooLow = getPreviousVersion(maxNodeVersion.minimumCompatibilityVersion()); + final Version tooLow = LegacyESVersion.fromString("6.7.0"); expectThrows(IllegalStateException.class, () -> { if (randomBoolean()) { JoinTaskExecutor.ensureNodesCompatibility(tooLow, nodes); diff --git a/server/src/test/java/org/opensearch/indices/TermsLookupTests.java b/server/src/test/java/org/opensearch/indices/TermsLookupTests.java index 414bda93e8734..fb1462b500ea9 100644 --- a/server/src/test/java/org/opensearch/indices/TermsLookupTests.java +++ b/server/src/test/java/org/opensearch/indices/TermsLookupTests.java @@ -32,7 +32,6 @@ package org.opensearch.indices; -import org.opensearch.LegacyESVersion; import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.xcontent.XContentParser; @@ -98,15 +97,6 @@ public void testSerialization() throws IOException { assertNotSame(deserializedLookup, termsLookup); } } - - try (BytesStreamOutput output = new BytesStreamOutput()) { - output.setVersion(LegacyESVersion.V_6_7_0); - IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> termsLookup.writeTo(output)); - assertEquals( - "Typeless [terms] lookup queries are not supported if any " + "node is running a version before 7.0.", - e.getMessage() - ); - } } public void testSerializationWithTypes() throws IOException {