From a830787b07be39d53d51623fdf6ad8b7dde54ec5 Mon Sep 17 00:00:00 2001 From: Simon Cooper Date: Tue, 15 Aug 2023 13:47:27 +0100 Subject: [PATCH] Bulk migration of Version.CURRENT for index created to IndexVersion.current() (#98490) --- .../AutoDateHistogramAggregatorTests.java | 4 +- .../common/CompoundAnalysisTests.java | 6 +- .../common/MultiplexerTokenFilterTests.java | 6 +- .../PatternCaptureTokenFilterTests.java | 4 +- .../PredicateTokenScriptFilterTests.java | 4 +- .../ScriptedConditionTokenFilterTests.java | 4 +- .../analysis/common/StopAnalyzerTests.java | 4 +- .../common/SynonymsAnalysisTests.java | 19 +++--- .../WhitespaceTokenizerFactoryTests.java | 6 +- ...DelimiterGraphTokenFilterFactoryTests.java | 3 +- .../DataStreamLifecycleServiceTests.java | 10 ++- .../elasticsearch/reindex/ReindexIdTests.java | 4 +- .../plugin/analysis/icu/IcuAnalyzerTests.java | 7 +- .../icu/IcuTokenizerFactoryTests.java | 4 +- .../kuromoji/KuromojiAnalysisTests.java | 6 +- .../analysis/nori/NoriAnalysisTests.java | 8 +-- .../phonetic/SimplePhoneticAnalysisTests.java | 4 +- .../reroute/ClusterRerouteResponseTests.java | 2 +- .../indices/TransportAnalyzeActionTests.java | 4 +- .../indices/resolve/ResolveIndexTests.java | 3 +- ...ransportIndicesShardStoresActionTests.java | 4 +- .../TransportBroadcastByNodeActionTests.java | 4 +- .../cluster/ClusterChangedEventTests.java | 4 +- .../cluster/ClusterStateTests.java | 10 +-- .../cluster/metadata/DataStreamTests.java | 6 +- .../cluster/metadata/IndexMetadataTests.java | 2 +- .../MetadataCreateDataStreamServiceTests.java | 4 +- .../MetadataDataStreamsServiceTests.java | 22 +++---- ...tadataMigrateToDataStreamServiceTests.java | 42 ++++++------ .../cluster/metadata/MetadataTests.java | 27 ++++---- .../metadata/ToAndFromJsonMetadataTests.java | 10 +-- .../cluster/routing/PrimaryTermsTests.java | 6 +- .../cluster/routing/RoutingTableTests.java | 5 +- ...ailabilityHealthIndicatorServiceTests.java | 47 +++++++------- .../common/lucene/uid/VersionsTests.java | 3 +- .../PersistedClusterStateServiceTests.java | 26 ++++---- .../elasticsearch/index/IndexModuleTests.java | 25 ++++---- .../index/IndexSettingsTests.java | 64 ++++++++++--------- .../index/IndexingSlowLogTests.java | 15 ++--- .../index/MergeSchedulerSettingsTests.java | 3 +- .../index/SearchSlowLogTests.java | 15 ++--- .../index/analysis/AnalysisRegistryTests.java | 10 ++- .../ReloadableCustomAnalyzerTests.java | 4 +- .../index/mapper/IndexFieldTypeTests.java | 4 +- .../index/mapper/RangeFieldTypeTests.java | 4 +- .../mapper/TextFieldAnalyzerModeTests.java | 3 +- .../index/mapper/TypeParsersTests.java | 3 +- .../index/shard/ShardPathTests.java | 6 +- .../index/shard/ShardSplittingQueryTests.java | 10 +-- .../index/shard/StoreRecoveryTests.java | 3 +- .../index/store/FsDirectoryFactoryTests.java | 4 +- .../indices/IndicesServiceTests.java | 12 ++-- .../indices/ShardLimitValidatorTests.java | 4 +- .../indices/analysis/AnalysisModuleTests.java | 4 +- .../action/cat/RestIndicesActionTests.java | 4 +- ...VariableWidthHistogramAggregatorTests.java | 4 +- .../terms/RareTermsAggregatorTests.java | 4 +- .../highlight/HighlightBuilderTests.java | 4 +- .../internal/ShardSearchRequestTests.java | 4 +- .../rescore/QueryRescorerBuilderTests.java | 6 +- .../AbstractSuggestionBuilderTestCase.java | 6 +- .../snapshots/SnapshotsServiceTests.java | 3 +- .../FrozenExistenceDeciderServiceTests.java | 3 +- .../FrozenStorageDeciderServiceTests.java | 4 +- .../autoscaling/util/FrozenUtilsTests.java | 4 +- .../org/elasticsearch/xpack/ccr/CcrTests.java | 4 +- .../action/AutoFollowCoordinatorTests.java | 15 ++--- .../TransportFollowStatsActionTests.java | 4 +- .../SourceOnlySnapshotShardTests.java | 5 +- .../mapper/DataTierFieldTypeTests.java | 6 +- .../core/ilm/AllocationRoutedStepTests.java | 22 +++---- .../core/ilm/CheckShrinkReadyStepTests.java | 24 +++---- .../TransportDownsampleActionTests.java | 6 +- .../ilm/IndexLifecycleTransitionTests.java | 3 +- ...lConfigMigrationEligibilityCheckTests.java | 4 +- .../DatafeedConfigAutoUpdaterTests.java | 4 +- .../ml/dataframe/DestinationIndexTests.java | 5 +- .../TrainedModelStatsServiceTests.java | 18 +++--- .../persistence/JobResultsProviderTests.java | 6 +- .../OpenJobPersistentTasksExecutorTests.java | 4 +- ...stractJobPersistentTasksExecutorTests.java | 4 +- .../xpack/profiling/KvIndexResolverTests.java | 4 +- .../accesscontrol/IndicesPermissionTests.java | 2 +- ...TransportGetShutdownStatusActionTests.java | 4 +- .../mapper/WildcardFieldMapperTests.java | 2 +- .../LicensedWriteLoadForecasterTests.java | 4 +- 86 files changed, 367 insertions(+), 356 deletions(-) diff --git a/modules/aggregations/src/test/java/org/elasticsearch/aggregations/bucket/histogram/AutoDateHistogramAggregatorTests.java b/modules/aggregations/src/test/java/org/elasticsearch/aggregations/bucket/histogram/AutoDateHistogramAggregatorTests.java index c8e6be2587a0..4298ec1ac6c9 100644 --- a/modules/aggregations/src/test/java/org/elasticsearch/aggregations/bucket/histogram/AutoDateHistogramAggregatorTests.java +++ b/modules/aggregations/src/test/java/org/elasticsearch/aggregations/bucket/histogram/AutoDateHistogramAggregatorTests.java @@ -23,7 +23,6 @@ import org.apache.lucene.store.Directory; import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.util.BytesRef; -import org.elasticsearch.Version; import org.elasticsearch.aggregations.AggregationsPlugin; import org.elasticsearch.aggregations.pipeline.DerivativePipelineAggregationBuilder; import org.elasticsearch.cluster.metadata.IndexMetadata; @@ -33,6 +32,7 @@ import org.elasticsearch.common.util.Maps; import org.elasticsearch.core.Strings; import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.mapper.BooleanFieldMapper; import org.elasticsearch.index.mapper.DateFieldMapper; import org.elasticsearch.index.mapper.IpFieldMapper; @@ -1008,7 +1008,7 @@ protected IndexSettings createIndexSettings() { final Settings nodeSettings = Settings.builder().put("search.max_buckets", 25000).build(); return new IndexSettings( IndexMetadata.builder("_index") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(1) .numberOfReplicas(0) .creationDate(System.currentTimeMillis()) diff --git a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/CompoundAnalysisTests.java b/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/CompoundAnalysisTests.java index 79a083073213..6ac62246e3da 100644 --- a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/CompoundAnalysisTests.java +++ b/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/CompoundAnalysisTests.java @@ -11,13 +11,13 @@ import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.env.TestEnvironment; import org.elasticsearch.index.IndexService.IndexCreationContext; import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.analysis.IndexAnalyzers; import org.elasticsearch.index.analysis.MyFilterTokenFilterFactory; import org.elasticsearch.index.analysis.TokenFilterFactory; @@ -94,7 +94,7 @@ private Settings getJsonSettings() throws IOException { String json = "/org/elasticsearch/analysis/common/test1.json"; return Settings.builder() .loadFromStream(json, getClass().getResourceAsStream(json), false) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()) .build(); } @@ -103,7 +103,7 @@ private Settings getYamlSettings() throws IOException { String yaml = "/org/elasticsearch/analysis/common/test1.yml"; return Settings.builder() .loadFromStream(yaml, getClass().getResourceAsStream(yaml), false) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()) .build(); } diff --git a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/MultiplexerTokenFilterTests.java b/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/MultiplexerTokenFilterTests.java index 1228be64130a..3d05bbb6cc54 100644 --- a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/MultiplexerTokenFilterTests.java +++ b/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/MultiplexerTokenFilterTests.java @@ -8,13 +8,13 @@ package org.elasticsearch.analysis.common; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.env.TestEnvironment; import org.elasticsearch.index.IndexService.IndexCreationContext; import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.analysis.IndexAnalyzers; import org.elasticsearch.index.analysis.NamedAnalyzer; import org.elasticsearch.indices.analysis.AnalysisModule; @@ -30,7 +30,7 @@ public class MultiplexerTokenFilterTests extends ESTokenStreamTestCase { public void testMultiplexingFilter() throws IOException { Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).build(); Settings indexSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put("index.analysis.filter.t.type", "truncate") .put("index.analysis.filter.t.length", "2") .put("index.analysis.filter.multiplexFilter.type", "multiplexer") @@ -64,7 +64,7 @@ public void testMultiplexingNoOriginal() throws IOException { Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).build(); Settings indexSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put("index.analysis.filter.t.type", "truncate") .put("index.analysis.filter.t.length", "2") .put("index.analysis.filter.multiplexFilter.type", "multiplexer") diff --git a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/PatternCaptureTokenFilterTests.java b/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/PatternCaptureTokenFilterTests.java index a8e4aeba4080..2db769127e3c 100644 --- a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/PatternCaptureTokenFilterTests.java +++ b/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/PatternCaptureTokenFilterTests.java @@ -8,11 +8,11 @@ package org.elasticsearch.analysis.common; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.analysis.IndexAnalyzers; import org.elasticsearch.index.analysis.NamedAnalyzer; import org.elasticsearch.test.ESTokenStreamTestCase; @@ -27,7 +27,7 @@ public void testPatternCaptureTokenFilter() throws Exception { Settings settings = Settings.builder() .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()) .loadFromStream(json, getClass().getResourceAsStream(json), false) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .build(); IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("index", settings); diff --git a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/PredicateTokenScriptFilterTests.java b/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/PredicateTokenScriptFilterTests.java index 8837695e876f..9a915d0c056d 100644 --- a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/PredicateTokenScriptFilterTests.java +++ b/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/PredicateTokenScriptFilterTests.java @@ -8,7 +8,6 @@ package org.elasticsearch.analysis.common; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionResponse; @@ -21,6 +20,7 @@ import org.elasticsearch.env.TestEnvironment; import org.elasticsearch.index.IndexService.IndexCreationContext; import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.analysis.IndexAnalyzers; import org.elasticsearch.index.analysis.NamedAnalyzer; import org.elasticsearch.indices.analysis.AnalysisModule; @@ -41,7 +41,7 @@ public class PredicateTokenScriptFilterTests extends ESTokenStreamTestCase { public void testSimpleFilter() throws IOException { Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).build(); Settings indexSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put("index.analysis.filter.f.type", "predicate_token_filter") .put("index.analysis.filter.f.script.source", "my_script") .put("index.analysis.analyzer.myAnalyzer.type", "custom") diff --git a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/ScriptedConditionTokenFilterTests.java b/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/ScriptedConditionTokenFilterTests.java index ab644f769436..c35127e1f079 100644 --- a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/ScriptedConditionTokenFilterTests.java +++ b/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/ScriptedConditionTokenFilterTests.java @@ -8,7 +8,6 @@ package org.elasticsearch.analysis.common; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionResponse; @@ -21,6 +20,7 @@ import org.elasticsearch.env.TestEnvironment; import org.elasticsearch.index.IndexService.IndexCreationContext; import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.analysis.IndexAnalyzers; import org.elasticsearch.index.analysis.NamedAnalyzer; import org.elasticsearch.indices.analysis.AnalysisModule; @@ -40,7 +40,7 @@ public class ScriptedConditionTokenFilterTests extends ESTokenStreamTestCase { public void testSimpleCondition() throws Exception { Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).build(); Settings indexSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put("index.analysis.filter.cond.type", "condition") .put("index.analysis.filter.cond.script.source", "token.getPosition() > 1") .putList("index.analysis.filter.cond.filter", "uppercase") diff --git a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/StopAnalyzerTests.java b/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/StopAnalyzerTests.java index 9dc6a5710682..58c2f30fd602 100644 --- a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/StopAnalyzerTests.java +++ b/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/StopAnalyzerTests.java @@ -8,11 +8,11 @@ package org.elasticsearch.analysis.common; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.analysis.IndexAnalyzers; import org.elasticsearch.index.analysis.NamedAnalyzer; import org.elasticsearch.test.ESTokenStreamTestCase; @@ -26,7 +26,7 @@ public void testDefaultsCompoundAnalysis() throws Exception { Settings settings = Settings.builder() .loadFromStream(json, getClass().getResourceAsStream(json), false) .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .build(); IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("index", settings); IndexAnalyzers indexAnalyzers = createTestAnalysis(idxSettings, settings, new CommonAnalysisPlugin()).indexAnalyzers; diff --git a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/SynonymsAnalysisTests.java b/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/SynonymsAnalysisTests.java index d4d6b9c55083..8f6e1752fdd2 100644 --- a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/SynonymsAnalysisTests.java +++ b/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/SynonymsAnalysisTests.java @@ -18,6 +18,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.analysis.IndexAnalyzers; import org.elasticsearch.index.analysis.PreConfiguredTokenFilter; import org.elasticsearch.index.analysis.TokenFilterFactory; @@ -57,7 +58,7 @@ public void testSynonymsAnalysis() throws IOException { Settings settings = Settings.builder() .loadFromStream(json, getClass().getResourceAsStream(json), false) .put(Environment.PATH_HOME_SETTING.getKey(), home) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .build(); IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("index", settings); @@ -78,7 +79,7 @@ public void testSynonymsAnalysis() throws IOException { public void testSynonymWordDeleteByAnalyzer() throws IOException { Settings settings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put("path.home", createTempDir().toString()) .put("index.analysis.filter.my_synonym.type", "synonym") .putList("index.analysis.filter.my_synonym.synonyms", "kimchy => shay", "dude => elasticsearch", "abides => man!") @@ -106,7 +107,7 @@ public void testSynonymWordDeleteByAnalyzerFromFile() throws IOException { Files.copy(synonyms, config.resolve("synonyms.txt")); Settings settings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put("path.home", home) .put("index.analysis.filter.my_synonym.type", "synonym") .put("index.analysis.filter.my_synonym.synonyms_path", "synonyms.txt") @@ -127,7 +128,7 @@ public void testSynonymWordDeleteByAnalyzerFromFile() throws IOException { public void testExpandSynonymWordDeleteByAnalyzer() throws IOException { Settings settings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put("path.home", createTempDir().toString()) .put("index.analysis.filter.synonym_expand.type", "synonym") .putList("index.analysis.filter.synonym_expand.synonyms", "kimchy, shay", "dude, elasticsearch", "abides, man!") @@ -149,7 +150,7 @@ public void testExpandSynonymWordDeleteByAnalyzer() throws IOException { public void testSynonymsWrappedByMultiplexer() throws IOException { Settings settings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put("path.home", createTempDir().toString()) .put("index.analysis.filter.synonyms.type", "synonym") .putList("index.analysis.filter.synonyms.synonyms", "programmer, developer") @@ -173,7 +174,7 @@ public void testSynonymsWrappedByMultiplexer() throws IOException { public void testAsciiFoldingFilterForSynonyms() throws IOException { Settings settings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put("path.home", createTempDir().toString()) .put("index.analysis.filter.synonyms.type", "synonym") .putList("index.analysis.filter.synonyms.synonyms", "hoj, height") @@ -193,7 +194,7 @@ public void testAsciiFoldingFilterForSynonyms() throws IOException { public void testPreconfigured() throws IOException { Settings settings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put("path.home", createTempDir().toString()) .put("index.analysis.filter.synonyms.type", "synonym") .putList("index.analysis.filter.synonyms.synonyms", "würst, sausage") @@ -213,7 +214,7 @@ public void testPreconfigured() throws IOException { public void testChainedSynonymFilters() throws IOException { Settings settings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put("path.home", createTempDir().toString()) .put("index.analysis.filter.synonyms1.type", "synonym") .putList("index.analysis.filter.synonyms1.synonyms", "term1, term2") @@ -255,7 +256,7 @@ public void testShingleFilters() { public void testTokenFiltersBypassSynonymAnalysis() throws IOException { Settings settings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put("path.home", createTempDir().toString()) .putList("word_list", "a") .put("hyphenation_patterns_path", "foo") diff --git a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/WhitespaceTokenizerFactoryTests.java b/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/WhitespaceTokenizerFactoryTests.java index 96725520a11b..87323f3a2bb8 100644 --- a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/WhitespaceTokenizerFactoryTests.java +++ b/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/WhitespaceTokenizerFactoryTests.java @@ -11,11 +11,11 @@ import com.carrotsearch.randomizedtesting.generators.RandomStrings; import org.apache.lucene.analysis.core.WhitespaceTokenizer; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.IndexSettingsModule; @@ -28,7 +28,7 @@ public class WhitespaceTokenizerFactoryTests extends ESTestCase { public void testSimpleWhiteSpaceTokenizer() throws IOException { - final Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build(); + final Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build(); IndexSettings indexProperties = IndexSettingsModule.newIndexSettings(new Index("test", "_na_"), indexSettings); WhitespaceTokenizer tokenizer = (WhitespaceTokenizer) new WhitespaceTokenizerFactory( indexProperties, @@ -44,7 +44,7 @@ public void testSimpleWhiteSpaceTokenizer() throws IOException { } public void testMaxTokenLength() throws IOException { - final Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build(); + final Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build(); IndexSettings indexProperties = IndexSettingsModule.newIndexSettings(new Index("test", "_na_"), indexSettings); final Settings settings = Settings.builder().put(WhitespaceTokenizerFactory.MAX_TOKEN_LENGTH, 2).build(); WhitespaceTokenizer tokenizer = (WhitespaceTokenizer) new WhitespaceTokenizerFactory( diff --git a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/WordDelimiterGraphTokenFilterFactoryTests.java b/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/WordDelimiterGraphTokenFilterFactoryTests.java index 31550ab0945f..cebfbd76cdf7 100644 --- a/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/WordDelimiterGraphTokenFilterFactoryTests.java +++ b/modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/WordDelimiterGraphTokenFilterFactoryTests.java @@ -16,6 +16,7 @@ import org.elasticsearch.env.TestEnvironment; import org.elasticsearch.index.IndexService.IndexCreationContext; import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.analysis.AnalysisTestsHelper; import org.elasticsearch.index.analysis.IndexAnalyzers; import org.elasticsearch.index.analysis.NamedAnalyzer; @@ -211,7 +212,7 @@ public void testPreconfiguredFilter() throws IOException { { Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).build(); Settings indexSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put("index.analysis.analyzer.my_analyzer.tokenizer", "standard") .putList("index.analysis.analyzer.my_analyzer.filter", "word_delimiter_graph") .build(); diff --git a/modules/data-streams/src/test/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleServiceTests.java b/modules/data-streams/src/test/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleServiceTests.java index a26aada20054..7e89ca4f37d9 100644 --- a/modules/data-streams/src/test/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleServiceTests.java +++ b/modules/data-streams/src/test/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleServiceTests.java @@ -215,7 +215,9 @@ public void testIlmManagedIndicesAreSkipped() { builder, dataStreamName, numBackingIndices, - Settings.builder().put(IndexMetadata.LIFECYCLE_NAME, "ILM_policy").put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT), + Settings.builder() + .put(IndexMetadata.LIFECYCLE_NAME, "ILM_policy") + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()), DataStreamLifecycle.newBuilder().dataRetention(0).build(), now ); @@ -234,7 +236,9 @@ public void testDataStreamsWithoutLifecycleAreSkipped() { builder, dataStreamName, numBackingIndices, - Settings.builder().put(IndexMetadata.LIFECYCLE_NAME, "ILM_policy").put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT), + Settings.builder() + .put(IndexMetadata.LIFECYCLE_NAME, "ILM_policy") + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()), null, now ); @@ -253,7 +257,7 @@ public void testDeletedIndicesAreRemovedFromTheErrorStore() throws IOException { builder, dataStreamName, numBackingIndices, - Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT), + Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()), new DataStreamLifecycle(), now ); diff --git a/modules/reindex/src/test/java/org/elasticsearch/reindex/ReindexIdTests.java b/modules/reindex/src/test/java/org/elasticsearch/reindex/ReindexIdTests.java index 646dc369c898..34db45953932 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/reindex/ReindexIdTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/reindex/ReindexIdTests.java @@ -8,7 +8,6 @@ package org.elasticsearch.reindex; -import org.elasticsearch.Version; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.ComponentTemplate; import org.elasticsearch.cluster.metadata.ComposableIndexTemplate; @@ -19,6 +18,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.IndexMode; import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.reindex.AbstractAsyncBulkByScrollActionTestCase; import org.elasticsearch.index.reindex.BulkByScrollResponse; import org.elasticsearch.index.reindex.ReindexRequest; @@ -68,7 +68,7 @@ private ClusterState stateWithTemplate(Settings.Builder settings) { private ClusterState stateWithIndex(Settings.Builder settings) { IndexMetadata.Builder meta = IndexMetadata.builder(request().getDestination().index()) - .settings(settings.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(settings.put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfReplicas(0) .numberOfShards(1); return ClusterState.builder(ClusterState.EMPTY_STATE).metadata(Metadata.builder(Metadata.EMPTY_METADATA).put(meta)).build(); diff --git a/plugins/analysis-icu/src/test/java/org/elasticsearch/plugin/analysis/icu/IcuAnalyzerTests.java b/plugins/analysis-icu/src/test/java/org/elasticsearch/plugin/analysis/icu/IcuAnalyzerTests.java index b07d4e1de162..fef40ca59940 100644 --- a/plugins/analysis-icu/src/test/java/org/elasticsearch/plugin/analysis/icu/IcuAnalyzerTests.java +++ b/plugins/analysis-icu/src/test/java/org/elasticsearch/plugin/analysis/icu/IcuAnalyzerTests.java @@ -10,9 +10,9 @@ import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.tests.analysis.BaseTokenStreamTestCase; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.index.IndexVersion; import java.io.IOException; @@ -50,7 +50,10 @@ public void testUnicodeNumericCharacters() throws IOException { public void testBadSettings() { - Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).put("mode", "wrong").build(); + Settings settings = Settings.builder() + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) + .put("mode", "wrong") + .build(); IllegalArgumentException e = expectThrows( IllegalArgumentException.class, diff --git a/plugins/analysis-icu/src/test/java/org/elasticsearch/plugin/analysis/icu/IcuTokenizerFactoryTests.java b/plugins/analysis-icu/src/test/java/org/elasticsearch/plugin/analysis/icu/IcuTokenizerFactoryTests.java index 87e7b2ebe498..30c908abbca3 100644 --- a/plugins/analysis-icu/src/test/java/org/elasticsearch/plugin/analysis/icu/IcuTokenizerFactoryTests.java +++ b/plugins/analysis-icu/src/test/java/org/elasticsearch/plugin/analysis/icu/IcuTokenizerFactoryTests.java @@ -9,11 +9,11 @@ package org.elasticsearch.plugin.analysis.icu; import org.apache.lucene.analysis.icu.segmentation.ICUTokenizer; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.index.Index; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.analysis.TokenizerFactory; import org.elasticsearch.test.ESTestCase; @@ -98,7 +98,7 @@ private static TestAnalysis createTestAnalysis() throws IOException { Settings settings = Settings.builder() .loadFromStream(json, IcuTokenizerFactoryTests.class.getResourceAsStream(json), false) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .build(); Settings nodeSettings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), home).build(); diff --git a/plugins/analysis-kuromoji/src/test/java/org/elasticsearch/plugin/analysis/kuromoji/KuromojiAnalysisTests.java b/plugins/analysis-kuromoji/src/test/java/org/elasticsearch/plugin/analysis/kuromoji/KuromojiAnalysisTests.java index ce7d8edbd59f..bb13f6a169a8 100644 --- a/plugins/analysis-kuromoji/src/test/java/org/elasticsearch/plugin/analysis/kuromoji/KuromojiAnalysisTests.java +++ b/plugins/analysis-kuromoji/src/test/java/org/elasticsearch/plugin/analysis/kuromoji/KuromojiAnalysisTests.java @@ -15,11 +15,11 @@ import org.apache.lucene.analysis.ja.JapaneseCompletionAnalyzer; import org.apache.lucene.analysis.ja.JapaneseTokenizer; import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.index.Index; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.analysis.AnalysisTestsHelper; import org.elasticsearch.index.analysis.CharFilterFactory; import org.elasticsearch.index.analysis.CustomAnalyzer; @@ -280,7 +280,7 @@ private static TestAnalysis createTestAnalysis() throws IOException { Settings settings = Settings.builder() .loadFromStream(json, KuromojiAnalysisTests.class.getResourceAsStream(json), false) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .build(); Settings nodeSettings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), home).build(); return createTestAnalysis(new Index("test", "_na_"), nodeSettings, settings, new AnalysisKuromojiPlugin()); @@ -437,7 +437,7 @@ private TestAnalysis createTestAnalysis(Settings analysisSettings) throws IOExce Files.createDirectory(config); Files.copy(dict, config.resolve("user_dict.txt")); Settings settings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(Environment.PATH_HOME_SETTING.getKey(), home) .put(analysisSettings) .build(); diff --git a/plugins/analysis-nori/src/test/java/org/elasticsearch/plugin/analysis/nori/NoriAnalysisTests.java b/plugins/analysis-nori/src/test/java/org/elasticsearch/plugin/analysis/nori/NoriAnalysisTests.java index c9fbef0d20ad..e09181318447 100644 --- a/plugins/analysis-nori/src/test/java/org/elasticsearch/plugin/analysis/nori/NoriAnalysisTests.java +++ b/plugins/analysis-nori/src/test/java/org/elasticsearch/plugin/analysis/nori/NoriAnalysisTests.java @@ -13,10 +13,10 @@ import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.ko.KoreanAnalyzer; import org.apache.lucene.analysis.ko.KoreanTokenizer; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.analysis.AnalysisTestsHelper; import org.elasticsearch.index.analysis.IndexAnalyzers; import org.elasticsearch.index.analysis.NamedAnalyzer; @@ -171,7 +171,7 @@ public void testNoriPartOfSpeech() throws IOException { public void testNoriReadingForm() throws IOException { Settings settings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()) .put("index.analysis.filter.my_filter.type", "nori_readingform") .build(); @@ -185,7 +185,7 @@ public void testNoriReadingForm() throws IOException { public void testNoriNumber() throws IOException { Settings settings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()) .put("index.analysis.filter.my_filter.type", "nori_number") .build(); @@ -211,7 +211,7 @@ private TestAnalysis createTestAnalysis(Settings analysisSettings) throws IOExce Files.createDirectory(config); Files.copy(dict, config.resolve("user_dict.txt")); Settings settings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(Environment.PATH_HOME_SETTING.getKey(), home) .put(analysisSettings) .build(); diff --git a/plugins/analysis-phonetic/src/test/java/org/elasticsearch/plugin/analysis/phonetic/SimplePhoneticAnalysisTests.java b/plugins/analysis-phonetic/src/test/java/org/elasticsearch/plugin/analysis/phonetic/SimplePhoneticAnalysisTests.java index 3e7081b76600..a6c9035b8ecc 100644 --- a/plugins/analysis-phonetic/src/test/java/org/elasticsearch/plugin/analysis/phonetic/SimplePhoneticAnalysisTests.java +++ b/plugins/analysis-phonetic/src/test/java/org/elasticsearch/plugin/analysis/phonetic/SimplePhoneticAnalysisTests.java @@ -12,10 +12,10 @@ import org.apache.lucene.analysis.core.WhitespaceTokenizer; import org.apache.lucene.analysis.phonetic.DaitchMokotoffSoundexFilter; import org.apache.lucene.tests.analysis.BaseTokenStreamTestCase; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.Index; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.analysis.TokenFilterFactory; import org.elasticsearch.test.ESTestCase; import org.hamcrest.MatcherAssert; @@ -35,7 +35,7 @@ public void setup() throws IOException { String yaml = "/org/elasticsearch/plugin/analysis/phonetic/phonetic-1.yml"; Settings settings = Settings.builder() .loadFromStream(yaml, getClass().getResourceAsStream(yaml), false) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .build(); this.analysis = createTestAnalysis(new Index("test", "_na_"), settings, new AnalysisPhoneticPlugin()); } diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteResponseTests.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteResponseTests.java index f5302554cec7..ddc5e8bec61c 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteResponseTests.java @@ -328,7 +328,7 @@ private static ClusterState createClusterState() { .settings( indexSettings(1, 0).put(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(), true) .put(IndexSettings.MAX_SCRIPT_FIELDS_SETTING.getKey(), 10) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .build() ) .build(), diff --git a/server/src/test/java/org/elasticsearch/action/admin/indices/TransportAnalyzeActionTests.java b/server/src/test/java/org/elasticsearch/action/admin/indices/TransportAnalyzeActionTests.java index 395a228e6db4..64d88df8ccfd 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/indices/TransportAnalyzeActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/indices/TransportAnalyzeActionTests.java @@ -12,7 +12,6 @@ import org.apache.lucene.tests.analysis.MockTokenizer; import org.apache.lucene.util.automaton.Automata; import org.apache.lucene.util.automaton.CharacterRunAutomaton; -import org.elasticsearch.Version; import org.elasticsearch.action.admin.indices.analyze.AnalyzeAction; import org.elasticsearch.action.admin.indices.analyze.TransportAnalyzeAction; import org.elasticsearch.cluster.metadata.IndexMetadata; @@ -22,6 +21,7 @@ import org.elasticsearch.env.TestEnvironment; import org.elasticsearch.index.IndexService; import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.analysis.AbstractCharFilterFactory; import org.elasticsearch.index.analysis.AbstractTokenFilterFactory; import org.elasticsearch.index.analysis.AnalysisRegistry; @@ -66,7 +66,7 @@ public void setUp() throws Exception { Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).build(); Settings indexSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID()) .put("index.analysis.analyzer.custom_analyzer.tokenizer", "standard") .put("index.analysis.analyzer.custom_analyzer.filter", "mock") diff --git a/server/src/test/java/org/elasticsearch/action/admin/indices/resolve/ResolveIndexTests.java b/server/src/test/java/org/elasticsearch/action/admin/indices/resolve/ResolveIndexTests.java index 11b919416c35..2f82ceb67917 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/indices/resolve/ResolveIndexTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/indices/resolve/ResolveIndexTests.java @@ -8,7 +8,6 @@ package org.elasticsearch.action.admin.indices.resolve; -import org.elasticsearch.Version; import org.elasticsearch.action.admin.indices.resolve.ResolveIndexAction.Request; import org.elasticsearch.action.admin.indices.resolve.ResolveIndexAction.ResolvedAlias; import org.elasticsearch.action.admin.indices.resolve.ResolveIndexAction.ResolvedDataStream; @@ -422,7 +421,7 @@ private static IndexMetadata createIndexMetadata( boolean frozen ) { Settings.Builder settingsBuilder = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put("index.hidden", hidden) .put("index.frozen", frozen); diff --git a/server/src/test/java/org/elasticsearch/action/admin/indices/shards/TransportIndicesShardStoresActionTests.java b/server/src/test/java/org/elasticsearch/action/admin/indices/shards/TransportIndicesShardStoresActionTests.java index a9df38aed6d1..dfafcd066229 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/indices/shards/TransportIndicesShardStoresActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/indices/shards/TransportIndicesShardStoresActionTests.java @@ -9,7 +9,6 @@ package org.elasticsearch.action.admin.indices.shards; import org.elasticsearch.ElasticsearchException; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.FailedNodeException; import org.elasticsearch.action.support.ActionFilters; @@ -30,6 +29,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.DeterministicTaskQueue; import org.elasticsearch.gateway.TransportNodesListGatewayStartedShards; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.indices.SystemIndices; import org.elasticsearch.tasks.CancellableTask; @@ -205,7 +205,7 @@ private abstract static class TestHarness implements Closeable { final var routingTable = RoutingTable.builder(); for (int i = 0; i < indexCount; i++) { final var indexMetadata = IndexMetadata.builder("index-" + i) - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(between(1, 3)) .numberOfReplicas(between(0, 2)) .build(); diff --git a/server/src/test/java/org/elasticsearch/action/support/broadcast/node/TransportBroadcastByNodeActionTests.java b/server/src/test/java/org/elasticsearch/action/support/broadcast/node/TransportBroadcastByNodeActionTests.java index 02c4b4ac417f..c711f320cdd3 100644 --- a/server/src/test/java/org/elasticsearch/action/support/broadcast/node/TransportBroadcastByNodeActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/support/broadcast/node/TransportBroadcastByNodeActionTests.java @@ -9,7 +9,6 @@ package org.elasticsearch.action.support.broadcast.node; import org.elasticsearch.ElasticsearchException; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionRunnable; import org.elasticsearch.action.IndicesRequest; @@ -49,6 +48,7 @@ import org.elasticsearch.core.RefCounted; import org.elasticsearch.core.TimeValue; import org.elasticsearch.index.Index; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.indices.EmptySystemIndices; import org.elasticsearch.rest.RestStatus; @@ -311,7 +311,7 @@ void setClusterState(ClusterService clusterService) { ClusterState.Builder stateBuilder = ClusterState.builder(new ClusterName(TEST_CLUSTER)); stateBuilder.nodes(discoBuilder); final IndexMetadata.Builder indexMetadata = IndexMetadata.builder(TEST_INDEX) - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfReplicas(0) .numberOfShards(totalIndexShards); diff --git a/server/src/test/java/org/elasticsearch/cluster/ClusterChangedEventTests.java b/server/src/test/java/org/elasticsearch/cluster/ClusterChangedEventTests.java index 8f7802bb6a65..d09a16ba07bb 100644 --- a/server/src/test/java/org/elasticsearch/cluster/ClusterChangedEventTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/ClusterChangedEventTests.java @@ -9,7 +9,6 @@ package org.elasticsearch.cluster; import org.elasticsearch.TransportVersion; -import org.elasticsearch.Version; import org.elasticsearch.cluster.block.ClusterBlocks; import org.elasticsearch.cluster.metadata.IndexGraveyard; import org.elasticsearch.cluster.metadata.IndexMetadata; @@ -22,6 +21,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.gateway.GatewayService; import org.elasticsearch.index.Index; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.TestCustomMetadata; @@ -488,7 +488,7 @@ private static IndexMetadata createIndexMetadata(final Index index) { // Create the index metadata for a given index, with the specified version. private static IndexMetadata createIndexMetadata(final Index index, final long version) { final Settings settings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()) .build(); return IndexMetadata.builder(index.getName()) diff --git a/server/src/test/java/org/elasticsearch/cluster/ClusterStateTests.java b/server/src/test/java/org/elasticsearch/cluster/ClusterStateTests.java index 2dd013783ff9..f43152666a37 100644 --- a/server/src/test/java/org/elasticsearch/cluster/ClusterStateTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/ClusterStateTests.java @@ -893,7 +893,7 @@ public void testToXContentSameTypeName() throws IOException { .put( IndexMetadata.builder("index") .state(IndexMetadata.State.OPEN) - .settings(Settings.builder().put(SETTING_VERSION_CREATED, Version.CURRENT.id)) + .settings(Settings.builder().put(SETTING_VERSION_CREATED, IndexVersion.current())) .putMapping( new MappingMetadata( "type", @@ -995,7 +995,7 @@ public void testToXContentSameTypeName() throws IOException { private ClusterState buildClusterState() throws IOException { IndexMetadata indexMetadata = IndexMetadata.builder("index") .state(IndexMetadata.State.OPEN) - .settings(Settings.builder().put(SETTING_VERSION_CREATED, Version.CURRENT.id)) + .settings(Settings.builder().put(SETTING_VERSION_CREATED, IndexVersion.current())) .putMapping(new MappingMetadata("type", new HashMap<>() { { put("type1", new HashMap() { @@ -1067,14 +1067,14 @@ private ClusterState buildClusterState() throws IOException { .addVotingConfigExclusion(new CoordinationMetadata.VotingConfigExclusion("exlucdedNodeId", "excludedNodeName")) .build() ) - .persistentSettings(Settings.builder().put(SETTING_VERSION_CREATED, Version.CURRENT.id).build()) - .transientSettings(Settings.builder().put(SETTING_VERSION_CREATED, Version.CURRENT.id).build()) + .persistentSettings(Settings.builder().put(SETTING_VERSION_CREATED, IndexVersion.current()).build()) + .transientSettings(Settings.builder().put(SETTING_VERSION_CREATED, IndexVersion.current()).build()) .put(indexMetadata, false) .put( IndexTemplateMetadata.builder("template") .patterns(List.of("pattern1", "pattern2")) .order(0) - .settings(Settings.builder().put(SETTING_VERSION_CREATED, Version.CURRENT.id)) + .settings(Settings.builder().put(SETTING_VERSION_CREATED, IndexVersion.current())) .putMapping("type", "{ \"key1\": {} }") .build() ) diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamTests.java index 95f0b9ddcb10..b23d68ccb8ac 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamTests.java @@ -1197,7 +1197,7 @@ public void testGetIndicesPastRetention() { creationAndRolloverTimes, Settings.builder() .put(IndexMetadata.LIFECYCLE_NAME, "ILM_policy") - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT), + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()), DataStreamLifecycle.newBuilder().dataRetention(0).build() ); Metadata metadata = builder.build(); @@ -1329,7 +1329,7 @@ public void testIsIndexManagedByDataStreamLifecycle() { creationAndRolloverTimes, Settings.builder() .put(IndexMetadata.LIFECYCLE_NAME, "ILM_policy") - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT), + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()), new DataStreamLifecycle() ); Metadata metadataIlm = builderWithIlm.build(); @@ -1349,7 +1349,7 @@ public void testIsIndexManagedByDataStreamLifecycle() { creationAndRolloverTimes, Settings.builder() .put(IndexMetadata.LIFECYCLE_NAME, "ILM_policy") - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexSettings.PREFER_ILM, false), new DataStreamLifecycle() ); diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/IndexMetadataTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/IndexMetadataTests.java index 75673454a44a..ed8d717209c7 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/IndexMetadataTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/IndexMetadataTests.java @@ -464,7 +464,7 @@ public void testIndexAndAliasWithSameName() { final IllegalArgumentException iae = expectThrows( IllegalArgumentException.class, () -> IndexMetadata.builder("index") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(1) .numberOfReplicas(0) .putAlias(AliasMetadata.builder("index").build()) diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataCreateDataStreamServiceTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataCreateDataStreamServiceTests.java index 6eb6050157ec..170fcd7fb4df 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataCreateDataStreamServiceTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataCreateDataStreamServiceTests.java @@ -8,7 +8,6 @@ package org.elasticsearch.cluster.metadata; import org.elasticsearch.ResourceAlreadyExistsException; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.admin.indices.create.CreateIndexClusterStateUpdateRequest; import org.elasticsearch.cluster.ClusterName; @@ -19,6 +18,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.Maps; import org.elasticsearch.core.TimeValue; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.indices.ExecutorNames; import org.elasticsearch.indices.SystemDataStreamDescriptor; import org.elasticsearch.indices.SystemDataStreamDescriptor.Type; @@ -346,7 +346,7 @@ private static MetadataCreateIndexService getMetadataCreateIndexService() throws IndexMetadata.builder(request.index()) .settings( Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(request.settings()) .build() ) diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataDataStreamsServiceTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataDataStreamsServiceTests.java index 6e025d928d8b..172b3a6902f8 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataDataStreamsServiceTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataDataStreamsServiceTests.java @@ -8,13 +8,13 @@ package org.elasticsearch.cluster.metadata; -import org.elasticsearch.Version; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.core.Tuple; import org.elasticsearch.index.Index; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.MapperServiceTestCase; @@ -41,7 +41,7 @@ public void testAddBackingIndex() { Metadata.Builder mb = Metadata.builder(); for (int k = 0; k < numBackingIndices; k++) { backingIndices[k] = IndexMetadata.builder(DataStream.getDefaultBackingIndexName(dataStreamName, k + 1, epochMillis)) - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(1) .numberOfReplicas(0) .putMapping(generateMapping("@timestamp")) @@ -52,7 +52,7 @@ public void testAddBackingIndex() { mb.put(DataStreamTestHelper.newInstance(dataStreamName, Arrays.stream(backingIndices).map(IndexMetadata::getIndex).toList())); final IndexMetadata indexToAdd = IndexMetadata.builder(randomAlphaOfLength(5)) - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(1) .numberOfReplicas(0) .putMapping(generateMapping("@timestamp")) @@ -91,7 +91,7 @@ public void testRemoveBackingIndex() { Metadata.Builder mb = Metadata.builder(); for (int k = 0; k < numBackingIndices; k++) { backingIndices[k] = IndexMetadata.builder(DataStream.getDefaultBackingIndexName(dataStreamName, k + 1, epochMillis)) - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(1) .numberOfReplicas(0) .putMapping(generateMapping("@timestamp")) @@ -134,7 +134,7 @@ public void testRemoveWriteIndexIsProhibited() { Metadata.Builder mb = Metadata.builder(); for (int k = 0; k < numBackingIndices; k++) { backingIndices[k] = IndexMetadata.builder(DataStream.getDefaultBackingIndexName(dataStreamName, k + 1, epochMillis)) - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(1) .numberOfReplicas(0) .putMapping(generateMapping("@timestamp")) @@ -177,7 +177,7 @@ public void testAddRemoveAddRoundtripInSingleRequest() { Metadata.Builder mb = Metadata.builder(); for (int k = 0; k < numBackingIndices; k++) { backingIndices[k] = IndexMetadata.builder(DataStream.getDefaultBackingIndexName(dataStreamName, k + 1, epochMillis)) - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(1) .numberOfReplicas(0) .putMapping(generateMapping("@timestamp")) @@ -188,7 +188,7 @@ public void testAddRemoveAddRoundtripInSingleRequest() { mb.put(DataStreamTestHelper.newInstance(dataStreamName, Arrays.stream(backingIndices).map(IndexMetadata::getIndex).toList())); final IndexMetadata indexToAdd = IndexMetadata.builder(randomAlphaOfLength(5)) - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(1) .numberOfReplicas(0) .putMapping(generateMapping("@timestamp")) @@ -231,7 +231,7 @@ public void testAddRemoveAddRoundtripInSeparateRequests() { Metadata.Builder mb = Metadata.builder(); for (int k = 0; k < numBackingIndices; k++) { backingIndices[k] = IndexMetadata.builder(DataStream.getDefaultBackingIndexName(dataStreamName, k + 1, epochMillis)) - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(1) .numberOfReplicas(0) .putMapping(generateMapping("@timestamp")) @@ -242,7 +242,7 @@ public void testAddRemoveAddRoundtripInSeparateRequests() { mb.put(DataStreamTestHelper.newInstance(dataStreamName, Arrays.stream(backingIndices).map(IndexMetadata::getIndex).toList())); final IndexMetadata indexToAdd = IndexMetadata.builder(randomAlphaOfLength(5)) - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(1) .numberOfReplicas(0) .putMapping(generateMapping("@timestamp")) @@ -286,7 +286,7 @@ public void testAddRemoveAddRoundtripInSeparateRequests() { public void testMissingDataStream() { Metadata.Builder mb = Metadata.builder(); final IndexMetadata indexToAdd = IndexMetadata.builder(randomAlphaOfLength(5)) - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(1) .numberOfReplicas(0) .putMapping(generateMapping("@timestamp")) @@ -316,7 +316,7 @@ public void testMissingIndex() { Metadata.Builder mb = Metadata.builder(); for (int k = 0; k < numBackingIndices; k++) { backingIndices[k] = IndexMetadata.builder(DataStream.getDefaultBackingIndexName(dataStreamName, k + 1, epochMillis)) - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(1) .numberOfReplicas(0) .putMapping(generateMapping("@timestamp")) diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataMigrateToDataStreamServiceTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataMigrateToDataStreamServiceTests.java index 49beb3ed5801..5b3079338e83 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataMigrateToDataStreamServiceTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataMigrateToDataStreamServiceTests.java @@ -8,7 +8,6 @@ package org.elasticsearch.cluster.metadata; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; @@ -16,6 +15,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.core.TimeValue; import org.elasticsearch.index.Index; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.index.mapper.MapperServiceTestCase; import org.elasticsearch.indices.EmptySystemIndices; @@ -61,7 +61,7 @@ public void testValidateRequestWithFilteredAlias() { Metadata.builder() .put( IndexMetadata.builder("foo") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .putAlias(filteredAlias) .numberOfShards(1) .numberOfReplicas(0) @@ -90,7 +90,7 @@ public void testValidateRequestWithAliasWithRouting() { Metadata.builder() .put( IndexMetadata.builder("foo") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .putAlias(aliasWithRouting) .numberOfShards(1) .numberOfReplicas(0) @@ -119,28 +119,28 @@ public void testValidateRequestWithAliasWithoutWriteIndex() { Metadata.builder() .put( IndexMetadata.builder("foo1") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .putAlias(alias1) .numberOfShards(1) .numberOfReplicas(0) ) .put( IndexMetadata.builder("foo2") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .putAlias(alias1) .numberOfShards(1) .numberOfReplicas(0) ) .put( IndexMetadata.builder("foo3") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .putAlias(alias1) .numberOfShards(1) .numberOfReplicas(0) ) .put( IndexMetadata.builder("foo4") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .putAlias(alias1) .numberOfShards(1) .numberOfReplicas(0) @@ -170,28 +170,28 @@ public void testValidateRequest() { Metadata.builder() .put( IndexMetadata.builder("foo1") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .putAlias(alias1) .numberOfShards(1) .numberOfReplicas(0) ) .put( IndexMetadata.builder("foo2") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .putAlias(alias1) .numberOfShards(1) .numberOfReplicas(0) ) .put( IndexMetadata.builder("foo3") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .putAlias(alias1) .numberOfShards(1) .numberOfReplicas(0) ) .put( IndexMetadata.builder("foo4") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .putAlias(AliasMetadata.builder(aliasName).writeIndex(true)) .numberOfShards(1) .numberOfReplicas(0) @@ -213,14 +213,14 @@ public void testValidateRequestWithIndicesWithMultipleAliasReferences() { Metadata.builder() .put( IndexMetadata.builder("foo1") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .putAlias(alias1) .numberOfShards(1) .numberOfReplicas(0) ) .put( IndexMetadata.builder("foo2") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .putAlias(alias1) .putAlias(alias2) .numberOfShards(1) @@ -228,7 +228,7 @@ public void testValidateRequestWithIndicesWithMultipleAliasReferences() { ) .put( IndexMetadata.builder("foo3") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .putAlias(alias1) .putAlias(alias2) .numberOfShards(1) @@ -236,7 +236,7 @@ public void testValidateRequestWithIndicesWithMultipleAliasReferences() { ) .put( IndexMetadata.builder("foo4") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .putAlias(alias1) .numberOfShards(1) .numberOfReplicas(0) @@ -259,14 +259,14 @@ public void testCreateDataStreamWithSuppliedWriteIndex() throws Exception { String dataStreamName = "foo"; AliasMetadata alias = AliasMetadata.builder(dataStreamName).build(); IndexMetadata foo1 = IndexMetadata.builder("foo1") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .putAlias(AliasMetadata.builder(dataStreamName).writeIndex(true).build()) .numberOfShards(1) .numberOfReplicas(0) .putMapping(generateMapping("@timestamp", "date")) .build(); IndexMetadata foo2 = IndexMetadata.builder("foo2") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .putAlias(alias) .numberOfShards(1) .numberOfReplicas(0) @@ -321,14 +321,14 @@ public void testCreateDataStreamHidesBackingIndicesAndRemovesAlias() throws Exce String dataStreamName = "foo"; AliasMetadata alias = AliasMetadata.builder(dataStreamName).build(); IndexMetadata foo1 = IndexMetadata.builder("foo1") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .putAlias(AliasMetadata.builder(dataStreamName).writeIndex(true).build()) .numberOfShards(1) .numberOfReplicas(0) .putMapping(generateMapping("@timestamp", "date")) .build(); IndexMetadata foo2 = IndexMetadata.builder("foo2") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .putAlias(alias) .numberOfShards(1) .numberOfReplicas(0) @@ -383,14 +383,14 @@ public void testCreateDataStreamWithoutSuppliedWriteIndex() { String dataStreamName = "foo"; AliasMetadata alias = AliasMetadata.builder(dataStreamName).build(); IndexMetadata foo1 = IndexMetadata.builder("foo1") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .putAlias(alias) .numberOfShards(1) .numberOfReplicas(0) .putMapping(generateMapping("@timestamp", "date")) .build(); IndexMetadata foo2 = IndexMetadata.builder("foo2") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .putAlias(alias) .numberOfShards(1) .numberOfReplicas(0) diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataTests.java index a77dd2fa1da3..fe877bac66b7 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataTests.java @@ -10,7 +10,6 @@ import org.elasticsearch.ResourceNotFoundException; import org.elasticsearch.TransportVersion; -import org.elasticsearch.Version; import org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest; import org.elasticsearch.cluster.ClusterModule; import org.elasticsearch.cluster.ClusterState; @@ -93,7 +92,7 @@ public void testFindAliases() { Metadata metadata = Metadata.builder() .put( IndexMetadata.builder("index") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(1) .numberOfReplicas(0) .putAlias(AliasMetadata.builder("alias1").build()) @@ -150,7 +149,7 @@ public void testFindAliasWithExclusion() { Metadata metadata = Metadata.builder() .put( IndexMetadata.builder("index") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(1) .numberOfReplicas(0) .putAlias(AliasMetadata.builder("alias1").build()) @@ -183,7 +182,7 @@ public void testFindAliasWithExclusionAndOverride() { Metadata metadata = Metadata.builder() .put( IndexMetadata.builder("index") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(1) .numberOfReplicas(0) .putAlias(AliasMetadata.builder("aa").build()) @@ -218,7 +217,7 @@ public void testAliasCollidingWithAnExistingIndex() { Metadata.Builder metadataBuilder = Metadata.builder(); for (String index : indices) { IndexMetadata.Builder indexBuilder = IndexMetadata.builder(index) - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(1) .numberOfReplicas(0); aliasToIndices.forEach((key, value) -> { @@ -290,12 +289,12 @@ private Metadata.Builder buildMetadataWithHiddenIndexMix( Boolean indexBHidden ) { IndexMetadata.Builder indexAMeta = IndexMetadata.builder(indexAName) - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(1) .numberOfReplicas(0) .putAlias(AliasMetadata.builder(aliasName).isHidden(indexAHidden).build()); IndexMetadata.Builder indexBMeta = IndexMetadata.builder(indexBName) - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(1) .numberOfReplicas(0) .putAlias(AliasMetadata.builder(aliasName).isHidden(indexBHidden).build()); @@ -304,7 +303,7 @@ private Metadata.Builder buildMetadataWithHiddenIndexMix( public void testResolveIndexRouting() { IndexMetadata.Builder builder = IndexMetadata.builder("index") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(1) .numberOfReplicas(0) .putAlias(AliasMetadata.builder("alias0").build()) @@ -346,7 +345,7 @@ public void testResolveIndexRouting() { ); IndexMetadata.Builder builder2 = IndexMetadata.builder("index2") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(1) .numberOfReplicas(0) .putAlias(AliasMetadata.builder("alias0").build()); @@ -366,7 +365,7 @@ public void testResolveWriteIndexRouting() { aliasZeroBuilder.writeIndex(true); } IndexMetadata.Builder builder = IndexMetadata.builder("index") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(1) .numberOfReplicas(0) .putAlias(aliasZeroBuilder.build()) @@ -423,7 +422,7 @@ public void testResolveWriteIndexRouting() { aliasZeroBuilder.writeIndex(false); } IndexMetadata.Builder builder2 = IndexMetadata.builder("index2") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(1) .numberOfReplicas(0) .putAlias(aliasZeroBuilderTwo.build()) @@ -2007,7 +2006,7 @@ public void testMappingDuplication() { Metadata.Builder mb = new Metadata.Builder(); for (int i = 0; i < numIndices; i++) { IndexMetadata.Builder indexBuilder = IndexMetadata.builder("index-" + i) - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .putMapping(definitions[i % randomMappingDefinitions.size()]) .numberOfShards(1) .numberOfReplicas(0); @@ -2032,7 +2031,7 @@ public void testMappingDuplication() { Metadata.Builder mb = new Metadata.Builder(metadata); mb.put( IndexMetadata.builder("index-" + numIndices) - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .putMapping(mapping) .numberOfShards(1) .numberOfReplicas(0) @@ -2079,7 +2078,7 @@ public void testMappingDuplication() { Metadata.Builder mb = new Metadata.Builder(metadata); mb.put( IndexMetadata.builder("index-" + numIndices) - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .putMapping(newMapping) .numberOfShards(1) .numberOfReplicas(0) diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/ToAndFromJsonMetadataTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/ToAndFromJsonMetadataTests.java index 58841890977f..21df3c5b5020 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/ToAndFromJsonMetadataTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/ToAndFromJsonMetadataTests.java @@ -291,7 +291,7 @@ public void testToXContentAPI_SameTypeName() throws IOException { .put( IndexMetadata.builder("index") .state(IndexMetadata.State.OPEN) - .settings(Settings.builder().put(SETTING_VERSION_CREATED, Version.CURRENT.id)) + .settings(Settings.builder().put(SETTING_VERSION_CREATED, IndexVersion.current())) .putMapping( new MappingMetadata( "type", @@ -850,12 +850,12 @@ private Metadata buildMetadata() throws IOException { .addVotingConfigExclusion(new CoordinationMetadata.VotingConfigExclusion("exlucdedNodeId", "excludedNodeName")) .build() ) - .persistentSettings(Settings.builder().put(SETTING_VERSION_CREATED, Version.CURRENT.id).build()) - .transientSettings(Settings.builder().put(SETTING_VERSION_CREATED, Version.CURRENT.id).build()) + .persistentSettings(Settings.builder().put(SETTING_VERSION_CREATED, IndexVersion.current()).build()) + .transientSettings(Settings.builder().put(SETTING_VERSION_CREATED, IndexVersion.current()).build()) .put( IndexMetadata.builder("index") .state(IndexMetadata.State.OPEN) - .settings(Settings.builder().put(SETTING_VERSION_CREATED, Version.CURRENT.id)) + .settings(Settings.builder().put(SETTING_VERSION_CREATED, IndexVersion.current())) .putMapping(new MappingMetadata("type", new HashMap<>() { { put("type1", new HashMap() { @@ -880,7 +880,7 @@ private Metadata buildMetadata() throws IOException { IndexTemplateMetadata.builder("template") .patterns(List.of("pattern1", "pattern2")) .order(0) - .settings(Settings.builder().put(SETTING_VERSION_CREATED, Version.CURRENT.id)) + .settings(Settings.builder().put(SETTING_VERSION_CREATED, IndexVersion.current())) .putMapping("type", "{ \"key1\": {} }") .build() ) diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/PrimaryTermsTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/PrimaryTermsTests.java index 3bfeb47ad6d2..d12633a8554f 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/PrimaryTermsTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/PrimaryTermsTests.java @@ -8,7 +8,6 @@ package org.elasticsearch.cluster.routing; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; @@ -22,6 +21,7 @@ import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.cluster.routing.allocation.FailedShard; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.index.IndexVersion; import java.util.ArrayList; import java.util.Collections; @@ -41,7 +41,9 @@ public class PrimaryTermsTests extends ESAllocationTestCase { private static final String TEST_INDEX_2 = "test2"; private int numberOfShards; private int numberOfReplicas; - private static final Settings DEFAULT_SETTINGS = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build(); + private static final Settings DEFAULT_SETTINGS = Settings.builder() + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) + .build(); private AllocationService allocationService; private ClusterState clusterState; diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/RoutingTableTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/RoutingTableTests.java index eb7b19a6e55c..de9918b1d2b3 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/RoutingTableTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/RoutingTableTests.java @@ -8,7 +8,6 @@ package org.elasticsearch.cluster.routing; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; @@ -55,7 +54,9 @@ public class RoutingTableTests extends ESAllocationTestCase { private int numberOfReplicas; private int shardsPerIndex; private int totalNumberOfShards; - private static final Settings DEFAULT_SETTINGS = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build(); + private static final Settings DEFAULT_SETTINGS = Settings.builder() + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) + .build(); private final AllocationService ALLOCATION_SERVICE = createAllocationService( Settings.builder() .put("cluster.routing.allocation.node_concurrent_recoveries", Integer.MAX_VALUE) // don't limit recoveries diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardsAvailabilityHealthIndicatorServiceTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardsAvailabilityHealthIndicatorServiceTests.java index 33a396434cab..81294c867f54 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardsAvailabilityHealthIndicatorServiceTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardsAvailabilityHealthIndicatorServiceTests.java @@ -45,6 +45,7 @@ import org.elasticsearch.health.SimpleHealthIndicatorDetails; import org.elasticsearch.health.node.HealthInfo; import org.elasticsearch.index.Index; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.indices.ExecutorNames; import org.elasticsearch.indices.SystemDataStreamDescriptor; @@ -614,7 +615,7 @@ public void testShouldBeRedWhenRestartingPrimariesReachedAllocationDelayAndNoRep public void testDiagnosisNotGeneratedWhenNotDrillingDown() { // Index definition, 1 primary no replicas IndexMetadata indexMetadata = IndexMetadata.builder("red-index") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build()) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build()) .numberOfShards(1) .numberOfReplicas(0) .build(); @@ -652,7 +653,7 @@ public void testDiagnosisNotGeneratedWhenNotDrillingDown() { public void testDiagnoseRestoreIndexAfterDataLoss() { // Index definition, 1 primary no replicas IndexMetadata indexMetadata = IndexMetadata.builder("red-index") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build()) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build()) .numberOfShards(1) .numberOfReplicas(0) .build(); @@ -676,13 +677,13 @@ public void testRestoreFromSnapshotReportsFeatureStates() { // affected feature states and indices IndexMetadata featureIndex = IndexMetadata.builder(".feature-index") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build()) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build()) .numberOfShards(1) .numberOfReplicas(0) .build(); IndexMetadata regularIndex = IndexMetadata.builder("regular-index") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build()) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build()) .numberOfShards(1) .numberOfReplicas(0) .build(); @@ -753,12 +754,12 @@ public void testGetRestoreFromSnapshotAffectedResources() { List indexMetadataList = List.of( IndexMetadata.builder(".feature-index") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build()) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build()) .numberOfShards(1) .numberOfReplicas(0) .build(), IndexMetadata.builder("regular-index") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build()) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build()) .numberOfShards(1) .numberOfReplicas(0) .build(), @@ -816,7 +817,7 @@ public void testGetRestoreFromSnapshotAffectedResources() { public void testDiagnoseUnknownAllocationDeciderIssue() { // Index definition, 1 primary no replicas IndexMetadata indexMetadata = IndexMetadata.builder("red-index") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build()) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build()) .numberOfShards(1) .numberOfReplicas(0) .build(); @@ -867,7 +868,7 @@ public void testDiagnoseEnableIndexAllocation() { IndexMetadata indexMetadata = IndexMetadata.builder("red-index") .settings( Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(EnableAllocationDecider.INDEX_ROUTING_ALLOCATION_ENABLE_SETTING.getKey(), "none") .build() ) @@ -899,7 +900,7 @@ public void testNodeAllocationResultWithNullDecision() { IndexMetadata indexMetadata = IndexMetadata.builder("red-index") .settings( Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(EnableAllocationDecider.INDEX_ROUTING_ALLOCATION_ENABLE_SETTING.getKey(), "none") .build() ) @@ -928,7 +929,7 @@ public void testNodeAllocationResultWithNullDecision() { public void testDiagnoseEnableClusterAllocation() { // Index definition, 1 primary no replicas IndexMetadata indexMetadata = IndexMetadata.builder("red-index") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build()) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build()) .numberOfShards(1) .numberOfReplicas(0) .build(); @@ -962,7 +963,7 @@ public void testDiagnoseEnableRoutingAllocation() { IndexMetadata indexMetadata = IndexMetadata.builder("red-index") .settings( Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(EnableAllocationDecider.INDEX_ROUTING_ALLOCATION_ENABLE_SETTING.getKey(), "none") .build() ) @@ -1000,7 +1001,7 @@ public void testDiagnoseEnableDataTiers() { IndexMetadata indexMetadata = IndexMetadata.builder("red-index") .settings( Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(DataTier.TIER_PREFERENCE, DataTier.DATA_HOT) .build() ) @@ -1033,7 +1034,7 @@ public void testDiagnoseIncreaseShardLimitIndexSettingInTier() { IndexMetadata indexMetadata = IndexMetadata.builder("red-index") .settings( Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(DataTier.TIER_PREFERENCE, DataTier.DATA_HOT) .put(ShardsLimitAllocationDecider.INDEX_TOTAL_SHARDS_PER_NODE_SETTING.getKey(), 1) .build() @@ -1092,7 +1093,7 @@ public void testDiagnoseIncreaseShardLimitClusterSettingInTier() { IndexMetadata indexMetadata = IndexMetadata.builder("red-index") .settings( Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(DataTier.TIER_PREFERENCE, DataTier.DATA_HOT) .build() ) @@ -1156,7 +1157,7 @@ public void testDiagnoseIncreaseShardLimitIndexSettingInGeneral() { IndexMetadata indexMetadata = IndexMetadata.builder("red-index") .settings( Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(DataTier.TIER_PREFERENCE, DataTier.DATA_HOT) .put(ShardsLimitAllocationDecider.INDEX_TOTAL_SHARDS_PER_NODE_SETTING.getKey(), 1) .build() @@ -1215,7 +1216,7 @@ public void testDiagnoseIncreaseShardLimitClusterSettingInGeneral() { IndexMetadata indexMetadata = IndexMetadata.builder("red-index") .settings( Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(DataTier.TIER_PREFERENCE, DataTier.DATA_HOT) .build() ) @@ -1279,7 +1280,7 @@ public void testDiagnoseMigrateDataRequiredToDataTiers() { IndexMetadata indexMetadata = IndexMetadata.builder("red-index") .settings( Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(DataTier.TIER_PREFERENCE, DataTier.DATA_HOT) .put(INDEX_ROUTING_REQUIRE_GROUP_PREFIX + ".data", "hot") .build() @@ -1315,7 +1316,7 @@ public void testDiagnoseMigrateDataIncludedToDataTiers() { IndexMetadata indexMetadata = IndexMetadata.builder("red-index") .settings( Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(DataTier.TIER_PREFERENCE, DataTier.DATA_HOT) .put(INDEX_ROUTING_INCLUDE_GROUP_PREFIX + ".data", "hot") .build() @@ -1351,7 +1352,7 @@ public void testDiagnoseOtherFilteringIssue() { IndexMetadata indexMetadata = IndexMetadata.builder("red-index") .settings( Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(DataTier.TIER_PREFERENCE, DataTier.DATA_HOT) .build() ) @@ -1386,7 +1387,7 @@ public void testDiagnoseIncreaseTierCapacity() { IndexMetadata indexMetadata = IndexMetadata.builder("red-index") .settings( Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(DataTier.TIER_PREFERENCE, DataTier.DATA_HOT) .build() ) @@ -1425,7 +1426,7 @@ public void testDiagnoseIncreaseNodeCapacity() { IndexMetadata indexMetadata = IndexMetadata.builder("red-index") .settings( Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(DataTier.TIER_PREFERENCE, DataTier.DATA_HOT) .build() ) @@ -1677,7 +1678,7 @@ private static ClusterState createClusterStateWith(List index List indices = indexRoutes.stream() .map( table -> IndexMetadata.builder(table.getIndex().getName()) - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build()) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build()) .numberOfShards(1) .numberOfReplicas(table.size() - 1) .build() @@ -1777,7 +1778,7 @@ private static Map addDefaults(Map override) { private static IndexRoutingTable index(String name, ShardAllocation primaryState, ShardAllocation... replicaStates) { return index( IndexMetadata.builder(name) - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build()) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build()) .numberOfShards(1) .numberOfReplicas(replicaStates.length) .build(), diff --git a/server/src/test/java/org/elasticsearch/common/lucene/uid/VersionsTests.java b/server/src/test/java/org/elasticsearch/common/lucene/uid/VersionsTests.java index 64a211ccaa50..976add854c58 100644 --- a/server/src/test/java/org/elasticsearch/common/lucene/uid/VersionsTests.java +++ b/server/src/test/java/org/elasticsearch/common/lucene/uid/VersionsTests.java @@ -18,7 +18,6 @@ import org.apache.lucene.index.Term; import org.apache.lucene.store.Directory; import org.apache.lucene.util.BytesRef; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.DataStream; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.routing.IndexRouting; @@ -274,7 +273,7 @@ public void testTimeSeriesLoadDocIdAndVersion() throws Exception { private static String createTSDBId(long timestamp) { Settings.Builder b = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.INDEX_ROUTING_PATH.getKey(), "field"); IndexMetadata indexMetadata = IndexMetadata.builder("idx").settings(b).numberOfShards(1).numberOfReplicas(0).build(); IndexRouting.ExtractFromSource.Builder routingBuilder = ((IndexRouting.ExtractFromSource) IndexRouting.fromIndexMetadata( diff --git a/server/src/test/java/org/elasticsearch/gateway/PersistedClusterStateServiceTests.java b/server/src/test/java/org/elasticsearch/gateway/PersistedClusterStateServiceTests.java index a9d8fb0f09c0..d464c646c103 100644 --- a/server/src/test/java/org/elasticsearch/gateway/PersistedClusterStateServiceTests.java +++ b/server/src/test/java/org/elasticsearch/gateway/PersistedClusterStateServiceTests.java @@ -727,7 +727,7 @@ public void testFailsIfIndexMetadataIsDuplicated() throws IOException { Settings.builder() .put(IndexMetadata.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) .put(IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, indexUUID) ) ) @@ -798,7 +798,7 @@ public void testPersistsAndReloadsIndexMetadataIffVersionOrTermChanges() throws Settings.builder() .put(IndexMetadata.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) .put(IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, indexUUID) ) ) @@ -932,7 +932,7 @@ public void testPersistsAndReloadsIndexMetadataForMultipleIndices() throws IOExc Settings.builder() .put(IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 1) .put(IndexMetadata.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, updatedIndexUuid) ) ) @@ -944,7 +944,7 @@ public void testPersistsAndReloadsIndexMetadataForMultipleIndices() throws IOExc Settings.builder() .put(IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 1) .put(IndexMetadata.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, deletedIndexUuid) ) ) @@ -991,7 +991,7 @@ public void testPersistsAndReloadsIndexMetadataForMultipleIndices() throws IOExc Settings.builder() .put(IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 1) .put(IndexMetadata.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, addedIndexUuid) ) ) @@ -1041,7 +1041,7 @@ public void testReloadsMetadataAcrossMultipleSegments() throws IOException { Settings.builder() .put(IndexMetadata.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) .put(IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()) ) ) @@ -1075,7 +1075,7 @@ public void testHandlesShuffledDocuments() throws IOException { Settings.builder() .put(IndexMetadata.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) .put(IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID(random())) ) ); @@ -1255,7 +1255,7 @@ public void testSlowLogging() throws IOException, IllegalAccessException { Settings.builder() .put(IndexMetadata.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) .put(IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, "test-uuid") ) ) @@ -1370,7 +1370,7 @@ public void testLimitsFileCount() throws IOException { Settings.builder() .put(IndexMetadata.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) .put(IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID(random())) ) ) @@ -1594,7 +1594,7 @@ public void testFailsIfMappingIsDuplicated() throws IOException { Settings.builder() .put(IndexMetadata.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) .put(IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID(random())) ) ) @@ -1649,7 +1649,7 @@ public void testFailsIfMappingIsMissing() throws IOException { Settings.builder() .put(IndexMetadata.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) .put(IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID(random())) ) ) @@ -1715,7 +1715,7 @@ public void testDeduplicatedMappings() throws IOException { Settings.builder() .put(IndexMetadata.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) .put(IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID(random())) ) ); @@ -1742,7 +1742,7 @@ public void testDeduplicatedMappings() throws IOException { Settings.builder() .put(IndexMetadata.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) .put(IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID(random())) ) ); diff --git a/server/src/test/java/org/elasticsearch/index/IndexModuleTests.java b/server/src/test/java/org/elasticsearch/index/IndexModuleTests.java index 1d5cead59af1..719fa5748fff 100644 --- a/server/src/test/java/org/elasticsearch/index/IndexModuleTests.java +++ b/server/src/test/java/org/elasticsearch/index/IndexModuleTests.java @@ -23,7 +23,6 @@ import org.apache.lucene.store.FilterDirectory; import org.apache.lucene.tests.index.AssertingDirectoryReader; import org.apache.lucene.util.SetOnce.AlreadySetException; -import org.elasticsearch.Version; import org.elasticsearch.action.admin.indices.flush.FlushRequest; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.cluster.metadata.IndexMetadata; @@ -165,7 +164,7 @@ public void beforeShardFoldersDeleted(ShardId shardId, IndexSettings indexSettin public void setUp() throws Exception { super.setUp(); settings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()) .build(); indicesQueryCache = new IndicesQueryCache(settings); @@ -247,7 +246,7 @@ public void testWrapperIsBound() throws IOException { public void testRegisterIndexStore() throws IOException { final Settings settings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()) .put(IndexModule.INDEX_STORE_TYPE_SETTING.getKey(), "foo_store") .build(); @@ -273,7 +272,7 @@ public void testRegisterIndexStore() throws IOException { public void testDirectoryWrapper() throws IOException { final Path homeDir = createTempDir(); final Settings settings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(Environment.PATH_HOME_SETTING.getKey(), homeDir.toString()) .build(); final IndexSettings indexSettings = IndexSettingsModule.newIndexSettings(index, settings); @@ -416,7 +415,7 @@ public void onNewReaderContext(ReaderContext readerContext) { public void testAddSimilarity() throws IOException { Settings settings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put("index.similarity.my_similarity.type", "test_similarity") .put("index.similarity.my_similarity.key", "there is a key") .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()) @@ -458,7 +457,7 @@ public void testFrozen() { public void testSetupUnknownSimilarity() { Settings settings = Settings.builder() .put("index.similarity.my_similarity.type", "test_similarity") - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()) .build(); final IndexSettings indexSettings = IndexSettingsModule.newIndexSettings("foo", settings); @@ -471,7 +470,7 @@ public void testSetupWithoutType() { Settings settings = Settings.builder() .put("index.similarity.my_similarity.foo", "bar") .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .build(); final IndexSettings indexSettings = IndexSettingsModule.newIndexSettings("foo", settings); IndexModule module = createIndexModule(indexSettings, emptyAnalysisRegistry, indexNameExpressionResolver); @@ -482,7 +481,7 @@ public void testSetupWithoutType() { public void testForceCustomQueryCache() throws IOException { Settings settings = Settings.builder() .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .build(); final IndexSettings indexSettings = IndexSettingsModule.newIndexSettings("foo", settings); IndexModule module = createIndexModule(indexSettings, emptyAnalysisRegistry, indexNameExpressionResolver); @@ -505,7 +504,7 @@ public void testForceCustomQueryCache() throws IOException { public void testDefaultQueryCacheImplIsSelected() throws IOException { Settings settings = Settings.builder() .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .build(); final IndexSettings indexSettings = IndexSettingsModule.newIndexSettings("foo", settings); IndexModule module = createIndexModule(indexSettings, emptyAnalysisRegistry, indexNameExpressionResolver); @@ -518,7 +517,7 @@ public void testDisableQueryCacheHasPrecedenceOverForceQueryCache() throws IOExc Settings settings = Settings.builder() .put(IndexModule.INDEX_QUERY_CACHE_ENABLED_SETTING.getKey(), false) .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .build(); final IndexSettings indexSettings = IndexSettingsModule.newIndexSettings("foo", settings); IndexModule module = createIndexModule(indexSettings, emptyAnalysisRegistry, indexNameExpressionResolver); @@ -531,7 +530,7 @@ public void testDisableQueryCacheHasPrecedenceOverForceQueryCache() throws IOExc public void testCustomQueryCacheCleanedUpIfIndexServiceCreationFails() { Settings settings = Settings.builder() .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .build(); final IndexSettings indexSettings = IndexSettingsModule.newIndexSettings("foo", settings); IndexModule module = createIndexModule(indexSettings, emptyAnalysisRegistry, indexNameExpressionResolver); @@ -549,7 +548,7 @@ public void testCustomQueryCacheCleanedUpIfIndexServiceCreationFails() { public void testIndexAnalyzersCleanedUpIfIndexServiceCreationFails() { Settings settings = Settings.builder() .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .build(); final IndexSettings indexSettings = IndexSettingsModule.newIndexSettings("foo", settings); @@ -616,7 +615,7 @@ public void testMmapNotAllowed() { public void testRegisterCustomRecoveryStateFactory() throws IOException { final Settings settings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()) .put(IndexModule.INDEX_RECOVERY_TYPE_SETTING.getKey(), "test_recovery") .build(); diff --git a/server/src/test/java/org/elasticsearch/index/IndexSettingsTests.java b/server/src/test/java/org/elasticsearch/index/IndexSettingsTests.java index 0cb39220ddc0..de4eafed8f53 100644 --- a/server/src/test/java/org/elasticsearch/index/IndexSettingsTests.java +++ b/server/src/test/java/org/elasticsearch/index/IndexSettingsTests.java @@ -155,7 +155,10 @@ public void testSettingsConsistency() { settings.updateIndexMetadata( newIndexMeta( "index", - Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).put("index.test.setting.int", 42).build() + Settings.builder() + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) + .put("index.test.setting.int", 42) + .build() ) ); fail("version has changed"); @@ -197,7 +200,7 @@ public void testSettingsConsistency() { metadata = newIndexMeta( "index", Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, "0xdeadbeef") .build() ); @@ -206,7 +209,10 @@ public void testSettingsConsistency() { settings.updateIndexMetadata( newIndexMeta( "index", - Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).put("index.test.setting.int", 42).build() + Settings.builder() + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) + .put("index.test.setting.int", 42) + .build() ) ); fail("uuid missing/change"); @@ -257,7 +263,7 @@ public void testUpdateDurability() { IndexMetadata metadata = newIndexMeta( "index", Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexSettings.INDEX_TRANSLOG_DURABILITY_SETTING.getKey(), "async") .build() ); @@ -268,7 +274,7 @@ public void testUpdateDurability() { ); assertEquals(Translog.Durability.REQUEST, settings.getTranslogDurability()); - metadata = newIndexMeta("index", Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build()); + metadata = newIndexMeta("index", Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build()); settings = new IndexSettings(metadata, Settings.EMPTY); assertEquals(Translog.Durability.REQUEST, settings.getTranslogDurability()); // test default } @@ -277,7 +283,7 @@ public void testIsWarmerEnabled() { IndexMetadata metadata = newIndexMeta( "index", Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexSettings.INDEX_WARMER_ENABLED_SETTING.getKey(), false) .build() ); @@ -287,7 +293,7 @@ public void testIsWarmerEnabled() { newIndexMeta("index", Settings.builder().put(IndexSettings.INDEX_WARMER_ENABLED_SETTING.getKey(), "true").build()) ); assertTrue(settings.isWarmerEnabled()); - metadata = newIndexMeta("index", Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build()); + metadata = newIndexMeta("index", Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build()); settings = new IndexSettings(metadata, Settings.EMPTY); assertTrue(settings.isWarmerEnabled()); } @@ -297,7 +303,7 @@ public void testRefreshInterval() { IndexMetadata metadata = newIndexMeta( "index", Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), refreshInterval) .build() ); @@ -327,7 +333,7 @@ public void testRefreshInterval() { public void testDefaultRefreshInterval() { IndexMetadata metadata = newIndexMeta( "index", - Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build() + Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build() ); IndexSettings settings = new IndexSettings(metadata, Settings.EMPTY); assertEquals(DEFAULT_REFRESH_INTERVAL, settings.getRefreshInterval()); @@ -337,7 +343,7 @@ public void testDisableRefreshInterval() { IndexMetadata metadata = newIndexMeta( "index", Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), TimeValue.MINUS_ONE) .build() ); @@ -349,7 +355,7 @@ public void testNegativeRefreshInterval() { IndexMetadata metadata = newIndexMeta( "index", Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), "-10s") .build() ); @@ -361,7 +367,7 @@ public void testStatelessDefaultRefreshInterval() { IndexMetadata metadata = newIndexMeta( "index", Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(EXISTING_SHARDS_ALLOCATOR_SETTING.getKey(), "stateless") .build() ); @@ -373,7 +379,7 @@ public void testStatelessMinRefreshInterval() { IndexMetadata metadata = newIndexMeta( "index", Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(EXISTING_SHARDS_ALLOCATOR_SETTING.getKey(), "stateless") .put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), "2s") .put(SETTING_INDEX_VERSION_CREATED.getKey(), IndexVersion.V_8_10_0.id() + 1) @@ -389,7 +395,7 @@ public void testStatelessDisableRefreshInterval() { IndexMetadata metadata = newIndexMeta( "index", Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(EXISTING_SHARDS_ALLOCATOR_SETTING.getKey(), "stateless") .put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), TimeValue.MINUS_ONE) .build() @@ -402,7 +408,7 @@ public void testStatelessFastRefreshDefaultRefreshInterval() { IndexMetadata metadata = IndexMetadata.builder("index") .system(true) .settings( - indexSettings(IndexVersion.current(), 1, 1).put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + indexSettings(IndexVersion.current(), 1, 1).put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(EXISTING_SHARDS_ALLOCATOR_SETTING.getKey(), "stateless") .put(INDEX_FAST_REFRESH_SETTING.getKey(), true) .build() @@ -416,7 +422,7 @@ public void testStatelessFastRefreshDisableRefreshInterval() { IndexMetadata metadata = IndexMetadata.builder("index") .system(true) .settings( - indexSettings(IndexVersion.current(), 1, 1).put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + indexSettings(IndexVersion.current(), 1, 1).put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(EXISTING_SHARDS_ALLOCATOR_SETTING.getKey(), "stateless") .put(INDEX_FAST_REFRESH_SETTING.getKey(), true) .put(IndexSettings.INDEX_REFRESH_INTERVAL_SETTING.getKey(), TimeValue.MINUS_ONE) @@ -440,7 +446,7 @@ public void testMaxResultWindow() { IndexMetadata metadata = newIndexMeta( "index", Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexSettings.MAX_RESULT_WINDOW_SETTING.getKey(), 15) .build() ); @@ -453,7 +459,7 @@ public void testMaxResultWindow() { settings.updateIndexMetadata(newIndexMeta("index", Settings.EMPTY)); assertEquals(IndexSettings.MAX_RESULT_WINDOW_SETTING.get(Settings.EMPTY).intValue(), settings.getMaxResultWindow()); - metadata = newIndexMeta("index", Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build()); + metadata = newIndexMeta("index", Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build()); settings = new IndexSettings(metadata, Settings.EMPTY); assertEquals(IndexSettings.MAX_RESULT_WINDOW_SETTING.get(Settings.EMPTY).intValue(), settings.getMaxResultWindow()); } @@ -462,7 +468,7 @@ public void testMaxInnerResultWindow() { IndexMetadata metadata = newIndexMeta( "index", Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexSettings.MAX_INNER_RESULT_WINDOW_SETTING.getKey(), 200) .build() ); @@ -475,7 +481,7 @@ public void testMaxInnerResultWindow() { settings.updateIndexMetadata(newIndexMeta("index", Settings.EMPTY)); assertEquals(IndexSettings.MAX_INNER_RESULT_WINDOW_SETTING.get(Settings.EMPTY).intValue(), settings.getMaxInnerResultWindow()); - metadata = newIndexMeta("index", Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build()); + metadata = newIndexMeta("index", Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build()); settings = new IndexSettings(metadata, Settings.EMPTY); assertEquals(IndexSettings.MAX_INNER_RESULT_WINDOW_SETTING.get(Settings.EMPTY).intValue(), settings.getMaxInnerResultWindow()); } @@ -484,7 +490,7 @@ public void testMaxDocvalueFields() { IndexMetadata metadata = newIndexMeta( "index", Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexSettings.MAX_DOCVALUE_FIELDS_SEARCH_SETTING.getKey(), 200) .build() ); @@ -497,7 +503,7 @@ public void testMaxDocvalueFields() { settings.updateIndexMetadata(newIndexMeta("index", Settings.EMPTY)); assertEquals(IndexSettings.MAX_DOCVALUE_FIELDS_SEARCH_SETTING.get(Settings.EMPTY).intValue(), settings.getMaxDocvalueFields()); - metadata = newIndexMeta("index", Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build()); + metadata = newIndexMeta("index", Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build()); settings = new IndexSettings(metadata, Settings.EMPTY); assertEquals(IndexSettings.MAX_DOCVALUE_FIELDS_SEARCH_SETTING.get(Settings.EMPTY).intValue(), settings.getMaxDocvalueFields()); } @@ -506,7 +512,7 @@ public void testMaxScriptFields() { IndexMetadata metadata = newIndexMeta( "index", Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexSettings.MAX_SCRIPT_FIELDS_SETTING.getKey(), 100) .build() ); @@ -519,7 +525,7 @@ public void testMaxScriptFields() { settings.updateIndexMetadata(newIndexMeta("index", Settings.EMPTY)); assertEquals(IndexSettings.MAX_SCRIPT_FIELDS_SETTING.get(Settings.EMPTY).intValue(), settings.getMaxScriptFields()); - metadata = newIndexMeta("index", Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build()); + metadata = newIndexMeta("index", Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build()); settings = new IndexSettings(metadata, Settings.EMPTY); assertEquals(IndexSettings.MAX_SCRIPT_FIELDS_SETTING.get(Settings.EMPTY).intValue(), settings.getMaxScriptFields()); } @@ -528,7 +534,7 @@ public void testMaxRegexLengthSetting() { IndexMetadata metadata = newIndexMeta( "index", Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexSettings.MAX_REGEX_LENGTH_SETTING.getKey(), 99) .build() ); @@ -541,7 +547,7 @@ public void testMaxRegexLengthSetting() { settings.updateIndexMetadata(newIndexMeta("index", Settings.EMPTY)); assertEquals(IndexSettings.MAX_REGEX_LENGTH_SETTING.get(Settings.EMPTY).intValue(), settings.getMaxRegexLength()); - metadata = newIndexMeta("index", Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build()); + metadata = newIndexMeta("index", Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build()); settings = new IndexSettings(metadata, Settings.EMPTY); assertEquals(IndexSettings.MAX_REGEX_LENGTH_SETTING.get(Settings.EMPTY).intValue(), settings.getMaxRegexLength()); } @@ -551,7 +557,7 @@ public void testGCDeletesSetting() { IndexMetadata metadata = newIndexMeta( "index", Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexSettings.INDEX_GC_DELETES_SETTING.getKey(), gcDeleteSetting.getStringRep()) .build() ); @@ -602,7 +608,7 @@ public void testTranslogFlushSizeThreshold() { IndexMetadata metadata = newIndexMeta( "index", Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexSettings.INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING.getKey(), translogFlushThresholdSize.getBytes() + "B") .build() ); @@ -630,7 +636,7 @@ public void testTranslogGenerationSizeThreshold() { final ByteSizeValue actualValue = ByteSizeValue.parseBytesSizeValue(size.getBytes() + "B", key); final IndexMetadata metadata = newIndexMeta( "index", - Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).put(key, size.getBytes() + "B").build() + Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).put(key, size.getBytes() + "B").build() ); final IndexSettings settings = new IndexSettings(metadata, Settings.EMPTY); assertEquals(actualValue, settings.getGenerationThresholdSize()); diff --git a/server/src/test/java/org/elasticsearch/index/IndexingSlowLogTests.java b/server/src/test/java/org/elasticsearch/index/IndexingSlowLogTests.java index 800e3a0936a3..fb83e817c052 100644 --- a/server/src/test/java/org/elasticsearch/index/IndexingSlowLogTests.java +++ b/server/src/test/java/org/elasticsearch/index/IndexingSlowLogTests.java @@ -14,7 +14,6 @@ import org.apache.logging.log4j.core.LoggerContext; import org.apache.lucene.document.NumericDocValuesField; import org.apache.lucene.index.Term; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.UUIDs; import org.elasticsearch.common.bytes.BytesArray; @@ -126,7 +125,7 @@ public void testTwoLoggersDifferentLevel() { createIndexMetadata( "index1", Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID()) .put(IndexingSlowLog.INDEX_INDEXING_SLOWLOG_THRESHOLD_INDEX_WARN_SETTING.getKey(), "40nanos") .build() @@ -139,7 +138,7 @@ public void testTwoLoggersDifferentLevel() { createIndexMetadata( "index2", Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID()) .put(IndexingSlowLog.INDEX_INDEXING_SLOWLOG_THRESHOLD_INDEX_TRACE_SETTING.getKey(), "10nanos") .build() @@ -188,7 +187,7 @@ private IndexMetadata createIndexMetadata(String index, Settings build) { private Settings settings(String uuid) { return Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, uuid) .put(IndexingSlowLog.INDEX_INDEXING_SLOWLOG_THRESHOLD_INDEX_TRACE_SETTING.getKey(), "10nanos") .put(IndexingSlowLog.INDEX_INDEXING_SLOWLOG_THRESHOLD_INDEX_DEBUG_SETTING.getKey(), "20nanos") @@ -307,7 +306,7 @@ public void testReformatSetting() { IndexMetadata metadata = newIndexMeta( "index", Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexingSlowLog.INDEX_INDEXING_SLOWLOG_REFORMAT_SETTING.getKey(), false) .build() ); @@ -327,7 +326,7 @@ public void testReformatSetting() { settings.updateIndexMetadata(newIndexMeta("index", Settings.EMPTY)); assertTrue(log.isReformat()); - metadata = newIndexMeta("index", Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build()); + metadata = newIndexMeta("index", Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build()); settings = new IndexSettings(metadata, Settings.EMPTY); log = new IndexingSlowLog(settings); assertTrue(log.isReformat()); @@ -354,7 +353,7 @@ public void testSetLevels() { IndexMetadata metadata = newIndexMeta( "index", Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexingSlowLog.INDEX_INDEXING_SLOWLOG_THRESHOLD_INDEX_TRACE_SETTING.getKey(), "100ms") .put(IndexingSlowLog.INDEX_INDEXING_SLOWLOG_THRESHOLD_INDEX_DEBUG_SETTING.getKey(), "200ms") .put(IndexingSlowLog.INDEX_INDEXING_SLOWLOG_THRESHOLD_INDEX_INFO_SETTING.getKey(), "300ms") @@ -385,7 +384,7 @@ public void testSetLevels() { assertEquals(TimeValue.timeValueMillis(320).nanos(), log.getIndexInfoThreshold()); assertEquals(TimeValue.timeValueMillis(420).nanos(), log.getIndexWarnThreshold()); - metadata = newIndexMeta("index", Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build()); + metadata = newIndexMeta("index", Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build()); settings.updateIndexMetadata(metadata); assertEquals(TimeValue.timeValueMillis(-1).nanos(), log.getIndexTraceThreshold()); assertEquals(TimeValue.timeValueMillis(-1).nanos(), log.getIndexDebugThreshold()); diff --git a/server/src/test/java/org/elasticsearch/index/MergeSchedulerSettingsTests.java b/server/src/test/java/org/elasticsearch/index/MergeSchedulerSettingsTests.java index 9d3b1081e098..9ee78a3008f3 100644 --- a/server/src/test/java/org/elasticsearch/index/MergeSchedulerSettingsTests.java +++ b/server/src/test/java/org/elasticsearch/index/MergeSchedulerSettingsTests.java @@ -14,7 +14,6 @@ import org.apache.logging.log4j.core.LogEvent; import org.apache.logging.log4j.core.appender.AbstractAppender; import org.apache.logging.log4j.core.filter.RegexFilter; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.settings.Settings; @@ -118,7 +117,7 @@ public void testUpdateMergeMaxThreadCount() throws Exception { } private static IndexMetadata createMetadata(int maxThreadCount, int maxMergeCount, int numProc) { - Settings.Builder builder = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT); + Settings.Builder builder = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()); if (maxThreadCount != -1) { builder.put(MAX_THREAD_COUNT_SETTING.getKey(), maxThreadCount); } diff --git a/server/src/test/java/org/elasticsearch/index/SearchSlowLogTests.java b/server/src/test/java/org/elasticsearch/index/SearchSlowLogTests.java index 756cdeaacb27..ecc55c36f61c 100644 --- a/server/src/test/java/org/elasticsearch/index/SearchSlowLogTests.java +++ b/server/src/test/java/org/elasticsearch/index/SearchSlowLogTests.java @@ -12,7 +12,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.core.LoggerContext; -import org.elasticsearch.Version; import org.elasticsearch.action.search.SearchShardTask; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.UUIDs; @@ -147,7 +146,7 @@ public void testLevelPrecedence() { private Settings.Builder settings(String uuid) { return Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, uuid) .put(SearchSlowLog.INDEX_SEARCH_SLOWLOG_THRESHOLD_FETCH_TRACE_SETTING.getKey(), "10nanos") .put(SearchSlowLog.INDEX_SEARCH_SLOWLOG_THRESHOLD_FETCH_DEBUG_SETTING.getKey(), "20nanos") @@ -167,7 +166,7 @@ public void testTwoLoggersDifferentLevel() { createIndexMetadata( "index-1", Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID()) .put(SearchSlowLog.INDEX_SEARCH_SLOWLOG_THRESHOLD_FETCH_WARN_SETTING.getKey(), "40nanos") .put(SearchSlowLog.INDEX_SEARCH_SLOWLOG_THRESHOLD_QUERY_WARN_SETTING.getKey(), "40nanos") @@ -180,7 +179,7 @@ public void testTwoLoggersDifferentLevel() { createIndexMetadata( "index-2", Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID()) .put(SearchSlowLog.INDEX_SEARCH_SLOWLOG_THRESHOLD_FETCH_TRACE_SETTING.getKey(), "10nanos") .put(SearchSlowLog.INDEX_SEARCH_SLOWLOG_THRESHOLD_QUERY_TRACE_SETTING.getKey(), "10nanos") @@ -275,7 +274,7 @@ public void testSetQueryLevels() { IndexMetadata metadata = newIndexMeta( "index", Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(SearchSlowLog.INDEX_SEARCH_SLOWLOG_THRESHOLD_QUERY_TRACE_SETTING.getKey(), "100ms") .put(SearchSlowLog.INDEX_SEARCH_SLOWLOG_THRESHOLD_QUERY_DEBUG_SETTING.getKey(), "200ms") .put(SearchSlowLog.INDEX_SEARCH_SLOWLOG_THRESHOLD_QUERY_INFO_SETTING.getKey(), "300ms") @@ -306,7 +305,7 @@ public void testSetQueryLevels() { assertEquals(TimeValue.timeValueMillis(320).nanos(), log.getQueryInfoThreshold()); assertEquals(TimeValue.timeValueMillis(420).nanos(), log.getQueryWarnThreshold()); - metadata = newIndexMeta("index", Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build()); + metadata = newIndexMeta("index", Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build()); settings.updateIndexMetadata(metadata); assertEquals(TimeValue.timeValueMillis(-1).nanos(), log.getQueryTraceThreshold()); assertEquals(TimeValue.timeValueMillis(-1).nanos(), log.getQueryDebugThreshold()); @@ -381,7 +380,7 @@ public void testSetFetchLevels() { IndexMetadata metadata = newIndexMeta( "index", Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(SearchSlowLog.INDEX_SEARCH_SLOWLOG_THRESHOLD_FETCH_TRACE_SETTING.getKey(), "100ms") .put(SearchSlowLog.INDEX_SEARCH_SLOWLOG_THRESHOLD_FETCH_DEBUG_SETTING.getKey(), "200ms") .put(SearchSlowLog.INDEX_SEARCH_SLOWLOG_THRESHOLD_FETCH_INFO_SETTING.getKey(), "300ms") @@ -412,7 +411,7 @@ public void testSetFetchLevels() { assertEquals(TimeValue.timeValueMillis(320).nanos(), log.getFetchInfoThreshold()); assertEquals(TimeValue.timeValueMillis(420).nanos(), log.getFetchWarnThreshold()); - metadata = newIndexMeta("index", Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build()); + metadata = newIndexMeta("index", Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build()); settings.updateIndexMetadata(metadata); assertEquals(TimeValue.timeValueMillis(-1).nanos(), log.getFetchTraceThreshold()); assertEquals(TimeValue.timeValueMillis(-1).nanos(), log.getFetchDebugThreshold()); diff --git a/server/src/test/java/org/elasticsearch/index/analysis/AnalysisRegistryTests.java b/server/src/test/java/org/elasticsearch/index/analysis/AnalysisRegistryTests.java index 5b7af56b7e6e..e07bf081af52 100644 --- a/server/src/test/java/org/elasticsearch/index/analysis/AnalysisRegistryTests.java +++ b/server/src/test/java/org/elasticsearch/index/analysis/AnalysisRegistryTests.java @@ -26,6 +26,7 @@ import org.elasticsearch.env.TestEnvironment; import org.elasticsearch.index.IndexService.IndexCreationContext; import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.mapper.MapperException; import org.elasticsearch.indices.analysis.AnalysisModule; import org.elasticsearch.indices.analysis.AnalysisModule.AnalysisProvider; @@ -84,7 +85,10 @@ public List getPreConfiguredTokenFilters() { } private static IndexSettings indexSettingsOfCurrentVersion(Settings.Builder settings) { - return IndexSettingsModule.newIndexSettings("index", settings.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build()); + return IndexSettingsModule.newIndexSettings( + "index", + settings.put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build() + ); } @Override @@ -234,7 +238,7 @@ public void testOverrideDefaultSearchAnalyzer() { public void testConfigureCamelCaseTokenFilter() throws IOException { Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).build(); Settings indexSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put("index.analysis.filter.testFilter.type", "mock") .put("index.analysis.filter.test_filter.type", "mock") .put("index.analysis.analyzer.custom_analyzer_with_camel_case.tokenizer", "standard") @@ -304,7 +308,7 @@ public Map> getTokenFilters() { public void testBuiltInAnalyzersAreCached() throws IOException { Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).build(); - Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build(); + Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build(); IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("index", indexSettings); IndexAnalyzers indexAnalyzers = emptyAnalysisRegistry(settings).build(IndexCreationContext.CREATE_INDEX, idxSettings); IndexAnalyzers otherIndexAnalyzers = emptyAnalysisRegistry(settings).build(IndexCreationContext.CREATE_INDEX, idxSettings); diff --git a/server/src/test/java/org/elasticsearch/index/analysis/ReloadableCustomAnalyzerTests.java b/server/src/test/java/org/elasticsearch/index/analysis/ReloadableCustomAnalyzerTests.java index 1b9fccb46ec0..f085f43ec892 100644 --- a/server/src/test/java/org/elasticsearch/index/analysis/ReloadableCustomAnalyzerTests.java +++ b/server/src/test/java/org/elasticsearch/index/analysis/ReloadableCustomAnalyzerTests.java @@ -12,11 +12,11 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; import org.elasticsearch.ExceptionsHelper; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexService.IndexCreationContext; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.test.ESTestCase; import org.junit.BeforeClass; @@ -32,7 +32,7 @@ public class ReloadableCustomAnalyzerTests extends ESTestCase { private static TestAnalysis testAnalysis; - private static Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build(); + private static Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build(); private static TokenFilterFactory NO_OP_SEARCH_TIME_FILTER = new AbstractTokenFilterFactory("my_filter", Settings.EMPTY) { @Override diff --git a/server/src/test/java/org/elasticsearch/index/mapper/IndexFieldTypeTests.java b/server/src/test/java/org/elasticsearch/index/mapper/IndexFieldTypeTests.java index e1202a3acf0c..796a336e1a2e 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/IndexFieldTypeTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/IndexFieldTypeTests.java @@ -9,12 +9,12 @@ import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.MatchNoDocsQuery; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.query.QueryShardException; import org.elasticsearch.index.query.SearchExecutionContext; import org.elasticsearch.test.ESTestCase; @@ -54,7 +54,7 @@ public void testRegexpQuery() { private SearchExecutionContext createContext() { IndexMetadata indexMetadata = IndexMetadata.builder("index") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(1) .numberOfReplicas(0) .build(); diff --git a/server/src/test/java/org/elasticsearch/index/mapper/RangeFieldTypeTests.java b/server/src/test/java/org/elasticsearch/index/mapper/RangeFieldTypeTests.java index 57b111172dcb..5bd9eb39d6bf 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/RangeFieldTypeTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/RangeFieldTypeTests.java @@ -19,13 +19,13 @@ import org.apache.lucene.search.Query; import org.apache.lucene.util.BytesRef; import org.elasticsearch.ElasticsearchParseException; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.geo.ShapeRelation; import org.elasticsearch.common.network.InetAddresses; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.time.DateFormatter; import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.mapper.DateFieldMapper.DateFieldType; import org.elasticsearch.index.mapper.RangeFieldMapper.RangeFieldType; import org.elasticsearch.index.query.QueryShardException; @@ -202,7 +202,7 @@ public void testFromLargerToErrors() throws Exception { } private SearchExecutionContext createContext() { - Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build(); + Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build(); IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(randomAlphaOfLengthBetween(1, 10), indexSettings); return SearchExecutionContextHelper.createSimple(idxSettings, parserConfig(), writableRegistry()); } diff --git a/server/src/test/java/org/elasticsearch/index/mapper/TextFieldAnalyzerModeTests.java b/server/src/test/java/org/elasticsearch/index/mapper/TextFieldAnalyzerModeTests.java index cbeafd0ea404..8cb3ecef4c35 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/TextFieldAnalyzerModeTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/TextFieldAnalyzerModeTests.java @@ -11,7 +11,6 @@ import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.standard.StandardAnalyzer; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.IndexVersion; @@ -42,7 +41,7 @@ private static Map defaultAnalyzers() { } private static final IndexMetadata EMPTY_INDEX_METADATA = IndexMetadata.builder("") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(1) .numberOfReplicas(0) .build(); diff --git a/server/src/test/java/org/elasticsearch/index/mapper/TypeParsersTests.java b/server/src/test/java/org/elasticsearch/index/mapper/TypeParsersTests.java index 35392498a9c7..31d39cc167b9 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/TypeParsersTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/TypeParsersTests.java @@ -9,7 +9,6 @@ package org.elasticsearch.index.mapper; import org.elasticsearch.TransportVersion; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.settings.Settings; @@ -77,7 +76,7 @@ public void testMultiFieldWithinMultiField() throws IOException { when(mapperService.getIndexAnalyzers()).thenReturn(indexAnalyzers); Settings settings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .build(); diff --git a/server/src/test/java/org/elasticsearch/index/shard/ShardPathTests.java b/server/src/test/java/org/elasticsearch/index/shard/ShardPathTests.java index 5d0171350632..0df76c6a950a 100644 --- a/server/src/test/java/org/elasticsearch/index/shard/ShardPathTests.java +++ b/server/src/test/java/org/elasticsearch/index/shard/ShardPathTests.java @@ -7,7 +7,6 @@ */ package org.elasticsearch.index.shard; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.routing.AllocationId; import org.elasticsearch.common.settings.Settings; @@ -17,6 +16,7 @@ import org.elasticsearch.env.ShardLock; import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.IndexSettingsModule; @@ -190,7 +190,7 @@ public void testShardPathSelection() throws IOException { assertThat(List.of(paths), hasItem(ShardPath.getPathWithMostFreeSpace(env))); ShardId shardId = new ShardId("foo", "0xDEADBEEF", 0); - Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build(); + Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build(); IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(randomAlphaOfLengthBetween(1, 10), indexSettings); ShardPath shardPath = ShardPath.selectNewPathForShard(env, shardId, idxSettings, 1L, new HashMap<>()); @@ -239,7 +239,7 @@ public void testDeleteLeftoverShardDirs() throws IOException { is("[foo][0] index UUID in shard state was: 0xDEADF00D expected: 0xDEADBEEF on shard path: " + badPath) ); - Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build(); + Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build(); IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(randomAlphaOfLengthBetween(1, 10), indexSettings); for (Path path : envPaths) { diff --git a/server/src/test/java/org/elasticsearch/index/shard/ShardSplittingQueryTests.java b/server/src/test/java/org/elasticsearch/index/shard/ShardSplittingQueryTests.java index 2013af6dc622..69668d4e0f09 100644 --- a/server/src/test/java/org/elasticsearch/index/shard/ShardSplittingQueryTests.java +++ b/server/src/test/java/org/elasticsearch/index/shard/ShardSplittingQueryTests.java @@ -23,11 +23,11 @@ import org.apache.lucene.store.Directory; import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.util.BytesRef; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.routing.IndexRouting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.core.Nullable; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.mapper.IdFieldMapper; import org.elasticsearch.index.mapper.LuceneDocument; import org.elasticsearch.index.mapper.NestedPathFieldMapper; @@ -49,7 +49,7 @@ public void testSplitOnID() throws IOException { RandomIndexWriter writer = new RandomIndexWriter(random(), dir); int numShards = randomIntBetween(2, 10); IndexMetadata metadata = IndexMetadata.builder("test") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(numShards) .setRoutingNumShards(numShards * 1000000) .numberOfReplicas(0) @@ -75,7 +75,7 @@ public void testSplitOnRouting() throws IOException { RandomIndexWriter writer = new RandomIndexWriter(random(), dir); int numShards = randomIntBetween(2, 10); IndexMetadata metadata = IndexMetadata.builder("test") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(numShards) .setRoutingNumShards(numShards * 1000000) .numberOfReplicas(0) @@ -100,7 +100,7 @@ public void testSplitOnIdOrRouting() throws IOException { RandomIndexWriter writer = new RandomIndexWriter(random(), dir); int numShards = randomIntBetween(2, 10); IndexMetadata metadata = IndexMetadata.builder("test") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(numShards) .setRoutingNumShards(numShards * 1000000) .numberOfReplicas(0) @@ -127,7 +127,7 @@ public void testSplitOnRoutingPartitioned() throws IOException { RandomIndexWriter writer = new RandomIndexWriter(random(), dir); int numShards = randomIntBetween(2, 10); IndexMetadata metadata = IndexMetadata.builder("test") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(numShards) .setRoutingNumShards(numShards * 1000000) .routingPartitionSize(randomIntBetween(1, 10)) diff --git a/server/src/test/java/org/elasticsearch/index/shard/StoreRecoveryTests.java b/server/src/test/java/org/elasticsearch/index/shard/StoreRecoveryTests.java index 8c2c547c89d6..8c349bcd3112 100644 --- a/server/src/test/java/org/elasticsearch/index/shard/StoreRecoveryTests.java +++ b/server/src/test/java/org/elasticsearch/index/shard/StoreRecoveryTests.java @@ -33,6 +33,7 @@ import org.elasticsearch.cluster.routing.IndexRouting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.core.IOUtils; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.engine.Engine; import org.elasticsearch.index.mapper.IdFieldMapper; import org.elasticsearch.index.mapper.Uid; @@ -158,7 +159,7 @@ public void testSplitShard() throws IOException { int numShards = randomIntBetween(2, 10); int targetShardId = randomIntBetween(0, numShards - 1); IndexMetadata metadata = IndexMetadata.builder("test") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(numShards) .setRoutingNumShards(numShards * 1000000) .numberOfReplicas(0) diff --git a/server/src/test/java/org/elasticsearch/index/store/FsDirectoryFactoryTests.java b/server/src/test/java/org/elasticsearch/index/store/FsDirectoryFactoryTests.java index 1cee0b015dd3..ef9ab4ca3a29 100644 --- a/server/src/test/java/org/elasticsearch/index/store/FsDirectoryFactoryTests.java +++ b/server/src/test/java/org/elasticsearch/index/store/FsDirectoryFactoryTests.java @@ -15,12 +15,12 @@ import org.apache.lucene.store.NoLockFactory; import org.apache.lucene.store.SleepingLockWrapper; import org.apache.lucene.util.Constants; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexModule; import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.index.shard.ShardPath; import org.elasticsearch.test.ESTestCase; @@ -122,7 +122,7 @@ public void testStoreDirectory() throws IOException { } private void doTestStoreDirectory(Path tempDir, String typeSettingValue, IndexModule.Type type) throws IOException { - Settings.Builder settingsBuilder = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT); + Settings.Builder settingsBuilder = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()); if (typeSettingValue != null) { settingsBuilder.put(IndexModule.INDEX_STORE_TYPE_SETTING.getKey(), typeSettingValue); } diff --git a/server/src/test/java/org/elasticsearch/indices/IndicesServiceTests.java b/server/src/test/java/org/elasticsearch/indices/IndicesServiceTests.java index 68888ddd9f30..d8f733e55017 100644 --- a/server/src/test/java/org/elasticsearch/indices/IndicesServiceTests.java +++ b/server/src/test/java/org/elasticsearch/indices/IndicesServiceTests.java @@ -368,7 +368,7 @@ public void testVerifyIfIndexContentDeleted() throws Exception { final ClusterService clusterService = getInstanceFromNode(ClusterService.class); final Settings idxSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()) .build(); final IndexMetadata indexMetadata = new IndexMetadata.Builder(index.getName()).settings(idxSettings) @@ -406,7 +406,7 @@ public void testDanglingIndicesWithAliasConflict() throws Exception { // try to import a dangling index with the same name as the alias, it should fail final LocalAllocateDangledIndices dangling = getInstanceFromNode(LocalAllocateDangledIndices.class); final Settings idxSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID()) .build(); final IndexMetadata indexMetadata = new IndexMetadata.Builder(alias).settings(idxSettings) @@ -465,7 +465,7 @@ public void testIndexAndTombstoneWithSameNameOnStartup() throws Exception { final Index index = new Index(indexName, UUIDs.randomBase64UUID()); final IndicesService indicesService = getIndicesService(); final Settings idxSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()) .build(); final IndexMetadata indexMetadata = new IndexMetadata.Builder(index.getName()).settings(idxSettings) @@ -489,7 +489,7 @@ public void testStandAloneMapperServiceWithPlugins() throws IOException { final Index index = new Index(indexName, UUIDs.randomBase64UUID()); final IndicesService indicesService = getIndicesService(); final Settings idxSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()) .put(IndexModule.SIMILARITY_SETTINGS_PREFIX + ".test.type", "fake-similarity") .build(); @@ -567,7 +567,7 @@ public void testGetEngineFactory() throws IOException { final String indexName = "foo-" + value; final Index index = new Index(indexName, UUIDs.randomBase64UUID()); final Settings.Builder builder = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()); if (value != null) { builder.put(FooEnginePlugin.FOO_INDEX_SETTING.getKey(), value); @@ -590,7 +590,7 @@ public void testConflictingEngineFactories() { final String indexName = "foobar"; final Index index = new Index(indexName, UUIDs.randomBase64UUID()); final Settings settings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()) .put(FooEnginePlugin.FOO_INDEX_SETTING.getKey(), true) .put(BarEnginePlugin.BAR_INDEX_SETTING.getKey(), true) diff --git a/server/src/test/java/org/elasticsearch/indices/ShardLimitValidatorTests.java b/server/src/test/java/org/elasticsearch/indices/ShardLimitValidatorTests.java index 3351d77ff446..90f3cb8eacf6 100644 --- a/server/src/test/java/org/elasticsearch/indices/ShardLimitValidatorTests.java +++ b/server/src/test/java/org/elasticsearch/indices/ShardLimitValidatorTests.java @@ -8,7 +8,6 @@ package org.elasticsearch.indices; -import org.elasticsearch.Version; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetadata; @@ -23,6 +22,7 @@ import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.Index; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.test.ESTestCase; import java.util.HashMap; @@ -209,7 +209,7 @@ public static ClusterState createClusterForShardLimitTest( ) { DiscoveryNodes nodes = createDiscoveryNodes(nodesInCluster, group); - Settings.Builder settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT); + Settings.Builder settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()); if (ShardLimitValidator.FROZEN_GROUP.equals(group) || randomBoolean()) { settings.put(ShardLimitValidator.INDEX_SETTING_SHARD_LIMIT_GROUP.getKey(), group); } diff --git a/server/src/test/java/org/elasticsearch/indices/analysis/AnalysisModuleTests.java b/server/src/test/java/org/elasticsearch/indices/analysis/AnalysisModuleTests.java index 1850ed40274e..69b0ef55de6f 100644 --- a/server/src/test/java/org/elasticsearch/indices/analysis/AnalysisModuleTests.java +++ b/server/src/test/java/org/elasticsearch/indices/analysis/AnalysisModuleTests.java @@ -100,7 +100,7 @@ public Map> getCharFilters() { private Settings loadFromClasspath(String path) throws IOException { return Settings.builder() .loadFromStream(path, getClass().getResourceAsStream(path), false) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()) .build(); @@ -448,7 +448,7 @@ public List getPreConfiguredTokenizers() { public void testRegisterHunspellDictionary() throws Exception { Settings settings = Settings.builder() .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .build(); Environment environment = TestEnvironment.newEnvironment(settings); InputStream aff = getClass().getResourceAsStream("/indices/analyze/conf_dir/hunspell/en_US/en_US.aff"); diff --git a/server/src/test/java/org/elasticsearch/rest/action/cat/RestIndicesActionTests.java b/server/src/test/java/org/elasticsearch/rest/action/cat/RestIndicesActionTests.java index b6a2f05164a1..f4ed46dead07 100644 --- a/server/src/test/java/org/elasticsearch/rest/action/cat/RestIndicesActionTests.java +++ b/server/src/test/java/org/elasticsearch/rest/action/cat/RestIndicesActionTests.java @@ -8,7 +8,6 @@ package org.elasticsearch.rest.action.cat; -import org.elasticsearch.Version; import org.elasticsearch.action.admin.indices.stats.CommonStats; import org.elasticsearch.action.admin.indices.stats.IndexStats; import org.elasticsearch.cluster.ClusterState; @@ -26,6 +25,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.rest.FakeRestRequest; @@ -55,7 +55,7 @@ public void testBuildTable() { String indexName = "index-" + i; Settings indexSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID()) .put(IndexSettings.INDEX_SEARCH_THROTTLED.getKey(), randomBoolean()) .build(); diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/histogram/VariableWidthHistogramAggregatorTests.java b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/histogram/VariableWidthHistogramAggregatorTests.java index 7fb04bb9f70f..32530e440f38 100644 --- a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/histogram/VariableWidthHistogramAggregatorTests.java +++ b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/histogram/VariableWidthHistogramAggregatorTests.java @@ -17,11 +17,11 @@ import org.apache.lucene.store.Directory; import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.util.NumericUtils; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.core.CheckedConsumer; import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.NumberFieldMapper; import org.elasticsearch.search.aggregations.AggregationBuilder; @@ -587,7 +587,7 @@ protected IndexSettings createIndexSettings() { final Settings nodeSettings = Settings.builder().put("search.max_buckets", 25000).build(); return new IndexSettings( IndexMetadata.builder("_index") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(1) .numberOfReplicas(0) .creationDate(System.currentTimeMillis()) diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/terms/RareTermsAggregatorTests.java b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/terms/RareTermsAggregatorTests.java index a7279f3991b6..088133f0e2de 100644 --- a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/terms/RareTermsAggregatorTests.java +++ b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/terms/RareTermsAggregatorTests.java @@ -26,10 +26,10 @@ import org.apache.lucene.store.Directory; import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.util.BytesRef; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.mapper.IdFieldMapper; import org.elasticsearch.index.mapper.KeywordFieldMapper; import org.elasticsearch.index.mapper.LuceneDocument; @@ -501,7 +501,7 @@ protected IndexSettings createIndexSettings() { Settings nodeSettings = Settings.builder().put("search.max_buckets", 100000).build(); return new IndexSettings( IndexMetadata.builder("_index") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(1) .numberOfReplicas(0) .creationDate(System.currentTimeMillis()) diff --git a/server/src/test/java/org/elasticsearch/search/fetch/subphase/highlight/HighlightBuilderTests.java b/server/src/test/java/org/elasticsearch/search/fetch/subphase/highlight/HighlightBuilderTests.java index a4f5610d2f81..6691bb7dfeb0 100644 --- a/server/src/test/java/org/elasticsearch/search/fetch/subphase/highlight/HighlightBuilderTests.java +++ b/server/src/test/java/org/elasticsearch/search/fetch/subphase/highlight/HighlightBuilderTests.java @@ -9,7 +9,6 @@ package org.elasticsearch.search.fetch.subphase.highlight; import org.apache.lucene.search.Query; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.io.stream.BytesStreamOutput; @@ -21,6 +20,7 @@ import org.elasticsearch.common.util.set.Sets; import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.MapperBuilderContext; import org.elasticsearch.index.mapper.MappingLookup; @@ -291,7 +291,7 @@ public void testTwoFieldsInObjectInFieldsArray() throws IOException { * than what we have in the random {@link HighlightBuilder} */ public void testBuildSearchContextHighlight() throws IOException { - Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build(); + Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build(); Index index = new Index(randomAlphaOfLengthBetween(1, 10), "_na_"); IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(index, indexSettings); // shard context will only need indicesQueriesRegistry for building Query objects nested in highlighter diff --git a/server/src/test/java/org/elasticsearch/search/internal/ShardSearchRequestTests.java b/server/src/test/java/org/elasticsearch/search/internal/ShardSearchRequestTests.java index f27e8beb1d1d..65b7eb1c844c 100644 --- a/server/src/test/java/org/elasticsearch/search/internal/ShardSearchRequestTests.java +++ b/server/src/test/java/org/elasticsearch/search/internal/ShardSearchRequestTests.java @@ -9,7 +9,6 @@ package org.elasticsearch.search.internal; import org.elasticsearch.TransportVersion; -import org.elasticsearch.Version; import org.elasticsearch.action.OriginalIndices; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.cluster.metadata.AliasMetadata; @@ -23,6 +22,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.core.Nullable; import org.elasticsearch.core.TimeValue; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.RandomQueryBuilder; @@ -55,7 +55,7 @@ public class ShardSearchRequestTests extends AbstractSearchTestCase { private static final IndexMetadata BASE_METADATA = IndexMetadata.builder("test") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build()) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build()) .numberOfShards(1) .numberOfReplicas(1) .build(); diff --git a/server/src/test/java/org/elasticsearch/search/rescore/QueryRescorerBuilderTests.java b/server/src/test/java/org/elasticsearch/search/rescore/QueryRescorerBuilderTests.java index 99de63ceca25..0e6c497f4635 100644 --- a/server/src/test/java/org/elasticsearch/search/rescore/QueryRescorerBuilderTests.java +++ b/server/src/test/java/org/elasticsearch/search/rescore/QueryRescorerBuilderTests.java @@ -10,13 +10,13 @@ import org.apache.lucene.search.Query; import org.elasticsearch.ElasticsearchParseException; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.MapperBuilderContext; import org.elasticsearch.index.mapper.MappingLookup; @@ -130,7 +130,7 @@ public void testFromXContent() throws IOException { */ public void testBuildRescoreSearchContext() throws ElasticsearchParseException, IOException { final long nowInMillis = randomNonNegativeLong(); - Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build(); + Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build(); IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(randomAlphaOfLengthBetween(1, 10), indexSettings); // shard context will only need indicesQueriesRegistry for building Query objects nested in query rescorer SearchExecutionContext mockContext = new SearchExecutionContext( @@ -193,7 +193,7 @@ protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws public void testRewritingKeepsSettings() throws IOException { final long nowInMillis = randomNonNegativeLong(); - Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build(); + Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build(); IndexSettings idxSettings = IndexSettingsModule.newIndexSettings(randomAlphaOfLengthBetween(1, 10), indexSettings); // shard context will only need indicesQueriesRegistry for building Query objects nested in query rescorer SearchExecutionContext mockContext = new SearchExecutionContext( diff --git a/server/src/test/java/org/elasticsearch/search/suggest/AbstractSuggestionBuilderTestCase.java b/server/src/test/java/org/elasticsearch/search/suggest/AbstractSuggestionBuilderTestCase.java index 40e1304f4fb2..900509f1bb64 100644 --- a/server/src/test/java/org/elasticsearch/search/suggest/AbstractSuggestionBuilderTestCase.java +++ b/server/src/test/java/org/elasticsearch/search/suggest/AbstractSuggestionBuilderTestCase.java @@ -9,7 +9,6 @@ package org.elasticsearch.search.suggest; import org.apache.lucene.analysis.core.SimpleAnalyzer; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.io.stream.Writeable; @@ -17,6 +16,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.analysis.AnalyzerScope; import org.elasticsearch.index.analysis.IndexAnalyzers; import org.elasticsearch.index.analysis.NamedAnalyzer; @@ -153,7 +153,7 @@ public void testFromXContent() throws IOException { public void testBuild() throws IOException { for (int runs = 0; runs < NUMBER_OF_TESTBUILDERS; runs++) { SB suggestionBuilder = randomTestBuilder(); - Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build(); + Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build(); IndexSettings idxSettings = IndexSettingsModule.newIndexSettings( new Index(randomAlphaOfLengthBetween(1, 10), "_na_"), indexSettings @@ -216,7 +216,7 @@ public void testBuild() throws IOException { } public void testBuildWithUnmappedField() { - Settings.Builder builder = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT); + Settings.Builder builder = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()); if (randomBoolean()) { builder.put(IndexSettings.ALLOW_UNMAPPED.getKey(), randomBoolean()); } diff --git a/server/src/test/java/org/elasticsearch/snapshots/SnapshotsServiceTests.java b/server/src/test/java/org/elasticsearch/snapshots/SnapshotsServiceTests.java index f9673a1457e8..069604b0282a 100644 --- a/server/src/test/java/org/elasticsearch/snapshots/SnapshotsServiceTests.java +++ b/server/src/test/java/org/elasticsearch/snapshots/SnapshotsServiceTests.java @@ -8,7 +8,6 @@ package org.elasticsearch.snapshots; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.SnapshotsInProgress; @@ -453,7 +452,7 @@ private static ClusterState stateWithUnassignedIndices(String... indexNames) { for (String index : indexNames) { metaBuilder.put( IndexMetadata.builder(index) - .settings(Settings.builder().put(SETTING_VERSION_CREATED, Version.CURRENT.id)) + .settings(Settings.builder().put(SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(1) .numberOfReplicas(0) .build(), diff --git a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/existence/FrozenExistenceDeciderServiceTests.java b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/existence/FrozenExistenceDeciderServiceTests.java index 3e8987fdb4cc..a061fe7da66a 100644 --- a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/existence/FrozenExistenceDeciderServiceTests.java +++ b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/existence/FrozenExistenceDeciderServiceTests.java @@ -7,7 +7,6 @@ package org.elasticsearch.xpack.autoscaling.existence; -import org.elasticsearch.Version; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetadata; @@ -38,7 +37,7 @@ public class FrozenExistenceDeciderServiceTests extends AutoscalingTestCase { public void testScale() { verify(ClusterState.EMPTY_STATE, this::assertZeroCapacity); - final Settings versionSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build(); + final Settings versionSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build(); final int shards = between(1, 3); final int replicas = between(0, 2); final Metadata nonFrozenMetadata = Metadata.builder() diff --git a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/storage/FrozenStorageDeciderServiceTests.java b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/storage/FrozenStorageDeciderServiceTests.java index d88e06777718..42348eec8481 100644 --- a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/storage/FrozenStorageDeciderServiceTests.java +++ b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/storage/FrozenStorageDeciderServiceTests.java @@ -7,7 +7,6 @@ package org.elasticsearch.xpack.autoscaling.storage; -import org.elasticsearch.Version; import org.elasticsearch.cluster.ClusterInfo; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; @@ -18,6 +17,7 @@ import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.core.Tuple; import org.elasticsearch.index.Index; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.xpack.autoscaling.AutoscalingTestCase; import org.elasticsearch.xpack.autoscaling.capacity.AutoscalingDeciderContext; @@ -38,7 +38,7 @@ public void testEstimateSize() { final int shards = between(1, 10); final int replicas = between(0, 9); final IndexMetadata indexMetadata = IndexMetadata.builder(randomAlphaOfLength(5)) - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(shards) .numberOfReplicas(replicas) .build(); diff --git a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/util/FrozenUtilsTests.java b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/util/FrozenUtilsTests.java index 01e4dbc77d9c..6a3128ae3f56 100644 --- a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/util/FrozenUtilsTests.java +++ b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/util/FrozenUtilsTests.java @@ -9,11 +9,11 @@ import joptsimple.internal.Strings; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.routing.allocation.DataTier; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.IndexModule; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.snapshots.SearchableSnapshotsSettings; import org.elasticsearch.xpack.autoscaling.AutoscalingTestCase; @@ -42,7 +42,7 @@ public static Settings indexSettings(String tierPreference) { Settings.Builder settings = Settings.builder() .put(randomAlphaOfLength(10), randomLong()) .put(DataTier.TIER_PREFERENCE, tierPreference) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT); + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()); // pass setting validator. if (Objects.equals(tierPreference, DataTier.DATA_FROZEN)) { settings.put(SearchableSnapshotsSettings.SNAPSHOT_PARTIAL_SETTING.getKey(), true) diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrTests.java index 829809410a5f..4fb05e2df7ac 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/CcrTests.java @@ -7,12 +7,12 @@ package org.elasticsearch.xpack.ccr; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.UUIDs; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.engine.EngineFactory; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.ccr.index.engine.FollowingEngineFactory; @@ -30,7 +30,7 @@ public void testGetEngineFactory() throws IOException { final String indexName = "following-" + value; final Index index = new Index(indexName, UUIDs.randomBase64UUID()); final Settings.Builder builder = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()); if (value != null) { builder.put(CcrSettings.CCR_FOLLOWING_INDEX_SETTING.getKey(), value); diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinatorTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinatorTests.java index a97f064d33ce..e004f9b8f81e 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinatorTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/AutoFollowCoordinatorTests.java @@ -6,7 +6,6 @@ */ package org.elasticsearch.xpack.ccr.action; -import org.elasticsearch.Version; import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; import org.elasticsearch.action.support.replication.ClusterStateCreationUtils; import org.elasticsearch.client.internal.Client; @@ -716,7 +715,7 @@ public void testGetLeaderIndicesToFollow() { for (int i = 0; i < 5; i++) { String indexName = "metrics-" + i; Settings.Builder builder = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, indexName); imdBuilder.put(IndexMetadata.builder(indexName).settings(builder).numberOfShards(1).numberOfReplicas(0)); @@ -1084,7 +1083,7 @@ public void testGenerateRequest() { Settings.builder() .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()) .build() ) @@ -1127,7 +1126,7 @@ public void testGenerateRequest() { Settings.builder() .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()) .build() ) @@ -1170,7 +1169,7 @@ public void testGenerateRequest() { Settings.builder() .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()) .build() ) @@ -1213,7 +1212,7 @@ public void testGenerateRequest() { Settings.builder() .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()) .build() ) @@ -1256,7 +1255,7 @@ public void testGenerateRequest() { Settings.builder() .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()) .build() ) @@ -1299,7 +1298,7 @@ public void testGenerateRequest() { Settings.builder() .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()) .build() ) diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/TransportFollowStatsActionTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/TransportFollowStatsActionTests.java index 2fc3ba8eb0ce..9a5afd65952a 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/TransportFollowStatsActionTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/TransportFollowStatsActionTests.java @@ -6,7 +6,6 @@ */ package org.elasticsearch.xpack.ccr.action; -import org.elasticsearch.Version; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetadata; @@ -16,6 +15,7 @@ import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.core.TimeValue; import org.elasticsearch.index.Index; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.persistent.PersistentTasksCustomMetadata; import org.elasticsearch.test.ESTestCase; @@ -31,7 +31,7 @@ public class TransportFollowStatsActionTests extends ESTestCase { public void testFindFollowerIndicesFromShardFollowTasks() { Settings indexSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) .build(); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/snapshots/sourceonly/SourceOnlySnapshotShardTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/snapshots/sourceonly/SourceOnlySnapshotShardTests.java index d825cdb31813..de7b35ae0c78 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/snapshots/sourceonly/SourceOnlySnapshotShardTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/snapshots/sourceonly/SourceOnlySnapshotShardTests.java @@ -21,7 +21,6 @@ import org.apache.lucene.search.TopDocs; import org.apache.lucene.util.Bits; import org.elasticsearch.ExceptionsHelper; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.support.PlainActionFuture; @@ -101,7 +100,7 @@ public void testSourceIncomplete() throws IOException { RecoverySource.EmptyStoreRecoverySource.INSTANCE ); Settings settings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .build(); @@ -449,7 +448,7 @@ public IndexShard reindex(DirectoryReader reader, MappingMetadata mapping) throw RecoverySource.EmptyStoreRecoverySource.INSTANCE ); Settings settings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .build(); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/cluster/routing/allocation/mapper/DataTierFieldTypeTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/cluster/routing/allocation/mapper/DataTierFieldTypeTests.java index c73c4592fbcf..65bde780f519 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/cluster/routing/allocation/mapper/DataTierFieldTypeTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/cluster/routing/allocation/mapper/DataTierFieldTypeTests.java @@ -9,12 +9,12 @@ import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.MatchNoDocsQuery; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.routing.allocation.DataTier; import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.MapperServiceTestCase; import org.elasticsearch.index.mapper.ValueFetcher; @@ -103,7 +103,7 @@ private SearchExecutionContext createContext() { IndexMetadata indexMetadata = IndexMetadata.builder("index") .settings( Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) // Tier can be an ordered list of preferences - starting with primary and followed by fallbacks. .put(DataTier.TIER_PREFERENCE, "data_warm,data_hot") ) @@ -118,7 +118,7 @@ private SearchExecutionContext createContext() { private SearchExecutionContext createContextWithoutSetting() { IndexMetadata indexMetadata = IndexMetadata.builder("index") - .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build()) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build()) .numberOfShards(1) .numberOfReplicas(0) .build(); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/AllocationRoutedStepTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/AllocationRoutedStepTests.java index e10ffcfd4378..4212975cb81f 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/AllocationRoutedStepTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/AllocationRoutedStepTests.java @@ -6,7 +6,6 @@ */ package org.elasticsearch.xpack.core.ilm; -import org.elasticsearch.Version; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.Metadata; @@ -22,6 +21,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.index.Index; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.node.Node; import org.elasticsearch.xpack.core.ilm.ClusterStateWaitStep.Result; @@ -68,7 +68,7 @@ public void testConditionMet() { Map excludes = AllocateActionTests.randomAllocationRoutingMap(1, 5); Map requires = AllocateActionTests.randomAllocationRoutingMap(1, 5); Settings.Builder existingSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.id) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()); Settings.Builder node1Settings = Settings.builder(); Settings.Builder node2Settings = Settings.builder(); @@ -109,7 +109,7 @@ public void testRequireConditionMetOnlyOneCopyAllocated() { Index index = new Index(randomAlphaOfLengthBetween(1, 20), randomAlphaOfLengthBetween(1, 20)); Map requires = Collections.singletonMap(IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_SETTING.getKey() + "foo", "bar"); Settings.Builder existingSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.id) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()); Settings.Builder node1Settings = Settings.builder(); requires.forEach((k, v) -> { @@ -139,7 +139,7 @@ public void testRequireConditionMetOnlyOneCopyAllocated() { public void testClusterExcludeFiltersConditionMetOnlyOneCopyAllocated() { Index index = new Index(randomAlphaOfLengthBetween(1, 20), randomAlphaOfLengthBetween(1, 20)); Settings.Builder existingSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.id) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()); boolean primaryOnNode1 = randomBoolean(); @@ -189,7 +189,7 @@ public void testExcludeConditionMetOnlyOneCopyAllocated() { Index index = new Index(randomAlphaOfLengthBetween(1, 20), randomAlphaOfLengthBetween(1, 20)); Map excludes = Collections.singletonMap(IndexMetadata.INDEX_ROUTING_EXCLUDE_GROUP_SETTING.getKey() + "foo", "bar"); Settings.Builder existingSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.id) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()); Settings.Builder node1Settings = Settings.builder(); excludes.forEach((k, v) -> { @@ -220,7 +220,7 @@ public void testIncludeConditionMetOnlyOneCopyAllocated() { Index index = new Index(randomAlphaOfLengthBetween(1, 20), randomAlphaOfLengthBetween(1, 20)); Map includes = Collections.singletonMap(IndexMetadata.INDEX_ROUTING_INCLUDE_GROUP_SETTING.getKey() + "foo", "bar"); Settings.Builder existingSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.id) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()); Settings.Builder node1Settings = Settings.builder(); includes.forEach((k, v) -> { @@ -251,7 +251,7 @@ public void testConditionNotMetDueToRelocation() { Index index = new Index(randomAlphaOfLengthBetween(1, 20), randomAlphaOfLengthBetween(1, 20)); Map requires = AllocateActionTests.randomAllocationRoutingMap(1, 5); Settings.Builder existingSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.id) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_PREFIX + "._id", "node1") .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()); Settings.Builder node1Settings = Settings.builder(); @@ -298,7 +298,7 @@ public void testExecuteAllocateNotComplete() throws Exception { () -> AllocateActionTests.randomAllocationRoutingMap(1, 5) ); Settings.Builder existingSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.id) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()); Settings.Builder node1Settings = Settings.builder(); Settings.Builder node2Settings = Settings.builder(); @@ -348,7 +348,7 @@ public void testExecuteAllocateNotCompleteOnlyOneCopyAllocated() throws Exceptio () -> AllocateActionTests.randomAllocationRoutingMap(1, 5) ); Settings.Builder existingSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.id) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()); Settings.Builder node1Settings = Settings.builder(); Settings.Builder node2Settings = Settings.builder(); @@ -399,7 +399,7 @@ public void testExecuteAllocateUnassigned() throws Exception { () -> AllocateActionTests.randomAllocationRoutingMap(1, 5) ); Settings.Builder existingSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.id) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()); Settings.Builder node1Settings = Settings.builder(); Settings.Builder node2Settings = Settings.builder(); @@ -466,7 +466,7 @@ public void testExecuteAllocateUnassigned() throws Exception { public void testExecuteReplicasNotAllocatedOnSingleNode() { Index index = new Index(randomAlphaOfLengthBetween(1, 20), randomAlphaOfLengthBetween(1, 20)); Settings.Builder existingSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.id) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()); Settings.Builder node1Settings = Settings.builder(); Settings.Builder node2Settings = Settings.builder(); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/CheckShrinkReadyStepTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/CheckShrinkReadyStepTests.java index 89c1a2a256b6..831949e574a5 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/CheckShrinkReadyStepTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/CheckShrinkReadyStepTests.java @@ -7,7 +7,6 @@ package org.elasticsearch.xpack.core.ilm; -import org.elasticsearch.Version; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.Metadata; @@ -26,6 +25,7 @@ import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.core.TimeValue; import org.elasticsearch.index.Index; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.node.Node; @@ -73,7 +73,7 @@ public void testNoSetting() { Index index = new Index(randomAlphaOfLengthBetween(1, 20), randomAlphaOfLengthBetween(1, 20)); Map requires = AllocateActionTests.randomAllocationRoutingMap(1, 5); Settings.Builder existingSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.id) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()); Settings.Builder expectedSettings = Settings.builder(); Settings.Builder node1Settings = Settings.builder(); @@ -108,7 +108,7 @@ public void testConditionMet() { Index index = new Index(randomAlphaOfLengthBetween(1, 20), randomAlphaOfLengthBetween(1, 20)); Map requires = AllocateActionTests.randomAllocationRoutingMap(1, 5); Settings.Builder existingSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.id) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_PREFIX + "._id", "node1") .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()); Settings.Builder expectedSettings = Settings.builder(); @@ -141,7 +141,7 @@ public void testConditionMetOnlyOneCopyAllocated() { Index index = new Index(randomAlphaOfLengthBetween(1, 20), randomAlphaOfLengthBetween(1, 20)); Map requires = AllocateActionTests.randomAllocationRoutingMap(1, 5); Settings.Builder existingSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.id) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_PREFIX + "._id", "node1") .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()); Settings.Builder expectedSettings = Settings.builder(); @@ -175,7 +175,7 @@ public void testConditionNotMetDueToRelocation() { Index index = new Index(randomAlphaOfLengthBetween(1, 20), randomAlphaOfLengthBetween(1, 20)); Map requires = AllocateActionTests.randomAllocationRoutingMap(1, 5); Settings.Builder existingSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.id) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_PREFIX + "._id", "node1") .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()); Settings.Builder expectedSettings = Settings.builder(); @@ -216,7 +216,7 @@ public void testExecuteAllocateNotComplete() throws Exception { Index index = new Index(randomAlphaOfLengthBetween(1, 20), randomAlphaOfLengthBetween(1, 20)); Map requires = AllocateActionTests.randomAllocationRoutingMap(1, 5); Settings.Builder existingSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.id) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_PREFIX + "._id", "node1") .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()); Settings.Builder expectedSettings = Settings.builder(); @@ -250,7 +250,7 @@ public void testExecuteAllocateNotCompleteOnlyOneCopyAllocated() throws Exceptio Index index = new Index(randomAlphaOfLengthBetween(1, 20), randomAlphaOfLengthBetween(1, 20)); Map requires = AllocateActionTests.randomAllocationRoutingMap(1, 5); Settings.Builder existingSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.id) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_PREFIX + "._id", "node1") .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()); Settings.Builder expectedSettings = Settings.builder(); @@ -285,7 +285,7 @@ public void testExecuteAllocateReplicaUnassigned() { Index index = new Index(randomAlphaOfLengthBetween(1, 20), randomAlphaOfLengthBetween(1, 20)); Map requires = AllocateActionTests.randomAllocationRoutingMap(1, 5); Settings.Builder existingSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.id) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_PREFIX + "._id", "node1") .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()); Settings.Builder expectedSettings = Settings.builder(); @@ -345,7 +345,7 @@ public void testExecuteReplicasNotAllocatedOnSingleNode() { Index index = new Index(randomAlphaOfLengthBetween(1, 20), randomAlphaOfLengthBetween(1, 20)); Map requires = Collections.singletonMap("_id", "node1"); Settings.Builder existingSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.id) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_PREFIX + "._id", "node1") .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()); Settings.Builder expectedSettings = Settings.builder(); @@ -386,7 +386,7 @@ public void testExecuteReplicasButCopiesNotPresent() { Index index = new Index(randomAlphaOfLengthBetween(1, 20), randomAlphaOfLengthBetween(1, 20)); Map requires = Collections.singletonMap("_id", "node1"); Settings.Builder existingSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.id) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_PREFIX + "._id", "node1") .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()); Settings.Builder expectedSettings = Settings.builder(); @@ -439,7 +439,7 @@ public void testStepCompletableIfAllShardsActive() { Index index = new Index(randomAlphaOfLengthBetween(1, 20), randomAlphaOfLengthBetween(1, 20)); Map requires = AllocateActionTests.randomAllocationRoutingMap(1, 5); Settings.Builder existingSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.id) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_PREFIX + "._id", "node1") .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()); Settings.Builder expectedSettings = Settings.builder(); @@ -518,7 +518,7 @@ public void testStepBecomesUncompletable() { Index index = new Index(randomAlphaOfLengthBetween(1, 20), randomAlphaOfLengthBetween(1, 20)); Map requires = AllocateActionTests.randomAllocationRoutingMap(1, 5); Settings.Builder existingSettings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.id) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_PREFIX + "._id", "node1") .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()); Settings.Builder expectedSettings = Settings.builder(); diff --git a/x-pack/plugin/downsample/src/test/java/org/elasticsearch/xpack/downsample/TransportDownsampleActionTests.java b/x-pack/plugin/downsample/src/test/java/org/elasticsearch/xpack/downsample/TransportDownsampleActionTests.java index f8432ace37ca..fb699fd7c341 100644 --- a/x-pack/plugin/downsample/src/test/java/org/elasticsearch/xpack/downsample/TransportDownsampleActionTests.java +++ b/x-pack/plugin/downsample/src/test/java/org/elasticsearch/xpack/downsample/TransportDownsampleActionTests.java @@ -7,12 +7,12 @@ package org.elasticsearch.xpack.downsample; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.routing.allocation.DataTier; import org.elasticsearch.common.settings.IndexScopedSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.core.ilm.LifecycleSettings; @@ -25,7 +25,7 @@ public void testCopyIndexMetadata() { final List tiers = List.of(DataTier.DATA_HOT, DataTier.DATA_WARM, DataTier.DATA_COLD, DataTier.DATA_CONTENT); final IndexMetadata source = new IndexMetadata.Builder(randomAlphaOfLength(10)).settings( Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, randomIntBetween(1, 5)) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, randomIntBetween(1, 3)) .put(IndexMetadata.INDEX_DOWNSAMPLE_SOURCE_UUID_KEY, UUID.randomUUID().toString()) @@ -38,7 +38,7 @@ public void testCopyIndexMetadata() { ).build(); final IndexMetadata target = new IndexMetadata.Builder(randomAlphaOfLength(10)).settings( Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 6) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 4) .put(IndexMetadata.INDEX_DOWNSAMPLE_SOURCE_UUID_KEY, UUID.randomUUID().toString()) diff --git a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/IndexLifecycleTransitionTests.java b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/IndexLifecycleTransitionTests.java index fdd63ea05a78..b1e07729bee0 100644 --- a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/IndexLifecycleTransitionTests.java +++ b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/IndexLifecycleTransitionTests.java @@ -8,7 +8,6 @@ package org.elasticsearch.xpack.ilm; import org.elasticsearch.ElasticsearchException; -import org.elasticsearch.Version; import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; @@ -1295,7 +1294,7 @@ private ClusterState buildClusterState( ) { Settings indexSettings = indexSettingsBuilder.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .build(); IndexMetadata indexMetadata = IndexMetadata.builder(indexName) .settings(indexSettings) diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/MlConfigMigrationEligibilityCheckTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/MlConfigMigrationEligibilityCheckTests.java index f77e8cd9ff1c..57acdf62d9b4 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/MlConfigMigrationEligibilityCheckTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/MlConfigMigrationEligibilityCheckTests.java @@ -6,7 +6,6 @@ */ package org.elasticsearch.xpack.ml; -import org.elasticsearch.Version; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.AliasMetadata; @@ -22,6 +21,7 @@ import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.Index; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.search.SearchModule; import org.elasticsearch.test.ESTestCase; @@ -116,7 +116,7 @@ private void addMlConfigIndex(String indexName, String aliasName, Metadata.Build indexMetadata.settings( Settings.builder() .put(IndexMetadata.SETTING_INDEX_UUID, uuid) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) ); diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedConfigAutoUpdaterTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedConfigAutoUpdaterTests.java index 6082ef5789f3..ccb163edb693 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedConfigAutoUpdaterTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/datafeed/DatafeedConfigAutoUpdaterTests.java @@ -8,7 +8,6 @@ package org.elasticsearch.xpack.ml.datafeed; import org.elasticsearch.ElasticsearchException; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; @@ -23,6 +22,7 @@ import org.elasticsearch.cluster.routing.UnassignedInfo; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.Index; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.indices.TestIndexNameExpressionResolver; import org.elasticsearch.test.ESTestCase; @@ -166,7 +166,7 @@ public void testIsAbleToRun() { IndexMetadata.Builder indexMetadata = IndexMetadata.builder(MlConfigIndex.indexName()); indexMetadata.settings( Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) ); diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/dataframe/DestinationIndexTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/dataframe/DestinationIndexTests.java index 9e0f505bcc64..445149c9deb4 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/dataframe/DestinationIndexTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/dataframe/DestinationIndexTests.java @@ -32,6 +32,7 @@ import org.elasticsearch.cluster.metadata.MappingMetadata; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.xcontent.XContentParser; @@ -166,7 +167,7 @@ private Map testCreateDestinationIndex(DataFrameAnalysis analysi ); Settings.Builder index1SettingsBuilder = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) .put("index.mapping.total_fields.limit", 1000) @@ -228,7 +229,7 @@ private Map testCreateDestinationIndex(DataFrameAnalysis analysi ); Settings.Builder index2SettingsBuilder = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 5) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1) .put("index.mapping.total_fields.limit", 99999999) diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/inference/TrainedModelStatsServiceTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/inference/TrainedModelStatsServiceTests.java index 3173cbd0908c..c9dcc15bc096 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/inference/TrainedModelStatsServiceTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/inference/TrainedModelStatsServiceTests.java @@ -7,7 +7,6 @@ package org.elasticsearch.xpack.ml.inference; -import org.elasticsearch.Version; import org.elasticsearch.client.internal.Client; import org.elasticsearch.client.internal.OriginSettingClient; import org.elasticsearch.cluster.ClusterChangedEvent; @@ -26,6 +25,7 @@ import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.Index; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.indices.TestIndexNameExpressionResolver; import org.elasticsearch.test.ESTestCase; @@ -68,7 +68,7 @@ public void testVerifyIndicesExistAndPrimaryShardsAreActive() { IndexMetadata.Builder indexMetadata = IndexMetadata.builder(concreteIndex) .settings( Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) ); @@ -88,7 +88,7 @@ public void testVerifyIndicesExistAndPrimaryShardsAreActive() { .putAlias(AliasMetadata.builder(aliasName).isHidden(true).build()) .settings( Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) ); @@ -108,7 +108,7 @@ public void testVerifyIndicesExistAndPrimaryShardsAreActive() { .putAlias(AliasMetadata.builder(aliasName).isHidden(true).build()) .settings( Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) ); @@ -171,7 +171,7 @@ public void testUpdateStatsUpgradeMode() { .putAlias(AliasMetadata.builder(aliasName).isHidden(true).build()) .settings( Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) ); @@ -198,7 +198,7 @@ public void testUpdateStatsUpgradeMode() { .putAlias(AliasMetadata.builder(aliasName).isHidden(true).build()) .settings( Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) ); @@ -229,7 +229,7 @@ public void testUpdateStatsUpgradeMode() { .putAlias(AliasMetadata.builder(aliasName).isHidden(true).build()) .settings( Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) ); @@ -285,7 +285,7 @@ public void testUpdateStatsResetMode() { .putAlias(AliasMetadata.builder(aliasName).isHidden(true).build()) .settings( Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) ); @@ -316,7 +316,7 @@ public void testUpdateStatsResetMode() { .putAlias(AliasMetadata.builder(aliasName).isHidden(true).build()) .settings( Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) ); diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/JobResultsProviderTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/JobResultsProviderTests.java index fdb1e4389f2b..e160b310df01 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/JobResultsProviderTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/persistence/JobResultsProviderTests.java @@ -9,7 +9,6 @@ import org.apache.lucene.search.TotalHits; import org.apache.lucene.util.SetOnce; import org.elasticsearch.ResourceNotFoundException; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.search.MultiSearchAction; import org.elasticsearch.action.search.MultiSearchRequest; @@ -27,6 +26,7 @@ import org.elasticsearch.common.document.DocumentField; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.indices.TestIndexNameExpressionResolver; import org.elasticsearch.search.SearchHit; @@ -646,7 +646,7 @@ public void testViolatedFieldCountLimit() { IndexMetadata indexMetadata1 = new IndexMetadata.Builder("index1").settings( Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) ).putMapping(new MappingMetadata("type1", Collections.singletonMap("properties", mapping))).build(); @@ -662,7 +662,7 @@ public void testViolatedFieldCountLimit() { IndexMetadata indexMetadata2 = new IndexMetadata.Builder("index1").settings( Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) ).putMapping(new MappingMetadata("type1", Collections.singletonMap("properties", mapping))).build(); diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/task/OpenJobPersistentTasksExecutorTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/task/OpenJobPersistentTasksExecutorTests.java index d33876e6ecb9..1c01072dcf51 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/task/OpenJobPersistentTasksExecutorTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/task/OpenJobPersistentTasksExecutorTests.java @@ -9,7 +9,6 @@ import org.elasticsearch.ElasticsearchStatusException; import org.elasticsearch.ResourceNotFoundException; -import org.elasticsearch.Version; import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; @@ -30,6 +29,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.EsExecutors; import org.elasticsearch.index.Index; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.indices.TestIndexNameExpressionResolver; import org.elasticsearch.license.XPackLicenseState; @@ -253,7 +253,7 @@ private void addIndices(Metadata.Builder metadata, RoutingTable.Builder routingT IndexMetadata.Builder indexMetadata = IndexMetadata.builder(indexName); indexMetadata.settings( Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) ); diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/task/AbstractJobPersistentTasksExecutorTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/task/AbstractJobPersistentTasksExecutorTests.java index dec5346b9cf7..bc75f0ca8289 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/task/AbstractJobPersistentTasksExecutorTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/task/AbstractJobPersistentTasksExecutorTests.java @@ -7,7 +7,6 @@ package org.elasticsearch.xpack.ml.task; -import org.elasticsearch.Version; import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; @@ -23,6 +22,7 @@ import org.elasticsearch.cluster.routing.UnassignedInfo; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.Index; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.indices.TestIndexNameExpressionResolver; import org.elasticsearch.test.ESTestCase; @@ -120,7 +120,7 @@ private void addIndices(Metadata.Builder metadata, RoutingTable.Builder routingT IndexMetadata.Builder indexMetadata = IndexMetadata.builder(indexName); indexMetadata.settings( Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) ); diff --git a/x-pack/plugin/profiling/src/test/java/org/elasticsearch/xpack/profiling/KvIndexResolverTests.java b/x-pack/plugin/profiling/src/test/java/org/elasticsearch/xpack/profiling/KvIndexResolverTests.java index a1c5ee7697ae..d6b943861111 100644 --- a/x-pack/plugin/profiling/src/test/java/org/elasticsearch/xpack/profiling/KvIndexResolverTests.java +++ b/x-pack/plugin/profiling/src/test/java/org/elasticsearch/xpack/profiling/KvIndexResolverTests.java @@ -7,7 +7,6 @@ package org.elasticsearch.xpack.profiling; -import org.elasticsearch.Version; import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetadata; @@ -16,6 +15,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.core.TimeValue; import org.elasticsearch.index.Index; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.test.ESTestCase; import org.junit.Before; @@ -132,7 +132,7 @@ public void testResolveRangeOfIndicesAtBoundary() { private IndexMetadata metadata(Index index, long creationDate) { final Settings settings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()) .build(); return IndexMetadata.builder(index.getName()) diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/IndicesPermissionTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/IndicesPermissionTests.java index 39f7413b828a..382c903dd761 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/IndicesPermissionTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/IndicesPermissionTests.java @@ -739,7 +739,7 @@ private static IndexAbstraction concreteIndexAbstraction(String name) { private static IndexMetadata createBackingIndexMetadata(String name) { Settings.Builder settingsBuilder = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put("index.hidden", true); IndexMetadata.Builder indexBuilder = IndexMetadata.builder(name) diff --git a/x-pack/plugin/shutdown/src/test/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusActionTests.java b/x-pack/plugin/shutdown/src/test/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusActionTests.java index e985fa8b7b0a..58a7aa497378 100644 --- a/x-pack/plugin/shutdown/src/test/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusActionTests.java +++ b/x-pack/plugin/shutdown/src/test/java/org/elasticsearch/xpack/shutdown/TransportGetShutdownStatusActionTests.java @@ -7,7 +7,6 @@ package org.elasticsearch.xpack.shutdown; -import org.elasticsearch.Version; import org.elasticsearch.cluster.ClusterInfoService; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.EmptyClusterInfoService; @@ -39,6 +38,7 @@ import org.elasticsearch.common.transport.TransportAddress; import org.elasticsearch.gateway.GatewayAllocator; import org.elasticsearch.index.Index; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.node.Node; import org.elasticsearch.snapshots.SnapshotShardSizeInfo; @@ -666,7 +666,7 @@ private IndexMetadata generateIndexMetadata(Index index, int numberOfShards, int return IndexMetadata.builder(index.getName()) .settings( Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.id) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()) ) .numberOfShards(numberOfShards) diff --git a/x-pack/plugin/wildcard/src/test/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapperTests.java b/x-pack/plugin/wildcard/src/test/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapperTests.java index 588417cac72d..bff7b68f912e 100644 --- a/x-pack/plugin/wildcard/src/test/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapperTests.java +++ b/x-pack/plugin/wildcard/src/test/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapperTests.java @@ -1080,7 +1080,7 @@ protected final SearchExecutionContext createMockContext() { Index index = new Index(randomAlphaOfLengthBetween(1, 10), "_na_"); IndexSettings idxSettings = IndexSettingsModule.newIndexSettings( index, - Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).build() + Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build() ); BitsetFilterCache bitsetFilterCache = new BitsetFilterCache(idxSettings, Mockito.mock(BitsetFilterCache.Listener.class)); BiFunction> indexFieldDataLookup = (fieldType, fdc) -> { diff --git a/x-pack/plugin/write-load-forecaster/src/test/java/org/elasticsearch/xpack/writeloadforecaster/LicensedWriteLoadForecasterTests.java b/x-pack/plugin/write-load-forecaster/src/test/java/org/elasticsearch/xpack/writeloadforecaster/LicensedWriteLoadForecasterTests.java index e7b12f828008..38e754c80298 100644 --- a/x-pack/plugin/write-load-forecaster/src/test/java/org/elasticsearch/xpack/writeloadforecaster/LicensedWriteLoadForecasterTests.java +++ b/x-pack/plugin/write-load-forecaster/src/test/java/org/elasticsearch/xpack/writeloadforecaster/LicensedWriteLoadForecasterTests.java @@ -7,7 +7,6 @@ package org.elasticsearch.xpack.writeloadforecaster; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.DataStream; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.IndexMetadataStats; @@ -18,6 +17,7 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexMode; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.threadpool.TestThreadPool; import org.elasticsearch.threadpool.ThreadPool; @@ -371,7 +371,7 @@ private IndexMetadata createIndexMetadata( .put(extraSettings) .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, numberOfShards) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) - .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .build() ) .stats(indexWriteLoad == null ? null : new IndexMetadataStats(indexWriteLoad, 1, 1))