From 39f82f2ecaef9f8cd890e01ce611d8371dfef707 Mon Sep 17 00:00:00 2001 From: Nicholas Walter Knize Date: Mon, 6 Sep 2021 13:32:14 -0500 Subject: [PATCH 1/3] [Remove] Legacy 6x BWC Support This commit removes all support for legacy 6x bwc logic that is no longer supported in 2.0. Signed-off-by: Nicholas Walter Knize --- .../index/reindex/RoundTripTests.java | 37 +--------- .../java/org/opensearch/LegacyESVersion.java | 37 +--------- .../org/opensearch/OpenSearchException.java | 2 +- .../src/main/java/org/opensearch/Version.java | 5 +- .../opensearch/action/DocWriteResponse.java | 16 ++--- .../cluster/health/ClusterHealthRequest.java | 8 +-- .../admin/cluster/node/stats/NodeStats.java | 11 +-- .../cluster/node/stats/NodesStatsRequest.java | 8 +-- .../reroute/ClusterRerouteResponse.java | 30 ++------ .../ClusterUpdateSettingsResponse.java | 25 ++----- .../snapshots/status/SnapshotStats.java | 16 ++--- .../cluster/state/ClusterStateRequest.java | 13 ++-- .../cluster/state/ClusterStateResponse.java | 33 ++------- .../DeleteStoredScriptRequest.java | 10 --- .../storedscripts/GetStoredScriptRequest.java | 10 --- .../GetStoredScriptResponse.java | 9 +-- .../cache/clear/ClearIndicesCacheRequest.java | 7 -- .../indices/create/CreateIndexRequest.java | 22 ------ .../admin/indices/get/GetIndexRequest.java | 9 +-- .../mapping/put/PutMappingRequest.java | 16 +---- .../admin/indices/open/OpenIndexRequest.java | 8 +-- .../indices/rollover/RolloverResponse.java | 68 ++++++------------- .../shards/IndicesShardStoresResponse.java | 8 --- .../admin/indices/shrink/ResizeAction.java | 3 - .../admin/indices/shrink/ResizeRequest.java | 27 ++------ .../indices/shrink/TransportResizeAction.java | 12 ---- .../decider/ResizeAllocationDecider.java | 3 - .../transport/TransportHandshaker.java | 2 +- .../java/org/opensearch/VersionTests.java | 21 +++--- .../health/ClusterHealthResponsesTests.java | 2 +- 30 files changed, 88 insertions(+), 390 deletions(-) diff --git a/modules/reindex/src/test/java/org/opensearch/index/reindex/RoundTripTests.java b/modules/reindex/src/test/java/org/opensearch/index/reindex/RoundTripTests.java index 1d4f83008b7f3..1eaadd3c2ad14 100644 --- a/modules/reindex/src/test/java/org/opensearch/index/reindex/RoundTripTests.java +++ b/modules/reindex/src/test/java/org/opensearch/index/reindex/RoundTripTests.java @@ -32,7 +32,6 @@ package org.opensearch.index.reindex; -import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.common.bytes.BytesArray; import org.opensearch.common.bytes.BytesReference; @@ -82,15 +81,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(LegacyESVersion.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(LegacyESVersion.V_6_0_0_alpha1, reindex, tripped); + assertRequestEquals(reindex, tripped); } public void testUpdateByQueryRequest() throws IOException { @@ -103,11 +97,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(LegacyESVersion.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)); @@ -121,11 +110,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(LegacyESVersion.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)); @@ -157,25 +141,6 @@ private void randomRequest(AbstractBulkIndexByScrollRequest request) { request.setScript(random().nextBoolean() ? null : randomScript()); } - private void assertRequestEquals(Version version, ReindexRequest request, ReindexRequest tripped) { - assertRequestEquals((AbstractBulkIndexByScrollRequest) request, (AbstractBulkIndexByScrollRequest) tripped); - assertEquals(request.getDestination().version(), tripped.getDestination().version()); - assertEquals(request.getDestination().index(), tripped.getDestination().index()); - if (request.getRemoteInfo() == null) { - assertNull(tripped.getRemoteInfo()); - } else { - assertNotNull(tripped.getRemoteInfo()); - assertEquals(request.getRemoteInfo().getScheme(), tripped.getRemoteInfo().getScheme()); - assertEquals(request.getRemoteInfo().getHost(), tripped.getRemoteInfo().getHost()); - assertEquals(request.getRemoteInfo().getQuery(), tripped.getRemoteInfo().getQuery()); - assertEquals(request.getRemoteInfo().getUsername(), tripped.getRemoteInfo().getUsername()); - assertEquals(request.getRemoteInfo().getPassword(), tripped.getRemoteInfo().getPassword()); - assertEquals(request.getRemoteInfo().getHeaders(), tripped.getRemoteInfo().getHeaders()); - assertEquals(request.getRemoteInfo().getSocketTimeout(), tripped.getRemoteInfo().getSocketTimeout()); - assertEquals(request.getRemoteInfo().getConnectTimeout(), tripped.getRemoteInfo().getConnectTimeout()); - } - } - private void assertRequestEquals(AbstractBulkIndexByScrollRequest request, AbstractBulkIndexByScrollRequest tripped) { assertRequestEquals((AbstractBulkByScrollRequest) request, (AbstractBulkByScrollRequest) tripped); diff --git a/server/src/main/java/org/opensearch/LegacyESVersion.java b/server/src/main/java/org/opensearch/LegacyESVersion.java index 3ba2195d4e6db..5a714416bdaba 100644 --- a/server/src/main/java/org/opensearch/LegacyESVersion.java +++ b/server/src/main/java/org/opensearch/LegacyESVersion.java @@ -64,52 +64,19 @@ public class LegacyESVersion extends Version { new LegacyESVersion(6000199, org.apache.lucene.util.Version.LUCENE_7_0_1); public static final LegacyESVersion V_6_1_0 = new LegacyESVersion(6010099, org.apache.lucene.util.Version.LUCENE_7_1_0); public static final LegacyESVersion V_6_1_1 = new LegacyESVersion(6010199, org.apache.lucene.util.Version.LUCENE_7_1_0); - public static final LegacyESVersion V_6_1_2 = new LegacyESVersion(6010299, org.apache.lucene.util.Version.LUCENE_7_1_0); - public static final LegacyESVersion V_6_1_3 = new LegacyESVersion(6010399, org.apache.lucene.util.Version.LUCENE_7_1_0); - public static final LegacyESVersion V_6_1_4 = new LegacyESVersion(6010499, org.apache.lucene.util.Version.LUCENE_7_1_0); // The below version is missing from the 7.3 JAR private static final org.apache.lucene.util.Version LUCENE_7_2_1 = org.apache.lucene.util.Version.fromBits(7, 2, 1); public static final LegacyESVersion V_6_2_0 = new LegacyESVersion(6020099, LUCENE_7_2_1); public static final LegacyESVersion V_6_2_1 = new LegacyESVersion(6020199, LUCENE_7_2_1); public static final LegacyESVersion V_6_2_2 = new LegacyESVersion(6020299, LUCENE_7_2_1); - public static final LegacyESVersion V_6_2_3 = new LegacyESVersion(6020399, LUCENE_7_2_1); public static final LegacyESVersion V_6_2_4 = new LegacyESVersion(6020499, LUCENE_7_2_1); public static final LegacyESVersion V_6_3_0 = new LegacyESVersion(6030099, org.apache.lucene.util.Version.LUCENE_7_3_1); public static final LegacyESVersion V_6_3_1 = new LegacyESVersion(6030199, org.apache.lucene.util.Version.LUCENE_7_3_1); - public static final LegacyESVersion V_6_3_2 = new LegacyESVersion(6030299, org.apache.lucene.util.Version.LUCENE_7_3_1); public static final LegacyESVersion V_6_4_0 = new LegacyESVersion(6040099, org.apache.lucene.util.Version.LUCENE_7_4_0); - public static final LegacyESVersion V_6_4_1 = new LegacyESVersion(6040199, org.apache.lucene.util.Version.LUCENE_7_4_0); - public static final LegacyESVersion V_6_4_2 = new LegacyESVersion(6040299, org.apache.lucene.util.Version.LUCENE_7_4_0); - public static final LegacyESVersion V_6_4_3 = new LegacyESVersion(6040399, org.apache.lucene.util.Version.LUCENE_7_4_0); public static final LegacyESVersion V_6_5_0 = new LegacyESVersion(6050099, org.apache.lucene.util.Version.LUCENE_7_5_0); - public static final LegacyESVersion V_6_5_1 = new LegacyESVersion(6050199, org.apache.lucene.util.Version.LUCENE_7_5_0); - public static final LegacyESVersion V_6_5_2 = new LegacyESVersion(6050299, org.apache.lucene.util.Version.LUCENE_7_5_0); - public static final LegacyESVersion V_6_5_3 = new LegacyESVersion(6050399, org.apache.lucene.util.Version.LUCENE_7_5_0); - public static final LegacyESVersion V_6_5_4 = new LegacyESVersion(6050499, org.apache.lucene.util.Version.LUCENE_7_5_0); 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); - 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); - public static final LegacyESVersion V_6_8_3 = new LegacyESVersion(6080399, org.apache.lucene.util.Version.LUCENE_7_7_0); - public static final LegacyESVersion V_6_8_4 = new LegacyESVersion(6080499, org.apache.lucene.util.Version.LUCENE_7_7_2); - public static final LegacyESVersion V_6_8_5 = new LegacyESVersion(6080599, org.apache.lucene.util.Version.LUCENE_7_7_2); - public static final LegacyESVersion V_6_8_6 = new LegacyESVersion(6080699, org.apache.lucene.util.Version.LUCENE_7_7_2); - public static final LegacyESVersion V_6_8_7 = new LegacyESVersion(6080799, org.apache.lucene.util.Version.LUCENE_7_7_2); - public static final LegacyESVersion V_6_8_8 = new LegacyESVersion(6080899, org.apache.lucene.util.Version.LUCENE_7_7_2); - // Version constant for Lucene 7.7.3 release with index corruption bug fix - private static final org.apache.lucene.util.Version LUCENE_7_7_3 = org.apache.lucene.util.Version.fromBits(7, 7, 3); - public static final LegacyESVersion V_6_8_9 = new LegacyESVersion(6080999, LUCENE_7_7_3); - public static final LegacyESVersion V_6_8_10 = new LegacyESVersion(6081099, LUCENE_7_7_3); - public static final LegacyESVersion V_6_8_11 = new LegacyESVersion(6081199, LUCENE_7_7_3); - public static final LegacyESVersion V_6_8_12 = new LegacyESVersion(6081299, LUCENE_7_7_3); - public static final LegacyESVersion V_6_8_13 = new LegacyESVersion(6081399, LUCENE_7_7_3); - public static final LegacyESVersion V_6_8_14 = new LegacyESVersion(6081499, LUCENE_7_7_3); - public static final LegacyESVersion V_6_8_15 = new LegacyESVersion(6081599, org.apache.lucene.util.Version.LUCENE_7_7_3); + public static final LegacyESVersion V_7_0_0 = new LegacyESVersion(7000099, org.apache.lucene.util.Version.LUCENE_8_0_0); public static final LegacyESVersion V_7_0_1 = new LegacyESVersion(7000199, org.apache.lucene.util.Version.LUCENE_8_0_0); public static final LegacyESVersion V_7_1_0 = new LegacyESVersion(7010099, org.apache.lucene.util.Version.LUCENE_8_0_0); @@ -288,7 +255,7 @@ private static Version fromStringSlow(String version) { protected int maskId(final int id) { return id; } - + @Override public String toString() { StringBuilder sb = new StringBuilder(); diff --git a/server/src/main/java/org/opensearch/OpenSearchException.java b/server/src/main/java/org/opensearch/OpenSearchException.java index 8cd06bcdc1d0a..37b1083edb526 100644 --- a/server/src/main/java/org/opensearch/OpenSearchException.java +++ b/server/src/main/java/org/opensearch/OpenSearchException.java @@ -1051,7 +1051,7 @@ private enum OpenSearchExceptionHandle { org.opensearch.index.shard.ShardNotInPrimaryModeException.class, org.opensearch.index.shard.ShardNotInPrimaryModeException::new, 155, - LegacyESVersion.V_6_8_1), + UNKNOWN_VERSION_ADDED), RETENTION_LEASE_INVALID_RETAINING_SEQUENCE_NUMBER_EXCEPTION( org.opensearch.index.seqno.RetentionLeaseInvalidRetainingSeqNoException.class, org.opensearch.index.seqno.RetentionLeaseInvalidRetainingSeqNoException::new, diff --git a/server/src/main/java/org/opensearch/Version.java b/server/src/main/java/org/opensearch/Version.java index 0495bff3a8fb3..4628a9d85fc28 100644 --- a/server/src/main/java/org/opensearch/Version.java +++ b/server/src/main/java/org/opensearch/Version.java @@ -306,12 +306,13 @@ public Version minimumCompatibilityVersion() { protected Version computeMinCompatVersion() { if (major == 1) { - return LegacyESVersion.V_6_8_0; + // force the minimum compatibility for opensearch version 1 to legacy 6.8 since we don't reference version 6 anymore + return LegacyESVersion.fromId(6080099); } else if (major == 2) { return LegacyESVersion.V_7_10_0; } else if (major == 6) { // force the minimum compatibility for version 6 to 5.6 since we don't reference version 5 anymore - return Version.fromId(5060099); + return LegacyESVersion.fromId(5060099); } else if (major >= 7) { // all major versions from 7 onwards are compatible with last minor series of the previous major Version bwcVersion = null; diff --git a/server/src/main/java/org/opensearch/action/DocWriteResponse.java b/server/src/main/java/org/opensearch/action/DocWriteResponse.java index 08e933ed9f8ca..7cce1b41d29fb 100644 --- a/server/src/main/java/org/opensearch/action/DocWriteResponse.java +++ b/server/src/main/java/org/opensearch/action/DocWriteResponse.java @@ -31,7 +31,6 @@ package org.opensearch.action; -import org.opensearch.LegacyESVersion; import org.opensearch.action.support.WriteRequest; import org.opensearch.action.support.WriteRequest.RefreshPolicy; import org.opensearch.action.support.WriteResponse; @@ -168,13 +167,8 @@ protected DocWriteResponse(StreamInput in) throws IOException { type = in.readString(); id = in.readString(); version = in.readZLong(); - if (in.getVersion().onOrAfter(LegacyESVersion.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); } @@ -317,10 +311,8 @@ private void writeWithoutShardId(StreamOutput out) throws IOException { out.writeString(type); out.writeString(id); out.writeZLong(version); - if (out.getVersion().onOrAfter(LegacyESVersion.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/opensearch/action/admin/cluster/health/ClusterHealthRequest.java b/server/src/main/java/org/opensearch/action/admin/cluster/health/ClusterHealthRequest.java index c2c807c0766bc..3e94c39119ee9 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/health/ClusterHealthRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/health/ClusterHealthRequest.java @@ -85,9 +85,7 @@ public ClusterHealthRequest(StreamInput in) throws IOException { if (in.readBoolean()) { waitForEvents = Priority.readFrom(in); } - if (in.getVersion().onOrAfter(LegacyESVersion.V_6_2_0)) { - waitForNoInitializingShards = in.readBoolean(); - } + waitForNoInitializingShards = in.readBoolean(); if (in.getVersion().onOrAfter(LegacyESVersion.V_7_2_0)) { indicesOptions = IndicesOptions.readIndicesOptions(in); } else { @@ -119,9 +117,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(true); Priority.writeTo(waitForEvents, out); } - if (out.getVersion().onOrAfter(LegacyESVersion.V_6_2_0)) { - out.writeBoolean(waitForNoInitializingShards); - } + out.writeBoolean(waitForNoInitializingShards); if (out.getVersion().onOrAfter(LegacyESVersion.V_7_2_0)) { indicesOptions.writeIndicesOptions(out); } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/stats/NodeStats.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/stats/NodeStats.java index 7f001a1f1bd6e..ba725ae8e03e6 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/stats/NodeStats.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/stats/NodeStats.java @@ -129,11 +129,7 @@ public NodeStats(StreamInput in) throws IOException { scriptStats = in.readOptionalWriteable(ScriptStats::new); discoveryStats = in.readOptionalWriteable(DiscoveryStats::new); ingestStats = in.readOptionalWriteable(IngestStats::new); - if (in.getVersion().onOrAfter(LegacyESVersion.V_6_1_0)) { - adaptiveSelectionStats = in.readOptionalWriteable(AdaptiveSelectionStats::new); - } else { - adaptiveSelectionStats = null; - } + adaptiveSelectionStats = in.readOptionalWriteable(AdaptiveSelectionStats::new); scriptCacheStats = null; if (in.getVersion().onOrAfter(LegacyESVersion.V_7_8_0)) { if (in.getVersion().before(LegacyESVersion.V_7_9_0)) { @@ -301,9 +297,8 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalWriteable(scriptStats); out.writeOptionalWriteable(discoveryStats); out.writeOptionalWriteable(ingestStats); - if (out.getVersion().onOrAfter(LegacyESVersion.V_6_1_0)) { - out.writeOptionalWriteable(adaptiveSelectionStats); - } if (out.getVersion().onOrAfter(LegacyESVersion.V_7_8_0) && out.getVersion().before(LegacyESVersion.V_7_9_0)) { + out.writeOptionalWriteable(adaptiveSelectionStats); + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_8_0) && out.getVersion().before(LegacyESVersion.V_7_9_0)) { out.writeOptionalWriteable(scriptCacheStats); } if (out.getVersion().onOrAfter(LegacyESVersion.V_7_9_0)) { diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/stats/NodesStatsRequest.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/stats/NodesStatsRequest.java index d6403448a0b8c..d5527c79a9886 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/stats/NodesStatsRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/stats/NodesStatsRequest.java @@ -74,9 +74,7 @@ public NodesStatsRequest(StreamInput in) throws IOException { optionallyAddMetric(in.readBoolean(), Metric.SCRIPT.metricName()); optionallyAddMetric(in.readBoolean(), Metric.DISCOVERY.metricName()); optionallyAddMetric(in.readBoolean(), Metric.INGEST.metricName()); - if (in.getVersion().onOrAfter(LegacyESVersion.V_6_1_0)) { - optionallyAddMetric(in.readBoolean(), Metric.ADAPTIVE_SELECTION.metricName()); - } + optionallyAddMetric(in.readBoolean(), Metric.ADAPTIVE_SELECTION.metricName()); } else { requestedMetrics.addAll(in.readStringList()); } @@ -212,9 +210,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(Metric.SCRIPT.containedIn(requestedMetrics)); out.writeBoolean(Metric.DISCOVERY.containedIn(requestedMetrics)); out.writeBoolean(Metric.INGEST.containedIn(requestedMetrics)); - if (out.getVersion().onOrAfter(LegacyESVersion.V_6_1_0)) { - out.writeBoolean(Metric.ADAPTIVE_SELECTION.containedIn(requestedMetrics)); - } + out.writeBoolean(Metric.ADAPTIVE_SELECTION.containedIn(requestedMetrics)); } else { out.writeStringArray(requestedMetrics.toArray(new String[0])); } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/reroute/ClusterRerouteResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/reroute/ClusterRerouteResponse.java index 50bc3845c15a9..da4cfb4333b3d 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/reroute/ClusterRerouteResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/reroute/ClusterRerouteResponse.java @@ -32,9 +32,7 @@ package org.opensearch.action.admin.cluster.reroute; -import org.opensearch.LegacyESVersion; import org.opensearch.action.support.master.AcknowledgedResponse; -import org.opensearch.cluster.ClusterModule; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.routing.allocation.RoutingExplanations; import org.opensearch.common.io.stream.StreamInput; @@ -54,15 +52,9 @@ public class ClusterRerouteResponse extends AcknowledgedResponse implements ToXC private final RoutingExplanations explanations; ClusterRerouteResponse(StreamInput in) throws IOException { - super(in, in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)); - if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) { - state = ClusterState.readFrom(in, null); - explanations = RoutingExplanations.readFrom(in); - } else { - state = ClusterState.readFrom(in, null); - acknowledged = in.readBoolean(); - explanations = RoutingExplanations.readFrom(in); - } + super(in); + state = ClusterState.readFrom(in, null); + explanations = RoutingExplanations.readFrom(in); } ClusterRerouteResponse(boolean acknowledged, ClusterState state, RoutingExplanations explanations) { @@ -84,19 +76,9 @@ public RoutingExplanations getExplanations() { @Override public void writeTo(StreamOutput out) throws IOException { - if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) { - super.writeTo(out); - state.writeTo(out); - RoutingExplanations.writeTo(explanations, out); - } else { - if (out.getVersion().onOrAfter(LegacyESVersion.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/opensearch/action/admin/cluster/settings/ClusterUpdateSettingsResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/settings/ClusterUpdateSettingsResponse.java index 724303e960029..b60128f2176f5 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/settings/ClusterUpdateSettingsResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/settings/ClusterUpdateSettingsResponse.java @@ -32,7 +32,6 @@ package org.opensearch.action.admin.cluster.settings; -import org.opensearch.LegacyESVersion; import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.common.ParseField; import org.opensearch.common.io.stream.StreamInput; @@ -69,15 +68,9 @@ public class ClusterUpdateSettingsResponse extends AcknowledgedResponse { final Settings persistentSettings; ClusterUpdateSettingsResponse(StreamInput in) throws IOException { - super(in, in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)); - if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) { - transientSettings = Settings.readSettingsFromStream(in); - persistentSettings = Settings.readSettingsFromStream(in); - } else { - transientSettings = Settings.readSettingsFromStream(in); - persistentSettings = Settings.readSettingsFromStream(in); - acknowledged = in.readBoolean(); - } + super(in); + transientSettings = Settings.readSettingsFromStream(in); + persistentSettings = Settings.readSettingsFromStream(in); } ClusterUpdateSettingsResponse(boolean acknowledged, Settings transientSettings, Settings persistentSettings) { @@ -96,15 +89,9 @@ public Settings getPersistentSettings() { @Override public void writeTo(StreamOutput out) throws IOException { - if (out.getVersion().onOrAfter(LegacyESVersion.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/opensearch/action/admin/cluster/snapshots/status/SnapshotStats.java b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotStats.java index 07b44c56155b1..fa500ce075e2a 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotStats.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotStats.java @@ -32,7 +32,6 @@ package org.opensearch.action.admin.cluster.snapshots.status; -import org.opensearch.LegacyESVersion; import org.opensearch.common.Strings; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; @@ -70,13 +69,8 @@ public class SnapshotStats implements Writeable, ToXContentObject { incrementalSize = in.readVLong(); processedSize = in.readVLong(); - if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) { - totalFileCount = in.readVInt(); - totalSize = in.readVLong(); - } else { - totalFileCount = incrementalFileCount; - totalSize = incrementalSize; - } + totalFileCount = in.readVInt(); + totalSize = in.readVLong(); } SnapshotStats(long startTime, long time, @@ -160,10 +154,8 @@ public void writeTo(StreamOutput out) throws IOException { out.writeVLong(incrementalSize); out.writeVLong(processedSize); - if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) { - out.writeVInt(totalFileCount); - out.writeVLong(totalSize); - } + out.writeVInt(totalFileCount); + out.writeVLong(totalSize); } static final class Fields { 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 6dc43afd07786..815f2014c3097 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; @@ -70,10 +69,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 @@ -86,10 +83,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 6dc75509463ae..80d5a6ceaee36 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 @@ -32,15 +32,12 @@ package org.opensearch.action.admin.cluster.state; -import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionResponse; -import org.opensearch.cluster.ClusterModule; import org.opensearch.cluster.ClusterName; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.node.DiscoveryNodes; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; -import org.opensearch.common.unit.ByteSizeValue; import java.io.IOException; import java.util.Objects; @@ -57,17 +54,8 @@ 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); - } - if (in.getVersion().before(LegacyESVersion.V_7_0_0)) { - new ByteSizeValue(in); - } - if (in.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) { - waitForTimedOut = in.readBoolean(); - } + clusterState = in.readOptionalWriteable(innerIn -> ClusterState.readFrom(innerIn, null)); + waitForTimedOut = in.readBoolean(); } public ClusterStateResponse(ClusterName clusterName, ClusterState clusterState, boolean waitForTimedOut) { @@ -102,21 +90,8 @@ 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 { - if (out.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) { - clusterState.writeTo(out); - } else { - ClusterModule.filterCustomsForPre63Clients(clusterState).writeTo(out); - } - } - 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.writeOptionalWriteable(clusterState); + out.writeBoolean(waitForTimedOut); } @Override diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/DeleteStoredScriptRequest.java b/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/DeleteStoredScriptRequest.java index 94f4f775738ea..eda9aa053854f 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/DeleteStoredScriptRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/DeleteStoredScriptRequest.java @@ -32,7 +32,6 @@ package org.opensearch.action.admin.cluster.storedscripts; -import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.support.master.AcknowledgedRequest; import org.opensearch.common.io.stream.StreamInput; @@ -48,10 +47,6 @@ public class DeleteStoredScriptRequest extends AcknowledgedRequest 0) { - throw new IllegalStateException("unexpected custom metadata when none is supported"); - } - } int aliasesSize = in.readVInt(); for (int i = 0; i < aliasesSize; i++) { aliases.add(new Alias(in)); } - if (in.getVersion().before(LegacyESVersion.V_7_0_0)) { - in.readBoolean(); // updateAllTypes - } waitForActiveShards = ActiveShardCount.readFrom(in); } @@ -478,17 +463,10 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(entry.getKey()); out.writeString(entry.getValue()); } - if (out.getVersion().before(LegacyESVersion.V_6_5_0)) { - // Size of custom index metadata, which is removed - out.writeVInt(0); - } out.writeVInt(aliases.size()); for (Alias alias : aliases) { alias.writeTo(out); } - if (out.getVersion().before(LegacyESVersion.V_7_0_0)) { - out.writeBoolean(true); // updateAllTypes - } waitForActiveShards.writeTo(out); } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/get/GetIndexRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/get/GetIndexRequest.java index 84f282c6a2820..b455c5c13ead2 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/get/GetIndexRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/get/GetIndexRequest.java @@ -90,9 +90,7 @@ public GetIndexRequest(StreamInput in) throws IOException { super(in); features = in.readArray(i -> Feature.fromId(i.readByte()), Feature[]::new); humanReadable = in.readBoolean(); - if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) { - includeDefaults = in.readBoolean(); - } + includeDefaults = in.readBoolean(); } public GetIndexRequest features(Feature... features) { @@ -156,9 +154,6 @@ public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeArray((o, f) -> o.writeByte(f.id), features); out.writeBoolean(humanReadable); - if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) { - out.writeBoolean(includeDefaults); - } + out.writeBoolean(includeDefaults); } - } 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 9781290e89677..17a21e7600143 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 @@ -99,15 +99,8 @@ public PutMappingRequest(StreamInput in) throws IOException { indicesOptions = IndicesOptions.readIndicesOptions(in); type = in.readOptionalString(); source = in.readString(); - if (in.getVersion().before(LegacyESVersion.V_7_0_0)) { - 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(); } @@ -357,13 +350,8 @@ public void writeTo(StreamOutput out) throws IOException { indicesOptions.writeIndicesOptions(out); out.writeOptionalString(type); out.writeString(source); - if (out.getVersion().before(LegacyESVersion.V_7_0_0)) { - 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/open/OpenIndexRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/open/OpenIndexRequest.java index dd997c189d78a..4b9a192d9deda 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/open/OpenIndexRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/open/OpenIndexRequest.java @@ -59,9 +59,7 @@ public OpenIndexRequest(StreamInput in) throws IOException { super(in); indices = in.readStringArray(); indicesOptions = IndicesOptions.readIndicesOptions(in); - if (in.getVersion().onOrAfter(LegacyESVersion.V_6_1_0)) { - waitForActiveShards = ActiveShardCount.readFrom(in); - } + waitForActiveShards = ActiveShardCount.readFrom(in); } public OpenIndexRequest() { @@ -168,8 +166,6 @@ public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeStringArray(indices); indicesOptions.writeIndicesOptions(out); - if (out.getVersion().onOrAfter(LegacyESVersion.V_6_1_0)) { - waitForActiveShards.writeTo(out); - } + waitForActiveShards.writeTo(out); } } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/rollover/RolloverResponse.java b/server/src/main/java/org/opensearch/action/admin/indices/rollover/RolloverResponse.java index b460a779f0b99..0c7732a39ae14 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/rollover/RolloverResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/rollover/RolloverResponse.java @@ -89,31 +89,17 @@ public final class RolloverResponse extends ShardsAcknowledgedResponse implement private final boolean shardsAcknowledged; RolloverResponse(StreamInput in) throws IOException { - super(in, false, in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)); - if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) { - 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(); - shardsAcknowledged = in.readBoolean(); - } 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(); - shardsAcknowledged = in.readBoolean(); + super(in, false); + 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(); + shardsAcknowledged = in.readBoolean(); } public RolloverResponse(String oldIndex, String newIndex, Map conditionResults, @@ -169,31 +155,17 @@ public boolean isShardsAcknowledged() { @Override public void writeTo(StreamOutput out) throws IOException { - if (out.getVersion().onOrAfter(LegacyESVersion.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); - out.writeBoolean(shardsAcknowledged); - } 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); + out.writeBoolean(shardsAcknowledged); } @Override diff --git a/server/src/main/java/org/opensearch/action/admin/indices/shards/IndicesShardStoresResponse.java b/server/src/main/java/org/opensearch/action/admin/indices/shards/IndicesShardStoresResponse.java index 64b0e2f536737..4a11932e01782 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/shards/IndicesShardStoresResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/shards/IndicesShardStoresResponse.java @@ -123,10 +123,6 @@ private void writeTo(StreamOutput out) throws IOException { public StoreStatus(StreamInput in) throws IOException { node = new DiscoveryNode(in); - if (in.getVersion().before(LegacyESVersion.V_6_0_0_alpha1)) { - // legacy version - in.readLong(); - } allocationId = in.readOptionalString(); allocationStatus = AllocationStatus.readFrom(in); if (in.readBoolean()) { @@ -177,10 +173,6 @@ public AllocationStatus getAllocationStatus() { @Override public void writeTo(StreamOutput out) throws IOException { node.writeTo(out); - if (out.getVersion().before(LegacyESVersion.V_6_0_0_alpha1)) { - // legacy version - out.writeLong(-1L); - } out.writeOptionalString(allocationId); allocationStatus.writeTo(out); if (storeException != null) { diff --git a/server/src/main/java/org/opensearch/action/admin/indices/shrink/ResizeAction.java b/server/src/main/java/org/opensearch/action/admin/indices/shrink/ResizeAction.java index e4d6a079d14d2..5ecdd62206177 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/shrink/ResizeAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/shrink/ResizeAction.java @@ -32,15 +32,12 @@ package org.opensearch.action.admin.indices.shrink; -import org.opensearch.LegacyESVersion; -import org.opensearch.Version; import org.opensearch.action.ActionType; public class ResizeAction extends ActionType { public static final ResizeAction INSTANCE = new ResizeAction(); public static final String NAME = "indices:admin/resize"; - public static final Version COMPATIBILITY_VERSION = LegacyESVersion.V_6_1_0; // TODO remove this once it's backported private ResizeAction() { super(NAME, ResizeResponse::new); diff --git a/server/src/main/java/org/opensearch/action/admin/indices/shrink/ResizeRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/shrink/ResizeRequest.java index 6acf2a6ff1197..4355d5e85bf8f 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/shrink/ResizeRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/shrink/ResizeRequest.java @@ -75,16 +75,8 @@ public ResizeRequest(StreamInput in) throws IOException { super(in); targetIndexRequest = new CreateIndexRequest(in); sourceIndex = in.readString(); - if (in.getVersion().onOrAfter(ResizeAction.COMPATIBILITY_VERSION)) { - type = in.readEnum(ResizeType.class); - } else { - type = ResizeType.SHRINK; // BWC this used to be shrink only - } - if (in.getVersion().before(LegacyESVersion.V_6_4_0)) { - copySettings = null; - } else { - copySettings = in.readOptionalBoolean(); - } + type = in.readEnum(ResizeType.class); + copySettings = in.readOptionalBoolean(); } ResizeRequest() {} @@ -122,18 +114,11 @@ public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); targetIndexRequest.writeTo(out); out.writeString(sourceIndex); - if (out.getVersion().onOrAfter(ResizeAction.COMPATIBILITY_VERSION)) { - if (type == ResizeType.CLONE && out.getVersion().before(LegacyESVersion.V_7_4_0)) { - throw new IllegalArgumentException("can't send clone request to a node that's older than " + LegacyESVersion.V_7_4_0); - } - out.writeEnum(type); - } - // noinspection StatementWithEmptyBody - if (out.getVersion().before(LegacyESVersion.V_6_4_0)) { - - } else { - out.writeOptionalBoolean(copySettings); + if (type == ResizeType.CLONE && out.getVersion().before(LegacyESVersion.V_7_4_0)) { + throw new IllegalArgumentException("can't send clone request to a node that's older than " + LegacyESVersion.V_7_4_0); } + out.writeEnum(type); + out.writeOptionalBoolean(copySettings); } @Override diff --git a/server/src/main/java/org/opensearch/action/admin/indices/shrink/TransportResizeAction.java b/server/src/main/java/org/opensearch/action/admin/indices/shrink/TransportResizeAction.java index 7475a1b71809b..68e8d914d88cd 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/shrink/TransportResizeAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/shrink/TransportResizeAction.java @@ -46,7 +46,6 @@ import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; import org.opensearch.cluster.metadata.MetadataCreateIndexService; -import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.inject.Inject; import org.opensearch.common.io.stream.StreamInput; @@ -208,15 +207,4 @@ static CreateIndexClusterStateUpdateRequest prepareCreateIndexRequest(final Resi .resizeType(resizeRequest.getResizeType()) .copySettings(resizeRequest.getCopySettings() == null ? false : resizeRequest.getCopySettings()); } - - @Override - protected String getMasterActionName(DiscoveryNode node) { - if (node.getVersion().onOrAfter(ResizeAction.COMPATIBILITY_VERSION)){ - return super.getMasterActionName(node); - } else { - // this is for BWC - when we send this to version that doesn't have ResizeAction.NAME registered - // we have to send to shrink instead. - return ShrinkAction.NAME; - } - } } diff --git a/server/src/main/java/org/opensearch/cluster/routing/allocation/decider/ResizeAllocationDecider.java b/server/src/main/java/org/opensearch/cluster/routing/allocation/decider/ResizeAllocationDecider.java index a15f283758de1..e26fb1ba1c90f 100644 --- a/server/src/main/java/org/opensearch/cluster/routing/allocation/decider/ResizeAllocationDecider.java +++ b/server/src/main/java/org/opensearch/cluster/routing/allocation/decider/ResizeAllocationDecider.java @@ -79,9 +79,6 @@ public Decision canAllocate(ShardRouting shardRouting, RoutingNode node, Routing return allocation.decision(Decision.NO, NAME, "source primary shard [%s] is not active", shardId); } if (node != null) { // we might get called from the 2 param canAllocate method.. - if (node.node().getVersion().before(ResizeAction.COMPATIBILITY_VERSION)) { - return allocation.decision(Decision.NO, NAME, "node [%s] is too old to split a shard", node.nodeId()); - } if (sourceShardRouting.currentNodeId().equals(node.nodeId())) { return allocation.decision(Decision.YES, NAME, "source primary is allocated on this node"); } else { diff --git a/server/src/main/java/org/opensearch/transport/TransportHandshaker.java b/server/src/main/java/org/opensearch/transport/TransportHandshaker.java index 70d29411877a2..94927843a2a4a 100644 --- a/server/src/main/java/org/opensearch/transport/TransportHandshaker.java +++ b/server/src/main/java/org/opensearch/transport/TransportHandshaker.java @@ -123,7 +123,7 @@ void handleHandshake(TransportChannel channel, long requestId, StreamInput strea // 2. if remote node is 6.8 then it would be 5.6.0 // 3. if remote node is OpenSearch 1.x then it would be 6.7.99 if((this.version.onOrAfter(Version.V_1_0_0) && this.version.before(Version.V_2_0_0)) && - (stream.getVersion().equals(LegacyESVersion.V_6_8_0) + (stream.getVersion().equals(LegacyESVersion.fromId(6080099)) || stream.getVersion().equals(Version.fromId(5060099)))) { channel.sendResponse(new HandshakeResponse(LegacyESVersion.V_7_10_2)); } else { diff --git a/server/src/test/java/org/opensearch/VersionTests.java b/server/src/test/java/org/opensearch/VersionTests.java index d8109216c7d44..3a5199e7bd210 100644 --- a/server/src/test/java/org/opensearch/VersionTests.java +++ b/server/src/test/java/org/opensearch/VersionTests.java @@ -204,7 +204,7 @@ public void testMinCompatVersion() { // from 7.0 on we are supporting the latest minor of the previous major... this might fail once we add a new version ie. 5.x is // released since we need to bump the supported minor in Version#minimumCompatibilityVersion() - Version lastVersion = LegacyESVersion.V_6_8_0; // TODO: remove this once min compat version is a constant instead of method + Version lastVersion = LegacyESVersion.fromId(6080099); // TODO: remove this once min compat version is a constant instead of method assertEquals(lastVersion.major, LegacyESVersion.V_7_0_0.minimumCompatibilityVersion().major); assertEquals("did you miss to bump the minor in Version#minimumCompatibilityVersion()", lastVersion.minor, LegacyESVersion.V_7_0_0.minimumCompatibilityVersion().minor); @@ -274,12 +274,12 @@ public void testIsRc() { for (int i = 0 ; i < 25; i++) { assertEquals(LegacyESVersion.fromString("5.0.0-rc" + i).id, LegacyESVersion.fromId(5000000 + i + 50).id); assertEquals("5.0.0-rc" + i, LegacyESVersion.fromId(5000000 + i + 50).toString()); - + assertEquals(Version.fromString("1.0.0-rc" + i).id, Version.fromId(135217728 + i + 50).id); assertEquals("1.0.0-rc" + i, Version.fromId(135217728 + i + 50).toString()); } } - + public void testIsBeta() { assertTrue(LegacyESVersion.fromString("2.0.0-beta1").isBeta()); assertTrue(LegacyESVersion.fromString("1.0.0.Beta1").isBeta()); @@ -290,7 +290,7 @@ public void testIsBeta() { for (int i = 0 ; i < 25; i++) { assertEquals(LegacyESVersion.fromString("5.0.0-beta" + i).id, LegacyESVersion.fromId(5000000 + i + 25).id); assertEquals("5.0.0-beta" + i, LegacyESVersion.fromId(5000000 + i + 25).toString()); - + assertEquals(Version.fromString("1.0.0-beta" + i).id, Version.fromId(135217728 + i + 25).id); assertEquals("1.0.0-beta" + i, Version.fromId(135217728 + i + 25).toString()); } @@ -303,14 +303,14 @@ public void testIsAlpha() { assertTrue(LegacyESVersion.fromString("5.0.0-alpha14").isAlpha()); assertEquals(5000014, LegacyESVersion.fromString("5.0.0-alpha14").id); assertTrue(LegacyESVersion.fromId(5000015).isAlpha()); - + assertEquals(135217742, Version.fromString("1.0.0-alpha14").id); assertTrue(Version.fromString("1.0.0-alpha14").isAlpha()); for (int i = 0 ; i < 25; i++) { assertEquals(LegacyESVersion.fromString("5.0.0-alpha" + i).id, LegacyESVersion.fromId(5000000 + i).id); assertEquals("5.0.0-alpha" + i, LegacyESVersion.fromId(5000000 + i).toString()); - + assertEquals(Version.fromString("1.0.0-alpha" + i).id, Version.fromId(135217728 + i).id); assertEquals("1.0.0-alpha" + i, Version.fromId(135217728 + i).toString()); } @@ -432,11 +432,10 @@ public static void assertUnknownVersion(Version version) { public void testIsCompatible() { assertTrue(isCompatible(Version.CURRENT, Version.CURRENT.minimumCompatibilityVersion())); - assertFalse(isCompatible(LegacyESVersion.V_6_6_0, LegacyESVersion.V_7_0_0)); - assertFalse(isCompatible(LegacyESVersion.V_6_7_0, LegacyESVersion.V_7_0_0)); - assertTrue(isCompatible(LegacyESVersion.V_6_8_0, LegacyESVersion.V_7_0_0)); - assertFalse(isCompatible(Version.fromId(2000099), LegacyESVersion.V_7_0_0)); - assertFalse(isCompatible(Version.fromId(2000099), LegacyESVersion.V_6_5_0)); + assertFalse(isCompatible(Version.V_1_0_0, Version.V_2_0_0)); + assertFalse(isCompatible(LegacyESVersion.fromId(6080099), LegacyESVersion.V_7_0_0)); + assertFalse(isCompatible(LegacyESVersion.fromId(2000099), LegacyESVersion.V_7_0_0)); + assertFalse(isCompatible(LegacyESVersion.fromId(2000099), LegacyESVersion.V_6_5_0)); int currentMajorID = Version.computeID(Version.CURRENT.major, 0, 0, 99); final Version currentMajorVersion = Version.fromId(currentMajorID); diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/health/ClusterHealthResponsesTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/health/ClusterHealthResponsesTests.java index 4140cce59d757..08bf6562c5691 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/health/ClusterHealthResponsesTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/health/ClusterHealthResponsesTests.java @@ -157,7 +157,7 @@ public void testVersionCompatibleSerialization() throws IOException { randomInt(100), TimeValue.timeValueMillis(randomInt(10000)), randomBoolean(), stateHealth); BytesStreamOutput out_lt_1_0 = new BytesStreamOutput(); - Version old_version = VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_6_0_0, LegacyESVersion.V_6_8_0); + Version old_version = VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_7_0_0, LegacyESVersion.V_7_10_2); out_lt_1_0.setVersion(old_version); clusterHealth.writeTo(out_lt_1_0); From 881d2f3e0b6391710eb3af314ae19c6ccc535930 Mon Sep 17 00:00:00 2001 From: Nicholas Walter Knize Date: Mon, 6 Sep 2021 16:24:23 -0500 Subject: [PATCH 2/3] continue removal of legay versions Signed-off-by: Nicholas Walter Knize --- .../storedscripts/PutStoredScriptRequest.java | 21 ++-------- .../action/admin/indices/alias/Alias.java | 12 ++---- .../indices/alias/IndicesAliasesRequest.java | 22 +++++----- .../indices/alias/get/GetAliasesRequest.java | 9 +--- .../admin/indices/open/OpenIndexResponse.java | 7 +--- .../admin/indices/rollover/Condition.java | 9 ---- .../indices/rollover/MaxSizeCondition.java | 7 ---- .../indices/rollover/RolloverRequest.java | 4 +- .../indices/rollover/RolloverResponse.java | 3 +- .../settings/get/GetSettingsRequest.java | 9 +--- .../admin/indices/stats/ShardStats.java | 17 ++------ .../template/put/PutIndexTemplateRequest.java | 24 +---------- .../validate/query/QueryExplanation.java | 13 +----- .../org/opensearch/action/get/GetRequest.java | 7 ---- .../resync/ResyncReplicationRequest.java | 33 ++------------- .../action/search/SearchRequest.java | 41 ++++++------------- 16 files changed, 50 insertions(+), 188 deletions(-) diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/PutStoredScriptRequest.java b/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/PutStoredScriptRequest.java index 231a876cb7920..3a466c2fb6ab3 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/PutStoredScriptRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/PutStoredScriptRequest.java @@ -32,7 +32,6 @@ package org.opensearch.action.admin.cluster.storedscripts; -import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.support.master.AcknowledgedRequest; import org.opensearch.common.bytes.BytesReference; @@ -59,18 +58,11 @@ public class PutStoredScriptRequest extends AcknowledgedRequest= value.getBytes()); } - @Override - boolean includedInVersion(Version version) { - return version.onOrAfter(LegacyESVersion.V_6_1_0); - } - @Override public String getWriteableName() { return NAME; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/rollover/RolloverRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/rollover/RolloverRequest.java index 67e5cf0206d5e..c1ebca44a84f2 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/rollover/RolloverRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/rollover/RolloverRequest.java @@ -147,9 +147,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/opensearch/action/admin/indices/rollover/RolloverResponse.java b/server/src/main/java/org/opensearch/action/admin/indices/rollover/RolloverResponse.java index 0c7732a39ae14..a764398e9690b 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/rollover/RolloverResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/rollover/RolloverResponse.java @@ -32,7 +32,6 @@ package org.opensearch.action.admin.indices.rollover; -import org.opensearch.LegacyESVersion; import org.opensearch.action.support.master.ShardsAcknowledgedResponse; import org.opensearch.common.ParseField; import org.opensearch.common.io.stream.StreamInput; @@ -89,7 +88,7 @@ public final class RolloverResponse extends ShardsAcknowledgedResponse implement private final boolean shardsAcknowledged; RolloverResponse(StreamInput in) throws IOException { - super(in, false); + super(in, false, true); oldIndex = in.readString(); newIndex = in.readString(); int conditionSize = in.readVInt(); diff --git a/server/src/main/java/org/opensearch/action/admin/indices/settings/get/GetSettingsRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/settings/get/GetSettingsRequest.java index 69be3e34383b8..7ad018179c29f 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/settings/get/GetSettingsRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/settings/get/GetSettingsRequest.java @@ -32,7 +32,6 @@ package org.opensearch.action.admin.indices.settings.get; -import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.IndicesRequest; import org.opensearch.action.ValidateActions; @@ -83,9 +82,7 @@ public GetSettingsRequest(StreamInput in) throws IOException { indicesOptions = IndicesOptions.readIndicesOptions(in); names = in.readStringArray(); humanReadable = in.readBoolean(); - if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) { - includeDefaults = in.readBoolean(); - } + includeDefaults = in.readBoolean(); } @Override @@ -95,9 +92,7 @@ public void writeTo(StreamOutput out) throws IOException { indicesOptions.writeIndicesOptions(out); out.writeStringArray(names); out.writeBoolean(humanReadable); - if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) { - out.writeBoolean(includeDefaults); - } + out.writeBoolean(includeDefaults); } @Override 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 3a2d8ded9e8db..24708970ace5b 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; @@ -79,12 +78,8 @@ public ShardStats(StreamInput in) throws IOException { statePath = in.readString(); dataPath = in.readString(); isCustomDataPath = in.readBoolean(); - if (in.getVersion().onOrAfter(LegacyESVersion.V_6_0_0_alpha1)) { - seqNoStats = in.readOptionalWriteable(SeqNoStats::new); - } - if (in.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { - retentionLeaseStats = in.readOptionalWriteable(RetentionLeaseStats::new); - } + seqNoStats = in.readOptionalWriteable(SeqNoStats::new); + retentionLeaseStats = in.readOptionalWriteable(RetentionLeaseStats::new); } public ShardStats( @@ -145,12 +140,8 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(statePath); out.writeString(dataPath); out.writeBoolean(isCustomDataPath); - if (out.getVersion().onOrAfter(LegacyESVersion.V_6_0_0_alpha1)) { - out.writeOptionalWriteable(seqNoStats); - } - if (out.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { - out.writeOptionalWriteable(retentionLeaseStats); - } + out.writeOptionalWriteable(seqNoStats); + out.writeOptionalWriteable(retentionLeaseStats); } @Override diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequest.java index 63d8af0655e46..6445905d60e73 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequest.java @@ -31,7 +31,6 @@ package org.opensearch.action.admin.indices.template.put; -import org.opensearch.LegacyESVersion; import org.opensearch.OpenSearchGenerationException; import org.opensearch.OpenSearchParseException; import org.opensearch.action.ActionRequestValidationException; @@ -105,11 +104,7 @@ public PutIndexTemplateRequest(StreamInput in) throws IOException { cause = in.readString(); name = in.readString(); - if (in.getVersion().onOrAfter(LegacyESVersion.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); @@ -119,14 +114,6 @@ public PutIndexTemplateRequest(StreamInput in) throws IOException { String mappingSource = in.readString(); mappings.put(type, mappingSource); } - if (in.getVersion().before(LegacyESVersion.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(new Alias(in)); @@ -496,11 +483,7 @@ public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeString(cause); out.writeString(name); - if (out.getVersion().onOrAfter(LegacyESVersion.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); @@ -509,9 +492,6 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(entry.getKey()); out.writeString(entry.getValue()); } - if (out.getVersion().before(LegacyESVersion.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/opensearch/action/admin/indices/validate/query/QueryExplanation.java b/server/src/main/java/org/opensearch/action/admin/indices/validate/query/QueryExplanation.java index f07746175de9e..0b9a990963b7c 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/validate/query/QueryExplanation.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/validate/query/QueryExplanation.java @@ -32,7 +32,6 @@ package org.opensearch.action.admin.indices.validate.query; -import org.opensearch.LegacyESVersion; import org.opensearch.common.ParseField; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; @@ -94,11 +93,7 @@ public class QueryExplanation implements Writeable, ToXContentFragment { private String error; public QueryExplanation(StreamInput in) throws IOException { - if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) { - index = in.readOptionalString(); - } else { - index = in.readString(); - } + index = in.readOptionalString(); shard = in.readInt(); valid = in.readBoolean(); explanation = in.readOptionalString(); @@ -136,11 +131,7 @@ public String getExplanation() { @Override public void writeTo(StreamOutput out) throws IOException { - if (out.getVersion().onOrAfter(LegacyESVersion.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/opensearch/action/get/GetRequest.java b/server/src/main/java/org/opensearch/action/get/GetRequest.java index 1edf23d0a6473..d1217a2aa84fe 100644 --- a/server/src/main/java/org/opensearch/action/get/GetRequest.java +++ b/server/src/main/java/org/opensearch/action/get/GetRequest.java @@ -32,7 +32,6 @@ package org.opensearch.action.get; -import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.RealtimeRequest; import org.opensearch.action.ValidateActions; @@ -88,9 +87,6 @@ public GetRequest() { type = in.readString(); id = in.readString(); routing = in.readOptionalString(); - if (in.getVersion().before(LegacyESVersion.V_7_0_0)) { - in.readOptionalString(); - } preference = in.readOptionalString(); refresh = in.readBoolean(); storedFields = in.readOptionalStringArray(); @@ -296,9 +292,6 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(type); out.writeString(id); out.writeOptionalString(routing); - if (out.getVersion().before(LegacyESVersion.V_7_0_0)) { - out.writeOptionalString(null); - } out.writeOptionalString(preference); out.writeBoolean(refresh); diff --git a/server/src/main/java/org/opensearch/action/resync/ResyncReplicationRequest.java b/server/src/main/java/org/opensearch/action/resync/ResyncReplicationRequest.java index eef72246b4ba2..a6393933acf9a 100644 --- a/server/src/main/java/org/opensearch/action/resync/ResyncReplicationRequest.java +++ b/server/src/main/java/org/opensearch/action/resync/ResyncReplicationRequest.java @@ -31,13 +31,9 @@ package org.opensearch.action.resync; -import org.opensearch.LegacyESVersion; -import org.opensearch.Version; -import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.replication.ReplicatedWriteRequest; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; -import org.opensearch.index.seqno.SequenceNumbers; import org.opensearch.index.shard.ShardId; import org.opensearch.index.translog.Translog; @@ -56,25 +52,8 @@ public final class ResyncReplicationRequest extends ReplicatedWriteRequest Date: Wed, 8 Sep 2021 11:00:03 -0500 Subject: [PATCH 3/3] continue to remove deprecated logic Signed-off-by: Nicholas Walter Knize --- .../upgrades/FullClusterRestartIT.java | 184 +++++------------- .../admin/indices/create/SplitIndexIT.java | 3 +- .../java/org/opensearch/LegacyESVersion.java | 3 - .../indices/create/CreateIndexRequest.java | 1 - .../admin/indices/get/GetIndexRequest.java | 1 - .../admin/indices/open/OpenIndexRequest.java | 1 - .../action/delete/DeleteRequest.java | 27 +-- .../FieldCapabilitiesIndexRequest.java | 10 +- .../action/get/MultiGetRequest.java | 9 - .../opensearch/action/index/IndexRequest.java | 42 +--- .../ingest/WriteableIngestDocument.java | 9 - .../opensearch/action/main/MainResponse.java | 6 - .../action/search/MultiSearchResponse.java | 11 +- .../action/search/SearchResponse.java | 10 +- .../action/support/IndicesOptions.java | 5 - .../TransportReplicationAction.java | 23 +-- .../termvectors/TermVectorsRequest.java | 24 --- .../action/update/UpdateRequest.java | 27 --- .../action/shard/ShardStateAction.java | 35 +--- .../cluster/block/ClusterBlock.java | 11 +- .../cluster/metadata/AliasMetadata.java | 11 +- .../metadata/IndexTemplateMetadata.java | 24 +-- .../cluster/metadata/MappingMetadata.java | 25 --- .../metadata/MetadataCreateIndexService.java | 6 - .../cluster/routing/OperationRouting.java | 18 +- .../cluster/routing/UnassignedInfo.java | 8 +- .../decider/ResizeAllocationDecider.java | 1 - .../breaker/CircuitBreakingException.java | 11 +- .../opensearch/common/unit/ByteSizeValue.java | 18 +- .../org/opensearch/common/unit/Fuzziness.java | 27 ++- .../opensearch/discovery/DiscoveryStats.java | 13 +- ...ransportNodesListGatewayStartedShards.java | 8 - .../org/opensearch/index/IndexSortConfig.java | 10 - .../index/analysis/AnalysisRegistry.java | 7 +- .../org/opensearch/index/engine/Segment.java | 25 +-- .../index/mapper/DynamicTemplate.java | 15 +- .../index/query/BoolQueryBuilder.java | 7 - .../index/query/CommonTermsQueryBuilder.java | 8 - .../reindex/AbstractBulkByScrollRequest.java | 9 +- .../org/opensearch/index/shard/DocsStats.java | 11 +- .../index/shard/ShardSplittingQuery.java | 5 - .../opensearch/index/shard/StoreRecovery.java | 3 - .../opensearch/index/translog/Translog.java | 9 +- .../org/opensearch/monitor/fs/FsInfo.java | 6 - .../org/opensearch/search/DocValueFormat.java | 20 +- .../CompositeValuesSourceBuilder.java | 29 +-- .../bucket/range/InternalRange.java | 11 +- .../pipeline/InternalPercentilesBucket.java | 12 +- .../search/dfs/DfsSearchResult.java | 28 +-- .../search/sort/FieldSortBuilder.java | 8 +- .../completion/CompletionSuggestion.java | 9 +- .../CompletionSuggestionBuilder.java | 9 +- .../org/opensearch/threadpool/ThreadPool.java | 9 +- .../opensearch/transport/OutboundMessage.java | 5 +- .../java/org/opensearch/VersionTests.java | 8 +- .../settings/get/GetSettingsActionTests.java | 3 - .../settings/get/GetSettingsRequestTests.java | 1 - .../get/GetSettingsResponseTests.java | 1 - .../action/search/SearchRequestTests.java | 51 +---- .../action/shard/ShardStateActionTests.java | 25 --- .../MetadataCreateIndexServiceTests.java | 9 +- .../MetadataIndexUpgradeServiceTests.java | 2 +- .../cluster/routing/UnassignedInfoTests.java | 25 --- .../allocation/FailedNodeRoutingTests.java | 3 +- .../allocation/FailedShardsRoutingTests.java | 7 +- .../index/analysis/AnalysisRegistryTests.java | 3 +- .../index/mapper/DynamicTemplateTests.java | 20 +- .../query/SimpleQueryStringBuilderTests.java | 3 - .../recovery/StartRecoveryRequestTests.java | 7 +- 69 files changed, 177 insertions(+), 858 deletions(-) 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 47aedac4272c5..08472f5990784 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 @@ -50,11 +50,7 @@ import org.opensearch.common.xcontent.json.JsonXContent; 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; import org.opensearch.test.NotEqualMessageBuilder; import org.opensearch.test.XContentTestUtils; import org.opensearch.test.rest.OpenSearchRestTestCase; @@ -100,21 +96,13 @@ * with {@code tests.is_old_cluster} set to {@code false}. */ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase { - private final boolean supportsLenientBooleans = getOldClusterVersion().before(LegacyESVersion.V_6_0_0_alpha1); - private String index; - private String type; @Before public void setIndex() { index = getTestName().toLowerCase(Locale.ROOT); } - @Before - public void setType() { - type = getOldClusterVersion().before(LegacyESVersion.V_6_7_0) ? "doc" : "_doc"; - } - public void testSearch() throws Exception { int count; if (isRunningAgainstOldCluster()) { @@ -128,9 +116,6 @@ public void testSearch() throws Exception { } { mappingsAndSettings.startObject("mappings"); - if (isRunningAgainstAncientCluster()) { - mappingsAndSettings.startObject(type); - } mappingsAndSettings.startObject("properties"); { mappingsAndSettings.startObject("string"); @@ -149,16 +134,12 @@ public void testSearch() throws Exception { mappingsAndSettings.endObject(); } mappingsAndSettings.endObject(); - if (isRunningAgainstAncientCluster()) { - mappingsAndSettings.endObject(); - } mappingsAndSettings.endObject(); } mappingsAndSettings.endObject(); Request createIndex = new Request("PUT", "/" + index); createIndex.setJsonEntity(Strings.toString(mappingsAndSettings)); - createIndex.setOptions(allowTypesRemovalWarnings()); client().performRequest(createIndex); count = randomIntBetween(2000, 3000); @@ -173,7 +154,7 @@ public void testSearch() throws Exception { .field("int", randomInt(100)) .field("float", randomFloat()) // be sure to create a "proper" boolean (True, False) for the first document so that automapping is correct - .field("bool", i > 0 && supportsLenientBooleans ? randomLenientBoolean() : randomBoolean()) + .field("bool", i > 0 && randomBoolean()) .field("field.with.dots", randomAlphaOfLength(10)) .field("binary", Base64.getEncoder().encodeToString(randomByteArray)) .endObject() @@ -187,7 +168,7 @@ public void testSearch() throws Exception { assertBasicSearchWorks(count); assertAllSearchWorks(count); assertBasicAggregationWorks(); - assertRealtimeGetWorks(type); + assertRealtimeGetWorks(); assertStoredBinaryFields(count); } @@ -203,9 +184,6 @@ public void testNewReplicasWork() throws Exception { } { mappingsAndSettings.startObject("mappings"); - if (isRunningAgainstAncientCluster()) { - mappingsAndSettings.startObject(type); - } mappingsAndSettings.startObject("properties"); { mappingsAndSettings.startObject("field"); @@ -213,16 +191,12 @@ public void testNewReplicasWork() throws Exception { mappingsAndSettings.endObject(); } mappingsAndSettings.endObject(); - if (isRunningAgainstAncientCluster()) { - mappingsAndSettings.endObject(); - } mappingsAndSettings.endObject(); } mappingsAndSettings.endObject(); Request createIndex = new Request("PUT", "/" + index); createIndex.setJsonEntity(Strings.toString(mappingsAndSettings)); - createIndex.setOptions(allowTypesRemovalWarnings()); client().performRequest(createIndex); int numDocs = randomIntBetween(2000, 3000); @@ -309,9 +283,6 @@ public void testShrink() throws IOException { { mappingsAndSettings.startObject("mappings"); { - if (isRunningAgainstAncientCluster()) { - mappingsAndSettings.startObject(type); - } mappingsAndSettings.startObject("properties"); { mappingsAndSettings.startObject("field"); @@ -321,25 +292,20 @@ public void testShrink() throws IOException { mappingsAndSettings.endObject(); } mappingsAndSettings.endObject(); - if (isRunningAgainstAncientCluster()) { - mappingsAndSettings.endObject(); - } } mappingsAndSettings.endObject(); - if (isRunningAgainstAncientCluster() == false) { - // the default number of shards is now one so we have to set the number of shards to be more than one explicitly - mappingsAndSettings.startObject("settings"); - { - mappingsAndSettings.field("index.number_of_shards", 5); - } - mappingsAndSettings.endObject(); + + // the default number of shards is one so we have to set the number of shards to be more than one explicitly + mappingsAndSettings.startObject("settings"); + { + mappingsAndSettings.field("index.number_of_shards", 5); } + mappingsAndSettings.endObject(); } mappingsAndSettings.endObject(); Request createIndex = new Request("PUT", "/" + index); createIndex.setJsonEntity(Strings.toString(mappingsAndSettings)); - createIndex.setOptions(allowTypesRemovalWarnings()); client().performRequest(createIndex); numDocs = randomIntBetween(512, 1024); @@ -392,9 +358,6 @@ public void testShrinkAfterUpgrade() throws IOException { { mappingsAndSettings.startObject("mappings"); { - if (isRunningAgainstAncientCluster()) { - mappingsAndSettings.startObject(type); - } mappingsAndSettings.startObject("properties"); { mappingsAndSettings.startObject("field"); @@ -404,23 +367,19 @@ public void testShrinkAfterUpgrade() throws IOException { mappingsAndSettings.endObject(); } mappingsAndSettings.endObject(); - if (isRunningAgainstAncientCluster()) { - mappingsAndSettings.endObject(); - } } mappingsAndSettings.endObject(); - if (isRunningAgainstAncientCluster() == false) { - // the default number of shards is now one so we have to set the number of shards to be more than one explicitly - mappingsAndSettings.startObject("settings"); - mappingsAndSettings.field("index.number_of_shards", 5); - mappingsAndSettings.endObject(); - } + + // the default number of shards is one so we have to set the number of shards to be more than one explicitly + mappingsAndSettings.startObject("settings"); + mappingsAndSettings.field("index.number_of_shards", 5); + mappingsAndSettings.endObject(); + } mappingsAndSettings.endObject(); Request createIndex = new Request("PUT", "/" + index); createIndex.setJsonEntity(Strings.toString(mappingsAndSettings)); - createIndex.setOptions(allowTypesRemovalWarnings()); client().performRequest(createIndex); numDocs = randomIntBetween(512, 1024); @@ -496,15 +455,13 @@ public void testRollover() throws IOException { bulk.append("{\"index\":{}}\n"); bulk.append("{\"test\":\"test\"}\n"); } - Request bulkRequest = new Request("POST", "/" + index + "_write/" + type + "/_bulk"); + Request bulkRequest = new Request("POST", "/" + index + "_write/_bulk"); bulkRequest.setJsonEntity(bulk.toString()); bulkRequest.addParameter("refresh", ""); - bulkRequest.setOptions(expectWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE)); assertThat(EntityUtils.toString(client().performRequest(bulkRequest).getEntity()), containsString("\"errors\":false")); if (isRunningAgainstOldCluster()) { Request rolloverRequest = new Request("POST", "/" + index + "_write/_rollover"); - rolloverRequest.setOptions(allowTypesRemovalWarnings()); rolloverRequest.setJsonEntity("{" + " \"conditions\": {" + " \"max_docs\": 5" @@ -574,12 +531,10 @@ void assertAllSearchWorks(int count) throws IOException { // the 'string' field has a boost of 4 in the mappings so it should get a payload boost String stringValue = (String) XContentMapValues.extractValue("_source.string", bestHit); assertNotNull(stringValue); - String type = (String) bestHit.get("_type"); String id = (String) bestHit.get("_id"); - Request explainRequest = new Request("GET", "/" + index + "/" + type + "/" + id + "/_explain"); + Request explainRequest = new Request("GET", "/" + index + "/_explain" + id); explainRequest.setJsonEntity("{ \"query\": { \"match_all\" : {} }}"); - explainRequest.setOptions(expectWarnings(RestExplainAction.TYPES_DEPRECATION_MESSAGE)); String explanation = toStr(client().performRequest(explainRequest)); assertFalse("Could not find payload boost in explanation\n" + explanation, explanation.contains("payloadBoost")); @@ -619,7 +574,7 @@ void assertBasicAggregationWorks() throws IOException { assertTotalHits(termsCount, boolTerms); } - void assertRealtimeGetWorks(final String typeName) throws IOException { + void assertRealtimeGetWorks() throws IOException { Request disableAutoRefresh = new Request("PUT", "/" + index + "/_settings"); disableAutoRefresh.setJsonEntity("{ \"index\": { \"refresh_interval\" : -1 }}"); client().performRequest(disableAutoRefresh); @@ -630,15 +585,12 @@ void assertRealtimeGetWorks(final String typeName) throws IOException { Map hit = (Map) ((List)(XContentMapValues.extractValue("hits.hits", searchResponse))).get(0); String docId = (String) hit.get("_id"); - Request updateRequest = new Request("POST", "/" + index + "/" + typeName + "/" + docId + "/_update"); + Request updateRequest = new Request("POST", "/" + index + "/_update" + docId); updateRequest.setOptions(expectWarnings(RestUpdateAction.TYPES_DEPRECATION_MESSAGE)); updateRequest.setJsonEntity("{ \"doc\" : { \"foo\": \"bar\"}}"); 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)); - } + Request getRequest = new Request("GET", "/" + index + "/_doc/" + docId); Map getRsp = entityAsMap(client().performRequest(getRequest)); Map source = (Map) getRsp.get("_source"); assertTrue("doc does not contain 'foo' key: " + source, source.containsKey("foo")); @@ -674,7 +626,7 @@ static String toStr(Response response) throws IOException { * Tests that a single document survives. Super basic smoke test. */ public void testSingleDoc() throws IOException { - String docLocation = "/" + index + "/" + type + "/1"; + String docLocation = "/" + index + "/_doc/1"; String doc = "{\"test\": \"test\"}"; if (isRunningAgainstOldCluster()) { @@ -685,9 +637,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)); } @@ -756,10 +705,10 @@ public void testRecovery() throws Exception { i -> jsonBuilder().startObject().field("field", "value").endObject() ); } - saveInfoDocument("should_have_translog", Boolean.toString(shouldHaveTranslog)); + saveInfoDocument(index + "_should_have_translog", Boolean.toString(shouldHaveTranslog)); } else { count = countOfIndexedRandomDocuments(); - shouldHaveTranslog = Booleans.parseBoolean(loadInfoDocument("should_have_translog")); + shouldHaveTranslog = Booleans.parseBoolean(loadInfoDocument(index + "_should_have_translog")); } // Count the documents in the index to make sure we have as many as we put there @@ -869,9 +818,6 @@ public void testSnapshotRestore() throws IOException { } templateBuilder.endObject(); templateBuilder.startObject("mappings"); { - if (isRunningAgainstAncientCluster()) { - templateBuilder.startObject(type); - } { templateBuilder.startObject("_source"); { @@ -879,9 +825,6 @@ public void testSnapshotRestore() throws IOException { } templateBuilder.endObject(); } - if (isRunningAgainstAncientCluster()) { - templateBuilder.endObject(); - } } templateBuilder.endObject(); templateBuilder.startObject("aliases"); { @@ -900,7 +843,6 @@ public void testSnapshotRestore() throws IOException { templateBuilder.endObject().endObject(); Request createTemplateRequest = new Request("PUT", "/_template/test_template"); createTemplateRequest.setJsonEntity(Strings.toString(templateBuilder)); - createTemplateRequest.setOptions(allowTypesRemovalWarnings()); client().performRequest(createTemplateRequest); @@ -991,10 +933,7 @@ public void testSoftDeletes() throws Exception { int numDocs = between(10, 100); for (int i = 0; i < numDocs; i++) { String doc = Strings.toString(JsonXContent.contentBuilder().startObject().field("field", "v1").endObject()); - Request request = new Request("POST", "/" + index + "/" + type + "/" + i); - if (isRunningAgainstAncientCluster() == false) { - request.setOptions(expectWarnings(RestIndexAction.TYPES_DEPRECATION_MESSAGE)); - } + Request request = new Request("POST", "/" + index + "/_doc/" + i); request.setJsonEntity(doc); client().performRequest(request); refresh(); @@ -1005,19 +944,19 @@ public void testSoftDeletes() throws Exception { for (int i = 0; i < numDocs; i++) { if (randomBoolean()) { String doc = Strings.toString(JsonXContent.contentBuilder().startObject().field("field", "v2").endObject()); - Request request = new Request("POST", "/" + index + "/" + type + "/" + i); + Request request = new Request("POST", "/" + index + "/_doc/" + i); request.setJsonEntity(doc); client().performRequest(request); } else if (randomBoolean()) { - client().performRequest(new Request("DELETE", "/" + index + "/" + type + "/" + i)); + client().performRequest(new Request("DELETE", "/" + index + "/_doc/" + i)); liveDocs--; } } refresh(); assertTotalHits(liveDocs, entityAsMap(client().performRequest(new Request("GET", "/" + index + "/_search")))); - saveInfoDocument("doc_count", Integer.toString(liveDocs)); + saveInfoDocument(index + "_doc_count", Integer.toString(liveDocs)); } else { - int liveDocs = Integer.parseInt(loadInfoDocument("doc_count")); + int liveDocs = Integer.parseInt(loadInfoDocument(index + "_doc_count")); assertTotalHits(liveDocs, entityAsMap(client().performRequest(new Request("GET", "/" + index + "/_search")))); } } @@ -1037,14 +976,14 @@ public void testClosedIndices() throws Exception { if (randomBoolean()) { numDocs = between(1, 100); for (int i = 0; i < numDocs; i++) { - final Request request = new Request("POST", "/" + index + "/" + type + "/" + i); + final Request request = new Request("POST", "/" + index + "/_doc/" + i); request.setJsonEntity(Strings.toString(JsonXContent.contentBuilder().startObject().field("field", "v1").endObject())); assertOK(client().performRequest(request)); if (rarely()) { - refresh(); + refreshAllIndices(); } } - refresh(); + refreshAllIndices(); } assertTotalHits(numDocs, entityAsMap(client().performRequest(new Request("GET", "/" + index + "/_search")))); @@ -1131,8 +1070,7 @@ private void checkSnapshot(final String snapshotName, final int count, final Ver * If this test is executed on the upgraded mode before testRemoteClusterSettingsUpgraded, * we will hit a warning exception because we put some deprecated settings in that test. */ - if (isRunningAgainstOldCluster() == false - && getOldClusterVersion().onOrAfter(LegacyESVersion.V_6_1_0) && getOldClusterVersion().before(LegacyESVersion.V_6_5_0)) { + if (isRunningAgainstOldCluster() == false) { for (String warning : e.getResponse().getWarnings()) { assertThat(warning, containsString( "setting was deprecated and will be removed in a future release! " @@ -1170,10 +1108,9 @@ && getOldClusterVersion().onOrAfter(LegacyESVersion.V_6_1_0) && getOldClusterVer bulk.append("{\"index\":{\"_id\":\"").append(count + i).append("\"}}\n"); bulk.append("{\"test\":\"test\"}\n"); } - Request writeToRestoredRequest = new Request("POST", "/restored_" + index + "/" + type + "/_bulk"); + Request writeToRestoredRequest = new Request("POST", "/restored_" + index + "/_bulk"); writeToRestoredRequest.addParameter("refresh", "true"); writeToRestoredRequest.setJsonEntity(bulk.toString()); - writeToRestoredRequest.setOptions(expectWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE)); assertThat(EntityUtils.toString(client().performRequest(writeToRestoredRequest).getEntity()), containsString("\"errors\":false")); // And count to make sure the add worked @@ -1196,7 +1133,6 @@ && getOldClusterVersion().onOrAfter(LegacyESVersion.V_6_1_0) && getOldClusterVer // Check that the template was restored successfully Request getTemplateRequest = new Request("GET", "/_template/test_template"); - getTemplateRequest.setOptions(allowTypesRemovalWarnings()); Map getTemplateResponse = entityAsMap(client().performRequest(getTemplateRequest)); Map expectedTemplate = new HashMap<>(); @@ -1206,13 +1142,7 @@ && getOldClusterVersion().onOrAfter(LegacyESVersion.V_6_1_0) && getOldClusterVer expectedTemplate.put("index_patterns", singletonList("evil_*")); } expectedTemplate.put("settings", singletonMap("index", singletonMap("number_of_shards", "1"))); - // We don't have the type in the response starting with 7.0, but we won't have it on old cluster after upgrade - // either so look at the response to figure out the correct assertions - if (isTypeInTemplateResponse(getTemplateResponse)) { - expectedTemplate.put("mappings", singletonMap(type, singletonMap("_source", singletonMap("enabled", true)))); - } else { - expectedTemplate.put("mappings", singletonMap("_source", singletonMap("enabled", true))); - } + expectedTemplate.put("mappings", singletonMap("_source", singletonMap("enabled", true))); expectedTemplate.put("order", 0); Map aliases = new HashMap<>(); @@ -1228,13 +1158,6 @@ && getOldClusterVersion().onOrAfter(LegacyESVersion.V_6_1_0) && getOldClusterVer } } - @SuppressWarnings("unchecked") - private boolean isTypeInTemplateResponse(Map getTemplateResponse) { - return ( (Map) ( - (Map) getTemplateResponse.getOrDefault("test_template", emptyMap()) - ).get("mappings")).get("_source") == null; - } - // TODO tests for upgrades after shrink. We've had trouble with shrink in the past. private void indexRandomDocuments( @@ -1246,10 +1169,7 @@ private void indexRandomDocuments( logger.info("Indexing {} random documents", count); for (int i = 0; i < count; i++) { logger.debug("Indexing document [{}]", i); - Request createDocument = new Request("POST", "/" + index + "/" + type + "/" + i); - if (isRunningAgainstAncientCluster() == false) { - createDocument.setOptions(expectWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE)); - } + Request createDocument = new Request("POST", "/" + index + "/_doc/" + i); createDocument.setJsonEntity(Strings.toString(docSupplier.apply(i))); client().performRequest(createDocument); if (rarely()) { @@ -1261,50 +1181,40 @@ private void indexRandomDocuments( } } if (saveInfo) { - saveInfoDocument("count", Integer.toString(count)); + saveInfoDocument(index + "_count", Integer.toString(count)); } } private void indexDocument(String id) throws IOException { - final Request indexRequest = new Request("POST", "/" + index + "/" + type + "/" + id); + final Request indexRequest = new Request("POST", "/" + index + "/_doc/" + id); indexRequest.setJsonEntity(Strings.toString(JsonXContent.contentBuilder().startObject().field("f", "v").endObject())); assertOK(client().performRequest(indexRequest)); } private int countOfIndexedRandomDocuments() throws IOException { - return Integer.parseInt(loadInfoDocument("count")); + return Integer.parseInt(loadInfoDocument(index + "_count")); } - private void saveInfoDocument(String type, String value) throws IOException { + private void saveInfoDocument(String id, String value) throws IOException { XContentBuilder infoDoc = JsonXContent.contentBuilder().startObject(); infoDoc.field("value", value); infoDoc.endObject(); // Only create the first version so we know how many documents are created when the index is first created - Request request = new Request("PUT", "/info/" + this.type + "/" + index + "_" + type); + Request request = new Request("PUT", "/info/_doc/" + id); request.addParameter("op_type", "create"); request.setJsonEntity(Strings.toString(infoDoc)); - if (isRunningAgainstAncientCluster() == false) { - request.setOptions(expectWarnings(RestIndexAction.TYPES_DEPRECATION_MESSAGE)); - } client().performRequest(request); } - private String loadInfoDocument(String type) throws IOException { - Request request = new Request("GET", "/info/" + this.type + "/" + index + "_" + type); + private String loadInfoDocument(String id) throws IOException { + Request request = new Request("GET", "/info/_doc/" + id); 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()); return m.group(1); } - private Object randomLenientBoolean() { - return randomFrom(new Object[] {"off", "no", "0", 0, "false", false, "on", "yes", "1", 1, "true", true}); - } - private void refresh() throws IOException { logger.debug("Refreshing [{}]", index); client().performRequest(new Request("POST", "/" + index + "/_refresh")); @@ -1480,11 +1390,8 @@ public void testSystemIndexMetadataIsUpgraded() throws Exception { Request bulk = new Request("POST", "/_bulk"); bulk.addParameter("refresh", "true"); - bulk.setJsonEntity("{\"index\": {\"_index\": \"test_index_old\", \"_type\" : \"" + type + "\"}}\n" + + bulk.setJsonEntity("{\"index\": {\"_index\": \"test_index_old\"}}\n" + "{\"f1\": \"v1\", \"f2\": \"v2\"}\n"); - if (isRunningAgainstAncientCluster() == false) { - bulk.setOptions(expectWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE)); - } client().performRequest(bulk); // start a async reindex job @@ -1510,9 +1417,6 @@ 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)) { - getTasksIndex.addParameter("include_type_name", "false"); - } getTasksIndex.setOptions(expectVersionSpecificWarnings(v -> { v.current(systemIndexWarning); @@ -1537,6 +1441,10 @@ public void testSystemIndexMetadataIsUpgraded() throws Exception { " {\"add\": {\"index\": \"test_index_reindex\", \"alias\": \"test-system-alias\"}}\n" + " ]\n" + "}"); + putAliasRequest.setOptions(expectVersionSpecificWarnings(v -> { + v.current(systemIndexWarning); + v.compatible(systemIndexWarning); + })); assertThat(client().performRequest(putAliasRequest).getStatusLine().getStatusCode(), is(200)); } } else { diff --git a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/SplitIndexIT.java b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/SplitIndexIT.java index 388e97a29629a..50a4160a3451b 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/SplitIndexIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/SplitIndexIT.java @@ -39,7 +39,6 @@ import org.apache.lucene.search.join.ScoreMode; import org.apache.lucene.util.Constants; -import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.action.admin.cluster.state.ClusterStateRequest; import org.opensearch.action.admin.cluster.state.ClusterStateResponse; @@ -371,7 +370,7 @@ private static IndexMetadata indexMetadata(final Client client, final String ind public void testCreateSplitIndex() throws Exception { internalCluster().ensureAtLeastNumDataNodes(2); - Version version = VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_6_0_0_rc2, Version.CURRENT); + Version version = VersionUtils.randomIndexCompatibleVersion(random()); prepareCreate("source").setSettings(Settings.builder().put(indexSettings()) .put("number_of_shards", 1) .put("index.version.created", version) diff --git a/server/src/main/java/org/opensearch/LegacyESVersion.java b/server/src/main/java/org/opensearch/LegacyESVersion.java index 5a714416bdaba..1ee1a48c49c01 100644 --- a/server/src/main/java/org/opensearch/LegacyESVersion.java +++ b/server/src/main/java/org/opensearch/LegacyESVersion.java @@ -56,8 +56,6 @@ public class LegacyESVersion extends Version { new LegacyESVersion(6000027, org.apache.lucene.util.Version.LUCENE_7_0_0); public static final LegacyESVersion V_6_0_0_rc1 = new LegacyESVersion(6000051, org.apache.lucene.util.Version.LUCENE_7_0_0); - public static final LegacyESVersion V_6_0_0_rc2 = - new LegacyESVersion(6000052, org.apache.lucene.util.Version.LUCENE_7_0_1); public static final LegacyESVersion V_6_0_0 = new LegacyESVersion(6000099, org.apache.lucene.util.Version.LUCENE_7_0_1); public static final LegacyESVersion V_6_0_1 = @@ -71,7 +69,6 @@ public class LegacyESVersion extends Version { public static final LegacyESVersion V_6_2_2 = new LegacyESVersion(6020299, LUCENE_7_2_1); public static final LegacyESVersion V_6_2_4 = new LegacyESVersion(6020499, LUCENE_7_2_1); public static final LegacyESVersion V_6_3_0 = new LegacyESVersion(6030099, org.apache.lucene.util.Version.LUCENE_7_3_1); - public static final LegacyESVersion V_6_3_1 = new LegacyESVersion(6030199, org.apache.lucene.util.Version.LUCENE_7_3_1); public static final LegacyESVersion V_6_4_0 = new LegacyESVersion(6040099, org.apache.lucene.util.Version.LUCENE_7_4_0); public static final LegacyESVersion V_6_5_0 = new LegacyESVersion(6050099, org.apache.lucene.util.Version.LUCENE_7_5_0); public static final LegacyESVersion V_6_6_0 = new LegacyESVersion(6060099, org.apache.lucene.util.Version.LUCENE_7_6_0); diff --git a/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequest.java index daba59398e82a..ff431a847faa3 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequest.java @@ -32,7 +32,6 @@ package org.opensearch.action.admin.indices.create; -import org.opensearch.LegacyESVersion; import org.opensearch.OpenSearchGenerationException; import org.opensearch.OpenSearchParseException; import org.opensearch.action.ActionRequestValidationException; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/get/GetIndexRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/get/GetIndexRequest.java index b455c5c13ead2..01e2c213f9bc5 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/get/GetIndexRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/get/GetIndexRequest.java @@ -32,7 +32,6 @@ package org.opensearch.action.admin.indices.get; -import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.support.master.info.ClusterInfoRequest; import org.opensearch.common.io.stream.StreamInput; diff --git a/server/src/main/java/org/opensearch/action/admin/indices/open/OpenIndexRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/open/OpenIndexRequest.java index 4b9a192d9deda..5bb5c93fc19cd 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/open/OpenIndexRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/open/OpenIndexRequest.java @@ -32,7 +32,6 @@ package org.opensearch.action.admin.indices.open; -import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.IndicesRequest; import org.opensearch.action.support.ActiveShardCount; 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 1ec1ee93da029..f3bf3b21d475b 100644 --- a/server/src/main/java/org/opensearch/action/delete/DeleteRequest.java +++ b/server/src/main/java/org/opensearch/action/delete/DeleteRequest.java @@ -33,7 +33,6 @@ package org.opensearch.action.delete; import org.apache.lucene.util.RamUsageEstimator; -import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.CompositeIndicesRequest; import org.opensearch.action.DocWriteRequest; @@ -90,18 +89,10 @@ public DeleteRequest(@Nullable ShardId shardId, StreamInput in) throws IOExcepti type = in.readString(); id = in.readString(); routing = in.readOptionalString(); - if (in.getVersion().before(LegacyESVersion.V_7_0_0)) { - in.readOptionalString(); // _parent - } 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() { @@ -341,20 +332,10 @@ private void writeBody(StreamOutput out) throws IOException { out.writeString(type()); out.writeString(id); out.writeOptionalString(routing()); - if (out.getVersion().before(LegacyESVersion.V_7_0_0)) { - out.writeOptionalString(null); // _parent - } 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/fieldcaps/FieldCapabilitiesIndexRequest.java b/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilitiesIndexRequest.java index 4b08c74c09bcf..3a2080a063d89 100644 --- a/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilitiesIndexRequest.java +++ b/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilitiesIndexRequest.java @@ -64,11 +64,7 @@ public class FieldCapabilitiesIndexRequest extends ActionRequest implements Indi shardId = in.readOptionalWriteable(ShardId::new); index = in.readOptionalString(); fields = in.readStringArray(); - if (in.getVersion().onOrAfter(LegacyESVersion.V_6_2_0)) { - originalIndices = OriginalIndices.readOriginalIndices(in); - } else { - originalIndices = OriginalIndices.NONE; - } + originalIndices = OriginalIndices.readOriginalIndices(in); indexFilter = in.getVersion().onOrAfter(LegacyESVersion.V_7_9_0) ? in.readOptionalNamedWriteable(QueryBuilder.class) : null; nowInMillis = in.getVersion().onOrAfter(LegacyESVersion.V_7_9_0) ? in.readLong() : 0L; } @@ -129,9 +125,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalWriteable(shardId); out.writeOptionalString(index); out.writeStringArray(fields); - if (out.getVersion().onOrAfter(LegacyESVersion.V_6_2_0)) { - OriginalIndices.writeOriginalIndices(originalIndices, out); - } + OriginalIndices.writeOriginalIndices(originalIndices, out); if (out.getVersion().onOrAfter(LegacyESVersion.V_7_9_0)) { out.writeOptionalNamedWriteable(indexFilter); out.writeLong(nowInMillis); diff --git a/server/src/main/java/org/opensearch/action/get/MultiGetRequest.java b/server/src/main/java/org/opensearch/action/get/MultiGetRequest.java index 03e89e98edc14..9c34160739704 100644 --- a/server/src/main/java/org/opensearch/action/get/MultiGetRequest.java +++ b/server/src/main/java/org/opensearch/action/get/MultiGetRequest.java @@ -32,7 +32,6 @@ package org.opensearch.action.get; -import org.opensearch.LegacyESVersion; import org.opensearch.OpenSearchParseException; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestValidationException; @@ -101,13 +100,9 @@ public Item(StreamInput in) throws IOException { type = in.readOptionalString(); id = in.readString(); routing = in.readOptionalString(); - if (in.getVersion().before(LegacyESVersion.V_7_0_0)) { - in.readOptionalString(); // _parent - } storedFields = in.readOptionalStringArray(); version = in.readLong(); versionType = VersionType.fromValue(in.readByte()); - fetchSourceContext = in.readOptionalWriteable(FetchSourceContext::new); } @@ -216,13 +211,9 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalString(type); out.writeString(id); out.writeOptionalString(routing); - if (out.getVersion().before(LegacyESVersion.V_7_0_0)) { - out.writeOptionalString(null); // _parent - } out.writeOptionalStringArray(storedFields); out.writeLong(version); out.writeByte(versionType.getValue()); - out.writeOptionalWriteable(fetchSourceContext); } 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 646b015d86c9f..c0af69716e2eb 100644 --- a/server/src/main/java/org/opensearch/action/index/IndexRequest.java +++ b/server/src/main/java/org/opensearch/action/index/IndexRequest.java @@ -146,13 +146,6 @@ public IndexRequest(@Nullable ShardId shardId, StreamInput in) throws IOExceptio type = in.readOptionalString(); id = in.readOptionalString(); routing = in.readOptionalString(); - if (in.getVersion().before(LegacyESVersion.V_7_0_0)) { - in.readOptionalString(); // _parent - } - if (in.getVersion().before(LegacyESVersion.V_6_0_0_alpha1)) { - in.readOptionalString(); // timestamp - in.readOptionalTimeValue(); // ttl - } source = in.readBytesReference(); opType = OpType.fromId(in.readByte()); version = in.readLong(); @@ -171,13 +164,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 { @@ -701,13 +689,7 @@ public void process(Version indexCreatedVersion, @Nullable MappingMetadata mappi assert ifSeqNo == UNASSIGNED_SEQ_NO; assert ifPrimaryTerm == UNASSIGNED_PRIMARY_TERM; autoGeneratedTimestamp = Math.max(0, System.currentTimeMillis()); // extra paranoia - String uid; - if (indexCreatedVersion.onOrAfter(LegacyESVersion.V_6_0_0_beta1)) { - uid = UUIDs.base64UUID(); - } else { - uid = UUIDs.legacyBase64UUID(); - } - id(uid); + id(UUIDs.base64UUID()); } } @@ -746,13 +728,6 @@ private void writeBody(StreamOutput out) throws IOException { if (out.getVersion().before(LegacyESVersion.V_7_0_0)) { out.writeOptionalString(null); // _parent } - if (out.getVersion().before(LegacyESVersion.V_6_0_0_alpha1)) { - // Serialize a fake timestamp. 5.x expect this value to be set by the #process method so we can't use null. - // On the other hand, indices created on 5.x do not index the timestamp field. Therefore passing a 0 (or any value) for - // the transport layer OK as it will be ignored. - out.writeOptionalString("0"); - out.writeOptionalWriteable(null); - } out.writeBytesReference(source); out.writeByte(opType.getId()); out.writeLong(version); @@ -772,15 +747,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/ingest/WriteableIngestDocument.java b/server/src/main/java/org/opensearch/action/ingest/WriteableIngestDocument.java index 0faf5328025ea..16c6b9e56ec21 100644 --- a/server/src/main/java/org/opensearch/action/ingest/WriteableIngestDocument.java +++ b/server/src/main/java/org/opensearch/action/ingest/WriteableIngestDocument.java @@ -32,7 +32,6 @@ package org.opensearch.action.ingest; -import org.opensearch.LegacyESVersion; import org.opensearch.common.ParseField; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; @@ -45,9 +44,7 @@ import org.opensearch.ingest.IngestDocument.Metadata; import java.io.IOException; -import java.time.ZoneId; import java.time.ZonedDateTime; -import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.Objects; @@ -125,12 +122,6 @@ final class WriteableIngestDocument implements Writeable, ToXContentFragment { WriteableIngestDocument(StreamInput in) throws IOException { Map sourceAndMetadata = in.readMap(); Map ingestMetadata = in.readMap(); - if (in.getVersion().before(LegacyESVersion.V_6_0_0_beta1)) { - ingestMetadata.computeIfPresent("timestamp", (k, o) -> { - Date date = (Date) o; - return date.toInstant().atZone(ZoneId.systemDefault()); - }); - } this.ingestDocument = new IngestDocument(sourceAndMetadata, ingestMetadata); } diff --git a/server/src/main/java/org/opensearch/action/main/MainResponse.java b/server/src/main/java/org/opensearch/action/main/MainResponse.java index c1c0a71b24365..7d663b2bbe2c4 100644 --- a/server/src/main/java/org/opensearch/action/main/MainResponse.java +++ b/server/src/main/java/org/opensearch/action/main/MainResponse.java @@ -67,9 +67,6 @@ public class MainResponse extends ActionResponse implements ToXContentObject { clusterName = new ClusterName(in); clusterUuid = in.readString(); build = Build.readBuild(in); - if (in.getVersion().before(LegacyESVersion.V_7_0_0)) { - in.readBoolean(); - } versionNumber = build.getQualifiedVersion(); } @@ -128,9 +125,6 @@ public void writeTo(StreamOutput out) throws IOException { clusterName.writeTo(out); out.writeString(clusterUuid); Build.writeBuild(build, out); - if (out.getVersion().before(LegacyESVersion.V_7_0_0)) { - out.writeBoolean(true); - } } @Override diff --git a/server/src/main/java/org/opensearch/action/search/MultiSearchResponse.java b/server/src/main/java/org/opensearch/action/search/MultiSearchResponse.java index 60dcb98864ff2..d32562cd26e3f 100644 --- a/server/src/main/java/org/opensearch/action/search/MultiSearchResponse.java +++ b/server/src/main/java/org/opensearch/action/search/MultiSearchResponse.java @@ -32,7 +32,6 @@ package org.opensearch.action.search; -import org.opensearch.LegacyESVersion; import org.opensearch.OpenSearchException; import org.opensearch.ExceptionsHelper; import org.opensearch.action.ActionResponse; @@ -140,11 +139,7 @@ public MultiSearchResponse(StreamInput in) throws IOException { for (int i = 0; i < items.length; i++) { items[i] = new Item(in); } - if (in.getVersion().onOrAfter(LegacyESVersion.V_7_0_0)) { - tookInMillis = in.readVLong(); - } else { - tookInMillis = 0L; - } + tookInMillis = in.readVLong(); } public MultiSearchResponse(Item[] items, long tookInMillis) { @@ -177,9 +172,7 @@ public void writeTo(StreamOutput out) throws IOException { for (Item item : items) { item.writeTo(out); } - if (out.getVersion().onOrAfter(LegacyESVersion.V_7_0_0)) { - out.writeVLong(tookInMillis); - } + out.writeVLong(tookInMillis); } @Override diff --git a/server/src/main/java/org/opensearch/action/search/SearchResponse.java b/server/src/main/java/org/opensearch/action/search/SearchResponse.java index 51e58bfb55054..a41f1d1c7f254 100644 --- a/server/src/main/java/org/opensearch/action/search/SearchResponse.java +++ b/server/src/main/java/org/opensearch/action/search/SearchResponse.java @@ -104,11 +104,7 @@ public SearchResponse(StreamInput in) throws IOException { shardFailures[i] = ShardSearchFailure.readShardSearchFailure(in); } } - if (in.getVersion().onOrAfter(LegacyESVersion.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(); @@ -420,9 +416,7 @@ public void writeTo(StreamOutput out) throws IOException { for (ShardSearchFailure shardSearchFailure : shardFailures) { shardSearchFailure.writeTo(out); } - if (out.getVersion().onOrAfter(LegacyESVersion.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/opensearch/action/support/IndicesOptions.java b/server/src/main/java/org/opensearch/action/support/IndicesOptions.java index 3f752723fd7d1..efe255e68a46b 100644 --- a/server/src/main/java/org/opensearch/action/support/IndicesOptions.java +++ b/server/src/main/java/org/opensearch/action/support/IndicesOptions.java @@ -245,11 +245,6 @@ public EnumSet getExpandWildcards() { public void writeIndicesOptions(StreamOutput out) throws IOException { EnumSet