diff --git a/CHANGELOG.md b/CHANGELOG.md index 218c291e1417c..1b2b6a39c0494 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -126,6 +126,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Remove unused private methods ([#4926](https://github.com/opensearch-project/OpenSearch/pull/4926)) - Revert PR 4656 to unblock Windows CI ([#4949](https://github.com/opensearch-project/OpenSearch/pull/4949)) - Remove LegacyESVersion.V_7_8_ and V_7_9_ Constants ([#4855](https://github.com/opensearch-project/OpenSearch/pull/4855)) +- Remove LegacyESVersion.V_7_6_ and V_7_7_ Constants ([#4837](https://github.com/opensearch-project/OpenSearch/pull/4837)) ### Fixed - `opensearch-service.bat start` and `opensearch-service.bat manager` failing to run ([#4289](https://github.com/opensearch-project/OpenSearch/pull/4289)) diff --git a/modules/analysis-common/src/main/java/org/opensearch/analysis/common/CommonAnalysisModulePlugin.java b/modules/analysis-common/src/main/java/org/opensearch/analysis/common/CommonAnalysisModulePlugin.java index b0850d0b9144d..1ee4eff6ba055 100644 --- a/modules/analysis-common/src/main/java/org/opensearch/analysis/common/CommonAnalysisModulePlugin.java +++ b/modules/analysis-common/src/main/java/org/opensearch/analysis/common/CommonAnalysisModulePlugin.java @@ -124,7 +124,7 @@ import org.apache.lucene.analysis.tr.TurkishAnalyzer; import org.apache.lucene.analysis.util.ElisionFilter; import org.apache.lucene.util.SetOnce; -import org.opensearch.LegacyESVersion; +import org.opensearch.Version; import org.opensearch.client.Client; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; import org.opensearch.cluster.service.ClusterService; @@ -347,7 +347,12 @@ public Map> getTokenizers() { tokenizers.put("simple_pattern_split", SimplePatternSplitTokenizerFactory::new); tokenizers.put("thai", ThaiTokenizerFactory::new); tokenizers.put("nGram", (IndexSettings indexSettings, Environment environment, String name, Settings settings) -> { - if (indexSettings.getIndexVersionCreated().onOrAfter(LegacyESVersion.V_7_6_0)) { + if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_3_0_0)) { + throw new IllegalArgumentException( + "The [nGram] tokenizer name was deprecated pre 1.0. " + + "Please use the tokenizer name to [ngram] for indices created in versions 3.0 or higher instead." + ); + } else { deprecationLogger.deprecate( "nGram_tokenizer_deprecation", "The [nGram] tokenizer name is deprecated and will be removed in a future version. " @@ -358,7 +363,12 @@ public Map> getTokenizers() { }); tokenizers.put("ngram", NGramTokenizerFactory::new); tokenizers.put("edgeNGram", (IndexSettings indexSettings, Environment environment, String name, Settings settings) -> { - if (indexSettings.getIndexVersionCreated().onOrAfter(LegacyESVersion.V_7_6_0)) { + if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_3_0_0)) { + throw new IllegalArgumentException( + "The [edgeNGram] tokenizer name was deprecated pre 1.0. " + + "Please use the tokenizer name to [edge_ngram] for indices created in versions 3.0 or higher instead." + ); + } else { deprecationLogger.deprecate( "edgeNGram_tokenizer_deprecation", "The [edgeNGram] tokenizer name is deprecated and will be removed in a future version. " @@ -606,7 +616,12 @@ public List getPreConfiguredTokenizers() { // Temporary shim for aliases. TODO deprecate after they are moved tokenizers.add(PreConfiguredTokenizer.openSearchVersion("nGram", (version) -> { - if (version.onOrAfter(LegacyESVersion.V_7_6_0)) { + if (version.onOrAfter(Version.V_3_0_0)) { + throw new IllegalArgumentException( + "The [nGram] tokenizer name was deprecated pre 1.0. " + + "Please use the tokenizer name to [ngram] for indices created in versions 3.0 or higher instead." + ); + } else { deprecationLogger.deprecate( "nGram_tokenizer_deprecation", "The [nGram] tokenizer name is deprecated and will be removed in a future version. " @@ -616,7 +631,12 @@ public List getPreConfiguredTokenizers() { return new NGramTokenizer(); })); tokenizers.add(PreConfiguredTokenizer.openSearchVersion("edgeNGram", (version) -> { - if (version.onOrAfter(LegacyESVersion.V_7_6_0)) { + if (version.onOrAfter(Version.V_3_0_0)) { + throw new IllegalArgumentException( + "The [edgeNGram] tokenizer name was deprecated pre 1.0. " + + "Please use the tokenizer name to [edge_ngram] for indices created in versions 3.0 or higher instead." + ); + } else { deprecationLogger.deprecate( "edgeNGram_tokenizer_deprecation", "The [edgeNGram] tokenizer name is deprecated and will be removed in a future version. " diff --git a/modules/analysis-common/src/main/java/org/opensearch/analysis/common/ConcatenateGraphTokenFilterFactory.java b/modules/analysis-common/src/main/java/org/opensearch/analysis/common/ConcatenateGraphTokenFilterFactory.java index 0d1a2b185d1d3..7c1c15ef74e30 100644 --- a/modules/analysis-common/src/main/java/org/opensearch/analysis/common/ConcatenateGraphTokenFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/opensearch/analysis/common/ConcatenateGraphTokenFilterFactory.java @@ -11,7 +11,6 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.miscellaneous.ConcatenateGraphFilter; import org.apache.lucene.util.automaton.TooComplexToDeterminizeException; -import org.opensearch.LegacyESVersion; import org.opensearch.common.settings.Settings; import org.opensearch.env.Environment; import org.opensearch.index.IndexSettings; @@ -24,11 +23,6 @@ * max_graph_expansions is 100 as the default value of 10_000 seems to be unnecessarily large and preserve_separator is false. * *
    - *
  • preserve_separator: - * For LegacyESVersion lesser than {@link LegacyESVersion#V_7_6_0} i.e. lucene versions lesser - * than {@link org.apache.lucene.util.Version#LUCENE_8_4_0} - * Whether {@link ConcatenateGraphFilter#SEP_LABEL} should separate the input tokens in the concatenated token. - *
  • *
  • token_separator: * Separator to use for concatenation. Must be a String with a single character or empty. * If not present, {@link ConcatenateGraphTokenFilterFactory#DEFAULT_TOKEN_SEPARATOR} will be used. @@ -59,17 +53,11 @@ public class ConcatenateGraphTokenFilterFactory extends AbstractTokenFilterFacto ConcatenateGraphTokenFilterFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) { super(indexSettings, name, settings); - if (indexSettings.getIndexVersionCreated().onOrAfter(LegacyESVersion.V_7_6_0)) { // i.e. Lucene 8.4.0 - String separator = settings.get("token_separator", DEFAULT_TOKEN_SEPARATOR); - if (separator.length() > 1) { - throw new IllegalArgumentException("token_separator must be either empty or a single character"); - } - tokenSeparator = separator.length() == 0 ? null : separator.charAt(0); // null means no separator while concatenating - } else { - boolean preserveSep = settings.getAsBoolean("preserve_separator", ConcatenateGraphFilter.DEFAULT_PRESERVE_SEP); - tokenSeparator = preserveSep ? ConcatenateGraphFilter.DEFAULT_TOKEN_SEPARATOR : null; + String separator = settings.get("token_separator", DEFAULT_TOKEN_SEPARATOR); + if (separator.length() > 1) { + throw new IllegalArgumentException("token_separator must be either empty or a single character"); } - + tokenSeparator = separator.length() == 0 ? null : separator.charAt(0); // null means no separator while concatenating maxGraphExpansions = settings.getAsInt("max_graph_expansions", DEFAULT_MAX_GRAPH_EXPANSIONS); preservePositionIncrements = settings.getAsBoolean("preserve_position_increments", DEFAULT_PRESERVE_POSITION_INCREMENTS); } diff --git a/modules/geo/src/main/java/org/opensearch/geo/search/aggregations/bucket/composite/GeoTileGridValuesSourceBuilder.java b/modules/geo/src/main/java/org/opensearch/geo/search/aggregations/bucket/composite/GeoTileGridValuesSourceBuilder.java index 84d5943da287f..9e671118637b9 100644 --- a/modules/geo/src/main/java/org/opensearch/geo/search/aggregations/bucket/composite/GeoTileGridValuesSourceBuilder.java +++ b/modules/geo/src/main/java/org/opensearch/geo/search/aggregations/bucket/composite/GeoTileGridValuesSourceBuilder.java @@ -33,7 +33,6 @@ package org.opensearch.geo.search.aggregations.bucket.composite; import org.apache.lucene.index.IndexReader; -import org.opensearch.LegacyESVersion; import org.opensearch.common.ParseField; import org.opensearch.common.geo.GeoBoundingBox; import org.opensearch.common.geo.GeoPoint; @@ -175,9 +174,7 @@ public static void register(ValuesSourceRegistry.Builder builder) { public GeoTileGridValuesSourceBuilder(StreamInput in) throws IOException { super(in); this.precision = in.readInt(); - if (in.getVersion().onOrAfter(LegacyESVersion.V_7_6_0)) { - this.geoBoundingBox = new GeoBoundingBox(in); - } + this.geoBoundingBox = new GeoBoundingBox(in); } public GeoTileGridValuesSourceBuilder precision(int precision) { @@ -198,9 +195,7 @@ public GeoTileGridValuesSourceBuilder format(String format) { @Override protected void innerWriteTo(StreamOutput out) throws IOException { out.writeInt(precision); - if (out.getVersion().onOrAfter(LegacyESVersion.V_7_6_0)) { - geoBoundingBox.writeTo(out); - } + geoBoundingBox.writeTo(out); } @Override diff --git a/modules/geo/src/main/java/org/opensearch/geo/search/aggregations/bucket/geogrid/GeoGridAggregationBuilder.java b/modules/geo/src/main/java/org/opensearch/geo/search/aggregations/bucket/geogrid/GeoGridAggregationBuilder.java index 0ca2a28844f99..abc892396fbf7 100644 --- a/modules/geo/src/main/java/org/opensearch/geo/search/aggregations/bucket/geogrid/GeoGridAggregationBuilder.java +++ b/modules/geo/src/main/java/org/opensearch/geo/search/aggregations/bucket/geogrid/GeoGridAggregationBuilder.java @@ -32,7 +32,6 @@ package org.opensearch.geo.search.aggregations.bucket.geogrid; -import org.opensearch.LegacyESVersion; import org.opensearch.OpenSearchException; import org.opensearch.common.ParseField; import org.opensearch.common.geo.GeoBoundingBox; @@ -125,9 +124,7 @@ public GeoGridAggregationBuilder(StreamInput in) throws IOException { precision = in.readVInt(); requiredSize = in.readVInt(); shardSize = in.readVInt(); - if (in.getVersion().onOrAfter(LegacyESVersion.V_7_6_0)) { - geoBoundingBox = new GeoBoundingBox(in); - } + geoBoundingBox = new GeoBoundingBox(in); } @Override @@ -140,9 +137,7 @@ protected void innerWriteTo(StreamOutput out) throws IOException { out.writeVInt(precision); out.writeVInt(requiredSize); out.writeVInt(shardSize); - if (out.getVersion().onOrAfter(LegacyESVersion.V_7_6_0)) { - geoBoundingBox.writeTo(out); - } + geoBoundingBox.writeTo(out); } /** diff --git a/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/RankEvalRequest.java b/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/RankEvalRequest.java index 66db397865a0b..d38307fc2194a 100644 --- a/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/RankEvalRequest.java +++ b/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/RankEvalRequest.java @@ -32,7 +32,6 @@ package org.opensearch.index.rankeval; -import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.IndicesRequest; @@ -69,9 +68,7 @@ public RankEvalRequest(RankEvalSpec rankingEvaluationSpec, String[] indices) { rankingEvaluationSpec = new RankEvalSpec(in); indices = in.readStringArray(); indicesOptions = IndicesOptions.readIndicesOptions(in); - if (in.getVersion().onOrAfter(LegacyESVersion.V_7_6_0)) { - searchType = SearchType.fromId(in.readByte()); - } + searchType = SearchType.fromId(in.readByte()); } RankEvalRequest() {} @@ -150,9 +147,7 @@ public void writeTo(StreamOutput out) throws IOException { rankingEvaluationSpec.writeTo(out); out.writeStringArray(indices); indicesOptions.writeIndicesOptions(out); - if (out.getVersion().onOrAfter(LegacyESVersion.V_7_6_0)) { - out.writeByte(searchType.id()); - } + out.writeByte(searchType.id()); } @Override diff --git a/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/RecoveryIT.java b/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/RecoveryIT.java index 870398ddf6fec..8c303eb5d0b55 100644 --- a/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/RecoveryIT.java +++ b/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/RecoveryIT.java @@ -720,12 +720,8 @@ public void testAutoExpandIndicesDuringRollingUpgrade() throws Exception { final int numberOfReplicas = Integer.parseInt( getIndexSettingsAsMap(indexName).get(IndexMetadata.SETTING_NUMBER_OF_REPLICAS).toString()); - if (minimumNodeVersion.onOrAfter(LegacyESVersion.V_7_6_0)) { - assertEquals(nodes.size() - 2, numberOfReplicas); - ensureGreen(indexName); - } else { - assertEquals(nodes.size() - 1, numberOfReplicas); - } + assertEquals(nodes.size() - 2, numberOfReplicas); + ensureGreen(indexName); } public void testSoftDeletesDisabledWarning() throws Exception { diff --git a/server/src/internalClusterTest/java/org/opensearch/index/shard/IndexShardIT.java b/server/src/internalClusterTest/java/org/opensearch/index/shard/IndexShardIT.java index 3d8da7eac7690..959b04b7861a3 100644 --- a/server/src/internalClusterTest/java/org/opensearch/index/shard/IndexShardIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/index/shard/IndexShardIT.java @@ -288,7 +288,14 @@ public void testIndexCanChangeCustomDataPath() throws Exception { final Path indexDataPath = sharedDataPath.resolve("start-" + randomAsciiLettersOfLength(10)); logger.info("--> creating index [{}] with data_path [{}]", index, indexDataPath); - createIndex(index, Settings.builder().put(IndexMetadata.SETTING_DATA_PATH, indexDataPath.toAbsolutePath().toString()).build()); + createIndex( + index, + Settings.builder() + .put(IndexMetadata.SETTING_DATA_PATH, indexDataPath.toAbsolutePath().toString()) + .put(IndexSettings.INDEX_TRANSLOG_DURABILITY_SETTING.getKey(), Translog.Durability.REQUEST) + .put(IndexSettings.INDEX_MERGE_ON_FLUSH_ENABLED.getKey(), false) + .build() + ); client().prepareIndex(index).setId("1").setSource("foo", "bar").setRefreshPolicy(IMMEDIATE).get(); ensureGreen(index); @@ -307,6 +314,16 @@ public void testIndexCanChangeCustomDataPath() throws Exception { logger.info("--> closing the index [{}] before updating data_path", index); assertAcked(client().admin().indices().prepareClose(index).setWaitForActiveShards(ActiveShardCount.DEFAULT)); + // race condition: async flush may cause translog file deletion resulting in an inconsistent stream from + // Files.walk below during copy phase + // temporarily disable refresh to avoid any flushes or syncs that may inadvertently cause the deletion + assertAcked( + client().admin() + .indices() + .prepareUpdateSettings(index) + .setSettings(Settings.builder().put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), "-1").build()) + ); + final Path newIndexDataPath = sharedDataPath.resolve("end-" + randomAlphaOfLength(10)); IOUtils.rm(newIndexDataPath); @@ -326,11 +343,17 @@ public void testIndexCanChangeCustomDataPath() throws Exception { } logger.info("--> updating data_path to [{}] for index [{}]", newIndexDataPath, index); + // update data path and re-enable refresh assertAcked( client().admin() .indices() .prepareUpdateSettings(index) - .setSettings(Settings.builder().put(IndexMetadata.SETTING_DATA_PATH, newIndexDataPath.toAbsolutePath().toString()).build()) + .setSettings( + Settings.builder() + .put(IndexMetadata.SETTING_DATA_PATH, newIndexDataPath.toAbsolutePath().toString()) + .put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), IndexSettings.DEFAULT_REFRESH_INTERVAL.toString()) + .build() + ) .setIndicesOptions(IndicesOptions.fromOptions(true, false, true, true)) ); diff --git a/server/src/main/java/org/opensearch/LegacyESVersion.java b/server/src/main/java/org/opensearch/LegacyESVersion.java index c020089afd1b9..9e9ef0113e17c 100644 --- a/server/src/main/java/org/opensearch/LegacyESVersion.java +++ b/server/src/main/java/org/opensearch/LegacyESVersion.java @@ -48,11 +48,6 @@ */ public class LegacyESVersion extends Version { - public static final LegacyESVersion V_7_6_0 = new LegacyESVersion(7060099, org.apache.lucene.util.Version.LUCENE_8_4_0); - public static final LegacyESVersion V_7_6_1 = new LegacyESVersion(7060199, org.apache.lucene.util.Version.LUCENE_8_4_0); - public static final LegacyESVersion V_7_6_2 = new LegacyESVersion(7060299, org.apache.lucene.util.Version.LUCENE_8_4_0); - public static final LegacyESVersion V_7_7_0 = new LegacyESVersion(7070099, org.apache.lucene.util.Version.LUCENE_8_5_1); - public static final LegacyESVersion V_7_7_1 = new LegacyESVersion(7070199, org.apache.lucene.util.Version.LUCENE_8_5_1); public static final LegacyESVersion V_7_10_0 = new LegacyESVersion(7100099, org.apache.lucene.util.Version.LUCENE_8_7_0); public static final LegacyESVersion V_7_10_1 = new LegacyESVersion(7100199, org.apache.lucene.util.Version.LUCENE_8_7_0); public static final LegacyESVersion V_7_10_2 = new LegacyESVersion(7100299, org.apache.lucene.util.Version.LUCENE_8_7_0); diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/info/NodesInfoRequest.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/info/NodesInfoRequest.java index d51be9bc27ac9..77ffd98513698 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/info/NodesInfoRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/info/NodesInfoRequest.java @@ -32,7 +32,6 @@ package org.opensearch.action.admin.cluster.node.info; -import org.opensearch.LegacyESVersion; import org.opensearch.action.support.nodes.BaseNodesRequest; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; @@ -63,22 +62,7 @@ public class NodesInfoRequest extends BaseNodesRequest { public NodesInfoRequest(StreamInput in) throws IOException { super(in); requestedMetrics.clear(); - if (in.getVersion().before(LegacyESVersion.V_7_7_0)) { - // prior to version 8.x, a NodesInfoRequest was serialized as a list - // of booleans in a fixed order - optionallyAddMetric(in.readBoolean(), Metric.SETTINGS.metricName()); - optionallyAddMetric(in.readBoolean(), Metric.OS.metricName()); - optionallyAddMetric(in.readBoolean(), Metric.PROCESS.metricName()); - optionallyAddMetric(in.readBoolean(), Metric.JVM.metricName()); - optionallyAddMetric(in.readBoolean(), Metric.THREAD_POOL.metricName()); - optionallyAddMetric(in.readBoolean(), Metric.TRANSPORT.metricName()); - optionallyAddMetric(in.readBoolean(), Metric.HTTP.metricName()); - optionallyAddMetric(in.readBoolean(), Metric.PLUGINS.metricName()); - optionallyAddMetric(in.readBoolean(), Metric.INGEST.metricName()); - optionallyAddMetric(in.readBoolean(), Metric.INDICES.metricName()); - } else { - requestedMetrics.addAll(Arrays.asList(in.readStringArray())); - } + requestedMetrics.addAll(Arrays.asList(in.readStringArray())); } /** @@ -165,22 +149,7 @@ private void optionallyAddMetric(boolean addMetric, String metricName) { @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - if (out.getVersion().before(LegacyESVersion.V_7_7_0)) { - // prior to version 8.x, a NodesInfoRequest was serialized as a list - // of booleans in a fixed order - out.writeBoolean(Metric.SETTINGS.containedIn(requestedMetrics)); - out.writeBoolean(Metric.OS.containedIn(requestedMetrics)); - out.writeBoolean(Metric.PROCESS.containedIn(requestedMetrics)); - out.writeBoolean(Metric.JVM.containedIn(requestedMetrics)); - out.writeBoolean(Metric.THREAD_POOL.containedIn(requestedMetrics)); - out.writeBoolean(Metric.TRANSPORT.containedIn(requestedMetrics)); - out.writeBoolean(Metric.HTTP.containedIn(requestedMetrics)); - out.writeBoolean(Metric.PLUGINS.containedIn(requestedMetrics)); - out.writeBoolean(Metric.INGEST.containedIn(requestedMetrics)); - out.writeBoolean(Metric.INDICES.containedIn(requestedMetrics)); - } else { - out.writeStringArray(requestedMetrics.toArray(new String[0])); - } + out.writeStringArray(requestedMetrics.toArray(new String[0])); } /** diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/reload/NodesReloadSecureSettingsRequest.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/reload/NodesReloadSecureSettingsRequest.java index b721c8f005974..b5298b5f5eefb 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/reload/NodesReloadSecureSettingsRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/reload/NodesReloadSecureSettingsRequest.java @@ -32,7 +32,6 @@ package org.opensearch.action.admin.cluster.node.reload; -import org.opensearch.LegacyESVersion; import org.opensearch.action.support.nodes.BaseNodesRequest; import org.opensearch.common.io.stream.StreamInput; @@ -68,18 +67,16 @@ public NodesReloadSecureSettingsRequest() { public NodesReloadSecureSettingsRequest(StreamInput in) throws IOException { super(in); - if (in.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) { - final BytesReference bytesRef = in.readOptionalBytesReference(); - if (bytesRef != null) { - byte[] bytes = BytesReference.toBytes(bytesRef); - try { - this.secureSettingsPassword = new SecureString(CharArrays.utf8BytesToChars(bytes)); - } finally { - Arrays.fill(bytes, (byte) 0); - } - } else { - this.secureSettingsPassword = null; + final BytesReference bytesRef = in.readOptionalBytesReference(); + if (bytesRef != null) { + byte[] bytes = BytesReference.toBytes(bytesRef); + try { + this.secureSettingsPassword = new SecureString(CharArrays.utf8BytesToChars(bytes)); + } finally { + Arrays.fill(bytes, (byte) 0); } + } else { + this.secureSettingsPassword = null; } } 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 babec0b7c119f..f6fb788289a5a 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 @@ -32,7 +32,6 @@ package org.opensearch.action.admin.cluster.node.stats; -import org.opensearch.LegacyESVersion; import org.opensearch.action.admin.indices.stats.CommonStatsFlags; import org.opensearch.action.support.nodes.BaseNodesRequest; import org.opensearch.common.io.stream.StreamInput; @@ -64,22 +63,7 @@ public NodesStatsRequest(StreamInput in) throws IOException { indices = new CommonStatsFlags(in); requestedMetrics.clear(); - if (in.getVersion().before(LegacyESVersion.V_7_7_0)) { - optionallyAddMetric(in.readBoolean(), Metric.OS.metricName()); - optionallyAddMetric(in.readBoolean(), Metric.PROCESS.metricName()); - optionallyAddMetric(in.readBoolean(), Metric.JVM.metricName()); - optionallyAddMetric(in.readBoolean(), Metric.THREAD_POOL.metricName()); - optionallyAddMetric(in.readBoolean(), Metric.FS.metricName()); - optionallyAddMetric(in.readBoolean(), Metric.TRANSPORT.metricName()); - optionallyAddMetric(in.readBoolean(), Metric.HTTP.metricName()); - optionallyAddMetric(in.readBoolean(), Metric.BREAKER.metricName()); - optionallyAddMetric(in.readBoolean(), Metric.SCRIPT.metricName()); - optionallyAddMetric(in.readBoolean(), Metric.DISCOVERY.metricName()); - optionallyAddMetric(in.readBoolean(), Metric.INGEST.metricName()); - optionallyAddMetric(in.readBoolean(), Metric.ADAPTIVE_SELECTION.metricName()); - } else { - requestedMetrics.addAll(in.readStringList()); - } + requestedMetrics.addAll(in.readStringList()); } /** @@ -200,22 +184,7 @@ private void optionallyAddMetric(boolean includeMetric, String metricName) { public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); indices.writeTo(out); - if (out.getVersion().before(LegacyESVersion.V_7_7_0)) { - out.writeBoolean(Metric.OS.containedIn(requestedMetrics)); - out.writeBoolean(Metric.PROCESS.containedIn(requestedMetrics)); - out.writeBoolean(Metric.JVM.containedIn(requestedMetrics)); - out.writeBoolean(Metric.THREAD_POOL.containedIn(requestedMetrics)); - out.writeBoolean(Metric.FS.containedIn(requestedMetrics)); - out.writeBoolean(Metric.TRANSPORT.containedIn(requestedMetrics)); - out.writeBoolean(Metric.HTTP.containedIn(requestedMetrics)); - out.writeBoolean(Metric.BREAKER.containedIn(requestedMetrics)); - out.writeBoolean(Metric.SCRIPT.containedIn(requestedMetrics)); - out.writeBoolean(Metric.DISCOVERY.containedIn(requestedMetrics)); - out.writeBoolean(Metric.INGEST.containedIn(requestedMetrics)); - out.writeBoolean(Metric.ADAPTIVE_SELECTION.containedIn(requestedMetrics)); - } else { - out.writeStringArray(requestedMetrics.toArray(new String[0])); - } + out.writeStringArray(requestedMetrics.toArray(new String[0])); } /** diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/restore/RestoreSnapshotRequest.java b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/restore/RestoreSnapshotRequest.java index 5fd83244f3dea..df889831cb4ca 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/restore/RestoreSnapshotRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/restore/RestoreSnapshotRequest.java @@ -144,9 +144,6 @@ public RestoreSnapshotRequest(StreamInput in) throws IOException { includeGlobalState = in.readBoolean(); partial = in.readBoolean(); includeAliases = in.readBoolean(); - if (in.getVersion().before(LegacyESVersion.V_7_7_0)) { - readSettingsFromStream(in); // formerly the unused settings field - } indexSettings = readSettingsFromStream(in); ignoreIndexSettings = in.readStringArray(); if (in.getVersion().onOrAfter(LegacyESVersion.V_7_10_0)) { @@ -170,9 +167,6 @@ public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(includeGlobalState); out.writeBoolean(partial); out.writeBoolean(includeAliases); - if (out.getVersion().before(LegacyESVersion.V_7_7_0)) { - writeSettingsToStream(Settings.EMPTY, out); // formerly the unused settings field - } writeSettingsToStream(indexSettings, out); out.writeStringArray(ignoreIndexSettings); if (out.getVersion().onOrAfter(LegacyESVersion.V_7_10_0)) { diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/stats/ClusterStatsResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/stats/ClusterStatsResponse.java index c6519d6669ea8..8c5d741251501 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/stats/ClusterStatsResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/stats/ClusterStatsResponse.java @@ -32,7 +32,6 @@ package org.opensearch.action.admin.cluster.stats; -import org.opensearch.LegacyESVersion; import org.opensearch.action.FailedNodeException; import org.opensearch.action.support.nodes.BaseNodesResponse; import org.opensearch.cluster.ClusterName; @@ -71,11 +70,9 @@ public ClusterStatsResponse(StreamInput in) throws IOException { String clusterUUID = null; MappingStats mappingStats = null; AnalysisStats analysisStats = null; - if (in.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) { - clusterUUID = in.readOptionalString(); - mappingStats = in.readOptionalWriteable(MappingStats::new); - analysisStats = in.readOptionalWriteable(AnalysisStats::new); - } + clusterUUID = in.readOptionalString(); + mappingStats = in.readOptionalWriteable(MappingStats::new); + analysisStats = in.readOptionalWriteable(AnalysisStats::new); this.clusterUUID = clusterUUID; // built from nodes rather than from the stream directly @@ -132,11 +129,9 @@ public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeVLong(timestamp); out.writeOptionalWriteable(status); - if (out.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) { - out.writeOptionalString(clusterUUID); - out.writeOptionalWriteable(indicesStats.getMappings()); - out.writeOptionalWriteable(indicesStats.getAnalysis()); - } + out.writeOptionalString(clusterUUID); + out.writeOptionalWriteable(indicesStats.getMappings()); + out.writeOptionalWriteable(indicesStats.getAnalysis()); } @Override diff --git a/server/src/main/java/org/opensearch/action/admin/indices/alias/Alias.java b/server/src/main/java/org/opensearch/action/admin/indices/alias/Alias.java index f9a785d1759d8..3f78d99d49423 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/alias/Alias.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/alias/Alias.java @@ -32,7 +32,6 @@ package org.opensearch.action.admin.indices.alias; -import org.opensearch.LegacyESVersion; import org.opensearch.OpenSearchGenerationException; import org.opensearch.common.Nullable; import org.opensearch.common.ParseField; @@ -90,11 +89,7 @@ public Alias(StreamInput in) throws IOException { indexRouting = in.readOptionalString(); searchRouting = in.readOptionalString(); writeIndex = in.readOptionalBoolean(); - if (in.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) { - isHidden = in.readOptionalBoolean(); - } else { - isHidden = null; - } + isHidden = in.readOptionalBoolean(); } public Alias(String name) { @@ -236,9 +231,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalString(indexRouting); out.writeOptionalString(searchRouting); out.writeOptionalBoolean(writeIndex); - if (out.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) { - out.writeOptionalBoolean(isHidden); - } + out.writeOptionalBoolean(isHidden); } /** diff --git a/server/src/main/java/org/opensearch/action/admin/indices/alias/IndicesAliasesRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/alias/IndicesAliasesRequest.java index e210d54a922b1..97f9911d8227e 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/alias/IndicesAliasesRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/alias/IndicesAliasesRequest.java @@ -32,7 +32,6 @@ package org.opensearch.action.admin.indices.alias; -import org.opensearch.LegacyESVersion; import org.opensearch.OpenSearchGenerationException; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.AliasesRequest; @@ -276,10 +275,7 @@ public AliasActions(StreamInput in) throws IOException { searchRouting = in.readOptionalString(); indexRouting = in.readOptionalString(); writeIndex = in.readOptionalBoolean(); - // TODO fix for backport of https://github.com/elastic/elasticsearch/pull/52547 - if (in.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) { - isHidden = in.readOptionalBoolean(); - } + isHidden = in.readOptionalBoolean(); originalAliases = in.readStringArray(); mustExist = in.readOptionalBoolean(); } @@ -294,10 +290,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalString(searchRouting); out.writeOptionalString(indexRouting); out.writeOptionalBoolean(writeIndex); - // TODO fix for backport https://github.com/elastic/elasticsearch/pull/52547 - if (out.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) { - out.writeOptionalBoolean(isHidden); - } + out.writeOptionalBoolean(isHidden); out.writeStringArray(originalAliases); out.writeOptionalBoolean(mustExist); } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/forcemerge/ForceMergeRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/forcemerge/ForceMergeRequest.java index b428c3523b666..77007fba539ec 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/forcemerge/ForceMergeRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/forcemerge/ForceMergeRequest.java @@ -32,13 +32,12 @@ package org.opensearch.action.admin.indices.forcemerge; -import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.action.support.broadcast.BroadcastRequest; -import org.opensearch.common.Nullable; import org.opensearch.common.UUIDs; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; +import org.opensearch.index.engine.Engine; import java.io.IOException; import java.util.Arrays; @@ -74,13 +73,12 @@ public static final class Defaults { private boolean onlyExpungeDeletes = Defaults.ONLY_EXPUNGE_DELETES; private boolean flush = Defaults.FLUSH; - private static final Version FORCE_MERGE_UUID_VERSION = LegacyESVersion.V_7_7_0; + private static final Version FORCE_MERGE_UUID_VERSION = Version.V_3_0_0; /** * Force merge UUID to store in the live commit data of a shard under * {@link org.opensearch.index.engine.Engine#FORCE_MERGE_UUID_KEY} after force merging it. */ - @Nullable private final String forceMergeUUID; /** @@ -99,9 +97,11 @@ public ForceMergeRequest(StreamInput in) throws IOException { onlyExpungeDeletes = in.readBoolean(); flush = in.readBoolean(); if (in.getVersion().onOrAfter(FORCE_MERGE_UUID_VERSION)) { - forceMergeUUID = in.readOptionalString(); - } else { - forceMergeUUID = null; + forceMergeUUID = in.readString(); + } else if ((forceMergeUUID = in.readOptionalString()) == null) { + throw new IllegalStateException( + "As of legacy version 7.7 [" + Engine.FORCE_MERGE_UUID_KEY + "] is no longer optional in force merge requests." + ); } } @@ -143,7 +143,6 @@ public ForceMergeRequest onlyExpungeDeletes(boolean onlyExpungeDeletes) { * Force merge UUID to use when force merging or {@code null} if not using one in a mixed version cluster containing nodes older than * {@link #FORCE_MERGE_UUID_VERSION}. */ - @Nullable public String forceMergeUUID() { return forceMergeUUID; } @@ -183,6 +182,8 @@ public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(onlyExpungeDeletes); out.writeBoolean(flush); if (out.getVersion().onOrAfter(FORCE_MERGE_UUID_VERSION)) { + out.writeString(forceMergeUUID); + } else { out.writeOptionalString(forceMergeUUID); } } diff --git a/server/src/main/java/org/opensearch/action/bulk/BulkItemResponse.java b/server/src/main/java/org/opensearch/action/bulk/BulkItemResponse.java index 346e394bbb35e..364952dff82f1 100644 --- a/server/src/main/java/org/opensearch/action/bulk/BulkItemResponse.java +++ b/server/src/main/java/org/opensearch/action/bulk/BulkItemResponse.java @@ -33,7 +33,6 @@ package org.opensearch.action.bulk; import org.opensearch.ExceptionsHelper; -import org.opensearch.LegacyESVersion; import org.opensearch.OpenSearchException; import org.opensearch.Version; import org.opensearch.action.DocWriteRequest.OpType; @@ -270,11 +269,7 @@ public Failure(StreamInput in) throws IOException { cause = in.readException(); status = ExceptionsHelper.status(cause); seqNo = in.readZLong(); - if (in.getVersion().onOrAfter(LegacyESVersion.V_7_6_0)) { - term = in.readVLong(); - } else { - term = SequenceNumbers.UNASSIGNED_PRIMARY_TERM; - } + term = in.readVLong(); aborted = in.readBoolean(); } @@ -287,9 +282,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalString(id); out.writeException(cause); out.writeZLong(seqNo); - if (out.getVersion().onOrAfter(LegacyESVersion.V_7_6_0)) { - out.writeVLong(term); - } + out.writeVLong(term); out.writeBoolean(aborted); } diff --git a/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilities.java b/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilities.java index 4fdf8d551af61..4afce67f98297 100644 --- a/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilities.java +++ b/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilities.java @@ -32,7 +32,6 @@ package org.opensearch.action.fieldcaps; -import org.opensearch.LegacyESVersion; import org.opensearch.common.ParseField; import org.opensearch.common.Strings; import org.opensearch.common.io.stream.StreamInput; @@ -125,11 +124,7 @@ public FieldCapabilities( this.indices = in.readOptionalStringArray(); this.nonSearchableIndices = in.readOptionalStringArray(); this.nonAggregatableIndices = in.readOptionalStringArray(); - if (in.getVersion().onOrAfter(LegacyESVersion.V_7_6_0)) { - meta = in.readMap(StreamInput::readString, i -> i.readSet(StreamInput::readString)); - } else { - meta = Collections.emptyMap(); - } + this.meta = in.readMap(StreamInput::readString, i -> i.readSet(StreamInput::readString)); } @Override @@ -141,9 +136,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalStringArray(indices); out.writeOptionalStringArray(nonSearchableIndices); out.writeOptionalStringArray(nonAggregatableIndices); - if (out.getVersion().onOrAfter(LegacyESVersion.V_7_6_0)) { - out.writeMap(meta, StreamOutput::writeString, (o, set) -> o.writeCollection(set, StreamOutput::writeString)); - } + out.writeMap(meta, StreamOutput::writeString, (o, set) -> o.writeCollection(set, StreamOutput::writeString)); } @Override diff --git a/server/src/main/java/org/opensearch/action/fieldcaps/IndexFieldCapabilities.java b/server/src/main/java/org/opensearch/action/fieldcaps/IndexFieldCapabilities.java index 062e5bc1af7e5..73025c2eac3f0 100644 --- a/server/src/main/java/org/opensearch/action/fieldcaps/IndexFieldCapabilities.java +++ b/server/src/main/java/org/opensearch/action/fieldcaps/IndexFieldCapabilities.java @@ -32,17 +32,13 @@ package org.opensearch.action.fieldcaps; -import org.opensearch.LegacyESVersion; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; import org.opensearch.common.io.stream.Writeable; import java.io.IOException; -import java.util.Collections; import java.util.Map; import java.util.Objects; -import java.util.Set; -import java.util.stream.Collectors; /** * Describes the capabilities of a field in a single index. @@ -74,42 +70,20 @@ public class IndexFieldCapabilities implements Writeable { } IndexFieldCapabilities(StreamInput in) throws IOException { - if (in.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) { - this.name = in.readString(); - this.type = in.readString(); - this.isSearchable = in.readBoolean(); - this.isAggregatable = in.readBoolean(); - this.meta = in.readMap(StreamInput::readString, StreamInput::readString); - } else { - // Previously we reused the FieldCapabilities class to represent index field capabilities. - FieldCapabilities fieldCaps = new FieldCapabilities(in); - this.name = fieldCaps.getName(); - this.type = fieldCaps.getType(); - this.isSearchable = fieldCaps.isSearchable(); - this.isAggregatable = fieldCaps.isAggregatable(); - this.meta = fieldCaps.meta() - .entrySet() - .stream() - .collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().iterator().next())); - } + this.name = in.readString(); + this.type = in.readString(); + this.isSearchable = in.readBoolean(); + this.isAggregatable = in.readBoolean(); + this.meta = in.readMap(StreamInput::readString, StreamInput::readString); } @Override public void writeTo(StreamOutput out) throws IOException { - if (out.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) { - out.writeString(name); - out.writeString(type); - out.writeBoolean(isSearchable); - out.writeBoolean(isAggregatable); - out.writeMap(meta, StreamOutput::writeString, StreamOutput::writeString); - } else { - // Previously we reused the FieldCapabilities class to represent index field capabilities. - Map> wrappedMeta = meta.entrySet() - .stream() - .collect(Collectors.toMap(Map.Entry::getKey, entry -> Collections.singleton(entry.getValue()))); - FieldCapabilities fieldCaps = new FieldCapabilities(name, type, isSearchable, isAggregatable, null, null, null, wrappedMeta); - fieldCaps.writeTo(out); - } + out.writeString(name); + out.writeString(type); + out.writeBoolean(isSearchable); + out.writeBoolean(isAggregatable); + out.writeMap(meta, StreamOutput::writeString, StreamOutput::writeString); } public String getName() { diff --git a/server/src/main/java/org/opensearch/action/search/SearchRequest.java b/server/src/main/java/org/opensearch/action/search/SearchRequest.java index e4dd0d0b1a116..ceb2a150bf352 100644 --- a/server/src/main/java/org/opensearch/action/search/SearchRequest.java +++ b/server/src/main/java/org/opensearch/action/search/SearchRequest.java @@ -32,7 +32,6 @@ package org.opensearch.action.search; -import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestValidationException; @@ -237,11 +236,7 @@ public SearchRequest(StreamInput in) throws IOException { requestCache = in.readOptionalBoolean(); batchedReduceSize = in.readVInt(); maxConcurrentShardRequests = in.readVInt(); - if (in.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) { - preFilterShardSize = in.readOptionalVInt(); - } else { - preFilterShardSize = in.readVInt(); - } + preFilterShardSize = in.readOptionalVInt(); allowPartialSearchResults = in.readOptionalBoolean(); localClusterAlias = in.readOptionalString(); if (localClusterAlias != null) { @@ -275,11 +270,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalBoolean(requestCache); out.writeVInt(batchedReduceSize); out.writeVInt(maxConcurrentShardRequests); - if (out.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) { - out.writeOptionalVInt(preFilterShardSize); - } else { - out.writeVInt(preFilterShardSize == null ? DEFAULT_BATCHED_REDUCE_SIZE : preFilterShardSize); - } + out.writeOptionalVInt(preFilterShardSize); out.writeOptionalBoolean(allowPartialSearchResults); out.writeOptionalString(localClusterAlias); if (localClusterAlias != null) { diff --git a/server/src/main/java/org/opensearch/action/search/TransportSearchHelper.java b/server/src/main/java/org/opensearch/action/search/TransportSearchHelper.java index 3e5c76aa1f66f..da432a73c8a1d 100644 --- a/server/src/main/java/org/opensearch/action/search/TransportSearchHelper.java +++ b/server/src/main/java/org/opensearch/action/search/TransportSearchHelper.java @@ -32,7 +32,6 @@ package org.opensearch.action.search; -import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.common.bytes.BytesReference; import org.opensearch.common.io.stream.BytesStreamInput; @@ -62,18 +61,13 @@ static InternalScrollSearchRequest internalScrollSearchRequest(ShardSearchContex } static String buildScrollId(AtomicArray searchPhaseResults, Version version) { - boolean includeContextUUID = version.onOrAfter(LegacyESVersion.V_7_7_0); try { BytesStreamOutput out = new BytesStreamOutput(); - if (includeContextUUID) { - out.writeString(INCLUDE_CONTEXT_UUID); - } + out.writeString(INCLUDE_CONTEXT_UUID); out.writeString(searchPhaseResults.length() == 1 ? ParsedScrollId.QUERY_AND_FETCH_TYPE : ParsedScrollId.QUERY_THEN_FETCH_TYPE); out.writeVInt(searchPhaseResults.asList().size()); for (SearchPhaseResult searchPhaseResult : searchPhaseResults.asList()) { - if (includeContextUUID) { - out.writeString(searchPhaseResult.getContextId().getSessionId()); - } + out.writeString(searchPhaseResult.getContextId().getSessionId()); out.writeLong(searchPhaseResult.getContextId().getId()); SearchShardTarget searchShardTarget = searchPhaseResult.getSearchShardTarget(); if (searchShardTarget.getClusterAlias() != null) { 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 3fb572d0ecbbf..2cf211fa6da3c 100644 --- a/server/src/main/java/org/opensearch/action/support/IndicesOptions.java +++ b/server/src/main/java/org/opensearch/action/support/IndicesOptions.java @@ -31,7 +31,6 @@ package org.opensearch.action.support; -import org.opensearch.LegacyESVersion; import org.opensearch.OpenSearchParseException; import org.opensearch.common.ParseField; import org.opensearch.common.io.stream.StreamInput; @@ -276,21 +275,12 @@ public EnumSet getExpandWildcards() { public void writeIndicesOptions(StreamOutput out) throws IOException { EnumSet