diff --git a/buildSrc/src/main/groovy/org/opensearch/gradle/plugin/PluginBuildPlugin.groovy b/buildSrc/src/main/groovy/org/opensearch/gradle/plugin/PluginBuildPlugin.groovy index 125e6720eba61..e07d4800ad7d1 100644 --- a/buildSrc/src/main/groovy/org/opensearch/gradle/plugin/PluginBuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/opensearch/gradle/plugin/PluginBuildPlugin.groovy @@ -102,7 +102,7 @@ class PluginBuildPlugin implements Plugin { 'name' : extension1.name, 'description' : extension1.description, 'version' : extension1.version, - 'opensearchVersion': Version.fromString(VersionProperties.getOpenSearch()).toString(), + 'opensearchVersion' : Version.fromString(VersionProperties.getOpenSearch()).toString(), 'javaVersion' : project.targetCompatibility as String, 'classname' : extension1.classname, 'extendedPlugins' : extension1.extendedPlugins.join(','), diff --git a/buildSrc/src/main/java/org/opensearch/gradle/BwcVersions.java b/buildSrc/src/main/java/org/opensearch/gradle/BwcVersions.java index 0cee964ccffe8..6c22c324916c8 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/BwcVersions.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/BwcVersions.java @@ -98,7 +98,7 @@ public class BwcVersions { private static final Pattern LINE_PATTERN = Pattern.compile( - "\\W+public static final Version V_(\\d+)_(\\d+)_(\\d+)(_alpha\\d+|_beta\\d+|_rc\\d+)? .*" + "\\W+public static final (LegacyES)?Version V_(\\d+)_(\\d+)_(\\d+)(_alpha\\d+|_beta\\d+|_rc\\d+)? .*" ); private final Version currentVersion; @@ -128,9 +128,9 @@ protected BwcVersions(List versionLines, Version currentVersionProperty) .filter(Matcher::matches) .map( match -> new Version( - Integer.parseInt(match.group(1)), Integer.parseInt(match.group(2)), - Integer.parseInt(match.group(3)) + Integer.parseInt(match.group(3)), + Integer.parseInt(match.group(4)) ) ) .collect(Collectors.toCollection(TreeSet::new)), @@ -144,12 +144,18 @@ public BwcVersions(SortedSet allVersions, Version currentVersionPropert throw new IllegalArgumentException("Could not parse any versions"); } + // hack: this is horribly volatile like this entire logic; fix currentVersion = allVersions.last(); groupByMajor = allVersions.stream() // We only care about the last 2 majors when it comes to BWC. // It might take us time to remove the older ones from versionLines, so we allow them to exist. - .filter(version -> version.getMajor() > currentVersion.getMajor() - 2) + // Adjust the major number since OpenSearch 1.x is released after predecessor version 7.x + .filter( + version -> (version.getMajor() == 1 ? 7 : version.getMajor()) > (currentVersion.getMajor() == 1 + ? 7 + : currentVersion.getMajor()) - 2 + ) .collect(Collectors.groupingBy(Version::getMajor, Collectors.toList())); assertCurrentVersionMatchesParsed(currentVersionProperty); @@ -262,14 +268,17 @@ public List getUnreleased() { // The current version is being worked, is always unreleased unreleased.add(currentVersion); - // the tip of the previous major is unreleased for sure, be it a minor or a bugfix - final Version latestOfPreviousMajor = getLatestVersionByKey(this.groupByMajor, currentVersion.getMajor() - 1); - unreleased.add(latestOfPreviousMajor); - if (latestOfPreviousMajor.getRevision() == 0) { - // if the previous major is a x.y.0 release, then the tip of the minor before that (y-1) is also unreleased - final Version previousMinor = getLatestInMinor(latestOfPreviousMajor.getMajor(), latestOfPreviousMajor.getMinor() - 1); - if (previousMinor != null) { - unreleased.add(previousMinor); + // version 1 is the first release, there is no previous "unreleased version": + if (currentVersion.getMajor() != 1) { + // the tip of the previous major is unreleased for sure, be it a minor or a bugfix + final Version latestOfPreviousMajor = getLatestVersionByKey(this.groupByMajor, currentVersion.getMajor() - 1); + unreleased.add(latestOfPreviousMajor); + if (latestOfPreviousMajor.getRevision() == 0) { + // if the previous major is a x.y.0 release, then the tip of the minor before that (y-1) is also unreleased + final Version previousMinor = getLatestInMinor(latestOfPreviousMajor.getMajor(), latestOfPreviousMajor.getMinor() - 1); + if (previousMinor != null) { + unreleased.add(previousMinor); + } } } @@ -306,8 +315,9 @@ private Version getLatestVersionByKey(Map> groupByMajor, } private Map> getReleasedMajorGroupedByMinor() { - List currentMajorVersions = groupByMajor.get(currentVersion.getMajor()); - List previousMajorVersions = groupByMajor.get(currentVersion.getMajor() - 1); + int currentMajor = currentVersion.getMajor(); + List currentMajorVersions = groupByMajor.get(currentMajor); + List previousMajorVersions = groupByMajor.get(getPreviousMajor(currentMajor)); final Map> groupByMinor; if (currentMajorVersions.size() == 1) { @@ -353,23 +363,36 @@ private List getReleased() { } public List getIndexCompatible() { - return unmodifiableList( - Stream.concat(groupByMajor.get(currentVersion.getMajor() - 1).stream(), groupByMajor.get(currentVersion.getMajor()).stream()) - .filter(version -> version.equals(currentVersion) == false) - .collect(Collectors.toList()) - ); - + int currentMajor = currentVersion.getMajor(); + int prevMajor = getPreviousMajor(currentMajor); + List result = Stream.concat(groupByMajor.get(prevMajor).stream(), groupByMajor.get(currentMajor).stream()) + .filter(version -> version.equals(currentVersion) == false) + .collect(Collectors.toList()); + if (currentMajor == 1) { + // add 6.x compatible for OpenSearch 1.0.0 + return unmodifiableList(Stream.concat(groupByMajor.get(prevMajor - 1).stream(), result.stream()).collect(Collectors.toList())); + } + return unmodifiableList(result); } public List getWireCompatible() { List wireCompat = new ArrayList<>(); + int currentMajor = currentVersion.getMajor(); + int lastMajor = currentMajor == 1 ? 6 : currentMajor - 1; + List lastMajorList = groupByMajor.get(lastMajor); + int minor = lastMajorList.get(lastMajorList.size() - 1).getMinor(); + for (int i = lastMajorList.size() - 1; i > 0 && lastMajorList.get(i).getMinor() == minor; --i) { + wireCompat.add(lastMajorList.get(i)); + } - List prevMajors = groupByMajor.get(currentVersion.getMajor() - 1); - int minor = prevMajors.get(prevMajors.size() - 1).getMinor(); - for (int i = prevMajors.size() - 1; i > 0 && prevMajors.get(i).getMinor() == minor; i--) { - wireCompat.add(prevMajors.get(i)); + // if current is OpenSearch 1.0.0 add all of the 7.x line: + if (currentMajor == 1) { + List previousMajor = groupByMajor.get(7); + for (Version v : previousMajor) { + wireCompat.add(v); + } } - wireCompat.addAll(groupByMajor.get(currentVersion.getMajor())); + wireCompat.addAll(groupByMajor.get(currentMajor)); wireCompat.remove(currentVersion); wireCompat.sort(Version::compareTo); @@ -388,4 +411,8 @@ public List getUnreleasedWireCompatible() { return unmodifiableList(unreleasedWireCompatible); } + private int getPreviousMajor(int currentMajor) { + return currentMajor == 1 ? 7 : currentMajor - 1; + } + } diff --git a/buildSrc/src/main/java/org/opensearch/gradle/Version.java b/buildSrc/src/main/java/org/opensearch/gradle/Version.java index 66994cd5cd57a..8e00b4419f5f3 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/Version.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/Version.java @@ -43,6 +43,8 @@ public final class Version implements Comparable { private final int minor; private final int revision; private final int id; + // used to identify rebase to OpenSearch 1.0.0 + public static final int MASK = 0x08000000; /** * Specifies how a version string should be parsed. @@ -73,7 +75,9 @@ public Version(int major, int minor, int revision) { this.revision = revision; // currently snapshot is not taken into account - this.id = major * 10000000 + minor * 100000 + revision * 1000; + int id = major * 10000000 + minor * 100000 + revision * 1000; + // identify if new OpenSearch version 1 + this.id = major == 1 ? id ^ MASK : id; } private static int parseSuffixNumber(String substring) { diff --git a/buildSrc/src/main/java/org/opensearch/gradle/info/GlobalBuildInfoPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/info/GlobalBuildInfoPlugin.java index 9387640d900cf..5ad7858846dae 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/info/GlobalBuildInfoPlugin.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/info/GlobalBuildInfoPlugin.java @@ -72,6 +72,7 @@ public class GlobalBuildInfoPlugin implements Plugin { private static final Logger LOGGER = Logging.getLogger(GlobalBuildInfoPlugin.class); + private static final String DEFAULT_LEGACY_VERSION_JAVA_FILE_PATH = "server/src/main/java/org/opensearch/LegacyESVersion.java"; private static final String DEFAULT_VERSION_JAVA_FILE_PATH = "server/src/main/java/org/opensearch/Version.java"; private static Integer _defaultParallel = null; private static Boolean _isBundledJdkSupported = null; @@ -140,9 +141,13 @@ public void apply(Project project) { * compatibility. It is *super* important that this logic is the same as the * logic in VersionUtils.java. */ private static BwcVersions resolveBwcVersions(File root) { + // todo redesign this terrible unreliable hack; should NEVER rely on parsing a source file + // for now, we hack the hack File versionsFile = new File(root, DEFAULT_VERSION_JAVA_FILE_PATH); - try { - List versionLines = IOUtils.readLines(new FileInputStream(versionsFile), "UTF-8"); + File legacyVersionsFile = new File(root, DEFAULT_LEGACY_VERSION_JAVA_FILE_PATH); + try (FileInputStream fis = new FileInputStream(versionsFile); FileInputStream fis2 = new FileInputStream(legacyVersionsFile)) { + List versionLines = IOUtils.readLines(fis, "UTF-8"); + versionLines.addAll(IOUtils.readLines(fis2, "UTF-8")); return new BwcVersions(versionLines); } catch (IOException e) { throw new IllegalStateException("Unable to resolve to resolve bwc versions from versionsFile.", e); diff --git a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java b/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java index 30b629fc3859b..bbe2da3d90b13 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java @@ -1151,13 +1151,13 @@ private void createConfiguration() { } else { baseConfig.put("script.max_compilations_rate", "2048/1m"); } - if (getVersion().getMajor() >= 6) { + if (getVersion().onOrAfter("6.0.0")) { baseConfig.put("cluster.routing.allocation.disk.watermark.flood_stage", "1b"); } // Temporarily disable the real memory usage circuit breaker. It depends on real memory usage which we have no full control // over and the REST client will not retry on circuit breaking exceptions yet (see #31986 for details). Once the REST client // can retry on circuit breaking exceptions, we can revert again to the default configuration. - if (getVersion().getMajor() >= 7) { + if (getVersion().onOrAfter("7.0.0")) { baseConfig.put("indices.breaker.total.use_real_memory", "false"); } // Don't wait for state, just start up quickly. This will also allow new and old nodes in the BWC case to become the master @@ -1236,7 +1236,7 @@ private Map jvmOptionExpansions() { if (version.onOrAfter("6.2.0")) { expansions.put("logs/gc.log", relativeLogPath.resolve("gc.log").toString()); } - if (getVersion().getMajor() >= 7) { + if (getVersion().onOrAfter("7.0.0")) { expansions.put( "-XX:ErrorFile=logs/hs_err_pid%p.log", "-XX:ErrorFile=" + relativeLogPath.resolve("hs_err_pid%p.log").toString() diff --git a/buildSrc/src/test/java/org/opensearch/gradle/DistributionDownloadPluginTests.java b/buildSrc/src/test/java/org/opensearch/gradle/DistributionDownloadPluginTests.java index a7fc9e415b721..22d51796bf80f 100644 --- a/buildSrc/src/test/java/org/opensearch/gradle/DistributionDownloadPluginTests.java +++ b/buildSrc/src/test/java/org/opensearch/gradle/DistributionDownloadPluginTests.java @@ -52,11 +52,11 @@ public class DistributionDownloadPluginTests extends GradleUnitTestCase { private static Project packagesProject; private static Project bwcProject; - private static final Version BWC_MAJOR_VERSION = Version.fromString("2.0.0"); - private static final Version BWC_MINOR_VERSION = Version.fromString("1.1.0"); - private static final Version BWC_STAGED_VERSION = Version.fromString("1.0.0"); - private static final Version BWC_BUGFIX_VERSION = Version.fromString("1.0.1"); - private static final Version BWC_MAINTENANCE_VERSION = Version.fromString("0.90.1"); + private static final Version BWC_MAJOR_VERSION = Version.fromString("4.0.0"); + private static final Version BWC_MINOR_VERSION = Version.fromString("3.1.0"); + private static final Version BWC_STAGED_VERSION = Version.fromString("3.0.0"); + private static final Version BWC_BUGFIX_VERSION = Version.fromString("3.0.1"); + private static final Version BWC_MAINTENANCE_VERSION = Version.fromString("2.90.1"); private static final BwcVersions BWC_MINOR = new BwcVersions( new TreeSet<>(Arrays.asList(BWC_BUGFIX_VERSION, BWC_MINOR_VERSION, BWC_MAJOR_VERSION)), BWC_MAJOR_VERSION diff --git a/buildSrc/src/test/java/org/opensearch/gradle/VersionTests.java b/buildSrc/src/test/java/org/opensearch/gradle/VersionTests.java index 0a4779d478184..40f9ffe7dfa8d 100644 --- a/buildSrc/src/test/java/org/opensearch/gradle/VersionTests.java +++ b/buildSrc/src/test/java/org/opensearch/gradle/VersionTests.java @@ -64,7 +64,8 @@ public void testRelaxedVersionParsing() { } public void testCompareWithStringVersions() { - assertTrue("1.10.20 is not interpreted as before 2.0.0", Version.fromString("1.10.20").before("2.0.0")); + // 1.10.2 is now rebased to OpenSearch version; so this needs to report + assertTrue("OpenSearch 1.10.20 is not interpreted as after Legacy 2.0.0", Version.fromString("1.10.20").after("2.0.0")); assertTrue( "7.0.0-alpha1 should be equal to 7.0.0-alpha1", Version.fromString("7.0.0-alpha1").equals(Version.fromString("7.0.0-alpha1")) diff --git a/buildSrc/version.properties b/buildSrc/version.properties index 89b0c6b9bd29d..bb0ec13f29a0d 100644 --- a/buildSrc/version.properties +++ b/buildSrc/version.properties @@ -1,4 +1,4 @@ -opensearch = 7.10.3 +opensearch = 1.0.0 lucene = 8.7.0 bundled_jdk_vendor = adoptopenjdk diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/core/MainResponseTests.java b/client/rest-high-level/src/test/java/org/opensearch/client/core/MainResponseTests.java index 48b21f96faa71..2eb746c2feec8 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/core/MainResponseTests.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/core/MainResponseTests.java @@ -33,6 +33,7 @@ package org.opensearch.client.core; import org.opensearch.Build; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.client.AbstractResponseTestCase; import org.opensearch.cluster.ClusterName; @@ -52,7 +53,7 @@ protected org.opensearch.action.main.MainResponse createServerTestInstance(XCont ClusterName clusterName = new ClusterName(randomAlphaOfLength(10)); String nodeName = randomAlphaOfLength(10); final String date = new Date(randomNonNegativeLong()).toString(); - Version version = VersionUtils.randomVersionBetween(random(), Version.V_6_0_1, Version.CURRENT); + Version version = VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_6_0_1, Version.CURRENT); Build build = new Build( Build.Type.UNKNOWN, randomAlphaOfLength(8), date, randomBoolean(), version.toString() diff --git a/distribution/tools/plugin-cli/src/test/java/org/opensearch/plugins/ListPluginsCommandTests.java b/distribution/tools/plugin-cli/src/test/java/org/opensearch/plugins/ListPluginsCommandTests.java index b9e29791c8b50..b5a0349ced205 100644 --- a/distribution/tools/plugin-cli/src/test/java/org/opensearch/plugins/ListPluginsCommandTests.java +++ b/distribution/tools/plugin-cli/src/test/java/org/opensearch/plugins/ListPluginsCommandTests.java @@ -41,6 +41,7 @@ import java.util.stream.Collectors; import org.apache.lucene.util.LuceneTestCase; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.cli.ExitCodes; import org.opensearch.cli.MockTerminal; @@ -262,7 +263,7 @@ public void testExistingIncompatiblePlugin() throws Exception { "version", "1.0", "opensearch.version", - Version.fromString("1.0.0").toString(), + LegacyESVersion.fromString("5.0.0").toString(), "java.version", System.getProperty("java.specification.version"), "classname", diff --git a/modules/analysis-common/src/main/java/org/opensearch/analysis/common/CJKBigramFilterFactory.java b/modules/analysis-common/src/main/java/org/opensearch/analysis/common/CJKBigramFilterFactory.java index 91e219145deca..695b1f1dbfc34 100644 --- a/modules/analysis-common/src/main/java/org/opensearch/analysis/common/CJKBigramFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/opensearch/analysis/common/CJKBigramFilterFactory.java @@ -35,7 +35,7 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.cjk.CJKBigramFilter; import org.apache.lucene.analysis.miscellaneous.DisableGraphAttribute; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.settings.Settings; import org.opensearch.env.Environment; @@ -110,7 +110,7 @@ public TokenStream create(TokenStream tokenStream) { @Override public TokenFilterFactory getSynonymFilter() { if (outputUnigrams) { - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { + if (indexSettings.getIndexVersionCreated().onOrAfter(LegacyESVersion.V_7_0_0)) { throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); } diff --git a/modules/analysis-common/src/main/java/org/opensearch/analysis/common/CommonAnalysisPlugin.java b/modules/analysis-common/src/main/java/org/opensearch/analysis/common/CommonAnalysisPlugin.java index 27c340a186afc..96dc596ae5dc1 100644 --- a/modules/analysis-common/src/main/java/org/opensearch/analysis/common/CommonAnalysisPlugin.java +++ b/modules/analysis-common/src/main/java/org/opensearch/analysis/common/CommonAnalysisPlugin.java @@ -124,7 +124,7 @@ import org.apache.lucene.analysis.tr.TurkishAnalyzer; import org.apache.lucene.analysis.util.ElisionFilter; import org.apache.lucene.util.SetOnce; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.client.Client; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; import org.opensearch.cluster.service.ClusterService; @@ -335,7 +335,7 @@ public Map> getTokenizers() { tokenizers.put("simple_pattern_split", SimplePatternSplitTokenizerFactory::new); tokenizers.put("thai", ThaiTokenizerFactory::new); tokenizers.put("nGram", (IndexSettings indexSettings, Environment environment, String name, Settings settings) -> { - if (indexSettings.getIndexVersionCreated().onOrAfter(org.opensearch.Version.V_7_6_0)) { + if (indexSettings.getIndexVersionCreated().onOrAfter(LegacyESVersion.V_7_6_0)) { deprecationLogger.deprecate("nGram_tokenizer_deprecation", "The [nGram] tokenizer name is deprecated and will be removed in a future version. " + "Please change the tokenizer name to [ngram] instead."); @@ -344,7 +344,7 @@ public Map> getTokenizers() { }); tokenizers.put("ngram", NGramTokenizerFactory::new); tokenizers.put("edgeNGram", (IndexSettings indexSettings, Environment environment, String name, Settings settings) -> { - if (indexSettings.getIndexVersionCreated().onOrAfter(org.opensearch.Version.V_7_6_0)) { + if (indexSettings.getIndexVersionCreated().onOrAfter(LegacyESVersion.V_7_6_0)) { deprecationLogger.deprecate("edgeNGram_tokenizer_deprecation", "The [edgeNGram] tokenizer name is deprecated and will be removed in a future version. " + "Please change the tokenizer name to [edge_ngram] instead."); @@ -425,7 +425,7 @@ public List getPreConfiguredCharFilters() { List filters = new ArrayList<>(); filters.add(PreConfiguredCharFilter.singleton("html_strip", false, HTMLStripCharFilter::new)); filters.add(PreConfiguredCharFilter.openSearchVersion("htmlStrip", false, (reader, version) -> { - if (version.onOrAfter(org.opensearch.Version.V_6_3_0)) { + if (version.onOrAfter(LegacyESVersion.V_6_3_0)) { deprecationLogger.deprecate("htmlStrip_deprecation", "The [htmpStrip] char filter name is deprecated and will be removed in a future version. " + "Please change the filter name to [html_strip] instead."); @@ -452,11 +452,11 @@ public List getPreConfiguredTokenFilters() { filters.add(PreConfiguredTokenFilter.singleton("czech_stem", false, CzechStemFilter::new)); filters.add(PreConfiguredTokenFilter.singleton("decimal_digit", true, DecimalDigitFilter::new)); filters.add(PreConfiguredTokenFilter.openSearchVersion("delimited_payload_filter", false, (input, version) -> { - if (version.onOrAfter(Version.V_7_0_0)) { + if (version.onOrAfter(LegacyESVersion.V_7_0_0)) { throw new IllegalArgumentException( "[delimited_payload_filter] is not supported for new indices, use [delimited_payload] instead"); } - if (version.onOrAfter(Version.V_6_2_0)) { + if (version.onOrAfter(LegacyESVersion.V_6_2_0)) { deprecationLogger.deprecate("analysis_delimited_payload_filter", "Deprecated [delimited_payload_filter] used, replaced by [delimited_payload]"); } @@ -472,7 +472,7 @@ public List getPreConfiguredTokenFilters() { filters.add(PreConfiguredTokenFilter.singleton("edge_ngram", false, false, input -> new EdgeNGramTokenFilter(input, 1))); filters.add(PreConfiguredTokenFilter.openSearchVersion("edgeNGram", false, false, (reader, version) -> { - if (version.onOrAfter(org.opensearch.Version.V_7_0_0)) { + if (version.onOrAfter(LegacyESVersion.V_7_0_0)) { throw new IllegalArgumentException( "The [edgeNGram] token filter name was deprecated in 6.4 and cannot be used in new indices. " + "Please change the filter name to [edge_ngram] instead."); @@ -500,7 +500,7 @@ public List getPreConfiguredTokenFilters() { LimitTokenCountFilterFactory.DEFAULT_CONSUME_ALL_TOKENS))); filters.add(PreConfiguredTokenFilter.singleton("ngram", false, false, reader -> new NGramTokenFilter(reader, 1, 2, false))); filters.add(PreConfiguredTokenFilter.openSearchVersion("nGram", false, false, (reader, version) -> { - if (version.onOrAfter(org.opensearch.Version.V_7_0_0)) { + if (version.onOrAfter(LegacyESVersion.V_7_0_0)) { throw new IllegalArgumentException("The [nGram] token filter name was deprecated in 6.4 and cannot be used in new indices. " + "Please change the filter name to [ngram] instead."); } else { @@ -546,7 +546,7 @@ public List getPreConfiguredTokenFilters() { | WordDelimiterFilter.SPLIT_ON_NUMERICS | WordDelimiterFilter.STEM_ENGLISH_POSSESSIVE, null))); filters.add(PreConfiguredTokenFilter.openSearchVersion("word_delimiter_graph", false, false, (input, version) -> { - boolean adjustOffsets = version.onOrAfter(Version.V_7_3_0); + boolean adjustOffsets = version.onOrAfter(LegacyESVersion.V_7_3_0); return new WordDelimiterGraphFilter(input, adjustOffsets, WordDelimiterIterator.DEFAULT_WORD_DELIM_TABLE, WordDelimiterGraphFilter.GENERATE_WORD_PARTS | WordDelimiterGraphFilter.GENERATE_NUMBER_PARTS @@ -568,7 +568,7 @@ public List getPreConfiguredTokenizers() { tokenizers.add(PreConfiguredTokenizer.singleton("whitespace", WhitespaceTokenizer::new)); tokenizers.add(PreConfiguredTokenizer.singleton("ngram", NGramTokenizer::new)); tokenizers.add(PreConfiguredTokenizer.openSearchVersion("edge_ngram", (version) -> { - if (version.onOrAfter(Version.V_7_3_0)) { + if (version.onOrAfter(LegacyESVersion.V_7_3_0)) { return new EdgeNGramTokenizer(NGramTokenizer.DEFAULT_MIN_NGRAM_SIZE, NGramTokenizer.DEFAULT_MAX_NGRAM_SIZE); } return new EdgeNGramTokenizer(EdgeNGramTokenizer.DEFAULT_MIN_GRAM_SIZE, EdgeNGramTokenizer.DEFAULT_MAX_GRAM_SIZE); @@ -581,7 +581,7 @@ public List getPreConfiguredTokenizers() { // Temporary shim for aliases. TODO deprecate after they are moved tokenizers.add(PreConfiguredTokenizer.openSearchVersion("nGram", (version) -> { - if (version.onOrAfter(org.opensearch.Version.V_7_6_0)) { + if (version.onOrAfter(LegacyESVersion.V_7_6_0)) { deprecationLogger.deprecate("nGram_tokenizer_deprecation", "The [nGram] tokenizer name is deprecated and will be removed in a future version. " + "Please change the tokenizer name to [ngram] instead."); @@ -589,12 +589,12 @@ public List getPreConfiguredTokenizers() { return new NGramTokenizer(); })); tokenizers.add(PreConfiguredTokenizer.openSearchVersion("edgeNGram", (version) -> { - if (version.onOrAfter(org.opensearch.Version.V_7_6_0)) { + if (version.onOrAfter(LegacyESVersion.V_7_6_0)) { deprecationLogger.deprecate("edgeNGram_tokenizer_deprecation", "The [edgeNGram] tokenizer name is deprecated and will be removed in a future version. " + "Please change the tokenizer name to [edge_ngram] instead."); } - if (version.onOrAfter(Version.V_7_3_0)) { + if (version.onOrAfter(LegacyESVersion.V_7_3_0)) { return new EdgeNGramTokenizer(NGramTokenizer.DEFAULT_MIN_NGRAM_SIZE, NGramTokenizer.DEFAULT_MAX_NGRAM_SIZE); } return new EdgeNGramTokenizer(EdgeNGramTokenizer.DEFAULT_MIN_GRAM_SIZE, EdgeNGramTokenizer.DEFAULT_MAX_GRAM_SIZE); diff --git a/modules/analysis-common/src/main/java/org/opensearch/analysis/common/CommonGramsTokenFilterFactory.java b/modules/analysis-common/src/main/java/org/opensearch/analysis/common/CommonGramsTokenFilterFactory.java index c629cdb2da679..d4c64a966d360 100644 --- a/modules/analysis-common/src/main/java/org/opensearch/analysis/common/CommonGramsTokenFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/opensearch/analysis/common/CommonGramsTokenFilterFactory.java @@ -36,7 +36,7 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.commongrams.CommonGramsFilter; import org.apache.lucene.analysis.commongrams.CommonGramsQueryFilter; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.settings.Settings; import org.opensearch.env.Environment; @@ -79,7 +79,7 @@ public TokenStream create(TokenStream tokenStream) { @Override public TokenFilterFactory getSynonymFilter() { - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { + if (indexSettings.getIndexVersionCreated().onOrAfter(LegacyESVersion.V_7_0_0)) { throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); } else { DEPRECATION_LOGGER.deprecate("synonym_tokenfilters", "Token filter [" + name() diff --git a/modules/analysis-common/src/main/java/org/opensearch/analysis/common/EdgeNGramTokenFilterFactory.java b/modules/analysis-common/src/main/java/org/opensearch/analysis/common/EdgeNGramTokenFilterFactory.java index 9039150b3af00..20e6dbe9a9e59 100644 --- a/modules/analysis-common/src/main/java/org/opensearch/analysis/common/EdgeNGramTokenFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/opensearch/analysis/common/EdgeNGramTokenFilterFactory.java @@ -35,7 +35,7 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.ngram.EdgeNGramTokenFilter; import org.apache.lucene.analysis.reverse.ReverseStringFilter; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.settings.Settings; import org.opensearch.env.Environment; @@ -100,7 +100,7 @@ public boolean breaksFastVectorHighlighter() { @Override public TokenFilterFactory getSynonymFilter() { - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { + if (indexSettings.getIndexVersionCreated().onOrAfter(LegacyESVersion.V_7_0_0)) { throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); } else { diff --git a/modules/analysis-common/src/main/java/org/opensearch/analysis/common/FingerprintTokenFilterFactory.java b/modules/analysis-common/src/main/java/org/opensearch/analysis/common/FingerprintTokenFilterFactory.java index bdf98b6e3ea23..3c6ba893b0c24 100644 --- a/modules/analysis-common/src/main/java/org/opensearch/analysis/common/FingerprintTokenFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/opensearch/analysis/common/FingerprintTokenFilterFactory.java @@ -34,7 +34,7 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.miscellaneous.FingerprintFilter; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.settings.Settings; import org.opensearch.env.Environment; @@ -67,7 +67,7 @@ public TokenStream create(TokenStream tokenStream) { @Override public TokenFilterFactory getSynonymFilter() { - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { + if (indexSettings.getIndexVersionCreated().onOrAfter(LegacyESVersion.V_7_0_0)) { throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); } else { diff --git a/modules/analysis-common/src/main/java/org/opensearch/analysis/common/LegacyDelimitedPayloadTokenFilterFactory.java b/modules/analysis-common/src/main/java/org/opensearch/analysis/common/LegacyDelimitedPayloadTokenFilterFactory.java index f2c1febde942c..66fbe8b2907ac 100644 --- a/modules/analysis-common/src/main/java/org/opensearch/analysis/common/LegacyDelimitedPayloadTokenFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/opensearch/analysis/common/LegacyDelimitedPayloadTokenFilterFactory.java @@ -32,7 +32,7 @@ package org.opensearch.analysis.common; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.settings.Settings; import org.opensearch.env.Environment; @@ -45,11 +45,11 @@ public class LegacyDelimitedPayloadTokenFilterFactory extends DelimitedPayloadTo LegacyDelimitedPayloadTokenFilterFactory(IndexSettings indexSettings, Environment env, String name, Settings settings) { super(indexSettings, env, name, settings); - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { + if (indexSettings.getIndexVersionCreated().onOrAfter(LegacyESVersion.V_7_0_0)) { throw new IllegalArgumentException( "[delimited_payload_filter] is not supported for new indices, use [delimited_payload] instead"); } - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_6_2_0)) { + if (indexSettings.getIndexVersionCreated().onOrAfter(LegacyESVersion.V_6_2_0)) { deprecationLogger.deprecate("analysis_legacy_delimited_payload_filter", "Deprecated [delimited_payload_filter] used, replaced by [delimited_payload]"); } diff --git a/modules/analysis-common/src/main/java/org/opensearch/analysis/common/MultiplexerTokenFilterFactory.java b/modules/analysis-common/src/main/java/org/opensearch/analysis/common/MultiplexerTokenFilterFactory.java index 55e3f68e1f1e4..7bbfed0c4405f 100644 --- a/modules/analysis-common/src/main/java/org/opensearch/analysis/common/MultiplexerTokenFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/opensearch/analysis/common/MultiplexerTokenFilterFactory.java @@ -37,7 +37,7 @@ import org.apache.lucene.analysis.miscellaneous.ConditionalTokenFilter; import org.apache.lucene.analysis.miscellaneous.RemoveDuplicatesTokenFilter; import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.common.Strings; import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.settings.Settings; @@ -74,7 +74,7 @@ public TokenStream create(TokenStream tokenStream) { @Override public TokenFilterFactory getSynonymFilter() { - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { + if (indexSettings.getIndexVersionCreated().onOrAfter(LegacyESVersion.V_7_0_0)) { throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); } else { @@ -137,7 +137,7 @@ public TokenStream create(TokenStream tokenStream) { @Override public TokenFilterFactory getSynonymFilter() { - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { + if (indexSettings.getIndexVersionCreated().onOrAfter(LegacyESVersion.V_7_0_0)) { throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); } else { diff --git a/modules/analysis-common/src/main/java/org/opensearch/analysis/common/NGramTokenFilterFactory.java b/modules/analysis-common/src/main/java/org/opensearch/analysis/common/NGramTokenFilterFactory.java index 217f0722f0d18..05204cb6e0238 100644 --- a/modules/analysis-common/src/main/java/org/opensearch/analysis/common/NGramTokenFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/opensearch/analysis/common/NGramTokenFilterFactory.java @@ -34,7 +34,7 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.ngram.NGramTokenFilter; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.settings.Settings; import org.opensearch.env.Environment; @@ -59,7 +59,7 @@ public class NGramTokenFilterFactory extends AbstractTokenFilterFactory { this.maxGram = settings.getAsInt("max_gram", 2); int ngramDiff = maxGram - minGram; if (ngramDiff > maxAllowedNgramDiff) { - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { + if (indexSettings.getIndexVersionCreated().onOrAfter(LegacyESVersion.V_7_0_0)) { throw new IllegalArgumentException( "The difference between max_gram and min_gram in NGram Tokenizer must be less than or equal to: [" + maxAllowedNgramDiff + "] but was [" + ngramDiff + "]. This limit can be set by changing the [" @@ -80,7 +80,7 @@ public TokenStream create(TokenStream tokenStream) { @Override public TokenFilterFactory getSynonymFilter() { - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { + if (indexSettings.getIndexVersionCreated().onOrAfter(LegacyESVersion.V_7_0_0)) { throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); } else { diff --git a/modules/analysis-common/src/main/java/org/opensearch/analysis/common/NGramTokenizerFactory.java b/modules/analysis-common/src/main/java/org/opensearch/analysis/common/NGramTokenizerFactory.java index da1306cad26d4..cdfd1f38d4338 100644 --- a/modules/analysis-common/src/main/java/org/opensearch/analysis/common/NGramTokenizerFactory.java +++ b/modules/analysis-common/src/main/java/org/opensearch/analysis/common/NGramTokenizerFactory.java @@ -34,7 +34,7 @@ import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.ngram.NGramTokenizer; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.common.settings.Settings; import org.opensearch.env.Environment; import org.opensearch.index.IndexSettings; @@ -125,7 +125,7 @@ public boolean isTokenChar(int c) { this.maxGram = settings.getAsInt("max_gram", NGramTokenizer.DEFAULT_MAX_NGRAM_SIZE); int ngramDiff = maxGram - minGram; if (ngramDiff > maxAllowedNgramDiff) { - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { + if (indexSettings.getIndexVersionCreated().onOrAfter(LegacyESVersion.V_7_0_0)) { throw new IllegalArgumentException( "The difference between max_gram and min_gram in NGram Tokenizer must be less than or equal to: [" + maxAllowedNgramDiff + "] but was [" + ngramDiff + "]. This limit can be set by changing the [" diff --git a/modules/analysis-common/src/main/java/org/opensearch/analysis/common/StandardHtmlStripAnalyzerProvider.java b/modules/analysis-common/src/main/java/org/opensearch/analysis/common/StandardHtmlStripAnalyzerProvider.java index 8621eef5478eb..01fb3163bc67d 100644 --- a/modules/analysis-common/src/main/java/org/opensearch/analysis/common/StandardHtmlStripAnalyzerProvider.java +++ b/modules/analysis-common/src/main/java/org/opensearch/analysis/common/StandardHtmlStripAnalyzerProvider.java @@ -33,7 +33,7 @@ package org.opensearch.analysis.common; import org.apache.lucene.analysis.CharArraySet; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.settings.Settings; import org.opensearch.env.Environment; @@ -58,7 +58,7 @@ public class StandardHtmlStripAnalyzerProvider extends AbstractIndexAnalyzerProv CharArraySet stopWords = Analysis.parseStopWords(env, settings, defaultStopwords); analyzer = new StandardHtmlStripAnalyzer(stopWords); analyzer.setVersion(version); - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { + if (indexSettings.getIndexVersionCreated().onOrAfter(LegacyESVersion.V_7_0_0)) { throw new IllegalArgumentException("[standard_html_strip] analyzer is not supported for new indices, " + "use a custom analyzer using [standard] tokenizer and [html_strip] char_filter, plus [lowercase] filter"); } else { diff --git a/modules/analysis-common/src/main/java/org/opensearch/analysis/common/WordDelimiterGraphTokenFilterFactory.java b/modules/analysis-common/src/main/java/org/opensearch/analysis/common/WordDelimiterGraphTokenFilterFactory.java index d0112cd0a472c..ae3a949fe6b81 100644 --- a/modules/analysis-common/src/main/java/org/opensearch/analysis/common/WordDelimiterGraphTokenFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/opensearch/analysis/common/WordDelimiterGraphTokenFilterFactory.java @@ -36,7 +36,7 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.miscellaneous.WordDelimiterGraphFilter; import org.apache.lucene.analysis.miscellaneous.WordDelimiterIterator; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.settings.Settings; import org.opensearch.env.Environment; @@ -121,7 +121,7 @@ public TokenStream create(TokenStream tokenStream) { @Override public TokenFilterFactory getSynonymFilter() { - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { + if (indexSettings.getIndexVersionCreated().onOrAfter(LegacyESVersion.V_7_0_0)) { throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); } else { diff --git a/modules/analysis-common/src/main/java/org/opensearch/analysis/common/WordDelimiterTokenFilterFactory.java b/modules/analysis-common/src/main/java/org/opensearch/analysis/common/WordDelimiterTokenFilterFactory.java index f652f0bc4d1f4..67ad8a7cb1eac 100644 --- a/modules/analysis-common/src/main/java/org/opensearch/analysis/common/WordDelimiterTokenFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/opensearch/analysis/common/WordDelimiterTokenFilterFactory.java @@ -36,7 +36,7 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.miscellaneous.WordDelimiterFilter; import org.apache.lucene.analysis.miscellaneous.WordDelimiterIterator; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.settings.Settings; import org.opensearch.env.Environment; @@ -124,7 +124,7 @@ public TokenStream create(TokenStream tokenStream) { @Override public TokenFilterFactory getSynonymFilter() { - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { + if (indexSettings.getIndexVersionCreated().onOrAfter(LegacyESVersion.V_7_0_0)) { throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); } else { diff --git a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/CommonAnalysisPluginTests.java b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/CommonAnalysisPluginTests.java index e230d33101600..5617d04432cc9 100644 --- a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/CommonAnalysisPluginTests.java +++ b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/CommonAnalysisPluginTests.java @@ -34,6 +34,7 @@ import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.Tokenizer; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.settings.Settings; @@ -57,7 +58,8 @@ public class CommonAnalysisPluginTests extends OpenSearchTestCase { public void testNGramDeprecationWarning() throws IOException { Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()) .put(IndexMetadata.SETTING_VERSION_CREATED, - VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, VersionUtils.getPreviousVersion(Version.V_7_0_0))) + VersionUtils.randomVersionBetween( + random(), LegacyESVersion.V_6_0_0, VersionUtils.getPreviousVersion(LegacyESVersion.V_7_0_0))) .put("index.analysis.analyzer.custom_analyzer.type", "custom") .put("index.analysis.analyzer.custom_analyzer.tokenizer", "standard") .putList("index.analysis.analyzer.custom_analyzer.filter", "nGram") @@ -76,7 +78,7 @@ public void testNGramDeprecationWarning() throws IOException { */ public void testNGramDeprecationError() throws IOException { Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()) - .put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, null)) + .put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_7_0_0, null)) .put("index.analysis.analyzer.custom_analyzer.type", "custom") .put("index.analysis.analyzer.custom_analyzer.tokenizer", "standard") .putList("index.analysis.analyzer.custom_analyzer.filter", "nGram") @@ -96,7 +98,8 @@ public void testNGramDeprecationError() throws IOException { public void testEdgeNGramDeprecationWarning() throws IOException { Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()) .put(IndexMetadata.SETTING_VERSION_CREATED, - VersionUtils.randomVersionBetween(random(), Version.V_6_4_0, VersionUtils.getPreviousVersion(Version.V_7_0_0))) + VersionUtils.randomVersionBetween( + random(), LegacyESVersion.V_6_4_0, VersionUtils.getPreviousVersion(LegacyESVersion.V_7_0_0))) .put("index.analysis.analyzer.custom_analyzer.type", "custom") .put("index.analysis.analyzer.custom_analyzer.tokenizer", "standard") .putList("index.analysis.analyzer.custom_analyzer.filter", "edgeNGram") @@ -114,7 +117,7 @@ public void testEdgeNGramDeprecationWarning() throws IOException { */ public void testEdgeNGramDeprecationError() throws IOException { Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()) - .put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, null)) + .put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_7_0_0, null)) .put("index.analysis.analyzer.custom_analyzer.type", "custom") .put("index.analysis.analyzer.custom_analyzer.tokenizer", "standard") .putList("index.analysis.analyzer.custom_analyzer.filter", "edgeNGram") @@ -134,7 +137,7 @@ public void testEdgeNGramDeprecationError() throws IOException { public void testStandardHtmlStripAnalyzerDeprecationError() throws IOException { Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()) .put(IndexMetadata.SETTING_VERSION_CREATED, - VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, Version.CURRENT)) + VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_7_0_0, Version.CURRENT)) .put("index.analysis.analyzer.custom_analyzer.type", "standard_html_strip") .putList("index.analysis.analyzer.custom_analyzer.stopwords", "a", "b") .build(); @@ -153,8 +156,8 @@ public void testStandardHtmlStripAnalyzerDeprecationError() throws IOException { public void testStandardHtmlStripAnalyzerDeprecationWarning() throws IOException { Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()) .put(IndexMetadata.SETTING_VERSION_CREATED, - VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, - VersionUtils.getPreviousVersion(Version.V_7_0_0))) + VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_6_0_0, + VersionUtils.getPreviousVersion(LegacyESVersion.V_7_0_0))) .put("index.analysis.analyzer.custom_analyzer.type", "standard_html_strip") .putList("index.analysis.analyzer.custom_analyzer.stopwords", "a", "b") .build(); @@ -176,7 +179,7 @@ public void testStandardHtmlStripAnalyzerDeprecationWarning() throws IOException public void testnGramFilterInCustomAnalyzerDeprecationError() throws IOException { final Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()) .put(IndexMetadata.SETTING_VERSION_CREATED, - VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, Version.CURRENT)) + VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_7_0_0, Version.CURRENT)) .put("index.analysis.analyzer.custom_analyzer.type", "custom") .put("index.analysis.analyzer.custom_analyzer.tokenizer", "standard") .putList("index.analysis.analyzer.custom_analyzer.filter", "my_ngram") @@ -196,7 +199,7 @@ public void testnGramFilterInCustomAnalyzerDeprecationError() throws IOException public void testEdgeNGramFilterInCustomAnalyzerDeprecationError() throws IOException { final Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()) .put(IndexMetadata.SETTING_VERSION_CREATED, - VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, Version.CURRENT)) + VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_7_0_0, Version.CURRENT)) .put("index.analysis.analyzer.custom_analyzer.type", "custom") .put("index.analysis.analyzer.custom_analyzer.tokenizer", "standard") .putList("index.analysis.analyzer.custom_analyzer.filter", "my_ngram") @@ -216,19 +219,19 @@ public void testEdgeNGramFilterInCustomAnalyzerDeprecationError() throws IOExcep public void testNGramTokenizerDeprecation() throws IOException { // tests for prebuilt tokenizer doTestPrebuiltTokenizerDeprecation("nGram", "ngram", - VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, Version.V_7_5_2), false); + VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_7_0_0, LegacyESVersion.V_7_5_2), false); doTestPrebuiltTokenizerDeprecation("edgeNGram", "edge_ngram", - VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, Version.V_7_5_2), false); - doTestPrebuiltTokenizerDeprecation("nGram", "ngram", Version.V_7_6_0, true); - doTestPrebuiltTokenizerDeprecation("edgeNGram", "edge_ngram", Version.V_7_6_0, true); + VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_7_0_0, LegacyESVersion.V_7_5_2), false); + doTestPrebuiltTokenizerDeprecation("nGram", "ngram", LegacyESVersion.V_7_6_0, true); + doTestPrebuiltTokenizerDeprecation("edgeNGram", "edge_ngram", LegacyESVersion.V_7_6_0, true); // same batch of tests for custom tokenizer definition in the settings doTestCustomTokenizerDeprecation("nGram", "ngram", - VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, Version.V_7_5_2), false); + VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_7_0_0, LegacyESVersion.V_7_5_2), false); doTestCustomTokenizerDeprecation("edgeNGram", "edge_ngram", - VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, Version.V_7_5_2), false); - doTestCustomTokenizerDeprecation("nGram", "ngram", Version.V_7_6_0, true); - doTestCustomTokenizerDeprecation("edgeNGram", "edge_ngram", Version.V_7_6_0, true); + VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_7_0_0, LegacyESVersion.V_7_5_2), false); + doTestCustomTokenizerDeprecation("nGram", "ngram", LegacyESVersion.V_7_6_0, true); + doTestCustomTokenizerDeprecation("edgeNGram", "edge_ngram", LegacyESVersion.V_7_6_0, true); } public void doTestPrebuiltTokenizerDeprecation(String deprecatedName, String replacement, Version version, boolean expectWarning) diff --git a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/EdgeNGramTokenizerTests.java b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/EdgeNGramTokenizerTests.java index 96b48a4355fb4..74f1ca9597b44 100644 --- a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/EdgeNGramTokenizerTests.java +++ b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/EdgeNGramTokenizerTests.java @@ -33,6 +33,7 @@ package org.opensearch.analysis.common; import org.apache.lucene.analysis.Tokenizer; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.settings.Settings; @@ -70,8 +71,8 @@ public void testPreConfiguredTokenizer() throws IOException { // Before 7.3 we return ngrams of length 1 only { - Version version = VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, - VersionUtils.getPreviousVersion(Version.V_7_3_0)); + Version version = VersionUtils.randomVersionBetween(random(), LegacyESVersion.fromString("7.0.0"), + VersionUtils.getPreviousVersion(LegacyESVersion.fromString("7.3.0"))); try (IndexAnalyzers indexAnalyzers = buildAnalyzers(version, "edge_ngram")) { NamedAnalyzer analyzer = indexAnalyzers.get("my_analyzer"); assertNotNull(analyzer); @@ -81,8 +82,8 @@ public void testPreConfiguredTokenizer() throws IOException { // Check deprecated name as well { - Version version = VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, - VersionUtils.getPreviousVersion(Version.V_7_3_0)); + Version version = VersionUtils.randomVersionBetween(random(), LegacyESVersion.fromString("7.0.0"), + VersionUtils.getPreviousVersion(LegacyESVersion.fromString("7.3.0"))); try (IndexAnalyzers indexAnalyzers = buildAnalyzers(version, "edgeNGram")) { NamedAnalyzer analyzer = indexAnalyzers.get("my_analyzer"); assertNotNull(analyzer); @@ -102,7 +103,7 @@ public void testPreConfiguredTokenizer() throws IOException { // Check deprecated name as well, needs version before 8.0 because throws IAE after that { try (IndexAnalyzers indexAnalyzers = buildAnalyzers( - VersionUtils.randomVersionBetween(random(), Version.V_7_3_0, Version.CURRENT), + VersionUtils.randomVersionBetween(random(), LegacyESVersion.fromString("7.3.0"), Version.CURRENT), "edgeNGram")) { NamedAnalyzer analyzer = indexAnalyzers.get("my_analyzer"); assertNotNull(analyzer); diff --git a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/HtmlStripCharFilterFactoryTests.java b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/HtmlStripCharFilterFactoryTests.java index bc95aedf3a016..1e5cd039b5354 100644 --- a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/HtmlStripCharFilterFactoryTests.java +++ b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/HtmlStripCharFilterFactoryTests.java @@ -32,6 +32,7 @@ package org.opensearch.analysis.common; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.settings.Settings; @@ -54,7 +55,8 @@ public class HtmlStripCharFilterFactoryTests extends OpenSearchTestCase { */ public void testDeprecationWarning() throws IOException { Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()) - .put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_6_3_0, Version.CURRENT)) + .put(IndexMetadata.SETTING_VERSION_CREATED, + VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_6_3_0, Version.CURRENT)) .build(); IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("index", settings); @@ -73,7 +75,7 @@ public void testDeprecationWarning() throws IOException { public void testNoDeprecationWarningPre6_3() throws IOException { Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()) .put(IndexMetadata.SETTING_VERSION_CREATED, - VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, Version.V_6_2_4)) + VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_6_0_0, LegacyESVersion.V_6_2_4)) .build(); IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("index", settings); diff --git a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/SynonymsAnalysisTests.java b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/SynonymsAnalysisTests.java index 66780eea32111..bb1ceb4663d0a 100644 --- a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/SynonymsAnalysisTests.java +++ b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/SynonymsAnalysisTests.java @@ -37,6 +37,7 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.core.KeywordTokenizer; import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.settings.Settings; @@ -219,7 +220,7 @@ public void testShingleFilters() { Settings settings = Settings.builder() .put(IndexMetadata.SETTING_VERSION_CREATED, - VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, Version.CURRENT)) + VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_7_0_0, Version.CURRENT)) .put("path.home", createTempDir().toString()) .put("index.analysis.filter.synonyms.type", "synonym") .putList("index.analysis.filter.synonyms.synonyms", "programmer, developer") @@ -271,7 +272,7 @@ public void testPreconfiguredTokenFilters() throws IOException { Settings settings = Settings.builder() .put(IndexMetadata.SETTING_VERSION_CREATED, - VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, Version.CURRENT)) + VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_7_0_0, Version.CURRENT)) .put("path.home", createTempDir().toString()) .build(); IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("index", settings); @@ -295,7 +296,8 @@ public void testPreconfiguredTokenFilters() throws IOException { Settings settings2 = Settings.builder() .put(IndexMetadata.SETTING_VERSION_CREATED, - VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, VersionUtils.getPreviousVersion(Version.V_7_0_0))) + VersionUtils.randomVersionBetween( + random(), LegacyESVersion.V_6_0_0, VersionUtils.getPreviousVersion(LegacyESVersion.V_7_0_0))) .put("path.home", createTempDir().toString()) .putList("common_words", "a", "b") .put("output_unigrams", "true") @@ -319,7 +321,7 @@ public void testDisallowedTokenFilters() throws IOException { Settings settings = Settings.builder() .put(IndexMetadata.SETTING_VERSION_CREATED, - VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, Version.CURRENT)) + VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_7_0_0, Version.CURRENT)) .put("path.home", createTempDir().toString()) .putList("common_words", "a", "b") .put("output_unigrams", "true") @@ -348,7 +350,8 @@ public void testDisallowedTokenFilters() throws IOException { settings = Settings.builder() .put(IndexMetadata.SETTING_VERSION_CREATED, - VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, VersionUtils.getPreviousVersion(Version.V_7_0_0))) + VersionUtils.randomVersionBetween( + random(), LegacyESVersion.V_6_0_0, VersionUtils.getPreviousVersion(LegacyESVersion.V_7_0_0))) .put("path.home", createTempDir().toString()) .putList("common_words", "a", "b") .put("output_unigrams", "true") @@ -370,7 +373,8 @@ public void testDisallowedTokenFilters() throws IOException { settings = Settings.builder() .put(IndexMetadata.SETTING_VERSION_CREATED, - VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, VersionUtils.getPreviousVersion(Version.V_7_0_0))) + VersionUtils.randomVersionBetween( + random(), LegacyESVersion.V_6_0_0, VersionUtils.getPreviousVersion(LegacyESVersion.V_7_0_0))) .put("path.home", createTempDir().toString()) .put("preserve_original", "false") .build(); diff --git a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/WordDelimiterGraphTokenFilterFactoryTests.java b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/WordDelimiterGraphTokenFilterFactoryTests.java index 0e31323f50dde..851f2bfebaaf2 100644 --- a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/WordDelimiterGraphTokenFilterFactoryTests.java +++ b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/WordDelimiterGraphTokenFilterFactoryTests.java @@ -33,6 +33,7 @@ import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.core.WhitespaceTokenizer; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.settings.Settings; @@ -171,7 +172,8 @@ public void testPreconfiguredFilter() throws IOException { .build(); Settings indexSettings = Settings.builder() .put(IndexMetadata.SETTING_VERSION_CREATED, - VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, VersionUtils.getPreviousVersion(Version.V_7_3_0))) + VersionUtils.randomVersionBetween( + random(), LegacyESVersion.V_7_0_0, VersionUtils.getPreviousVersion(LegacyESVersion.V_7_3_0))) .put("index.analysis.analyzer.my_analyzer.tokenizer", "standard") .putList("index.analysis.analyzer.my_analyzer.filter", "word_delimiter_graph") .build(); diff --git a/modules/ingest-common/src/main/java/org/opensearch/ingest/common/GrokProcessorGetAction.java b/modules/ingest-common/src/main/java/org/opensearch/ingest/common/GrokProcessorGetAction.java index 09518e2df92a6..bb587350f4256 100644 --- a/modules/ingest-common/src/main/java/org/opensearch/ingest/common/GrokProcessorGetAction.java +++ b/modules/ingest-common/src/main/java/org/opensearch/ingest/common/GrokProcessorGetAction.java @@ -31,7 +31,7 @@ package org.opensearch.ingest.common; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionListener; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestValidationException; @@ -79,7 +79,7 @@ public Request(boolean sorted) { Request(StreamInput in) throws IOException { super(in); - this.sorted = in.getVersion().onOrAfter(Version.V_7_10_0) ? in.readBoolean() : false; + this.sorted = in.getVersion().onOrAfter(LegacyESVersion.V_7_10_0) ? in.readBoolean() : false; } @Override @@ -90,7 +90,7 @@ public ActionRequestValidationException validate() { @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - if (out.getVersion().onOrAfter(Version.V_7_10_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_10_0)) { out.writeBoolean(sorted); } } diff --git a/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/MultiSearchTemplateResponse.java b/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/MultiSearchTemplateResponse.java index b7d77ad1740cc..5a7848cd86f0a 100644 --- a/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/MultiSearchTemplateResponse.java +++ b/modules/lang-mustache/src/main/java/org/opensearch/script/mustache/MultiSearchTemplateResponse.java @@ -32,8 +32,8 @@ package org.opensearch.script.mustache; +import org.opensearch.LegacyESVersion; import org.opensearch.OpenSearchException; -import org.opensearch.Version; import org.opensearch.action.ActionResponse; import org.opensearch.action.search.MultiSearchResponse; import org.opensearch.common.Nullable; @@ -125,7 +125,7 @@ public String toString() { MultiSearchTemplateResponse(StreamInput in) throws IOException { super(in); items = in.readArray(Item::new, Item[]::new); - if (in.getVersion().onOrAfter(Version.V_7_0_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_0_0)) { tookInMillis = in.readVLong(); } else { tookInMillis = -1L; @@ -159,7 +159,7 @@ public TimeValue getTook() { @Override public void writeTo(StreamOutput out) throws IOException { out.writeArray(items); - if (out.getVersion().onOrAfter(Version.V_7_0_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_0_0)) { out.writeVLong(tookInMillis); } } diff --git a/modules/lang-painless/src/main/java/org/opensearch/painless/action/PainlessExecuteAction.java b/modules/lang-painless/src/main/java/org/opensearch/painless/action/PainlessExecuteAction.java index a256fb5f20af0..60efa205b4152 100644 --- a/modules/lang-painless/src/main/java/org/opensearch/painless/action/PainlessExecuteAction.java +++ b/modules/lang-painless/src/main/java/org/opensearch/painless/action/PainlessExecuteAction.java @@ -42,7 +42,7 @@ import org.apache.lucene.search.ScoreMode; import org.apache.lucene.search.Scorer; import org.apache.lucene.search.Weight; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.apache.lucene.store.ByteBuffersDirectory; import org.apache.lucene.store.Directory; import org.opensearch.action.ActionRequestValidationException; @@ -297,7 +297,7 @@ static Request parse(XContentParser parser) throws IOException { Request(StreamInput in) throws IOException { super(in); script = new Script(in); - if (in.getVersion().before(Version.V_6_4_0)) { + if (in.getVersion().before(LegacyESVersion.V_6_4_0)) { byte scriptContextId = in.readByte(); assert scriptContextId == 0; context = null; @@ -341,7 +341,7 @@ public ActionRequestValidationException validate() { public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); script.writeTo(out); - if (out.getVersion().before(Version.V_6_4_0)) { + if (out.getVersion().before(LegacyESVersion.V_6_4_0)) { out.writeByte((byte) 0); } else { out.writeString(context.name); diff --git a/modules/parent-join/src/yamlRestTest/resources/rest-api-spec/test/30_inner_hits.yml b/modules/parent-join/src/yamlRestTest/resources/rest-api-spec/test/30_inner_hits.yml index 9f9bbbacf1217..5ba4077beac46 100644 --- a/modules/parent-join/src/yamlRestTest/resources/rest-api-spec/test/30_inner_hits.yml +++ b/modules/parent-join/src/yamlRestTest/resources/rest-api-spec/test/30_inner_hits.yml @@ -1,8 +1,8 @@ --- setup: - skip: - version: " - 7.6.99" - reason: "implemented in 7.7.0" + version: " - 7.5.99" + reason: "The bug was corrected from 7.6" - do: indices.create: @@ -59,49 +59,9 @@ teardown: --- "Test two sub-queries with only one having inner_hits": - skip: - version: " - 7.59.99" + version: " - 7.5.99" reason: "The bug was corrected from 7.6" - - do: - indices.create: - index: test - body: - mappings: - properties: - entity_type: { "type": "keyword" } - join_field: { "type": "join", "relations": { "question": "answer", "person" : "address" } } - settings: - number_of_shards: 1 - - - do: - index: - index: test - id: 1 - body: { "join_field": { "name": "question" }, "entity_type": "question" } - - - do: - index: - index: test - id: 2 - routing: 1 - body: { "join_field": { "name": "answer", "parent": 1} , "entity_type": "answer" } - - - do: - index: - index: test - id: 3 - body: { "join_field": { "name": "person" }, "entity_type": "person" } - - - do: - index: - index: test - routing: 3 - id: 4 - body: { "join_field": { "name": "address", "parent": 3 }, "entity_type": "address" } - - - do: - indices.refresh: {} - - do: search: index: test diff --git a/modules/percolator/src/main/java/org/opensearch/percolator/PercolateQueryBuilder.java b/modules/percolator/src/main/java/org/opensearch/percolator/PercolateQueryBuilder.java index 67eb8d948e0b2..f68467f241e99 100644 --- a/modules/percolator/src/main/java/org/opensearch/percolator/PercolateQueryBuilder.java +++ b/modules/percolator/src/main/java/org/opensearch/percolator/PercolateQueryBuilder.java @@ -55,6 +55,7 @@ import org.apache.lucene.util.BitSet; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.SetOnce; +import org.opensearch.LegacyESVersion; import org.opensearch.OpenSearchException; import org.opensearch.ResourceNotFoundException; import org.opensearch.Version; @@ -264,10 +265,10 @@ public PercolateQueryBuilder(String field, String documentType, String indexedDo PercolateQueryBuilder(StreamInput in) throws IOException { super(in); field = in.readString(); - if (in.getVersion().onOrAfter(Version.V_6_1_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_6_1_0)) { name = in.readOptionalString(); } - if (in.getVersion().before(Version.V_6_0_0_beta1)) { + if (in.getVersion().before(LegacyESVersion.V_6_0_0_beta1)) { documentType = in.readString(); } else { documentType = in.readOptionalString(); @@ -282,7 +283,7 @@ public PercolateQueryBuilder(String field, String documentType, String indexedDo } else { indexedDocumentVersion = null; } - if (in.getVersion().onOrAfter(Version.V_6_1_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_6_1_0)) { documents = in.readList(StreamInput::readBytesReference); } else { BytesReference document = in.readOptionalBytesReference(); @@ -311,10 +312,10 @@ protected void doWriteTo(StreamOutput out) throws IOException { throw new IllegalStateException("supplier must be null, can't serialize suppliers, missing a rewriteAndFetch?"); } out.writeString(field); - if (out.getVersion().onOrAfter(Version.V_6_1_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_6_1_0)) { out.writeOptionalString(name); } - if (out.getVersion().before(Version.V_6_0_0_beta1)) { + if (out.getVersion().before(LegacyESVersion.V_6_0_0_beta1)) { out.writeString(documentType); } else { out.writeOptionalString(documentType); @@ -330,7 +331,7 @@ protected void doWriteTo(StreamOutput out) throws IOException { } else { out.writeBoolean(false); } - if (out.getVersion().onOrAfter(Version.V_6_1_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_6_1_0)) { out.writeVInt(documents.size()); for (BytesReference document : documents) { out.writeBytesReference(document); @@ -657,7 +658,7 @@ static PercolateQuery.QueryStore createStore(MappedFieldType queryBuilderFieldTy if (binaryDocValues == null) { return docId -> null; } - if (indexVersion.onOrAfter(Version.V_6_0_0_beta2)) { + if (indexVersion.onOrAfter(LegacyESVersion.V_6_0_0_beta2)) { return docId -> { if (binaryDocValues.advanceExact(docId)) { BytesRef qbSource = binaryDocValues.binaryValue(); diff --git a/modules/percolator/src/main/java/org/opensearch/percolator/PercolatorFieldMapper.java b/modules/percolator/src/main/java/org/opensearch/percolator/PercolatorFieldMapper.java index 63cbc24af55ee..78d6fbe4702b6 100644 --- a/modules/percolator/src/main/java/org/opensearch/percolator/PercolatorFieldMapper.java +++ b/modules/percolator/src/main/java/org/opensearch/percolator/PercolatorFieldMapper.java @@ -55,6 +55,7 @@ import org.apache.lucene.search.TermQuery; import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.BytesRefBuilder; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.action.support.PlainActionFuture; import org.opensearch.common.ParsingException; @@ -286,7 +287,7 @@ Tuple createCandidateQuery(IndexReader indexReader, Versi } BooleanQuery.Builder candidateQuery = new BooleanQuery.Builder(); - if (canUseMinimumShouldMatchField && indexVersion.onOrAfter(Version.V_6_1_0)) { + if (canUseMinimumShouldMatchField && indexVersion.onOrAfter(LegacyESVersion.V_6_1_0)) { LongValuesSource valuesSource = LongValuesSource.fromIntField(minimumShouldMatchField.name()); for (BytesRef extractedTerm : extractedTerms) { subQueries.add(new TermQuery(new Term(queryTermsField.name(), extractedTerm))); @@ -393,7 +394,7 @@ public void parse(ParseContext context) throws IOException { static void createQueryBuilderField(Version indexVersion, BinaryFieldMapper qbField, QueryBuilder queryBuilder, ParseContext context) throws IOException { - if (indexVersion.onOrAfter(Version.V_6_0_0_beta2)) { + if (indexVersion.onOrAfter(LegacyESVersion.V_6_0_0_beta2)) { try (ByteArrayOutputStream stream = new ByteArrayOutputStream()) { try (OutputStreamStreamOutput out = new OutputStreamStreamOutput(stream)) { out.setVersion(indexVersion); @@ -457,7 +458,7 @@ void processQuery(Query query, ParseContext context) { } createFieldNamesField(context); - if (indexVersionCreated.onOrAfter(Version.V_6_1_0)) { + if (indexVersionCreated.onOrAfter(LegacyESVersion.V_6_1_0)) { doc.add(new NumericDocValuesField(minimumShouldMatchFieldMapper.name(), result.minimumShouldMatch)); } } diff --git a/modules/percolator/src/main/java/org/opensearch/percolator/QueryAnalyzer.java b/modules/percolator/src/main/java/org/opensearch/percolator/QueryAnalyzer.java index 28987bcf66254..4dd136818f4ce 100644 --- a/modules/percolator/src/main/java/org/opensearch/percolator/QueryAnalyzer.java +++ b/modules/percolator/src/main/java/org/opensearch/percolator/QueryAnalyzer.java @@ -53,6 +53,7 @@ import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.NumericUtils; import org.apache.lucene.util.automaton.ByteRunAutomaton; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.common.lucene.search.function.FunctionScoreQuery; import org.opensearch.index.query.DateRangeIncludingNowQuery; @@ -222,7 +223,7 @@ public void consumeTerms(Query query, Term... terms) { boolean verified = isVerified(query); Set qe = Arrays.stream(terms).map(QueryExtraction::new).collect(Collectors.toSet()); if (qe.size() > 0) { - if (version.before(Version.V_6_1_0) && conjunction) { + if (version.before(LegacyESVersion.V_6_1_0) && conjunction) { Optional longest = qe.stream() .filter(q -> q.term != null) .max(Comparator.comparingInt(q -> q.term.bytes().length)); @@ -290,7 +291,7 @@ private static Result handleConjunction(List conjunctionsWithUnknowns, V if (conjunctionsWithUnknowns.size() == 1) { return conjunctionsWithUnknowns.get(0); } - if (version.onOrAfter(Version.V_6_1_0)) { + if (version.onOrAfter(LegacyESVersion.V_6_1_0)) { for (Result subResult : conjunctions) { if (subResult.isMatchNoDocs()) { return subResult; @@ -382,7 +383,7 @@ private static Result handleDisjunction(List disjunctions, int requiredS // Keep track of the msm for each clause: List clauses = new ArrayList<>(disjunctions.size()); boolean verified; - if (version.before(Version.V_6_1_0)) { + if (version.before(LegacyESVersion.V_6_1_0)) { verified = requiredShouldClauses <= 1; } else { verified = true; @@ -433,7 +434,7 @@ private static Result handleDisjunction(List disjunctions, int requiredS boolean matchAllDocs = numMatchAllClauses > 0 && numMatchAllClauses >= requiredShouldClauses; int msm = 0; - if (version.onOrAfter(Version.V_6_1_0) && + if (version.onOrAfter(LegacyESVersion.V_6_1_0) && // Having ranges would mean we need to juggle with the msm and that complicates this logic a lot, // so for now lets not do it. hasRangeExtractions == false) { diff --git a/modules/percolator/src/test/java/org/opensearch/percolator/CandidateQueryTests.java b/modules/percolator/src/test/java/org/opensearch/percolator/CandidateQueryTests.java index a447686057469..064df79ed54e4 100644 --- a/modules/percolator/src/test/java/org/opensearch/percolator/CandidateQueryTests.java +++ b/modules/percolator/src/test/java/org/opensearch/percolator/CandidateQueryTests.java @@ -90,6 +90,7 @@ import org.apache.lucene.store.ByteBuffersDirectory; import org.apache.lucene.store.Directory; import org.apache.lucene.util.BytesRef; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.CheckedFunction; @@ -612,7 +613,7 @@ public void testRangeQueries() throws Exception { IndexSearcher shardSearcher = newSearcher(directoryReader); shardSearcher.setQueryCache(null); - Version v = Version.V_6_1_0; + Version v = LegacyESVersion.V_6_1_0; MemoryIndex memoryIndex = MemoryIndex.fromDocument(Collections.singleton(new IntPoint("int_field", 3)), new WhitespaceAnalyzer()); IndexSearcher percolateSearcher = memoryIndex.createSearcher(); Query query = fieldType.percolateQuery("_name", queryStore, Collections.singletonList(new BytesArray("{}")), diff --git a/modules/percolator/src/test/java/org/opensearch/percolator/PercolatorFieldMapperTests.java b/modules/percolator/src/test/java/org/opensearch/percolator/PercolatorFieldMapperTests.java index 3d91e572f22b4..b6c7516a3e9ef 100644 --- a/modules/percolator/src/test/java/org/opensearch/percolator/PercolatorFieldMapperTests.java +++ b/modules/percolator/src/test/java/org/opensearch/percolator/PercolatorFieldMapperTests.java @@ -53,6 +53,7 @@ import org.apache.lucene.search.TermRangeQuery; import org.apache.lucene.search.join.ScoreMode; import org.apache.lucene.util.BytesRef; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.action.support.PlainActionFuture; import org.opensearch.cluster.metadata.IndexMetadata; @@ -425,7 +426,7 @@ public void testCreateCandidateQuery_oldIndex() throws Exception { assertThat(t.v1().clauses().get(0).getQuery(), instanceOf(CoveringQuery.class)); assertThat(t.v1().clauses().get(1).getQuery(), instanceOf(TermQuery.class)); - t = fieldType.createCandidateQuery(indexReader, Version.V_6_0_0); + t = fieldType.createCandidateQuery(indexReader, LegacyESVersion.V_6_0_0); assertTrue(t.v2()); assertEquals(2, t.v1().clauses().size()); assertThat(t.v1().clauses().get(0).getQuery(), instanceOf(TermInSetQuery.class)); diff --git a/modules/percolator/src/test/java/org/opensearch/percolator/QueryAnalyzerTests.java b/modules/percolator/src/test/java/org/opensearch/percolator/QueryAnalyzerTests.java index 7c6363c44c300..ecb44e90674b5 100644 --- a/modules/percolator/src/test/java/org/opensearch/percolator/QueryAnalyzerTests.java +++ b/modules/percolator/src/test/java/org/opensearch/percolator/QueryAnalyzerTests.java @@ -69,6 +69,7 @@ import org.apache.lucene.search.spans.SpanOrQuery; import org.apache.lucene.search.spans.SpanTermQuery; import org.apache.lucene.util.BytesRef; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.common.lucene.search.function.CombineFunction; import org.opensearch.common.lucene.search.function.FunctionScoreQuery; @@ -171,7 +172,7 @@ public void testExtractQueryMetadata_multiPhraseQuery_pre6dot1() { .add(new Term[] {new Term("_field", "_long_term"), new Term("_field", "_very_long_term")}) .add(new Term[] {new Term("_field", "_very_long_term")}) .build(); - Result result = analyze(multiPhraseQuery, Version.V_6_0_0); + Result result = analyze(multiPhraseQuery, LegacyESVersion.V_6_0_0); assertThat(result.verified, is(false)); assertThat(result.minimumShouldMatch, equalTo(1)); List terms = new ArrayList<>(result.extractions); @@ -242,7 +243,7 @@ public void testExtractQueryMetadata_booleanQuery_pre6dot1() { builder.add(subBuilder.build(), BooleanClause.Occur.SHOULD); BooleanQuery booleanQuery = builder.build(); - Result result = analyze(booleanQuery, Version.V_6_0_0); + Result result = analyze(booleanQuery, LegacyESVersion.V_6_0_0); assertThat("Should clause with phrase query isn't verified, so entire query can't be verified", result.verified, is(false)); assertThat(result.minimumShouldMatch, equalTo(1)); List terms = new ArrayList<>(result.extractions); @@ -353,7 +354,7 @@ public void testExtractQueryMetadata_booleanQuery_msm_pre6dot1() { builder.add(termQuery3, BooleanClause.Occur.SHOULD); BooleanQuery booleanQuery = builder.build(); - Result result = analyze(booleanQuery, Version.V_6_0_0); + Result result = analyze(booleanQuery, LegacyESVersion.V_6_0_0); assertThat(result.verified, is(false)); assertThat(result.minimumShouldMatch, equalTo(1)); List extractions = new ArrayList<>(result.extractions); @@ -418,7 +419,7 @@ public void testExtractQueryMetadata_booleanQueryWithMustNot() { assertThat(result.minimumShouldMatch, equalTo(0)); assertTermsEqual(result.extractions); - result = analyze(booleanQuery, Version.V_6_0_0); + result = analyze(booleanQuery, LegacyESVersion.V_6_0_0); assertThat(result.matchAllDocs, is(true)); assertThat(result.verified, is(false)); assertThat(result.minimumShouldMatch, equalTo(0)); @@ -679,7 +680,7 @@ public void testExtractQueryMetadata_spanNearQuery_pre6dot1() { SpanNearQuery spanNearQuery = new SpanNearQuery.Builder("_field", true) .addClause(spanTermQuery1).addClause(spanTermQuery2).build(); - Result result = analyze(spanNearQuery, Version.V_6_0_0); + Result result = analyze(spanNearQuery, LegacyESVersion.V_6_0_0); assertThat(result.verified, is(false)); assertThat(result.minimumShouldMatch, equalTo(1)); assertTermsEqual(result.extractions, spanTermQuery2.getTerm()); @@ -1229,7 +1230,7 @@ public void testPointRangeQuerySelectShortestRange() { BooleanQuery.Builder boolQuery = new BooleanQuery.Builder(); boolQuery.add(LongPoint.newRangeQuery("_field1", 10, 20), BooleanClause.Occur.FILTER); boolQuery.add(LongPoint.newRangeQuery("_field2", 10, 15), BooleanClause.Occur.FILTER); - Result result = analyze(boolQuery.build(), Version.V_6_0_0); + Result result = analyze(boolQuery.build(), LegacyESVersion.V_6_0_0); assertFalse(result.verified); assertThat(result.minimumShouldMatch, equalTo(1)); assertEquals(1, result.extractions.size()); @@ -1238,7 +1239,7 @@ public void testPointRangeQuerySelectShortestRange() { boolQuery = new BooleanQuery.Builder(); boolQuery.add(LongPoint.newRangeQuery("_field1", 10, 20), BooleanClause.Occur.FILTER); boolQuery.add(IntPoint.newRangeQuery("_field2", 10, 15), BooleanClause.Occur.FILTER); - result = analyze(boolQuery.build(), Version.V_6_0_0); + result = analyze(boolQuery.build(), LegacyESVersion.V_6_0_0); assertFalse(result.verified); assertThat(result.minimumShouldMatch, equalTo(1)); assertEquals(1, result.extractions.size()); @@ -1247,7 +1248,7 @@ public void testPointRangeQuerySelectShortestRange() { boolQuery = new BooleanQuery.Builder(); boolQuery.add(DoublePoint.newRangeQuery("_field1", 10, 20), BooleanClause.Occur.FILTER); boolQuery.add(DoublePoint.newRangeQuery("_field2", 10, 15), BooleanClause.Occur.FILTER); - result = analyze(boolQuery.build(), Version.V_6_0_0); + result = analyze(boolQuery.build(), LegacyESVersion.V_6_0_0); assertFalse(result.verified); assertThat(result.minimumShouldMatch, equalTo(1)); assertEquals(1, result.extractions.size()); @@ -1256,7 +1257,7 @@ public void testPointRangeQuerySelectShortestRange() { boolQuery = new BooleanQuery.Builder(); boolQuery.add(DoublePoint.newRangeQuery("_field1", 10, 20), BooleanClause.Occur.FILTER); boolQuery.add(FloatPoint.newRangeQuery("_field2", 10, 15), BooleanClause.Occur.FILTER); - result = analyze(boolQuery.build(), Version.V_6_0_0); + result = analyze(boolQuery.build(), LegacyESVersion.V_6_0_0); assertFalse(result.verified); assertThat(result.minimumShouldMatch, equalTo(1)); assertEquals(1, result.extractions.size()); @@ -1265,7 +1266,7 @@ public void testPointRangeQuerySelectShortestRange() { boolQuery = new BooleanQuery.Builder(); boolQuery.add(HalfFloatPoint.newRangeQuery("_field1", 10, 20), BooleanClause.Occur.FILTER); boolQuery.add(HalfFloatPoint.newRangeQuery("_field2", 10, 15), BooleanClause.Occur.FILTER); - result = analyze(boolQuery.build(), Version.V_6_0_0); + result = analyze(boolQuery.build(), LegacyESVersion.V_6_0_0); assertFalse(result.verified); assertThat(result.minimumShouldMatch, equalTo(1)); assertEquals(1, result.extractions.size()); diff --git a/modules/percolator/src/test/java/org/opensearch/percolator/QueryBuilderStoreTests.java b/modules/percolator/src/test/java/org/opensearch/percolator/QueryBuilderStoreTests.java index f759e937dcda6..c5af42dcfdf50 100644 --- a/modules/percolator/src/test/java/org/opensearch/percolator/QueryBuilderStoreTests.java +++ b/modules/percolator/src/test/java/org/opensearch/percolator/QueryBuilderStoreTests.java @@ -41,6 +41,7 @@ import org.apache.lucene.search.Query; import org.apache.lucene.search.TermQuery; import org.apache.lucene.store.Directory; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.CheckedFunction; @@ -89,7 +90,7 @@ public void testStoringQueryBuilders() throws IOException { BinaryFieldMapper fieldMapper = PercolatorFieldMapper.Builder.createQueryBuilderFieldBuilder( new Mapper.BuilderContext(settings, new ContentPath(0))); - Version version = Version.V_6_0_0_beta2; + Version version = LegacyESVersion.V_6_0_0_beta2; try (IndexWriter indexWriter = new IndexWriter(directory, config)) { for (int i = 0; i < queryBuilders.length; i++) { queryBuilders[i] = new TermQueryBuilder(randomAlphaOfLength(4), randomAlphaOfLength(8)); diff --git a/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/RankEvalRequest.java b/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/RankEvalRequest.java index a38aa0df22b86..f45274f6116eb 100644 --- a/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/RankEvalRequest.java +++ b/modules/rank-eval/src/main/java/org/opensearch/index/rankeval/RankEvalRequest.java @@ -32,7 +32,7 @@ package org.opensearch.index.rankeval; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.IndicesRequest; @@ -69,7 +69,7 @@ public RankEvalRequest(RankEvalSpec rankingEvaluationSpec, String[] indices) { rankingEvaluationSpec = new RankEvalSpec(in); indices = in.readStringArray(); indicesOptions = IndicesOptions.readIndicesOptions(in); - if (in.getVersion().onOrAfter(Version.V_7_6_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_6_0)) { searchType = SearchType.fromId(in.readByte()); } } @@ -151,7 +151,7 @@ public void writeTo(StreamOutput out) throws IOException { rankingEvaluationSpec.writeTo(out); out.writeStringArray(indices); indicesOptions.writeIndicesOptions(out); - if (out.getVersion().onOrAfter(Version.V_7_6_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_6_0)) { out.writeByte(searchType.id()); } } diff --git a/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportUpdateByQueryAction.java b/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportUpdateByQueryAction.java index 2bef72c8c6493..2c5f6bf6a376b 100644 --- a/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportUpdateByQueryAction.java +++ b/modules/reindex/src/main/java/org/opensearch/index/reindex/TransportUpdateByQueryAction.java @@ -33,7 +33,7 @@ package org.opensearch.index.reindex; import org.apache.logging.log4j.Logger; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionListener; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.ActionFilters; @@ -102,11 +102,11 @@ static class AsyncIndexBySearchAction extends AbstractAsyncBulkByScrollAction listener) { super(task, // not all nodes support sequence number powered optimistic concurrency control, we fall back to version - clusterState.nodes().getMinNodeVersion().onOrAfter(Version.V_6_7_0) == false, + clusterState.nodes().getMinNodeVersion().onOrAfter(LegacyESVersion.V_6_7_0) == false, // all nodes support sequence number powered optimistic concurrency control and we can use it - clusterState.nodes().getMinNodeVersion().onOrAfter(Version.V_6_7_0), + clusterState.nodes().getMinNodeVersion().onOrAfter(LegacyESVersion.V_6_7_0), logger, client, threadPool, request, listener, scriptService, null); - useSeqNoForCAS = clusterState.nodes().getMinNodeVersion().onOrAfter(Version.V_6_7_0); + useSeqNoForCAS = clusterState.nodes().getMinNodeVersion().onOrAfter(LegacyESVersion.V_6_7_0); } @Override diff --git a/modules/reindex/src/test/java/org/opensearch/index/reindex/RoundTripTests.java b/modules/reindex/src/test/java/org/opensearch/index/reindex/RoundTripTests.java index c8e48e877b3c2..1d4f83008b7f3 100644 --- a/modules/reindex/src/test/java/org/opensearch/index/reindex/RoundTripTests.java +++ b/modules/reindex/src/test/java/org/opensearch/index/reindex/RoundTripTests.java @@ -32,6 +32,7 @@ package org.opensearch.index.reindex; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.common.bytes.BytesArray; import org.opensearch.common.bytes.BytesReference; @@ -83,13 +84,13 @@ public void testReindexRequest() throws IOException { // Try slices=auto with a version that doesn't support it, which should fail reindex.setSlices(AbstractBulkByScrollRequest.AUTO_SLICES); - Exception e = expectThrows(IllegalArgumentException.class, () -> toInputByteStream(Version.V_6_0_0_alpha1, reindex)); + Exception e = expectThrows(IllegalArgumentException.class, () -> toInputByteStream(LegacyESVersion.V_6_0_0_alpha1, reindex)); assertEquals("Slices set as \"auto\" are not supported before version [6.1.0]. Found version [6.0.0-alpha1]", e.getMessage()); // Try regular slices with a version that doesn't support slices=auto, which should succeed reindex.setSlices(between(1, Integer.MAX_VALUE)); tripped = new ReindexRequest(toInputByteStream(reindex)); - assertRequestEquals(Version.V_6_0_0_alpha1, reindex, tripped); + assertRequestEquals(LegacyESVersion.V_6_0_0_alpha1, reindex, tripped); } public void testUpdateByQueryRequest() throws IOException { @@ -104,7 +105,7 @@ public void testUpdateByQueryRequest() throws IOException { // Try slices=auto with a version that doesn't support it, which should fail update.setSlices(AbstractBulkByScrollRequest.AUTO_SLICES); - Exception e = expectThrows(IllegalArgumentException.class, () -> toInputByteStream(Version.V_6_0_0_alpha1, update)); + Exception e = expectThrows(IllegalArgumentException.class, () -> toInputByteStream(LegacyESVersion.V_6_0_0_alpha1, update)); assertEquals("Slices set as \"auto\" are not supported before version [6.1.0]. Found version [6.0.0-alpha1]", e.getMessage()); // Try regular slices with a version that doesn't support slices=auto, which should succeed @@ -122,7 +123,7 @@ public void testDeleteByQueryRequest() throws IOException { // Try slices=auto with a version that doesn't support it, which should fail delete.setSlices(AbstractBulkByScrollRequest.AUTO_SLICES); - Exception e = expectThrows(IllegalArgumentException.class, () -> toInputByteStream(Version.V_6_0_0_alpha1, delete)); + Exception e = expectThrows(IllegalArgumentException.class, () -> toInputByteStream(LegacyESVersion.V_6_0_0_alpha1, delete)); assertEquals("Slices set as \"auto\" are not supported before version [6.1.0]. Found version [6.0.0-alpha1]", e.getMessage()); // Try regular slices with a version that doesn't support slices=auto, which should succeed diff --git a/plugins/analysis-icu/src/main/java/org/opensearch/index/analysis/IcuNormalizerTokenFilterFactory.java b/plugins/analysis-icu/src/main/java/org/opensearch/index/analysis/IcuNormalizerTokenFilterFactory.java index 45f27cf11f2ea..a8bc583140cac 100644 --- a/plugins/analysis-icu/src/main/java/org/opensearch/index/analysis/IcuNormalizerTokenFilterFactory.java +++ b/plugins/analysis-icu/src/main/java/org/opensearch/index/analysis/IcuNormalizerTokenFilterFactory.java @@ -36,7 +36,7 @@ import com.ibm.icu.text.Normalizer2; import com.ibm.icu.text.UnicodeSet; import org.apache.lucene.analysis.TokenStream; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.settings.Settings; import org.opensearch.env.Environment; @@ -71,7 +71,7 @@ static Normalizer2 wrapWithUnicodeSetFilter(final IndexSettings indexSettings, final Normalizer2 normalizer, final Settings settings) { String unicodeSetFilter = settings.get("unicodeSetFilter"); - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { + if (indexSettings.getIndexVersionCreated().onOrAfter(LegacyESVersion.V_7_0_0)) { if (unicodeSetFilter != null) { deprecationLogger.deprecate("icu_normalizer_unicode_set_filter", "[unicodeSetFilter] has been deprecated in favor of [unicode_set_filter]"); diff --git a/plugins/analysis-phonetic/src/main/java/org/opensearch/index/analysis/PhoneticTokenFilterFactory.java b/plugins/analysis-phonetic/src/main/java/org/opensearch/index/analysis/PhoneticTokenFilterFactory.java index dda364e923768..758d32a76b73f 100644 --- a/plugins/analysis-phonetic/src/main/java/org/opensearch/index/analysis/PhoneticTokenFilterFactory.java +++ b/plugins/analysis-phonetic/src/main/java/org/opensearch/index/analysis/PhoneticTokenFilterFactory.java @@ -48,7 +48,7 @@ import org.apache.lucene.analysis.phonetic.DaitchMokotoffSoundexFilter; import org.apache.lucene.analysis.phonetic.DoubleMetaphoneFilter; import org.apache.lucene.analysis.phonetic.PhoneticFilter; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.common.logging.DeprecationLogger; import org.opensearch.common.settings.Settings; import org.opensearch.env.Environment; @@ -159,7 +159,7 @@ public TokenStream create(TokenStream tokenStream) { @Override public TokenFilterFactory getSynonymFilter() { - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { + if (indexSettings.getIndexVersionCreated().onOrAfter(LegacyESVersion.V_7_0_0)) { throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); } else { diff --git a/plugins/analysis-phonetic/src/test/java/org/opensearch/index/analysis/AnalysisPhoneticFactoryTests.java b/plugins/analysis-phonetic/src/test/java/org/opensearch/index/analysis/AnalysisPhoneticFactoryTests.java index b8735c3f4a3b2..c16d0881fa7af 100644 --- a/plugins/analysis-phonetic/src/test/java/org/opensearch/index/analysis/AnalysisPhoneticFactoryTests.java +++ b/plugins/analysis-phonetic/src/test/java/org/opensearch/index/analysis/AnalysisPhoneticFactoryTests.java @@ -32,6 +32,7 @@ package org.opensearch.index.analysis; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.settings.Settings; @@ -64,7 +65,8 @@ public void testDisallowedWithSynonyms() throws IOException { AnalysisPhoneticPlugin plugin = new AnalysisPhoneticPlugin(); Settings settings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, Version.CURRENT)) + .put(IndexMetadata.SETTING_VERSION_CREATED, + VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_7_0_0, Version.CURRENT)) .put("path.home", createTempDir().toString()) .build(); IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("index", settings); @@ -76,7 +78,7 @@ public void testDisallowedWithSynonyms() throws IOException { settings = Settings.builder() .put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), - Version.V_6_0_0, VersionUtils.getPreviousVersion(Version.V_7_0_0))) + LegacyESVersion.V_6_0_0, VersionUtils.getPreviousVersion(LegacyESVersion.V_7_0_0))) .put("path.home", createTempDir().toString()) .build(); idxSettings = IndexSettingsModule.newIndexSettings("index", settings); diff --git a/plugins/repository-gcs/src/main/java/org/opensearch/repositories/gcs/GoogleCloudStorageRetryingInputStream.java b/plugins/repository-gcs/src/main/java/org/opensearch/repositories/gcs/GoogleCloudStorageRetryingInputStream.java index 2ca52bbd70f8f..a7f6ffe53e02e 100644 --- a/plugins/repository-gcs/src/main/java/org/opensearch/repositories/gcs/GoogleCloudStorageRetryingInputStream.java +++ b/plugins/repository-gcs/src/main/java/org/opensearch/repositories/gcs/GoogleCloudStorageRetryingInputStream.java @@ -42,6 +42,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; +import org.opensearch.LegacyESVersion; import org.opensearch.SpecialPermission; import org.opensearch.common.SuppressForbidden; import org.opensearch.core.internal.io.IOUtils; @@ -60,7 +61,7 @@ /** * Wrapper around reads from GCS that will retry blob downloads that fail part-way through, resuming from where the failure occurred. * This should be handled by the SDK but it isn't today. This should be revisited in the future (e.g. before removing - * the {@link org.opensearch.Version#V_7_0_0} version constant) and removed if the SDK handles retries itself in the future. + * the {@link LegacyESVersion#V_7_0_0} version constant) and removed if the SDK handles retries itself in the future. */ class GoogleCloudStorageRetryingInputStream extends InputStream { diff --git a/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3Repository.java b/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3Repository.java index d01c2a2fdc21e..1de31ad879e82 100644 --- a/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3Repository.java +++ b/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3Repository.java @@ -35,6 +35,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.action.ActionListener; import org.opensearch.action.ActionRunnable; @@ -177,12 +178,12 @@ class S3Repository extends MeteredBlobStoreRepository { /** * Artificial delay to introduce after a snapshot finalization or delete has finished so long as the repository is still using the * backwards compatible snapshot format from before - * {@link org.opensearch.snapshots.SnapshotsService#SHARD_GEN_IN_REPO_DATA_VERSION} ({@link org.opensearch.Version#V_7_6_0}). + * {@link org.opensearch.snapshots.SnapshotsService#SHARD_GEN_IN_REPO_DATA_VERSION} ({@link LegacyESVersion#V_7_6_0}). * This delay is necessary so that the eventually consistent nature of AWS S3 does not randomly result in repository corruption when * doing repository operations in rapid succession on a repository in the old metadata format. * This setting should not be adjusted in production when working with an AWS S3 backed repository. Doing so risks the repository * becoming silently corrupted. To get rid of this waiting period, either create a new S3 repository or remove all snapshots older than - * {@link org.opensearch.Version#V_7_6_0} from the repository which will trigger an upgrade of the repository metadata to the new + * {@link LegacyESVersion#V_7_6_0} from the repository which will trigger an upgrade of the repository metadata to the new * format and disable the cooldown period. */ static final Setting COOLDOWN_PERIOD = Setting.timeSetting( diff --git a/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3RetryingInputStream.java b/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3RetryingInputStream.java index 76a1f364f58dd..e6c697d271c7a 100644 --- a/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3RetryingInputStream.java +++ b/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3RetryingInputStream.java @@ -40,7 +40,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.core.internal.io.IOUtils; import java.io.IOException; @@ -52,7 +52,7 @@ /** * Wrapper around an S3 object that will retry the {@link GetObjectRequest} if the download fails part-way through, resuming from where * the failure occurred. This should be handled by the SDK but it isn't today. This should be revisited in the future (e.g. before removing - * the {@link Version#V_7_0_0} version constant) and removed when the SDK handles retries itself. + * the {@link LegacyESVersion#V_7_0_0} version constant) and removed when the SDK handles retries itself. * * See https://github.com/aws/aws-sdk-java/issues/856 for the related SDK issue */ diff --git a/qa/full-cluster-restart/src/test/java/org/opensearch/upgrades/FullClusterRestartIT.java b/qa/full-cluster-restart/src/test/java/org/opensearch/upgrades/FullClusterRestartIT.java index e7ae4ab8eed23..47aedac4272c5 100644 --- a/qa/full-cluster-restart/src/test/java/org/opensearch/upgrades/FullClusterRestartIT.java +++ b/qa/full-cluster-restart/src/test/java/org/opensearch/upgrades/FullClusterRestartIT.java @@ -33,6 +33,7 @@ package org.opensearch.upgrades; import org.apache.http.util.EntityUtils; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.client.Request; import org.opensearch.client.Response; @@ -99,7 +100,7 @@ * with {@code tests.is_old_cluster} set to {@code false}. */ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase { - private final boolean supportsLenientBooleans = getOldClusterVersion().before(Version.V_6_0_0_alpha1); + private final boolean supportsLenientBooleans = getOldClusterVersion().before(LegacyESVersion.V_6_0_0_alpha1); private String index; private String type; @@ -111,7 +112,7 @@ public void setIndex() { @Before public void setType() { - type = getOldClusterVersion().before(Version.V_6_7_0) ? "doc" : "_doc"; + type = getOldClusterVersion().before(LegacyESVersion.V_6_7_0) ? "doc" : "_doc"; } public void testSearch() throws Exception { @@ -352,7 +353,7 @@ public void testShrink() throws IOException { client().performRequest(updateSettingsRequest); Request shrinkIndexRequest = new Request("PUT", "/" + index + "/_shrink/" + shrunkenIndex); - if (getOldClusterVersion().onOrAfter(Version.V_6_4_0) && getOldClusterVersion().before(Version.V_7_0_0)) { + if (getOldClusterVersion().onOrAfter(LegacyESVersion.V_6_4_0) && getOldClusterVersion().before(LegacyESVersion.V_7_0_0)) { shrinkIndexRequest.addParameter("copy_settings", "true"); } shrinkIndexRequest.setJsonEntity("{\"settings\": {\"index.number_of_shards\": 1}}"); @@ -635,7 +636,7 @@ void assertRealtimeGetWorks(final String typeName) throws IOException { client().performRequest(updateRequest); Request getRequest = new Request("GET", "/" + index + "/" + typeName + "/" + docId); - if (getOldClusterVersion().before(Version.V_6_7_0)) { + if (getOldClusterVersion().before(LegacyESVersion.V_6_7_0)) { getRequest.setOptions(expectWarnings(RestGetAction.TYPES_DEPRECATION_MESSAGE)); } Map getRsp = entityAsMap(client().performRequest(getRequest)); @@ -684,7 +685,7 @@ public void testSingleDoc() throws IOException { Request request = new Request("GET", docLocation); - if (getOldClusterVersion().before(Version.V_6_7_0)) { + if (getOldClusterVersion().before(LegacyESVersion.V_6_7_0)) { request.setOptions(expectWarnings(RestGetAction.TYPES_DEPRECATION_MESSAGE)); } assertThat(toStr(client().performRequest(request)), containsString(doc)); @@ -706,7 +707,7 @@ public void testEmptyShard() throws IOException { // before timing out .put(INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "100ms") .put(SETTING_ALLOCATION_MAX_RETRY.getKey(), "0"); // fail faster - if (getOldClusterVersion().onOrAfter(Version.V_6_5_0)) { + if (getOldClusterVersion().onOrAfter(LegacyESVersion.V_6_5_0)) { settings.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), randomBoolean()); } if (randomBoolean()) { @@ -978,7 +979,7 @@ public void testSoftDeletes() throws Exception { mappingsAndSettings.startObject("settings"); mappingsAndSettings.field("number_of_shards", 1); mappingsAndSettings.field("number_of_replicas", 1); - if (getOldClusterVersion().onOrAfter(Version.V_6_5_0) && randomBoolean()) { + if (getOldClusterVersion().onOrAfter(LegacyESVersion.V_6_5_0) && randomBoolean()) { mappingsAndSettings.field("soft_deletes.enabled", true); } mappingsAndSettings.endObject(); @@ -1051,7 +1052,7 @@ public void testClosedIndices() throws Exception { closeIndex(index); } - if (getOldClusterVersion().onOrAfter(Version.V_7_2_0)) { + if (getOldClusterVersion().onOrAfter(LegacyESVersion.V_7_2_0)) { ensureGreenLongWait(index); assertClosedIndex(index, true); } else { @@ -1131,7 +1132,7 @@ private void checkSnapshot(final String snapshotName, final int count, final Ver * we will hit a warning exception because we put some deprecated settings in that test. */ if (isRunningAgainstOldCluster() == false - && getOldClusterVersion().onOrAfter(Version.V_6_1_0) && getOldClusterVersion().before(Version.V_6_5_0)) { + && getOldClusterVersion().onOrAfter(LegacyESVersion.V_6_1_0) && getOldClusterVersion().before(LegacyESVersion.V_6_5_0)) { for (String warning : e.getResponse().getWarnings()) { assertThat(warning, containsString( "setting was deprecated and will be removed in a future release! " @@ -1199,7 +1200,7 @@ && getOldClusterVersion().onOrAfter(Version.V_6_1_0) && getOldClusterVersion().b Map getTemplateResponse = entityAsMap(client().performRequest(getTemplateRequest)); Map expectedTemplate = new HashMap<>(); - if (isRunningAgainstOldCluster() && getOldClusterVersion().before(Version.V_6_0_0_beta1)) { + if (isRunningAgainstOldCluster() && getOldClusterVersion().before(LegacyESVersion.V_6_0_0_beta1)) { expectedTemplate.put("template", "evil_*"); } else { expectedTemplate.put("index_patterns", singletonList("evil_*")); @@ -1291,7 +1292,7 @@ private void saveInfoDocument(String type, String value) throws IOException { private String loadInfoDocument(String type) throws IOException { Request request = new Request("GET", "/info/" + this.type + "/" + index + "_" + type); request.addParameter("filter_path", "_source"); - if (getOldClusterVersion().before(Version.V_6_7_0)) { + if (getOldClusterVersion().before(LegacyESVersion.V_6_7_0)) { request.setOptions(expectWarnings(RestGetAction.TYPES_DEPRECATION_MESSAGE)); } String doc = toStr(client().performRequest(request)); @@ -1340,7 +1341,7 @@ protected void ensureGreenLongWait(String index) throws IOException { } public void testPeerRecoveryRetentionLeases() throws Exception { - assumeTrue(getOldClusterVersion() + " does not support soft deletes", getOldClusterVersion().onOrAfter(Version.V_6_5_0)); + assumeTrue(getOldClusterVersion() + " does not support soft deletes", getOldClusterVersion().onOrAfter(LegacyESVersion.V_6_5_0)); if (isRunningAgainstOldCluster()) { XContentBuilder settings = jsonBuilder(); settings.startObject(); @@ -1348,7 +1349,7 @@ public void testPeerRecoveryRetentionLeases() throws Exception { settings.startObject("settings"); settings.field("number_of_shards", between(1, 5)); settings.field("number_of_replicas", between(0, 1)); - if (randomBoolean() || getOldClusterVersion().before(Version.V_7_0_0)) { + if (randomBoolean() || getOldClusterVersion().before(LegacyESVersion.V_7_0_0)) { // this is the default after v7.0.0, but is required before that settings.field("soft_deletes.enabled", true); } @@ -1375,7 +1376,7 @@ public void testOperationBasedRecovery() throws Exception { final Settings.Builder settings = Settings.builder() .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1); - if (getOldClusterVersion().onOrAfter(Version.V_6_7_0)) { + if (getOldClusterVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { settings.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), randomBoolean()); } createIndex(index, settings.build()); @@ -1406,7 +1407,7 @@ public void testOperationBasedRecovery() throws Exception { * Verifies that once all shard copies on the new version, we should turn off the translog retention for indices with soft-deletes. */ public void testTurnOffTranslogRetentionAfterUpgraded() throws Exception { - assumeTrue("requires soft-deletes and retention leases", getOldClusterVersion().onOrAfter(Version.V_6_7_0)); + assumeTrue("requires soft-deletes and retention leases", getOldClusterVersion().onOrAfter(LegacyESVersion.V_6_7_0)); if (isRunningAgainstOldCluster()) { createIndex(index, Settings.builder() .put(IndexMetadata.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) @@ -1433,7 +1434,7 @@ public void testRecoveryWithTranslogRetentionDisabled() throws Exception { final Settings.Builder settings = Settings.builder() .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1); - if (getOldClusterVersion().onOrAfter(Version.V_6_5_0)) { + if (getOldClusterVersion().onOrAfter(LegacyESVersion.V_6_5_0)) { settings.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), randomBoolean()); } if (randomBoolean()) { @@ -1509,7 +1510,7 @@ public void testSystemIndexMetadataIsUpgraded() throws Exception { // make sure .tasks index exists Request getTasksIndex = new Request("GET", "/.tasks"); getTasksIndex.addParameter("allow_no_indices", "false"); - if (getOldClusterVersion().onOrAfter(Version.V_6_7_0) && getOldClusterVersion().before(Version.V_7_0_0)) { + if (getOldClusterVersion().onOrAfter(LegacyESVersion.V_6_7_0) && getOldClusterVersion().before(LegacyESVersion.V_7_0_0)) { getTasksIndex.addParameter("include_type_name", "false"); } @@ -1577,7 +1578,7 @@ public void testEnableSoftDeletesOnRestore() throws Exception { final Settings.Builder settings = Settings.builder() .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1); - if (getOldClusterVersion().onOrAfter(Version.V_6_5_0)) { + if (getOldClusterVersion().onOrAfter(LegacyESVersion.V_6_5_0)) { settings.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), randomBoolean()); } createIndex(index, settings.build()); @@ -1628,7 +1629,7 @@ public void testEnableSoftDeletesOnRestore() throws Exception { } public void testForbidDisableSoftDeletesOnRestore() throws Exception { - assumeTrue("soft deletes is introduced in 6.5", getOldClusterVersion().onOrAfter(Version.V_6_5_0)); + assumeTrue("soft deletes is introduced in 6.5", getOldClusterVersion().onOrAfter(LegacyESVersion.V_6_5_0)); final String snapshot = "snapshot-" + index; if (isRunningAgainstOldCluster()) { final Settings.Builder settings = Settings.builder() diff --git a/qa/full-cluster-restart/src/test/java/org/opensearch/upgrades/FullClusterRestartSettingsUpgradeIT.java b/qa/full-cluster-restart/src/test/java/org/opensearch/upgrades/FullClusterRestartSettingsUpgradeIT.java index 51586f597857b..5670c56597575 100644 --- a/qa/full-cluster-restart/src/test/java/org/opensearch/upgrades/FullClusterRestartSettingsUpgradeIT.java +++ b/qa/full-cluster-restart/src/test/java/org/opensearch/upgrades/FullClusterRestartSettingsUpgradeIT.java @@ -32,7 +32,7 @@ package org.opensearch.upgrades; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.admin.cluster.settings.ClusterGetSettingsResponse; import org.opensearch.client.Request; import org.opensearch.client.Response; @@ -56,8 +56,8 @@ public class FullClusterRestartSettingsUpgradeIT extends AbstractFullClusterRestartTestCase { public void testRemoteClusterSettingsUpgraded() throws IOException { - assumeTrue("skip_unavailable did not exist until 6.1.0", getOldClusterVersion().onOrAfter(Version.V_6_1_0)); - assumeTrue("settings automatically upgraded since 6.5.0", getOldClusterVersion().before(Version.V_6_5_0)); + assumeTrue("skip_unavailable did not exist until 6.1.0", getOldClusterVersion().onOrAfter(LegacyESVersion.V_6_1_0)); + assumeTrue("settings automatically upgraded since 6.5.0", getOldClusterVersion().before(LegacyESVersion.V_6_5_0)); if (isRunningAgainstOldCluster()) { final Request putSettingsRequest = new Request("PUT", "/_cluster/settings"); try (XContentBuilder builder = jsonBuilder()) { diff --git a/qa/full-cluster-restart/src/test/java/org/opensearch/upgrades/QueryBuilderBWCIT.java b/qa/full-cluster-restart/src/test/java/org/opensearch/upgrades/QueryBuilderBWCIT.java index 2ba95c6973b59..324bfeb9f8ca3 100644 --- a/qa/full-cluster-restart/src/test/java/org/opensearch/upgrades/QueryBuilderBWCIT.java +++ b/qa/full-cluster-restart/src/test/java/org/opensearch/upgrades/QueryBuilderBWCIT.java @@ -33,7 +33,7 @@ package org.opensearch.upgrades; import org.apache.http.util.EntityUtils; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.client.Request; import org.opensearch.client.Response; import org.opensearch.common.Strings; @@ -157,7 +157,7 @@ private static void addCandidate(String querySource, QueryBuilder expectedQb) { } public void testQueryBuilderBWC() throws Exception { - final String type = getOldClusterVersion().before(Version.V_7_0_0) ? "doc" : "_doc"; + final String type = getOldClusterVersion().before(LegacyESVersion.V_7_0_0) ? "doc" : "_doc"; String index = "queries"; if (isRunningAgainstOldCluster()) { XContentBuilder mappingsAndSettings = jsonBuilder(); diff --git a/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/IndexingIT.java b/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/IndexingIT.java index 3a2f11dac08e5..1f875158932ee 100644 --- a/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/IndexingIT.java +++ b/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/IndexingIT.java @@ -32,6 +32,7 @@ package org.opensearch.upgrades; import org.apache.http.util.EntityUtils; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.client.Request; import org.opensearch.client.Response; @@ -91,8 +92,8 @@ public void testIndexing() throws IOException { { Version minimumIndexCompatibilityVersion = Version.CURRENT.minimumIndexCompatibilityVersion(); assertThat("this branch is not needed if we aren't compatible with 6.0", - minimumIndexCompatibilityVersion.onOrBefore(Version.V_6_0_0), equalTo(true)); - if (minimumIndexCompatibilityVersion.before(Version.V_7_0_0)) { + minimumIndexCompatibilityVersion.onOrBefore(LegacyESVersion.V_6_0_0), equalTo(true)); + if (minimumIndexCompatibilityVersion.before(LegacyESVersion.V_7_0_0)) { XContentBuilder template = jsonBuilder(); template.startObject(); { @@ -203,7 +204,7 @@ public void testAutoIdWithOpTypeCreate() throws IOException { } } - if (minNodeVersion.before(Version.V_7_5_0)) { + if (minNodeVersion.before(LegacyESVersion.V_7_5_0)) { ResponseException e = expectThrows(ResponseException.class, () -> client().performRequest(bulk)); assertEquals(400, e.getResponse().getStatusLine().getStatusCode()); assertThat(e.getMessage(), diff --git a/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/JodaCompatibilityIT.java b/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/JodaCompatibilityIT.java index 5745eee30b831..0ef1e3a5050af 100644 --- a/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/JodaCompatibilityIT.java +++ b/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/JodaCompatibilityIT.java @@ -33,7 +33,7 @@ import org.apache.http.HttpStatus; import org.apache.http.util.EntityUtils; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.client.Node; import org.opensearch.client.Request; import org.opensearch.client.RequestOptions; @@ -74,7 +74,7 @@ public class JodaCompatibilityIT extends AbstractRollingTestCase { @BeforeClass public static void init(){ assumeTrue("upgrading from 7.0-7.6 will fail parsing joda formats", - UPGRADE_FROM_VERSION.before(Version.V_7_0_0)); + UPGRADE_FROM_VERSION.before(LegacyESVersion.V_7_0_0)); } public void testJodaBackedDocValueAndDateFields() throws Exception { diff --git a/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/MappingIT.java b/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/MappingIT.java index e83313f709bbb..07b1d67fde7ff 100644 --- a/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/MappingIT.java +++ b/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/MappingIT.java @@ -31,7 +31,7 @@ package org.opensearch.upgrades; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.client.Request; import org.opensearch.client.Response; import org.opensearch.common.xcontent.support.XContentMapValues; @@ -42,7 +42,7 @@ public class MappingIT extends AbstractRollingTestCase { * and check that it can be upgraded to 7x. */ public void testAllFieldDisable6x() throws Exception { - assumeTrue("_all", UPGRADE_FROM_VERSION.before(Version.V_7_0_0)); + assumeTrue("_all", UPGRADE_FROM_VERSION.before(LegacyESVersion.V_7_0_0)); switch (CLUSTER_TYPE) { case OLD: Request createTestIndex = new Request("PUT", "all-index"); diff --git a/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/RecoveryIT.java b/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/RecoveryIT.java index 29318d18cbe90..5507a5a221473 100644 --- a/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/RecoveryIT.java +++ b/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/RecoveryIT.java @@ -32,6 +32,7 @@ package org.opensearch.upgrades; import org.apache.http.util.EntityUtils; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.action.support.PlainActionFuture; import org.opensearch.client.Request; @@ -351,7 +352,7 @@ public void testRecovery() throws Exception { if (randomBoolean()) { indexDocs(index, i, 1); // update } else if (randomBoolean()) { - if (getNodeId(v -> v.onOrAfter(Version.V_7_0_0)) == null) { + if (getNodeId(v -> v.onOrAfter(LegacyESVersion.V_7_0_0)) == null) { client().performRequest(new Request("DELETE", index + "/test/" + i)); } else { client().performRequest(new Request("DELETE", index + "/_doc/" + i)); @@ -455,7 +456,7 @@ public void testRecoveryClosedIndex() throws Exception { } final Version indexVersionCreated = indexVersionCreated(indexName); - if (indexVersionCreated.onOrAfter(Version.V_7_2_0)) { + if (indexVersionCreated.onOrAfter(LegacyESVersion.V_7_2_0)) { // index was created on a version that supports the replication of closed indices, // so we expect the index to be closed and replicated ensureGreen(indexName); @@ -488,7 +489,7 @@ public void testCloseIndexDuringRollingUpgrade() throws Exception { closeIndex(indexName); } - if (minimumNodeVersion.onOrAfter(Version.V_7_2_0)) { + if (minimumNodeVersion.onOrAfter(LegacyESVersion.V_7_2_0)) { // index is created on a version that supports the replication of closed indices, // so we expect the index to be closed and replicated ensureGreen(indexName); @@ -523,12 +524,12 @@ public void testClosedIndexNoopRecovery() throws Exception { } final Version indexVersionCreated = indexVersionCreated(indexName); - if (indexVersionCreated.onOrAfter(Version.V_7_2_0)) { + if (indexVersionCreated.onOrAfter(LegacyESVersion.V_7_2_0)) { // index was created on a version that supports the replication of closed indices, // so we expect the index to be closed and replicated ensureGreen(indexName); assertClosedIndex(indexName, true); - if (minimumNodeVersion().onOrAfter(Version.V_7_2_0)) { + if (minimumNodeVersion().onOrAfter(LegacyESVersion.V_7_2_0)) { switch (CLUSTER_TYPE) { case OLD: break; case MIXED: @@ -777,7 +778,7 @@ public void testAutoExpandIndicesDuringRollingUpgrade() throws Exception { final int numberOfReplicas = Integer.parseInt( getIndexSettingsAsMap(indexName).get(IndexMetadata.SETTING_NUMBER_OF_REPLICAS).toString()); - if (minimumNodeVersion.onOrAfter(Version.V_7_6_0)) { + if (minimumNodeVersion.onOrAfter(LegacyESVersion.V_7_6_0)) { assertEquals(nodes.size() - 2, numberOfReplicas); ensureGreen(indexName); } else { diff --git a/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/SystemIndicesUpgradeIT.java b/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/SystemIndicesUpgradeIT.java index acd6a93182a88..c50af0084b000 100644 --- a/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/SystemIndicesUpgradeIT.java +++ b/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/SystemIndicesUpgradeIT.java @@ -32,6 +32,7 @@ package org.opensearch.upgrades; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.client.Request; import org.opensearch.client.ResponseException; @@ -58,7 +59,7 @@ public void testSystemIndicesUpgrades() throws Exception { Request bulk = new Request("POST", "/_bulk"); bulk.addParameter("refresh", "true"); - if (UPGRADE_FROM_VERSION.before(Version.V_7_0_0)) { + if (UPGRADE_FROM_VERSION.before(LegacyESVersion.V_7_0_0)) { bulk.setJsonEntity("{\"index\": {\"_index\": \"test_index_old\", \"_type\" : \"_doc\"}}\n" + "{\"f1\": \"v1\", \"f2\": \"v2\"}\n"); } else { @@ -90,7 +91,7 @@ public void testSystemIndicesUpgrades() throws Exception { // make sure .tasks index exists Request getTasksIndex = new Request("GET", "/.tasks"); getTasksIndex.addParameter("allow_no_indices", "false"); - if (UPGRADE_FROM_VERSION.before(Version.V_7_0_0)) { + if (UPGRADE_FROM_VERSION.before(LegacyESVersion.V_7_0_0)) { getTasksIndex.addParameter("include_type_name", "false"); } diff --git a/qa/translog-policy/src/test/java/org/opensearch/upgrades/TranslogPolicyIT.java b/qa/translog-policy/src/test/java/org/opensearch/upgrades/TranslogPolicyIT.java index c0e0521735a51..30ac77cf2d421 100644 --- a/qa/translog-policy/src/test/java/org/opensearch/upgrades/TranslogPolicyIT.java +++ b/qa/translog-policy/src/test/java/org/opensearch/upgrades/TranslogPolicyIT.java @@ -32,7 +32,7 @@ package org.opensearch.upgrades; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.client.Request; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.Strings; @@ -95,7 +95,7 @@ public void setIndex() { @Before public void setType() { - type = getOldClusterVersion().before(Version.V_6_7_0) ? "doc" : "_doc"; + type = getOldClusterVersion().before(LegacyESVersion.V_6_7_0) ? "doc" : "_doc"; } public void testEmptyIndex() throws Exception { @@ -103,7 +103,7 @@ public void testEmptyIndex() throws Exception { final Settings.Builder settings = Settings.builder() .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, between(0, 1)); - if (getOldClusterVersion().onOrAfter(Version.V_6_5_0)) { + if (getOldClusterVersion().onOrAfter(LegacyESVersion.V_6_5_0)) { settings.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), randomBoolean()); } if (randomBoolean()) { @@ -121,7 +121,7 @@ public void testRecoverReplica() throws Exception { final Settings.Builder settings = Settings.builder() .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1); - if (getOldClusterVersion().onOrAfter(Version.V_6_5_0)) { + if (getOldClusterVersion().onOrAfter(LegacyESVersion.V_6_5_0)) { settings.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), randomBoolean()); } if (randomBoolean()) { diff --git a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/SplitIndexIT.java b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/SplitIndexIT.java index 2b53d303979c7..388e97a29629a 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/SplitIndexIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/admin/indices/create/SplitIndexIT.java @@ -39,6 +39,7 @@ import org.apache.lucene.search.join.ScoreMode; import org.apache.lucene.util.Constants; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.action.admin.cluster.state.ClusterStateRequest; import org.opensearch.action.admin.cluster.state.ClusterStateResponse; @@ -370,7 +371,7 @@ private static IndexMetadata indexMetadata(final Client client, final String ind public void testCreateSplitIndex() throws Exception { internalCluster().ensureAtLeastNumDataNodes(2); - Version version = VersionUtils.randomVersionBetween(random(), Version.V_6_0_0_rc2, Version.CURRENT); + Version version = VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_6_0_0_rc2, Version.CURRENT); prepareCreate("source").setSettings(Settings.builder().put(indexSettings()) .put("number_of_shards", 1) .put("index.version.created", version) diff --git a/server/src/internalClusterTest/java/org/opensearch/gateway/ReplicaShardAllocatorIT.java b/server/src/internalClusterTest/java/org/opensearch/gateway/ReplicaShardAllocatorIT.java index 3228ecd4511cb..63e4dfc782739 100644 --- a/server/src/internalClusterTest/java/org/opensearch/gateway/ReplicaShardAllocatorIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/gateway/ReplicaShardAllocatorIT.java @@ -32,6 +32,7 @@ package org.opensearch.gateway; +import org.opensearch.LegacyESVersion; import org.opensearch.action.admin.indices.flush.SyncedFlushResponse; import org.opensearch.action.admin.indices.stats.ShardStats; import org.opensearch.cluster.metadata.IndexMetadata; @@ -374,7 +375,7 @@ public void testPeerRecoveryForClosedIndices() throws Exception { } /** - * If the recovery source is on an old node (before
{@link org.opensearch.Version#V_7_2_0}
) then the recovery target + * If the recovery source is on an old node (before
{@link LegacyESVersion#V_7_2_0}
) then the recovery target * won't have the safe commit after phase1 because the recovery source does not send the global checkpoint in the clean_files * step. And if the recovery fails and retries, then the recovery stage might not transition properly. This test simulates * this behavior by changing the global checkpoint in phase1 to unassigned. diff --git a/server/src/internalClusterTest/java/org/opensearch/get/LegacyGetActionIT.java b/server/src/internalClusterTest/java/org/opensearch/get/LegacyGetActionIT.java index 7bb143de496b7..a418dcafe1702 100644 --- a/server/src/internalClusterTest/java/org/opensearch/get/LegacyGetActionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/get/LegacyGetActionIT.java @@ -32,7 +32,7 @@ package org.opensearch.get; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.admin.indices.alias.Alias; import org.opensearch.action.get.GetResponse; import org.opensearch.cluster.metadata.IndexMetadata; @@ -59,7 +59,8 @@ public void testGetFieldsMetadataWithRouting() throws Exception { .setSettings( Settings.builder() .put("index.refresh_interval", -1) - .put(IndexMetadata.SETTING_INDEX_VERSION_CREATED.getKey(), Version.V_6_0_0))); // multi-types in 6.0.0 + // multi-types in 6.0.0 + .put(IndexMetadata.SETTING_INDEX_VERSION_CREATED.getKey(), LegacyESVersion.V_6_0_0))); try (XContentBuilder source = jsonBuilder().startObject().field("field1", "value").endObject()) { client() diff --git a/server/src/internalClusterTest/java/org/opensearch/index/seqno/PeerRecoveryRetentionLeaseCreationIT.java b/server/src/internalClusterTest/java/org/opensearch/index/seqno/PeerRecoveryRetentionLeaseCreationIT.java index 646a65e831846..5ae2ee6a814c8 100644 --- a/server/src/internalClusterTest/java/org/opensearch/index/seqno/PeerRecoveryRetentionLeaseCreationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/index/seqno/PeerRecoveryRetentionLeaseCreationIT.java @@ -31,6 +31,7 @@ package org.opensearch.index.seqno; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.common.UUIDs; @@ -73,7 +74,7 @@ public void testCanRecoverFromStoreWithoutPeerRecoveryRetentionLease() throws Ex .put(IndexMetadata.SETTING_VERSION_CREATED, // simulate a version which supports soft deletes (v6.5.0-and-later) with which this node is compatible VersionUtils.randomVersionBetween(random(), - Version.max(Version.CURRENT.minimumIndexCompatibilityVersion(), Version.V_6_5_0), Version.CURRENT)))); + Version.max(Version.CURRENT.minimumIndexCompatibilityVersion(), LegacyESVersion.V_6_5_0), Version.CURRENT)))); ensureGreen("index"); // Change the node ID so that the persisted retention lease no longer applies. diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/IndicesLifecycleListenerIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/IndicesLifecycleListenerIT.java index e7d51f38e2087..9870fd8df571c 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/IndicesLifecycleListenerIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/IndicesLifecycleListenerIT.java @@ -32,6 +32,7 @@ package org.opensearch.indices; +import org.opensearch.LegacyESVersion; import org.opensearch.OpenSearchException; import org.opensearch.Version; import org.opensearch.action.admin.cluster.state.ClusterStateResponse; @@ -227,7 +228,7 @@ public void testIndexStateShardChanged() throws Throwable { assertThat(stateChangeListenerNode1.afterCloseSettings.getAsInt(SETTING_NUMBER_OF_SHARDS, -1), equalTo(6)); assertThat(stateChangeListenerNode1.afterCloseSettings.getAsInt(SETTING_NUMBER_OF_REPLICAS, -1), equalTo(1)); - if (Version.CURRENT.onOrAfter(Version.V_7_2_0)) { + if (Version.CURRENT.onOrAfter(LegacyESVersion.V_7_2_0)) { assertShardStatesMatch(stateChangeListenerNode1, 6, CLOSED, CREATED, RECOVERING, POST_RECOVERY, STARTED); assertShardStatesMatch(stateChangeListenerNode2, 6, CLOSED, CREATED, RECOVERING, POST_RECOVERY, STARTED); } else { diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/mapping/LegacyUpdateMappingIntegrationIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/mapping/LegacyUpdateMappingIntegrationIT.java index 06461563f06ac..ee3bb6a60d29d 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/mapping/LegacyUpdateMappingIntegrationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/mapping/LegacyUpdateMappingIntegrationIT.java @@ -32,7 +32,7 @@ package org.opensearch.indices.mapping; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.admin.indices.mapping.get.GetMappingsResponse; import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.cluster.metadata.IndexMetadata; @@ -74,7 +74,7 @@ public void testUpdateDefaultMappingSettings() throws Exception { .admin() .indices() .prepareCreate("test") - .setSettings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.V_6_3_0).build()) + .setSettings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, LegacyESVersion.V_6_3_0).build()) .addMapping(MapperService.DEFAULT_MAPPING, defaultMapping) .get(); } diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/stats/LegacyIndexStatsIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/stats/LegacyIndexStatsIT.java index 9f124b0573822..83ebefeb56c05 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/stats/LegacyIndexStatsIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/stats/LegacyIndexStatsIT.java @@ -32,7 +32,7 @@ package org.opensearch.indices.stats; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.admin.indices.stats.IndicesStatsRequestBuilder; import org.opensearch.action.admin.indices.stats.IndicesStatsResponse; import org.opensearch.cluster.metadata.IndexMetadata; @@ -59,7 +59,7 @@ public void testFieldDataFieldsParam() { .admin() .indices() .prepareCreate("test1") - .setSettings(Settings.builder().put(IndexMetadata.SETTING_INDEX_VERSION_CREATED.getKey(), Version.V_6_0_0)) + .setSettings(Settings.builder().put(IndexMetadata.SETTING_INDEX_VERSION_CREATED.getKey(), LegacyESVersion.V_6_0_0)) .addMapping("_doc", "bar", "type=text,fielddata=true", "baz", "type=text,fielddata=true") .get()); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/GeoDistanceIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/GeoDistanceIT.java index cc2d8bf03c419..c80e747c1eb16 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/GeoDistanceIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/GeoDistanceIT.java @@ -31,6 +31,7 @@ package org.opensearch.search.aggregations.bucket; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.action.index.IndexRequestBuilder; import org.opensearch.action.search.SearchPhaseExecutionException; @@ -77,7 +78,7 @@ protected boolean forbidPrivateIndexSettings() { return false; } - private Version version = VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, Version.CURRENT); + private Version version = VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_6_0_0, Version.CURRENT); private IndexRequestBuilder indexCity(String idx, String name, String... latLons) throws Exception { XContentBuilder source = jsonBuilder().startObject().field("city", name); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/GeoHashGridIT.java b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/GeoHashGridIT.java index dc62acd50bc83..63176fab451fa 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/GeoHashGridIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/aggregations/bucket/GeoHashGridIT.java @@ -34,6 +34,7 @@ import com.carrotsearch.hppc.ObjectIntHashMap; import com.carrotsearch.hppc.ObjectIntMap; import com.carrotsearch.hppc.cursors.ObjectIntCursor; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.action.index.IndexRequestBuilder; import org.opensearch.action.search.SearchResponse; @@ -74,7 +75,7 @@ protected boolean forbidPrivateIndexSettings() { return false; } - private Version version = VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, + private Version version = VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_6_0_0, Version.CURRENT); static ObjectIntMap expectedDocCountsForGeoHash = null; diff --git a/server/src/internalClusterTest/java/org/opensearch/search/functionscore/DecayFunctionScoreIT.java b/server/src/internalClusterTest/java/org/opensearch/search/functionscore/DecayFunctionScoreIT.java index 83ee2ae37e538..dfeff93839056 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/functionscore/DecayFunctionScoreIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/functionscore/DecayFunctionScoreIT.java @@ -32,6 +32,7 @@ package org.opensearch.search.functionscore; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.action.ActionFuture; import org.opensearch.action.index.IndexRequestBuilder; @@ -623,7 +624,7 @@ public void testDateWithoutOrigin() throws Exception { } public void testManyDocsLin() throws Exception { - Version version = VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, Version.CURRENT); + Version version = VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_6_0_0, Version.CURRENT); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); XContentBuilder xContentBuilder = jsonBuilder().startObject().startObject("type").startObject("properties") .startObject("test").field("type", "text").endObject().startObject("date").field("type", "date") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoBoundingBoxQueryIT.java b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoBoundingBoxQueryIT.java index 510fd3b33e499..7aad27d68dba7 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoBoundingBoxQueryIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoBoundingBoxQueryIT.java @@ -32,6 +32,7 @@ package org.opensearch.search.geo; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.action.search.SearchResponse; import org.opensearch.cluster.metadata.IndexMetadata; @@ -60,7 +61,7 @@ protected boolean forbidPrivateIndexSettings() { } public void testSimpleBoundingBoxTest() throws Exception { - Version version = VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, + Version version = VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_6_0_0, Version.CURRENT); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type1") @@ -132,7 +133,7 @@ public void testSimpleBoundingBoxTest() throws Exception { } public void testLimit2BoundingBox() throws Exception { - Version version = VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, + Version version = VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_6_0_0, Version.CURRENT); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type1") @@ -187,7 +188,7 @@ public void testLimit2BoundingBox() throws Exception { } public void testCompleteLonRange() throws Exception { - Version version = VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, + Version version = VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_6_0_0, Version.CURRENT); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type1") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoDistanceIT.java b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoDistanceIT.java index 75894a8504cf3..60bbe89ffd125 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoDistanceIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoDistanceIT.java @@ -32,6 +32,7 @@ package org.opensearch.search.geo; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.action.search.SearchRequestBuilder; import org.opensearch.action.search.SearchResponse; @@ -117,7 +118,7 @@ protected boolean forbidPrivateIndexSettings() { @Before public void setupTestIndex() throws IOException { - Version version = VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, + Version version = VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_6_0_0, Version.CURRENT); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type1") diff --git a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoFilterIT.java b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoFilterIT.java index 49e3281ae37e4..5d9f2df81ff8a 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoFilterIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoFilterIT.java @@ -40,6 +40,7 @@ import org.apache.lucene.spatial.query.SpatialOperation; import org.apache.lucene.spatial.query.UnsupportedSpatialOperation; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.action.admin.indices.create.CreateIndexRequestBuilder; import org.opensearch.action.bulk.BulkItemResponse; @@ -382,7 +383,7 @@ public void testShapeRelations() throws Exception { public void testBulk() throws Exception { byte[] bulkAction = unZipData("/org/opensearch/search/geo/gzippedmap.gz"); - Version version = VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, + Version version = VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_6_0_0, Version.CURRENT); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); XContentBuilder xContentBuilder = XContentFactory.jsonBuilder() diff --git a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoPolygonIT.java b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoPolygonIT.java index c2a1477b62090..284c848e4d6de 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoPolygonIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/geo/GeoPolygonIT.java @@ -32,6 +32,7 @@ package org.opensearch.search.geo; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.action.search.SearchResponse; import org.opensearch.cluster.metadata.IndexMetadata; @@ -62,7 +63,7 @@ protected boolean forbidPrivateIndexSettings() { @Override protected void setupSuiteScopeCluster() throws Exception { - Version version = VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, + Version version = VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_6_0_0, Version.CURRENT); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); diff --git a/server/src/internalClusterTest/java/org/opensearch/search/sort/GeoDistanceIT.java b/server/src/internalClusterTest/java/org/opensearch/search/sort/GeoDistanceIT.java index 9f6644e8d6012..3ad026f3cca78 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/sort/GeoDistanceIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/sort/GeoDistanceIT.java @@ -32,6 +32,7 @@ package org.opensearch.search.sort; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.action.search.SearchResponse; import org.opensearch.cluster.metadata.IndexMetadata; @@ -68,7 +69,7 @@ protected boolean forbidPrivateIndexSettings() { } public void testDistanceSortingMVFields() throws Exception { - Version version = VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, + Version version = VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_6_0_0, Version.CURRENT); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties") @@ -195,7 +196,7 @@ public void testDistanceSortingMVFields() throws Exception { // Regression bug: // https://github.com/elastic/elasticsearch/issues/2851 public void testDistanceSortingWithMissingGeoPoint() throws Exception { - Version version = VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, + Version version = VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_6_0_0, Version.CURRENT); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties") @@ -238,7 +239,7 @@ public void testDistanceSortingWithMissingGeoPoint() throws Exception { } public void testDistanceSortingNestedFields() throws Exception { - Version version = VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, + Version version = VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_6_0_0, Version.CURRENT); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("company").startObject("properties") @@ -387,7 +388,7 @@ public void testDistanceSortingNestedFields() throws Exception { * Issue 3073 */ public void testGeoDistanceFilter() throws IOException { - Version version = VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, + Version version = VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_6_0_0, Version.CURRENT); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); double lat = 40.720611; diff --git a/server/src/internalClusterTest/java/org/opensearch/search/sort/GeoDistanceSortBuilderIT.java b/server/src/internalClusterTest/java/org/opensearch/search/sort/GeoDistanceSortBuilderIT.java index 0bd5e2d2d7039..7504789f1cd17 100644 --- a/server/src/internalClusterTest/java/org/opensearch/search/sort/GeoDistanceSortBuilderIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/search/sort/GeoDistanceSortBuilderIT.java @@ -32,6 +32,7 @@ package org.opensearch.search.sort; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.action.search.SearchResponse; import org.opensearch.cluster.metadata.IndexMetadata; @@ -82,7 +83,7 @@ public void testManyToManyGeoPoints() throws ExecutionException, InterruptedExce * 1 2 3 4 5 6 7 */ Version version = randomBoolean() ? Version.CURRENT - : VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, Version.CURRENT); + : VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_6_0_0, Version.CURRENT); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); assertAcked(prepareCreate("index").setSettings(settings).addMapping("type", LOCATION_FIELD, "type=geo_point")); XContentBuilder d1Builder = jsonBuilder(); @@ -156,7 +157,7 @@ public void testSingeToManyAvgMedian() throws ExecutionException, InterruptedExc * d2 = (0, 1), (0, 5), (0, 6); so avg. distance is 4, median distance is 5 */ Version version = randomBoolean() ? Version.CURRENT - : VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, Version.CURRENT); + : VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_6_0_0, Version.CURRENT); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); assertAcked(prepareCreate("index").setSettings(settings).addMapping("type", LOCATION_FIELD, "type=geo_point")); XContentBuilder d1Builder = jsonBuilder(); @@ -221,7 +222,7 @@ public void testManyToManyGeoPointsWithDifferentFormats() throws ExecutionExcept * 1 2 3 4 5 6 */ Version version = randomBoolean() ? Version.CURRENT - : VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, Version.CURRENT); + : VersionUtils.randomVersionBetween(random(), LegacyESVersion.V_6_0_0, Version.CURRENT); Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); assertAcked(prepareCreate("index").setSettings(settings).addMapping("type", LOCATION_FIELD, "type=geo_point")); XContentBuilder d1Builder = jsonBuilder(); diff --git a/server/src/main/java/org/opensearch/Build.java b/server/src/main/java/org/opensearch/Build.java index 79d19514d4ab6..8c3b45c49317f 100644 --- a/server/src/main/java/org/opensearch/Build.java +++ b/server/src/main/java/org/opensearch/Build.java @@ -202,10 +202,10 @@ public static Build readBuild(StreamInput in) throws IOException { // TODO - clean this up when OSS flavor is removed in all of the code base // (Integ test zip still write OSS as distribution) // See issue: https://github.com/opendistro-for-elasticsearch/search/issues/159 - if (in.getVersion().onOrAfter(Version.V_6_3_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) { flavor = in.readString(); } - if (in.getVersion().onOrAfter(Version.V_6_3_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) { // be lenient when reading on the wire, the enumeration values from other versions might be different than what we know type = Type.fromDisplayName(in.readString(), false); } else { @@ -216,7 +216,7 @@ public static Build readBuild(StreamInput in) throws IOException { boolean snapshot = in.readBoolean(); final String version; - if (in.getVersion().onOrAfter(Version.V_7_0_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_0_0)) { version = in.readString(); } else { version = in.getVersion().toString(); @@ -229,12 +229,12 @@ public static void writeBuild(Build build, StreamOutput out) throws IOException // TODO - clean up this code when we remove all v6 bwc tests. // TODO - clean this up when OSS flavor is removed in all of the code base // See issue: https://github.com/opendistro-for-elasticsearch/search/issues/159 - if (out.getVersion().onOrAfter(Version.V_6_3_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) { out.writeString("oss"); } - if (out.getVersion().onOrAfter(Version.V_6_3_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) { final Type buildType; - if (out.getVersion().before(Version.V_6_7_0) && build.type() == Type.DOCKER) { + if (out.getVersion().before(LegacyESVersion.V_6_7_0) && build.type() == Type.DOCKER) { buildType = Type.TAR; } else { buildType = build.type(); @@ -244,7 +244,7 @@ public static void writeBuild(Build build, StreamOutput out) throws IOException out.writeString(build.hash()); out.writeString(build.date()); out.writeBoolean(build.isSnapshot()); - if (out.getVersion().onOrAfter(Version.V_7_0_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_0_0)) { out.writeString(build.getQualifiedVersion()); } } diff --git a/server/src/main/java/org/opensearch/LegacyESVersion.java b/server/src/main/java/org/opensearch/LegacyESVersion.java new file mode 100644 index 0000000000000..c69dd1aa6afdb --- /dev/null +++ b/server/src/main/java/org/opensearch/LegacyESVersion.java @@ -0,0 +1,159 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * GitHub history for details. + */ + +package org.opensearch; + +/** + * The Contents of this file were originally moved from {@link Version}. + * + * This class keeps all the supported OpenSearch predecessor versions for + * backward compatibility purpose. + */ +public class LegacyESVersion extends Version { + + public static final LegacyESVersion V_6_0_0_alpha1 = + new LegacyESVersion(6000001, org.apache.lucene.util.Version.LUCENE_7_0_0); + public static final LegacyESVersion V_6_0_0_alpha2 = + new LegacyESVersion(6000002, org.apache.lucene.util.Version.LUCENE_7_0_0); + public static final LegacyESVersion V_6_0_0_beta1 = + new LegacyESVersion(6000026, org.apache.lucene.util.Version.LUCENE_7_0_0); + public static final LegacyESVersion V_6_0_0_beta2 = + new LegacyESVersion(6000027, org.apache.lucene.util.Version.LUCENE_7_0_0); + public static final LegacyESVersion V_6_0_0_rc1 = + new LegacyESVersion(6000051, org.apache.lucene.util.Version.LUCENE_7_0_0); + public static final LegacyESVersion V_6_0_0_rc2 = + new LegacyESVersion(6000052, org.apache.lucene.util.Version.LUCENE_7_0_1); + public static final LegacyESVersion V_6_0_0 = + new LegacyESVersion(6000099, org.apache.lucene.util.Version.LUCENE_7_0_1); + public static final LegacyESVersion V_6_0_1 = + new LegacyESVersion(6000199, org.apache.lucene.util.Version.LUCENE_7_0_1); + public static final LegacyESVersion V_6_1_0 = new LegacyESVersion(6010099, org.apache.lucene.util.Version.LUCENE_7_1_0); + public static final LegacyESVersion V_6_1_1 = new LegacyESVersion(6010199, org.apache.lucene.util.Version.LUCENE_7_1_0); + public static final LegacyESVersion V_6_1_2 = new LegacyESVersion(6010299, org.apache.lucene.util.Version.LUCENE_7_1_0); + public static final LegacyESVersion V_6_1_3 = new LegacyESVersion(6010399, org.apache.lucene.util.Version.LUCENE_7_1_0); + public static final LegacyESVersion V_6_1_4 = new LegacyESVersion(6010499, org.apache.lucene.util.Version.LUCENE_7_1_0); + // The below version is missing from the 7.3 JAR + private static final org.apache.lucene.util.Version LUCENE_7_2_1 = org.apache.lucene.util.Version.fromBits(7, 2, 1); + public static final LegacyESVersion V_6_2_0 = new LegacyESVersion(6020099, LUCENE_7_2_1); + public static final LegacyESVersion V_6_2_1 = new LegacyESVersion(6020199, LUCENE_7_2_1); + public static final LegacyESVersion V_6_2_2 = new LegacyESVersion(6020299, LUCENE_7_2_1); + public static final LegacyESVersion V_6_2_3 = new LegacyESVersion(6020399, LUCENE_7_2_1); + public static final LegacyESVersion V_6_2_4 = new LegacyESVersion(6020499, LUCENE_7_2_1); + public static final LegacyESVersion V_6_3_0 = new LegacyESVersion(6030099, org.apache.lucene.util.Version.LUCENE_7_3_1); + public static final LegacyESVersion V_6_3_1 = new LegacyESVersion(6030199, org.apache.lucene.util.Version.LUCENE_7_3_1); + public static final LegacyESVersion V_6_3_2 = new LegacyESVersion(6030299, org.apache.lucene.util.Version.LUCENE_7_3_1); + public static final LegacyESVersion V_6_4_0 = new LegacyESVersion(6040099, org.apache.lucene.util.Version.LUCENE_7_4_0); + public static final LegacyESVersion V_6_4_1 = new LegacyESVersion(6040199, org.apache.lucene.util.Version.LUCENE_7_4_0); + public static final LegacyESVersion V_6_4_2 = new LegacyESVersion(6040299, org.apache.lucene.util.Version.LUCENE_7_4_0); + public static final LegacyESVersion V_6_4_3 = new LegacyESVersion(6040399, org.apache.lucene.util.Version.LUCENE_7_4_0); + public static final LegacyESVersion V_6_5_0 = new LegacyESVersion(6050099, org.apache.lucene.util.Version.LUCENE_7_5_0); + public static final LegacyESVersion V_6_5_1 = new LegacyESVersion(6050199, org.apache.lucene.util.Version.LUCENE_7_5_0); + public static final LegacyESVersion V_6_5_2 = new LegacyESVersion(6050299, org.apache.lucene.util.Version.LUCENE_7_5_0); + public static final LegacyESVersion V_6_5_3 = new LegacyESVersion(6050399, org.apache.lucene.util.Version.LUCENE_7_5_0); + public static final LegacyESVersion V_6_5_4 = new LegacyESVersion(6050499, org.apache.lucene.util.Version.LUCENE_7_5_0); + public static final LegacyESVersion V_6_6_0 = new LegacyESVersion(6060099, org.apache.lucene.util.Version.LUCENE_7_6_0); + public static final LegacyESVersion V_6_6_1 = new LegacyESVersion(6060199, org.apache.lucene.util.Version.LUCENE_7_6_0); + public static final LegacyESVersion V_6_6_2 = new LegacyESVersion(6060299, org.apache.lucene.util.Version.LUCENE_7_6_0); + public static final LegacyESVersion V_6_7_0 = new LegacyESVersion(6070099, org.apache.lucene.util.Version.LUCENE_7_7_0); + public static final LegacyESVersion V_6_7_1 = new LegacyESVersion(6070199, org.apache.lucene.util.Version.LUCENE_7_7_0); + public static final LegacyESVersion V_6_7_2 = new LegacyESVersion(6070299, org.apache.lucene.util.Version.LUCENE_7_7_0); + public static final LegacyESVersion V_6_8_0 = new LegacyESVersion(6080099, org.apache.lucene.util.Version.LUCENE_7_7_0); + public static final LegacyESVersion V_6_8_1 = new LegacyESVersion(6080199, org.apache.lucene.util.Version.LUCENE_7_7_0); + public static final LegacyESVersion V_6_8_2 = new LegacyESVersion(6080299, org.apache.lucene.util.Version.LUCENE_7_7_0); + public static final LegacyESVersion V_6_8_3 = new LegacyESVersion(6080399, org.apache.lucene.util.Version.LUCENE_7_7_0); + public static final LegacyESVersion V_6_8_4 = new LegacyESVersion(6080499, org.apache.lucene.util.Version.LUCENE_7_7_2); + public static final LegacyESVersion V_6_8_5 = new LegacyESVersion(6080599, org.apache.lucene.util.Version.LUCENE_7_7_2); + public static final LegacyESVersion V_6_8_6 = new LegacyESVersion(6080699, org.apache.lucene.util.Version.LUCENE_7_7_2); + public static final LegacyESVersion V_6_8_7 = new LegacyESVersion(6080799, org.apache.lucene.util.Version.LUCENE_7_7_2); + public static final LegacyESVersion V_6_8_8 = new LegacyESVersion(6080899, org.apache.lucene.util.Version.LUCENE_7_7_2); + // Version constant for Lucene 7.7.3 release with index corruption bug fix + private static final org.apache.lucene.util.Version LUCENE_7_7_3 = org.apache.lucene.util.Version.fromBits(7, 7, 3); + public static final LegacyESVersion V_6_8_9 = new LegacyESVersion(6080999, LUCENE_7_7_3); + public static final LegacyESVersion V_6_8_10 = new LegacyESVersion(6081099, LUCENE_7_7_3); + public static final LegacyESVersion V_6_8_11 = new LegacyESVersion(6081199, LUCENE_7_7_3); + public static final LegacyESVersion V_6_8_12 = new LegacyESVersion(6081299, LUCENE_7_7_3); + public static final LegacyESVersion V_6_8_13 = new LegacyESVersion(6081399, LUCENE_7_7_3); + public static final LegacyESVersion V_6_8_14 = new LegacyESVersion(6081499, LUCENE_7_7_3); + public static final LegacyESVersion V_6_8_15 = new LegacyESVersion(6081599, org.apache.lucene.util.Version.LUCENE_7_7_3); + public static final LegacyESVersion V_7_0_0 = new LegacyESVersion(7000099, org.apache.lucene.util.Version.LUCENE_8_0_0); + public static final LegacyESVersion V_7_0_1 = new LegacyESVersion(7000199, org.apache.lucene.util.Version.LUCENE_8_0_0); + public static final LegacyESVersion V_7_1_0 = new LegacyESVersion(7010099, org.apache.lucene.util.Version.LUCENE_8_0_0); + public static final LegacyESVersion V_7_1_1 = new LegacyESVersion(7010199, org.apache.lucene.util.Version.LUCENE_8_0_0); + public static final LegacyESVersion V_7_2_0 = new LegacyESVersion(7020099, org.apache.lucene.util.Version.LUCENE_8_0_0); + public static final LegacyESVersion V_7_2_1 = new LegacyESVersion(7020199, org.apache.lucene.util.Version.LUCENE_8_0_0); + public static final LegacyESVersion V_7_3_0 = new LegacyESVersion(7030099, org.apache.lucene.util.Version.LUCENE_8_1_0); + public static final LegacyESVersion V_7_3_1 = new LegacyESVersion(7030199, org.apache.lucene.util.Version.LUCENE_8_1_0); + public static final LegacyESVersion V_7_3_2 = new LegacyESVersion(7030299, org.apache.lucene.util.Version.LUCENE_8_1_0); + public static final LegacyESVersion V_7_4_0 = new LegacyESVersion(7040099, org.apache.lucene.util.Version.LUCENE_8_2_0); + public static final LegacyESVersion V_7_4_1 = new LegacyESVersion(7040199, org.apache.lucene.util.Version.LUCENE_8_2_0); + public static final LegacyESVersion V_7_4_2 = new LegacyESVersion(7040299, org.apache.lucene.util.Version.LUCENE_8_2_0); + public static final LegacyESVersion V_7_5_0 = new LegacyESVersion(7050099, org.apache.lucene.util.Version.LUCENE_8_3_0); + public static final LegacyESVersion V_7_5_1 = new LegacyESVersion(7050199, org.apache.lucene.util.Version.LUCENE_8_3_0); + public static final LegacyESVersion V_7_5_2 = new LegacyESVersion(7050299, org.apache.lucene.util.Version.LUCENE_8_3_0); + public static final LegacyESVersion V_7_6_0 = new LegacyESVersion(7060099, org.apache.lucene.util.Version.LUCENE_8_4_0); + public static final LegacyESVersion V_7_6_1 = new LegacyESVersion(7060199, org.apache.lucene.util.Version.LUCENE_8_4_0); + public static final LegacyESVersion V_7_6_2 = new LegacyESVersion(7060299, org.apache.lucene.util.Version.LUCENE_8_4_0); + public static final LegacyESVersion V_7_7_0 = new LegacyESVersion(7070099, org.apache.lucene.util.Version.LUCENE_8_5_1); + public static final LegacyESVersion V_7_7_1 = new LegacyESVersion(7070199, org.apache.lucene.util.Version.LUCENE_8_5_1); + public static final LegacyESVersion V_7_8_0 = new LegacyESVersion(7080099, org.apache.lucene.util.Version.LUCENE_8_5_1); + public static final LegacyESVersion V_7_8_1 = new LegacyESVersion(7080199, org.apache.lucene.util.Version.LUCENE_8_5_1); + public static final LegacyESVersion V_7_9_0 = new LegacyESVersion(7090099, org.apache.lucene.util.Version.LUCENE_8_6_0); + public static final LegacyESVersion V_7_9_1 = new LegacyESVersion(7090199, org.apache.lucene.util.Version.LUCENE_8_6_2); + public static final LegacyESVersion V_7_9_2 = new LegacyESVersion(7090299, org.apache.lucene.util.Version.LUCENE_8_6_2); + public static final LegacyESVersion V_7_9_3 = new LegacyESVersion(7090399, org.apache.lucene.util.Version.LUCENE_8_6_2); + public static final LegacyESVersion V_7_10_0 = new LegacyESVersion(7100099, org.apache.lucene.util.Version.LUCENE_8_7_0); + public static final LegacyESVersion V_7_10_1 = new LegacyESVersion(7100199, org.apache.lucene.util.Version.LUCENE_8_7_0); + public static final LegacyESVersion V_7_10_2 = new LegacyESVersion(7100299, org.apache.lucene.util.Version.LUCENE_8_7_0); + public static final LegacyESVersion V_7_10_3 = new LegacyESVersion(7100399, org.apache.lucene.util.Version.LUCENE_8_7_0); + + protected LegacyESVersion(int id, org.apache.lucene.util.Version luceneVersion) { + // flip the 28th bit of the version id + // this will be flipped back in the parent class to correctly identify as a legacy version; + // giving backwards compatibility with legacy systems + super(id ^ 0x08000000, luceneVersion); + } + + @Override + public boolean isBeta() { + return major < 5 ? build < 50 : build >= 25 && build < 50; + } + + /** + * Returns true iff this version is an alpha version + * Note: This has been introduced in version 5 of the OpenSearch predecessor. Previous versions will never + * have an alpha version. + */ + @Override + public boolean isAlpha() { + return major < 5 ? false : build < 25; + } +} diff --git a/server/src/main/java/org/opensearch/OpenSearchException.java b/server/src/main/java/org/opensearch/OpenSearchException.java index 47ad9f60153fa..b89aebf4b3488 100644 --- a/server/src/main/java/org/opensearch/OpenSearchException.java +++ b/server/src/main/java/org/opensearch/OpenSearchException.java @@ -299,7 +299,7 @@ public void writeTo(StreamOutput out) throws IOException { public static OpenSearchException readException(StreamInput input, int id) throws IOException { CheckedFunction opensearchException = ID_TO_SUPPLIER.get(id); if (opensearchException == null) { - if (id == 127 && input.getVersion().before(Version.V_7_5_0)) { + if (id == 127 && input.getVersion().before(LegacyESVersion.V_7_5_0)) { // was SearchContextException return new SearchException(input); } @@ -1016,53 +1016,53 @@ private enum OpenSearchExceptionHandle { org.opensearch.env.ShardLockObtainFailedException::new, 147, UNKNOWN_VERSION_ADDED), // 148 was UnknownNamedObjectException TOO_MANY_BUCKETS_EXCEPTION(MultiBucketConsumerService.TooManyBucketsException.class, - MultiBucketConsumerService.TooManyBucketsException::new, 149, Version.V_6_2_0), + MultiBucketConsumerService.TooManyBucketsException::new, 149, LegacyESVersion.V_6_2_0), COORDINATION_STATE_REJECTED_EXCEPTION(org.opensearch.cluster.coordination.CoordinationStateRejectedException.class, - org.opensearch.cluster.coordination.CoordinationStateRejectedException::new, 150, Version.V_7_0_0), + org.opensearch.cluster.coordination.CoordinationStateRejectedException::new, 150, LegacyESVersion.V_7_0_0), SNAPSHOT_IN_PROGRESS_EXCEPTION(org.opensearch.snapshots.SnapshotInProgressException.class, - org.opensearch.snapshots.SnapshotInProgressException::new, 151, Version.V_6_7_0), + org.opensearch.snapshots.SnapshotInProgressException::new, 151, LegacyESVersion.V_6_7_0), NO_SUCH_REMOTE_CLUSTER_EXCEPTION(org.opensearch.transport.NoSuchRemoteClusterException.class, - org.opensearch.transport.NoSuchRemoteClusterException::new, 152, Version.V_6_7_0), + org.opensearch.transport.NoSuchRemoteClusterException::new, 152, LegacyESVersion.V_6_7_0), RETENTION_LEASE_ALREADY_EXISTS_EXCEPTION( org.opensearch.index.seqno.RetentionLeaseAlreadyExistsException.class, org.opensearch.index.seqno.RetentionLeaseAlreadyExistsException::new, 153, - Version.V_6_7_0), + LegacyESVersion.V_6_7_0), RETENTION_LEASE_NOT_FOUND_EXCEPTION( org.opensearch.index.seqno.RetentionLeaseNotFoundException.class, org.opensearch.index.seqno.RetentionLeaseNotFoundException::new, 154, - Version.V_6_7_0), + LegacyESVersion.V_6_7_0), SHARD_NOT_IN_PRIMARY_MODE_EXCEPTION( org.opensearch.index.shard.ShardNotInPrimaryModeException.class, org.opensearch.index.shard.ShardNotInPrimaryModeException::new, 155, - Version.V_6_8_1), + LegacyESVersion.V_6_8_1), RETENTION_LEASE_INVALID_RETAINING_SEQUENCE_NUMBER_EXCEPTION( org.opensearch.index.seqno.RetentionLeaseInvalidRetainingSeqNoException.class, org.opensearch.index.seqno.RetentionLeaseInvalidRetainingSeqNoException::new, 156, - Version.V_7_5_0), + LegacyESVersion.V_7_5_0), INGEST_PROCESSOR_EXCEPTION( org.opensearch.ingest.IngestProcessorException.class, org.opensearch.ingest.IngestProcessorException::new, 157, - Version.V_7_5_0), + LegacyESVersion.V_7_5_0), PEER_RECOVERY_NOT_FOUND_EXCEPTION( org.opensearch.indices.recovery.PeerRecoveryNotFound.class, org.opensearch.indices.recovery.PeerRecoveryNotFound::new, 158, - Version.V_7_9_0), + LegacyESVersion.V_7_9_0), NODE_HEALTH_CHECK_FAILURE_EXCEPTION( org.opensearch.cluster.coordination.NodeHealthCheckFailureException.class, org.opensearch.cluster.coordination.NodeHealthCheckFailureException::new, 159, - Version.V_7_9_0), + LegacyESVersion.V_7_9_0), NO_SEED_NODE_LEFT_EXCEPTION( org.opensearch.transport.NoSeedNodeLeftException.class, org.opensearch.transport.NoSeedNodeLeftException::new, 160, - Version.V_7_10_0); + LegacyESVersion.V_7_10_0); final Class exceptionClass; final CheckedFunction constructor; diff --git a/server/src/main/java/org/opensearch/Version.java b/server/src/main/java/org/opensearch/Version.java index c5fa71026b009..78e60b4cc58cd 100644 --- a/server/src/main/java/org/opensearch/Version.java +++ b/server/src/main/java/org/opensearch/Version.java @@ -72,101 +72,8 @@ public class Version implements Comparable, ToXContentFragment { public static final int V_EMPTY_ID = 0; public static final Version V_EMPTY = new Version(V_EMPTY_ID, org.apache.lucene.util.Version.LATEST); - public static final Version V_6_0_0_alpha1 = - new Version(6000001, org.apache.lucene.util.Version.LUCENE_7_0_0); - public static final Version V_6_0_0_alpha2 = - new Version(6000002, org.apache.lucene.util.Version.LUCENE_7_0_0); - public static final Version V_6_0_0_beta1 = - new Version(6000026, org.apache.lucene.util.Version.LUCENE_7_0_0); - public static final Version V_6_0_0_beta2 = - new Version(6000027, org.apache.lucene.util.Version.LUCENE_7_0_0); - public static final Version V_6_0_0_rc1 = - new Version(6000051, org.apache.lucene.util.Version.LUCENE_7_0_0); - public static final Version V_6_0_0_rc2 = - new Version(6000052, org.apache.lucene.util.Version.LUCENE_7_0_1); - public static final Version V_6_0_0 = - new Version(6000099, org.apache.lucene.util.Version.LUCENE_7_0_1); - public static final Version V_6_0_1 = - new Version(6000199, org.apache.lucene.util.Version.LUCENE_7_0_1); - public static final Version V_6_1_0 = new Version(6010099, org.apache.lucene.util.Version.LUCENE_7_1_0); - public static final Version V_6_1_1 = new Version(6010199, org.apache.lucene.util.Version.LUCENE_7_1_0); - public static final Version V_6_1_2 = new Version(6010299, org.apache.lucene.util.Version.LUCENE_7_1_0); - public static final Version V_6_1_3 = new Version(6010399, org.apache.lucene.util.Version.LUCENE_7_1_0); - public static final Version V_6_1_4 = new Version(6010499, org.apache.lucene.util.Version.LUCENE_7_1_0); - // The below version is missing from the 7.3 JAR - private static final org.apache.lucene.util.Version LUCENE_7_2_1 = org.apache.lucene.util.Version.fromBits(7, 2, 1); - // Version constant for Lucene 7.7.3 release with index corruption bug fix - private static final org.apache.lucene.util.Version LUCENE_7_7_3 = org.apache.lucene.util.Version.fromBits(7, 7, 3); - public static final Version V_6_2_0 = new Version(6020099, LUCENE_7_2_1); - public static final Version V_6_2_1 = new Version(6020199, LUCENE_7_2_1); - public static final Version V_6_2_2 = new Version(6020299, LUCENE_7_2_1); - public static final Version V_6_2_3 = new Version(6020399, LUCENE_7_2_1); - public static final Version V_6_2_4 = new Version(6020499, LUCENE_7_2_1); - public static final Version V_6_3_0 = new Version(6030099, org.apache.lucene.util.Version.LUCENE_7_3_1); - public static final Version V_6_3_1 = new Version(6030199, org.apache.lucene.util.Version.LUCENE_7_3_1); - public static final Version V_6_3_2 = new Version(6030299, org.apache.lucene.util.Version.LUCENE_7_3_1); - public static final Version V_6_4_0 = new Version(6040099, org.apache.lucene.util.Version.LUCENE_7_4_0); - public static final Version V_6_4_1 = new Version(6040199, org.apache.lucene.util.Version.LUCENE_7_4_0); - public static final Version V_6_4_2 = new Version(6040299, org.apache.lucene.util.Version.LUCENE_7_4_0); - public static final Version V_6_4_3 = new Version(6040399, org.apache.lucene.util.Version.LUCENE_7_4_0); - public static final Version V_6_5_0 = new Version(6050099, org.apache.lucene.util.Version.LUCENE_7_5_0); - public static final Version V_6_5_1 = new Version(6050199, org.apache.lucene.util.Version.LUCENE_7_5_0); - public static final Version V_6_5_2 = new Version(6050299, org.apache.lucene.util.Version.LUCENE_7_5_0); - public static final Version V_6_5_3 = new Version(6050399, org.apache.lucene.util.Version.LUCENE_7_5_0); - public static final Version V_6_5_4 = new Version(6050499, org.apache.lucene.util.Version.LUCENE_7_5_0); - public static final Version V_6_6_0 = new Version(6060099, org.apache.lucene.util.Version.LUCENE_7_6_0); - public static final Version V_6_6_1 = new Version(6060199, org.apache.lucene.util.Version.LUCENE_7_6_0); - public static final Version V_6_6_2 = new Version(6060299, org.apache.lucene.util.Version.LUCENE_7_6_0); - public static final Version V_6_7_0 = new Version(6070099, org.apache.lucene.util.Version.LUCENE_7_7_0); - public static final Version V_6_7_1 = new Version(6070199, org.apache.lucene.util.Version.LUCENE_7_7_0); - public static final Version V_6_7_2 = new Version(6070299, org.apache.lucene.util.Version.LUCENE_7_7_0); - public static final Version V_6_8_0 = new Version(6080099, org.apache.lucene.util.Version.LUCENE_7_7_0); - public static final Version V_6_8_1 = new Version(6080199, org.apache.lucene.util.Version.LUCENE_7_7_0); - public static final Version V_6_8_2 = new Version(6080299, org.apache.lucene.util.Version.LUCENE_7_7_0); - public static final Version V_6_8_3 = new Version(6080399, org.apache.lucene.util.Version.LUCENE_7_7_0); - public static final Version V_6_8_4 = new Version(6080499, org.apache.lucene.util.Version.LUCENE_7_7_2); - public static final Version V_6_8_5 = new Version(6080599, org.apache.lucene.util.Version.LUCENE_7_7_2); - public static final Version V_6_8_6 = new Version(6080699, org.apache.lucene.util.Version.LUCENE_7_7_2); - public static final Version V_6_8_7 = new Version(6080799, org.apache.lucene.util.Version.LUCENE_7_7_2); - public static final Version V_6_8_8 = new Version(6080899, org.apache.lucene.util.Version.LUCENE_7_7_2); - public static final Version V_6_8_9 = new Version(6080999, LUCENE_7_7_3); - public static final Version V_6_8_10 = new Version(6081099, LUCENE_7_7_3); - public static final Version V_6_8_11 = new Version(6081199, LUCENE_7_7_3); - public static final Version V_6_8_12 = new Version(6081299, LUCENE_7_7_3); - public static final Version V_6_8_13 = new Version(6081399, LUCENE_7_7_3); - public static final Version V_6_8_14 = new Version(6081499, LUCENE_7_7_3); - public static final Version V_6_8_15 = new Version(6081599, org.apache.lucene.util.Version.LUCENE_7_7_3); - public static final Version V_7_0_0 = new Version(7000099, org.apache.lucene.util.Version.LUCENE_8_0_0); - public static final Version V_7_0_1 = new Version(7000199, org.apache.lucene.util.Version.LUCENE_8_0_0); - public static final Version V_7_1_0 = new Version(7010099, org.apache.lucene.util.Version.LUCENE_8_0_0); - public static final Version V_7_1_1 = new Version(7010199, org.apache.lucene.util.Version.LUCENE_8_0_0); - public static final Version V_7_2_0 = new Version(7020099, org.apache.lucene.util.Version.LUCENE_8_0_0); - public static final Version V_7_2_1 = new Version(7020199, org.apache.lucene.util.Version.LUCENE_8_0_0); - public static final Version V_7_3_0 = new Version(7030099, org.apache.lucene.util.Version.LUCENE_8_1_0); - public static final Version V_7_3_1 = new Version(7030199, org.apache.lucene.util.Version.LUCENE_8_1_0); - public static final Version V_7_3_2 = new Version(7030299, org.apache.lucene.util.Version.LUCENE_8_1_0); - public static final Version V_7_4_0 = new Version(7040099, org.apache.lucene.util.Version.LUCENE_8_2_0); - public static final Version V_7_4_1 = new Version(7040199, org.apache.lucene.util.Version.LUCENE_8_2_0); - public static final Version V_7_4_2 = new Version(7040299, org.apache.lucene.util.Version.LUCENE_8_2_0); - public static final Version V_7_5_0 = new Version(7050099, org.apache.lucene.util.Version.LUCENE_8_3_0); - public static final Version V_7_5_1 = new Version(7050199, org.apache.lucene.util.Version.LUCENE_8_3_0); - public static final Version V_7_5_2 = new Version(7050299, org.apache.lucene.util.Version.LUCENE_8_3_0); - public static final Version V_7_6_0 = new Version(7060099, org.apache.lucene.util.Version.LUCENE_8_4_0); - public static final Version V_7_6_1 = new Version(7060199, org.apache.lucene.util.Version.LUCENE_8_4_0); - public static final Version V_7_6_2 = new Version(7060299, org.apache.lucene.util.Version.LUCENE_8_4_0); - public static final Version V_7_7_0 = new Version(7070099, org.apache.lucene.util.Version.LUCENE_8_5_1); - public static final Version V_7_7_1 = new Version(7070199, org.apache.lucene.util.Version.LUCENE_8_5_1); - public static final Version V_7_8_0 = new Version(7080099, org.apache.lucene.util.Version.LUCENE_8_5_1); - public static final Version V_7_8_1 = new Version(7080199, org.apache.lucene.util.Version.LUCENE_8_5_1); - public static final Version V_7_9_0 = new Version(7090099, org.apache.lucene.util.Version.LUCENE_8_6_0); - public static final Version V_7_9_1 = new Version(7090199, org.apache.lucene.util.Version.LUCENE_8_6_2); - public static final Version V_7_9_2 = new Version(7090299, org.apache.lucene.util.Version.LUCENE_8_6_2); - public static final Version V_7_9_3 = new Version(7090399, org.apache.lucene.util.Version.LUCENE_8_6_2); - public static final Version V_7_10_0 = new Version(7100099, org.apache.lucene.util.Version.LUCENE_8_7_0); - public static final Version V_7_10_1 = new Version(7100199, org.apache.lucene.util.Version.LUCENE_8_7_0); - public static final Version V_7_10_2 = new Version(7100299, org.apache.lucene.util.Version.LUCENE_8_7_0); - public static final Version V_7_10_3 = new Version(7100399, org.apache.lucene.util.Version.LUCENE_8_7_0); - public static final Version CURRENT = V_7_10_3; + public static final Version V_1_0_0 = new Version(1000099, org.apache.lucene.util.Version.LUCENE_8_7_0); + public static final Version CURRENT = V_1_0_0; private static final ImmutableOpenIntMap idToVersion; private static final ImmutableOpenMap stringToVersion; @@ -175,8 +82,8 @@ public class Version implements Comparable, ToXContentFragment { final ImmutableOpenIntMap.Builder builder = ImmutableOpenIntMap.builder(); final ImmutableOpenMap.Builder builderByString = ImmutableOpenMap.builder(); - for (final Field declaredField : Version.class.getFields()) { - if (declaredField.getType().equals(Version.class)) { + for (final Field declaredField : LegacyESVersion.class.getFields()) { + if (declaredField.getType().equals(Version.class) || declaredField.getType().equals(LegacyESVersion.class)) { final String fieldName = declaredField.getName(); if (fieldName.equals("CURRENT") || fieldName.equals("V_EMPTY")) { continue; @@ -188,13 +95,18 @@ public class Version implements Comparable, ToXContentFragment { if (Assertions.ENABLED) { final String[] fields = fieldName.split("_"); if (fields.length == 5) { - assert fields[1].equals("6") && fields[2].equals("0") : + assert (fields[1].equals("1") || fields[1].equals("6")) && fields[2].equals("0") : "field " + fieldName + " should not have a build qualifier"; } else { final int major = Integer.valueOf(fields[1]) * 1000000; final int minor = Integer.valueOf(fields[2]) * 10000; final int revision = Integer.valueOf(fields[3]) * 100; - final int expectedId = major + minor + revision + 99; + final int expectedId; + if (fields[1].equals("1")) { + expectedId = 0x08000000 ^ (major + minor + revision + 99); + } else { + expectedId = (major + minor + revision + 99); + } assert version.id == expectedId : "expected version [" + fieldName + "] to have id [" + expectedId + "] but was [" + version.id + "]"; } @@ -236,7 +148,8 @@ private static Version fromIdSlow(int id) { // least correct for patch versions of known minors since we never // update the Lucene dependency for patch versions. List versions = DeclaredVersionsHolder.DECLARED_VERSIONS; - Version tmp = new Version(id, org.apache.lucene.util.Version.LATEST); + Version tmp = id < MASK ? new LegacyESVersion(id, org.apache.lucene.util.Version.LATEST) : + new Version(id ^ MASK, org.apache.lucene.util.Version.LATEST); int index = Collections.binarySearch(versions, tmp); if (index < 0) { index = -2 - index; @@ -253,7 +166,7 @@ private static Version fromIdSlow(int id) { } else { luceneVersion = versions.get(index).luceneVersion; } - return new Version(id, luceneVersion); + return id < MASK ? new LegacyESVersion(id, luceneVersion) : new Version(id ^ MASK, luceneVersion); } /** @@ -264,7 +177,7 @@ private static Version fromIdSlow(int id) { */ public static Version indexCreated(Settings indexSettings) { final Version indexVersion = IndexMetadata.SETTING_INDEX_VERSION_CREATED.get(indexSettings); - if (indexVersion == V_EMPTY) { + if (indexVersion.equals(V_EMPTY)) { final String message = String.format( Locale.ROOT, "[%s] is not present in the index settings for index with UUID [%s]", @@ -279,6 +192,14 @@ public static void writeVersion(Version version, StreamOutput out) throws IOExce out.writeVInt(version.id); } + public static int computeLegacyID(int major, int minor, int revision, int build) { + return major * 1000000 + minor * 10000 + revision * 100 + build; + } + + public static int computeID(int major, int minor, int revision, int build) { + return computeLegacyID(major, minor, revision, build) ^ MASK; + } + /** * Returns the minimum version between the 2. */ @@ -355,6 +276,7 @@ private static Version fromStringSlow(String version) { } } + public static final int MASK = 0x08000000; public final int id; public final byte major; public final byte minor; @@ -363,7 +285,14 @@ private static Version fromStringSlow(String version) { public final org.apache.lucene.util.Version luceneVersion; Version(int id, org.apache.lucene.util.Version luceneVersion) { - this.id = id; + // flip the 28th bit of the ID; identify as an opensearch vs legacy system: + // we start from version 1 for opensearch, so ignore the 0 (empty) version + if(id != 0) { + this.id = id ^ MASK; + id &= 0xF7FFFFFF; + } else { + this.id = id; + } this.major = (byte) ((id / 1000000) % 100); this.minor = (byte) ((id / 10000) % 100); this.revision = (byte) ((id / 100) % 100); @@ -402,8 +331,9 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws * is not cheap. Since computing the minimum compatibility version can occur often, we use this holder to compute the declared versions * lazily once. */ - private static class DeclaredVersionsHolder { - static final List DECLARED_VERSIONS = Collections.unmodifiableList(getDeclaredVersions(Version.class)); + static class DeclaredVersionsHolder { + // use LegacyESVersion.class since it inherits Version fields + protected static final List DECLARED_VERSIONS = Collections.unmodifiableList(getDeclaredVersions(LegacyESVersion.class)); } // lazy initialized because we don't yet have the declared versions ready when instantiating the cached Version @@ -431,7 +361,9 @@ public Version minimumCompatibilityVersion() { } private Version computeMinCompatVersion() { - if (major == 6) { + if (major == 1) { + return Version.fromId(6080099); + } else if (major == 6) { // force the minimum compatibility for version 6 to 5.6 since we don't reference version 5 anymore return Version.fromId(5060099); } else if (major >= 7) { @@ -471,13 +403,13 @@ private Version computeMinIndexCompatVersion() { final int bwcMajor; if (major == 5) { bwcMajor = 2; // we jumped from 2 to 5 - } else if (major == 7) { - return V_6_0_0_beta1; + } else if (major == 7 || major == 1) { + return LegacyESVersion.V_6_0_0_beta1; } else { bwcMajor = major - 1; } final int bwcMinor = 0; - return Version.min(this, fromId(bwcMajor * 1000000 + bwcMinor * 10000 + 99)); + return Version.min(this, fromId((bwcMajor * 1000000 + bwcMinor * 10000 + 99) )); } /** @@ -487,7 +419,11 @@ public boolean isCompatible(Version version) { boolean compatible = onOrAfter(version.minimumCompatibilityVersion()) && version.onOrAfter(minimumCompatibilityVersion()); - assert compatible == false || Math.max(major, version.major) - Math.min(major, version.major) <= 1; + // OpenSearch version 1 is the functional equivalent of predecessor version 7 + int a = major == 1 ? 7 : major; + int b = version.major == 1 ? 7 : version.major; + + assert compatible == false || Math.max(a, b) - Math.min(a, b) <= 1; return compatible; } @@ -553,7 +489,7 @@ public int hashCode() { } public boolean isBeta() { - return major < 5 ? build < 50 : build >= 25 && build < 50; + return build >= 25 && build < 50; } /** @@ -562,7 +498,7 @@ public boolean isBeta() { * have an alpha version. */ public boolean isAlpha() { - return major < 5 ? false : build < 25; + return build < 25; } public boolean isRC() { @@ -586,7 +522,7 @@ public static List getDeclaredVersions(final Class versionClass) { if (false == Modifier.isStatic(mod) && Modifier.isFinal(mod) && Modifier.isPublic(mod)) { continue; } - if (field.getType() != Version.class) { + if (field.getType() != Version.class && field.getType() != LegacyESVersion.class) { continue; } switch (field.getName()) { diff --git a/server/src/main/java/org/opensearch/action/DocWriteResponse.java b/server/src/main/java/org/opensearch/action/DocWriteResponse.java index 5329d5ec2adb1..08e933ed9f8ca 100644 --- a/server/src/main/java/org/opensearch/action/DocWriteResponse.java +++ b/server/src/main/java/org/opensearch/action/DocWriteResponse.java @@ -31,7 +31,7 @@ package org.opensearch.action; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.support.WriteRequest; import org.opensearch.action.support.WriteRequest.RefreshPolicy; import org.opensearch.action.support.WriteResponse; @@ -168,7 +168,7 @@ protected DocWriteResponse(StreamInput in) throws IOException { type = in.readString(); id = in.readString(); version = in.readZLong(); - if (in.getVersion().onOrAfter(Version.V_6_0_0_alpha1)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_6_0_0_alpha1)) { seqNo = in.readZLong(); primaryTerm = in.readVLong(); } else { @@ -317,7 +317,7 @@ private void writeWithoutShardId(StreamOutput out) throws IOException { out.writeString(type); out.writeString(id); out.writeZLong(version); - if (out.getVersion().onOrAfter(Version.V_6_0_0_alpha1)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_6_0_0_alpha1)) { out.writeZLong(seqNo); out.writeVLong(primaryTerm); } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/configuration/AddVotingConfigExclusionsRequest.java b/server/src/main/java/org/opensearch/action/admin/cluster/configuration/AddVotingConfigExclusionsRequest.java index fee027f3b2de9..05e702c4f1096 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/configuration/AddVotingConfigExclusionsRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/configuration/AddVotingConfigExclusionsRequest.java @@ -31,7 +31,7 @@ package org.opensearch.action.admin.cluster.configuration; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.support.master.MasterNodeRequest; import org.opensearch.cluster.ClusterState; @@ -107,7 +107,7 @@ public AddVotingConfigExclusionsRequest(String[] nodeDescriptions, String[] node public AddVotingConfigExclusionsRequest(StreamInput in) throws IOException { super(in); nodeDescriptions = in.readStringArray(); - if (in.getVersion().onOrAfter(Version.V_7_8_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_8_0)) { nodeIds = in.readStringArray(); nodeNames = in.readStringArray(); } else { @@ -229,7 +229,7 @@ public ActionRequestValidationException validate() { public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeStringArray(nodeDescriptions); - if (out.getVersion().onOrAfter(Version.V_7_8_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_8_0)) { out.writeStringArray(nodeIds); out.writeStringArray(nodeNames); } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/health/ClusterHealthRequest.java b/server/src/main/java/org/opensearch/action/admin/cluster/health/ClusterHealthRequest.java index 85bb240855fda..c2c807c0766bc 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/health/ClusterHealthRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/health/ClusterHealthRequest.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.health; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.IndicesRequest; import org.opensearch.action.support.ActiveShardCount; @@ -85,10 +85,10 @@ public ClusterHealthRequest(StreamInput in) throws IOException { if (in.readBoolean()) { waitForEvents = Priority.readFrom(in); } - if (in.getVersion().onOrAfter(Version.V_6_2_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_6_2_0)) { waitForNoInitializingShards = in.readBoolean(); } - if (in.getVersion().onOrAfter(Version.V_7_2_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_2_0)) { indicesOptions = IndicesOptions.readIndicesOptions(in); } else { indicesOptions = IndicesOptions.lenientExpandOpen(); @@ -119,10 +119,10 @@ public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(true); Priority.writeTo(waitForEvents, out); } - if (out.getVersion().onOrAfter(Version.V_6_2_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_6_2_0)) { out.writeBoolean(waitForNoInitializingShards); } - if (out.getVersion().onOrAfter(Version.V_7_2_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_2_0)) { indicesOptions.writeIndicesOptions(out); } } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/info/NodeInfo.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/info/NodeInfo.java index ac68d4696594a..b592cb3024c26 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/info/NodeInfo.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/info/NodeInfo.java @@ -33,6 +33,7 @@ package org.opensearch.action.admin.cluster.node.info; import org.opensearch.Build; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.action.support.nodes.BaseNodeResponse; import org.opensearch.cluster.node.DiscoveryNode; @@ -96,7 +97,7 @@ public NodeInfo(StreamInput in) throws IOException { addInfoIfNonNull(HttpInfo.class, in.readOptionalWriteable(HttpInfo::new)); addInfoIfNonNull(PluginsAndModules.class, in.readOptionalWriteable(PluginsAndModules::new)); addInfoIfNonNull(IngestInfo.class, in.readOptionalWriteable(IngestInfo::new)); - if (in.getVersion().onOrAfter(Version.V_7_10_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_10_0)) { addInfoIfNonNull(AggregationInfo.class, in.readOptionalWriteable(AggregationInfo::new)); } } @@ -205,7 +206,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalWriteable(getInfo(HttpInfo.class)); out.writeOptionalWriteable(getInfo(PluginsAndModules.class)); out.writeOptionalWriteable(getInfo(IngestInfo.class)); - if (out.getVersion().onOrAfter(Version.V_7_10_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_10_0)) { out.writeOptionalWriteable(getInfo(AggregationInfo.class)); } } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/info/NodesInfoRequest.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/info/NodesInfoRequest.java index a8c1808e15d77..ecd9556a79bc4 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/info/NodesInfoRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/info/NodesInfoRequest.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.node.info; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.support.nodes.BaseNodesRequest; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; @@ -61,7 +61,7 @@ public class NodesInfoRequest extends BaseNodesRequest { public NodesInfoRequest(StreamInput in) throws IOException { super(in); requestedMetrics.clear(); - if (in.getVersion().before(Version.V_7_7_0)){ + if (in.getVersion().before(LegacyESVersion.V_7_7_0)){ // prior to version 8.x, a NodesInfoRequest was serialized as a list // of booleans in a fixed order optionallyAddMetric(in.readBoolean(), Metric.SETTINGS.metricName()); @@ -163,7 +163,7 @@ private void optionallyAddMetric(boolean addMetric, String metricName) { @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - if (out.getVersion().before(Version.V_7_7_0)){ + if (out.getVersion().before(LegacyESVersion.V_7_7_0)){ // prior to version 8.x, a NodesInfoRequest was serialized as a list // of booleans in a fixed order out.writeBoolean(Metric.SETTINGS.containedIn(requestedMetrics)); diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/reload/NodesReloadSecureSettingsRequest.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/reload/NodesReloadSecureSettingsRequest.java index 800a5e07d5574..5a6c4c2ae7c83 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/reload/NodesReloadSecureSettingsRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/reload/NodesReloadSecureSettingsRequest.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.node.reload; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.support.nodes.BaseNodesRequest; import org.opensearch.common.io.stream.StreamInput; @@ -66,7 +66,7 @@ public NodesReloadSecureSettingsRequest() { public NodesReloadSecureSettingsRequest(StreamInput in) throws IOException { super(in); - if (in.getVersion().onOrAfter(Version.V_7_7_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) { final BytesReference bytesRef = in.readOptionalBytesReference(); if (bytesRef != null) { byte[] bytes = BytesReference.toBytes(bytesRef); @@ -112,7 +112,7 @@ boolean hasPassword() { @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - if (out.getVersion().onOrAfter(Version.V_7_4_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_4_0)) { if (this.secureSettingsPassword == null) { out.writeOptionalBytesReference(null); } else { diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/stats/NodeStats.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/stats/NodeStats.java index 2e76e50db0edb..7f001a1f1bd6e 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/stats/NodeStats.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/stats/NodeStats.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.node.stats; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.support.nodes.BaseNodeResponse; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.node.DiscoveryNodeRole; @@ -129,20 +129,20 @@ public NodeStats(StreamInput in) throws IOException { scriptStats = in.readOptionalWriteable(ScriptStats::new); discoveryStats = in.readOptionalWriteable(DiscoveryStats::new); ingestStats = in.readOptionalWriteable(IngestStats::new); - if (in.getVersion().onOrAfter(Version.V_6_1_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_6_1_0)) { adaptiveSelectionStats = in.readOptionalWriteable(AdaptiveSelectionStats::new); } else { adaptiveSelectionStats = null; } scriptCacheStats = null; - if (in.getVersion().onOrAfter(Version.V_7_8_0)) { - if (in.getVersion().before(Version.V_7_9_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_8_0)) { + if (in.getVersion().before(LegacyESVersion.V_7_9_0)) { scriptCacheStats = in.readOptionalWriteable(ScriptCacheStats::new); } else if (scriptStats != null) { scriptCacheStats = scriptStats.toScriptCacheStats(); } } - if (in.getVersion().onOrAfter(Version.V_7_9_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_9_0)) { indexingPressureStats = in.readOptionalWriteable(IndexingPressureStats::new); } else { indexingPressureStats = null; @@ -301,12 +301,12 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalWriteable(scriptStats); out.writeOptionalWriteable(discoveryStats); out.writeOptionalWriteable(ingestStats); - if (out.getVersion().onOrAfter(Version.V_6_1_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_6_1_0)) { out.writeOptionalWriteable(adaptiveSelectionStats); - } if (out.getVersion().onOrAfter(Version.V_7_8_0) && out.getVersion().before(Version.V_7_9_0)) { + } if (out.getVersion().onOrAfter(LegacyESVersion.V_7_8_0) && out.getVersion().before(LegacyESVersion.V_7_9_0)) { out.writeOptionalWriteable(scriptCacheStats); } - if (out.getVersion().onOrAfter(Version.V_7_9_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_9_0)) { out.writeOptionalWriteable(indexingPressureStats); } } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/stats/NodesStatsRequest.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/stats/NodesStatsRequest.java index f6aefbb912522..d6403448a0b8c 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/stats/NodesStatsRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/stats/NodesStatsRequest.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.node.stats; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.admin.indices.stats.CommonStatsFlags; import org.opensearch.action.support.nodes.BaseNodesRequest; import org.opensearch.common.io.stream.StreamInput; @@ -62,7 +62,7 @@ public NodesStatsRequest(StreamInput in) throws IOException { indices = new CommonStatsFlags(in); requestedMetrics.clear(); - if (in.getVersion().before(Version.V_7_7_0)) { + if (in.getVersion().before(LegacyESVersion.V_7_7_0)) { optionallyAddMetric(in.readBoolean(), Metric.OS.metricName()); optionallyAddMetric(in.readBoolean(), Metric.PROCESS.metricName()); optionallyAddMetric(in.readBoolean(), Metric.JVM.metricName()); @@ -74,7 +74,7 @@ public NodesStatsRequest(StreamInput in) throws IOException { optionallyAddMetric(in.readBoolean(), Metric.SCRIPT.metricName()); optionallyAddMetric(in.readBoolean(), Metric.DISCOVERY.metricName()); optionallyAddMetric(in.readBoolean(), Metric.INGEST.metricName()); - if (in.getVersion().onOrAfter(Version.V_6_1_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_6_1_0)) { optionallyAddMetric(in.readBoolean(), Metric.ADAPTIVE_SELECTION.metricName()); } } else { @@ -200,7 +200,7 @@ private void optionallyAddMetric(boolean includeMetric, String metricName) { public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); indices.writeTo(out); - if (out.getVersion().before(Version.V_7_7_0)) { + if (out.getVersion().before(LegacyESVersion.V_7_7_0)) { out.writeBoolean(Metric.OS.containedIn(requestedMetrics)); out.writeBoolean(Metric.PROCESS.containedIn(requestedMetrics)); out.writeBoolean(Metric.JVM.containedIn(requestedMetrics)); @@ -212,7 +212,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(Metric.SCRIPT.containedIn(requestedMetrics)); out.writeBoolean(Metric.DISCOVERY.containedIn(requestedMetrics)); out.writeBoolean(Metric.INGEST.containedIn(requestedMetrics)); - if (out.getVersion().onOrAfter(Version.V_6_1_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_6_1_0)) { out.writeBoolean(Metric.ADAPTIVE_SELECTION.containedIn(requestedMetrics)); } } else { diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/cancel/CancelTasksRequest.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/cancel/CancelTasksRequest.java index e6d64ecb99ab4..01340ff809680 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/cancel/CancelTasksRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/tasks/cancel/CancelTasksRequest.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.node.tasks.cancel; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.support.tasks.BaseTasksRequest; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; @@ -58,7 +58,7 @@ public CancelTasksRequest() {} public CancelTasksRequest(StreamInput in) throws IOException { super(in); this.reason = in.readString(); - if (in.getVersion().onOrAfter(Version.V_7_8_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_8_0)) { waitForCompletion = in.readBoolean(); } } @@ -67,7 +67,7 @@ public CancelTasksRequest(StreamInput in) throws IOException { public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeString(reason); - if (out.getVersion().onOrAfter(Version.V_7_8_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_8_0)) { out.writeBoolean(waitForCompletion); } } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/usage/NodeUsage.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/usage/NodeUsage.java index 36fb308512146..2636757291be4 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/usage/NodeUsage.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/usage/NodeUsage.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.node.usage; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.support.nodes.BaseNodeResponse; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.common.io.stream.StreamInput; @@ -56,7 +56,7 @@ public NodeUsage(StreamInput in) throws IOException { timestamp = in.readLong(); sinceTime = in.readLong(); restUsage = (Map) in.readGenericValue(); - if (in.getVersion().onOrAfter(Version.V_7_8_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_8_0)) { aggregationUsage = (Map) in.readGenericValue(); } else { aggregationUsage = null; @@ -134,7 +134,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeLong(timestamp); out.writeLong(sinceTime); out.writeGenericValue(restUsage); - if (out.getVersion().onOrAfter(Version.V_7_8_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_8_0)) { out.writeGenericValue(aggregationUsage); } } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/usage/NodesUsageRequest.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/usage/NodesUsageRequest.java index fa365a1f57c0d..b49f2b8a9087c 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/usage/NodesUsageRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/usage/NodesUsageRequest.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.node.usage; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.support.nodes.BaseNodesRequest; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; @@ -47,7 +47,7 @@ public class NodesUsageRequest extends BaseNodesRequest { public NodesUsageRequest(StreamInput in) throws IOException { super(in); this.restActions = in.readBoolean(); - if (in.getVersion().onOrAfter(Version.V_7_8_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_8_0)) { this.aggregations = in.readBoolean(); } } @@ -112,7 +112,7 @@ public NodesUsageRequest aggregations(boolean aggregations) { public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeBoolean(restActions); - if (out.getVersion().onOrAfter(Version.V_7_8_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_8_0)) { out.writeBoolean(aggregations); } } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/repositories/cleanup/TransportCleanupRepositoryAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/repositories/cleanup/TransportCleanupRepositoryAction.java index 18546b83cec57..e6471bdde695a 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/repositories/cleanup/TransportCleanupRepositoryAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/repositories/cleanup/TransportCleanupRepositoryAction.java @@ -34,6 +34,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.action.ActionListener; import org.opensearch.action.ActionRunnable; @@ -87,7 +88,7 @@ public final class TransportCleanupRepositoryAction extends TransportMasterNodeA private static final Logger logger = LogManager.getLogger(TransportCleanupRepositoryAction.class); - private static final Version MIN_VERSION = Version.V_7_4_0; + private static final Version MIN_VERSION = LegacyESVersion.V_7_4_0; private final RepositoriesService repositoriesService; diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/reroute/ClusterRerouteResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/reroute/ClusterRerouteResponse.java index e9225e1d6103b..50bc3845c15a9 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/reroute/ClusterRerouteResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/reroute/ClusterRerouteResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.reroute; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.cluster.ClusterModule; import org.opensearch.cluster.ClusterState; @@ -54,8 +54,8 @@ public class ClusterRerouteResponse extends AcknowledgedResponse implements ToXC private final RoutingExplanations explanations; ClusterRerouteResponse(StreamInput in) throws IOException { - super(in, in.getVersion().onOrAfter(Version.V_6_4_0)); - if (in.getVersion().onOrAfter(Version.V_6_4_0)) { + super(in, in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)); + if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) { state = ClusterState.readFrom(in, null); explanations = RoutingExplanations.readFrom(in); } else { @@ -84,12 +84,12 @@ public RoutingExplanations getExplanations() { @Override public void writeTo(StreamOutput out) throws IOException { - if (out.getVersion().onOrAfter(Version.V_6_4_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) { super.writeTo(out); state.writeTo(out); RoutingExplanations.writeTo(explanations, out); } else { - if (out.getVersion().onOrAfter(Version.V_6_3_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) { state.writeTo(out); } else { ClusterModule.filterCustomsForPre63Clients(state).writeTo(out); diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/settings/ClusterUpdateSettingsResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/settings/ClusterUpdateSettingsResponse.java index 0d2971cad7708..724303e960029 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/settings/ClusterUpdateSettingsResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/settings/ClusterUpdateSettingsResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.settings; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.common.ParseField; import org.opensearch.common.io.stream.StreamInput; @@ -69,8 +69,8 @@ public class ClusterUpdateSettingsResponse extends AcknowledgedResponse { final Settings persistentSettings; ClusterUpdateSettingsResponse(StreamInput in) throws IOException { - super(in, in.getVersion().onOrAfter(Version.V_6_4_0)); - if (in.getVersion().onOrAfter(Version.V_6_4_0)) { + super(in, in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)); + if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) { transientSettings = Settings.readSettingsFromStream(in); persistentSettings = Settings.readSettingsFromStream(in); } else { @@ -96,7 +96,7 @@ public Settings getPersistentSettings() { @Override public void writeTo(StreamOutput out) throws IOException { - if (out.getVersion().onOrAfter(Version.V_6_4_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) { super.writeTo(out); Settings.writeSettingsToStream(transientSettings, out); Settings.writeSettingsToStream(persistentSettings, out); diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/restore/RestoreSnapshotRequest.java b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/restore/RestoreSnapshotRequest.java index 577bb4194239e..9536f9e0f19b9 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/restore/RestoreSnapshotRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/restore/RestoreSnapshotRequest.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.snapshots.restore; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.support.IndicesOptions; import org.opensearch.action.support.master.MasterNodeRequest; @@ -108,12 +108,12 @@ public RestoreSnapshotRequest(StreamInput in) throws IOException { includeGlobalState = in.readBoolean(); partial = in.readBoolean(); includeAliases = in.readBoolean(); - if (in.getVersion().before(Version.V_7_7_0)) { + if (in.getVersion().before(LegacyESVersion.V_7_7_0)) { readSettingsFromStream(in); // formerly the unused settings field } indexSettings = readSettingsFromStream(in); ignoreIndexSettings = in.readStringArray(); - if (in.getVersion().onOrAfter(Version.V_7_10_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_10_0)) { snapshotUuid = in.readOptionalString(); } } @@ -131,12 +131,12 @@ public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(includeGlobalState); out.writeBoolean(partial); out.writeBoolean(includeAliases); - if (out.getVersion().before(Version.V_7_7_0)) { + if (out.getVersion().before(LegacyESVersion.V_7_7_0)) { writeSettingsToStream(Settings.EMPTY, out); // formerly the unused settings field } writeSettingsToStream(indexSettings, out); out.writeStringArray(ignoreIndexSettings); - if (out.getVersion().onOrAfter(Version.V_7_10_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_10_0)) { out.writeOptionalString(snapshotUuid); } else if (snapshotUuid != null) { throw new IllegalStateException( diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotStats.java b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotStats.java index 64a55990f444c..07b44c56155b1 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotStats.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotStats.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.snapshots.status; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.common.Strings; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; @@ -70,7 +70,7 @@ public class SnapshotStats implements Writeable, ToXContentObject { incrementalSize = in.readVLong(); processedSize = in.readVLong(); - if (in.getVersion().onOrAfter(Version.V_6_4_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) { totalFileCount = in.readVInt(); totalSize = in.readVLong(); } else { @@ -160,7 +160,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeVLong(incrementalSize); out.writeVLong(processedSize); - if (out.getVersion().onOrAfter(Version.V_6_4_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) { out.writeVInt(totalFileCount); out.writeVLong(totalSize); } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotStatus.java b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotStatus.java index d559862a77f91..e630eb4299fd0 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotStatus.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/snapshots/status/SnapshotStatus.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.snapshots.status; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.cluster.SnapshotsInProgress; import org.opensearch.cluster.SnapshotsInProgress.State; import org.opensearch.common.Nullable; @@ -92,7 +92,7 @@ public class SnapshotStatus implements ToXContentObject, Writeable { includeGlobalState = in.readOptionalBoolean(); final long startTime; final long time; - if (in.getVersion().onOrAfter(Version.V_7_4_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_4_0)) { startTime = in.readLong(); time = in.readLong(); } else { @@ -193,7 +193,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeByte(state.value()); out.writeList(shards); out.writeOptionalBoolean(includeGlobalState); - if (out.getVersion().onOrAfter(Version.V_7_4_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_4_0)) { out.writeLong(stats.getStartTime()); out.writeLong(stats.getTime()); } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/state/ClusterStateRequest.java b/server/src/main/java/org/opensearch/action/admin/cluster/state/ClusterStateRequest.java index dfecc06f0d0c8..6dc43afd07786 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/state/ClusterStateRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/state/ClusterStateRequest.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.state; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.IndicesRequest; import org.opensearch.action.support.IndicesOptions; @@ -70,7 +70,7 @@ public ClusterStateRequest(StreamInput in) throws IOException { customs = in.readBoolean(); indices = in.readStringArray(); indicesOptions = IndicesOptions.readIndicesOptions(in); - if (in.getVersion().onOrAfter(Version.V_6_6_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) { waitForTimeout = in.readTimeValue(); waitForMetadataVersion = in.readOptionalLong(); } @@ -86,7 +86,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(customs); out.writeStringArray(indices); indicesOptions.writeIndicesOptions(out); - if (out.getVersion().onOrAfter(Version.V_6_6_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) { out.writeTimeValue(waitForTimeout); out.writeOptionalLong(waitForMetadataVersion); } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/state/ClusterStateResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/state/ClusterStateResponse.java index 37c7f69e8a1d3..6dc75509463ae 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/state/ClusterStateResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/state/ClusterStateResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.state; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionResponse; import org.opensearch.cluster.ClusterModule; import org.opensearch.cluster.ClusterName; @@ -57,15 +57,15 @@ public class ClusterStateResponse extends ActionResponse { public ClusterStateResponse(StreamInput in) throws IOException { super(in); clusterName = new ClusterName(in); - if (in.getVersion().onOrAfter(Version.V_6_6_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) { clusterState = in.readOptionalWriteable(innerIn -> ClusterState.readFrom(innerIn, null)); } else { clusterState = ClusterState.readFrom(in, null); } - if (in.getVersion().before(Version.V_7_0_0)) { + if (in.getVersion().before(LegacyESVersion.V_7_0_0)) { new ByteSizeValue(in); } - if (in.getVersion().onOrAfter(Version.V_6_6_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) { waitForTimedOut = in.readBoolean(); } } @@ -102,19 +102,19 @@ public boolean isWaitForTimedOut() { @Override public void writeTo(StreamOutput out) throws IOException { clusterName.writeTo(out); - if (out.getVersion().onOrAfter(Version.V_6_6_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) { out.writeOptionalWriteable(clusterState); } else { - if (out.getVersion().onOrAfter(Version.V_6_3_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_6_3_0)) { clusterState.writeTo(out); } else { ClusterModule.filterCustomsForPre63Clients(clusterState).writeTo(out); } } - if (out.getVersion().before(Version.V_7_0_0)) { + if (out.getVersion().before(LegacyESVersion.V_7_0_0)) { ByteSizeValue.ZERO.writeTo(out); } - if (out.getVersion().onOrAfter(Version.V_6_6_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) { out.writeBoolean(waitForTimedOut); } } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/stats/ClusterStatsResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/stats/ClusterStatsResponse.java index acecfd24e363a..7d88bb063ed91 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/stats/ClusterStatsResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/stats/ClusterStatsResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.stats; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.FailedNodeException; import org.opensearch.action.support.nodes.BaseNodesResponse; import org.opensearch.cluster.ClusterName; @@ -66,7 +66,7 @@ public ClusterStatsResponse(StreamInput in) throws IOException { String clusterUUID = null; MappingStats mappingStats = null; AnalysisStats analysisStats = null; - if (in.getVersion().onOrAfter(Version.V_7_7_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) { clusterUUID = in.readOptionalString(); mappingStats = in.readOptionalWriteable(MappingStats::new); analysisStats = in.readOptionalWriteable(AnalysisStats::new); @@ -125,7 +125,7 @@ public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeVLong(timestamp); out.writeOptionalWriteable(status); - if (out.getVersion().onOrAfter(Version.V_7_7_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) { out.writeOptionalString(clusterUUID); out.writeOptionalWriteable(indicesStats.getMappings()); out.writeOptionalWriteable(indicesStats.getAnalysis()); diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/DeleteStoredScriptRequest.java b/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/DeleteStoredScriptRequest.java index 25f34591114cc..94f4f775738ea 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/DeleteStoredScriptRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/storedscripts/DeleteStoredScriptRequest.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.cluster.storedscripts; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.support.master.AcknowledgedRequest; import org.opensearch.common.io.stream.StreamInput; @@ -48,7 +48,7 @@ public class DeleteStoredScriptRequest extends AcknowledgedRequest tokens, DetailAnalyzeResponse detail) { } public Response(StreamInput in) throws IOException { - if (in.getVersion().onOrAfter(Version.V_7_3_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_3_0)) { AnalyzeToken[] tokenArray = in.readOptionalArray(AnalyzeToken::new, AnalyzeToken[]::new); tokens = tokenArray != null ? Arrays.asList(tokenArray) : null; } else { @@ -356,7 +356,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws @Override public void writeTo(StreamOutput out) throws IOException { - if (out.getVersion().onOrAfter(Version.V_7_3_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_3_0)) { AnalyzeToken[] tokenArray = null; if (tokens != null) { tokenArray = tokens.toArray(new AnalyzeToken[0]); @@ -724,7 +724,7 @@ public AnalyzeTokenList(String name, AnalyzeToken[] tokens) { AnalyzeTokenList(StreamInput in) throws IOException { name = in.readString(); - if (in.getVersion().onOrAfter(Version.V_7_3_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_3_0)) { tokens = in.readOptionalArray(AnalyzeToken::new, AnalyzeToken[]::new); } else { int size = in.readVInt(); @@ -769,7 +769,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws @Override public void writeTo(StreamOutput out) throws IOException { out.writeString(name); - if (out.getVersion().onOrAfter(Version.V_7_3_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_3_0)) { out.writeOptionalArray(tokens); } else { if (tokens != null) { diff --git a/server/src/main/java/org/opensearch/action/admin/indices/cache/clear/ClearIndicesCacheRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/cache/clear/ClearIndicesCacheRequest.java index ee3a2abfcc871..a10b98d827f83 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/cache/clear/ClearIndicesCacheRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/cache/clear/ClearIndicesCacheRequest.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.indices.cache.clear; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.support.broadcast.BroadcastRequest; import org.opensearch.common.Strings; import org.opensearch.common.io.stream.StreamInput; @@ -51,7 +51,7 @@ public ClearIndicesCacheRequest(StreamInput in) throws IOException { super(in); queryCache = in.readBoolean(); fieldDataCache = in.readBoolean(); - if (in.getVersion().before(Version.V_6_0_0_beta1)) { + if (in.getVersion().before(LegacyESVersion.V_6_0_0_beta1)) { in.readBoolean(); // recycler } fields = in.readStringArray(); @@ -103,7 +103,7 @@ public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeBoolean(queryCache); out.writeBoolean(fieldDataCache); - if (out.getVersion().before(Version.V_6_0_0_beta1)) { + if (out.getVersion().before(LegacyESVersion.V_6_0_0_beta1)) { out.writeBoolean(false); // recycler } out.writeStringArrayNullable(fields); diff --git a/server/src/main/java/org/opensearch/action/admin/indices/close/CloseIndexRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/close/CloseIndexRequest.java index d833947614bd0..ad975ef8ecfc5 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/close/CloseIndexRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/close/CloseIndexRequest.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.indices.close; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.IndicesRequest; import org.opensearch.action.support.ActiveShardCount; @@ -59,7 +59,7 @@ public CloseIndexRequest(StreamInput in) throws IOException { super(in); indices = in.readStringArray(); indicesOptions = IndicesOptions.readIndicesOptions(in); - if (in.getVersion().onOrAfter(Version.V_7_2_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_2_0)) { waitForActiveShards = ActiveShardCount.readFrom(in); } else { waitForActiveShards = ActiveShardCount.NONE; @@ -142,7 +142,7 @@ public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeStringArray(indices); indicesOptions.writeIndicesOptions(out); - if (out.getVersion().onOrAfter(Version.V_7_2_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_2_0)) { waitForActiveShards.writeTo(out); } } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/close/CloseIndexResponse.java b/server/src/main/java/org/opensearch/action/admin/indices/close/CloseIndexResponse.java index ff749a55b3cc4..6b89a335fc313 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/close/CloseIndexResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/close/CloseIndexResponse.java @@ -31,8 +31,8 @@ package org.opensearch.action.admin.indices.close; +import org.opensearch.LegacyESVersion; import org.opensearch.OpenSearchException; -import org.opensearch.Version; import org.opensearch.action.support.DefaultShardOperationFailedException; import org.opensearch.action.support.master.ShardsAcknowledgedResponse; import org.opensearch.common.Nullable; @@ -57,8 +57,8 @@ public class CloseIndexResponse extends ShardsAcknowledgedResponse { private final List indices; CloseIndexResponse(StreamInput in) throws IOException { - super(in, in.getVersion().onOrAfter(Version.V_7_2_0), true); - if (in.getVersion().onOrAfter(Version.V_7_3_0)) { + super(in, in.getVersion().onOrAfter(LegacyESVersion.V_7_2_0), true); + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_3_0)) { indices = unmodifiableList(in.readList(IndexResult::new)); } else { indices = unmodifiableList(emptyList()); @@ -77,10 +77,10 @@ public List getIndices() { @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - if (out.getVersion().onOrAfter(Version.V_7_2_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_2_0)) { writeShardsAcknowledged(out); } - if (out.getVersion().onOrAfter(Version.V_7_3_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_3_0)) { out.writeList(indices); } } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/close/TransportVerifyShardBeforeCloseAction.java b/server/src/main/java/org/opensearch/action/admin/indices/close/TransportVerifyShardBeforeCloseAction.java index f065b33a9c32b..0369088e7edf8 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/close/TransportVerifyShardBeforeCloseAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/close/TransportVerifyShardBeforeCloseAction.java @@ -33,7 +33,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionListener; import org.opensearch.action.admin.indices.flush.FlushRequest; import org.opensearch.action.support.ActionFilters; @@ -166,7 +166,7 @@ public static class ShardRequest extends ReplicationRequest { ShardRequest(StreamInput in) throws IOException { super(in); clusterBlock = new ClusterBlock(in); - if (in.getVersion().onOrAfter(Version.V_7_3_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_3_0)) { phase1 = in.readBoolean(); } else { phase1 = false; @@ -189,7 +189,7 @@ public String toString() { public void writeTo(final StreamOutput out) throws IOException { super.writeTo(out); clusterBlock.writeTo(out); - if (out.getVersion().onOrAfter(Version.V_7_3_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_3_0)) { out.writeBoolean(phase1); } } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequest.java index 86ccaeb35ce5e..c26796465c82c 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/create/CreateIndexRequest.java @@ -32,9 +32,9 @@ package org.opensearch.action.admin.indices.create; +import org.opensearch.LegacyESVersion; import org.opensearch.OpenSearchGenerationException; import org.opensearch.OpenSearchParseException; -import org.opensearch.Version; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.IndicesRequest; import org.opensearch.action.admin.indices.alias.Alias; @@ -109,13 +109,13 @@ public CreateIndexRequest(StreamInput in) throws IOException { for (int i = 0; i < size; i++) { final String type = in.readString(); String source = in.readString(); - if (in.getVersion().before(Version.V_6_0_0_alpha1)) { // TODO change to 5.3.0 after backport + if (in.getVersion().before(LegacyESVersion.V_6_0_0_alpha1)) { // TODO change to 5.3.0 after backport // we do not know the content type that comes from earlier versions so we autodetect and convert source = XContentHelper.convertToJson(new BytesArray(source), false, false, XContentFactory.xContentType(source)); } mappings.put(type, source); } - if (in.getVersion().before(Version.V_6_5_0)) { + if (in.getVersion().before(LegacyESVersion.V_6_5_0)) { // This used to be the size of custom metadata classes int customSize = in.readVInt(); assert customSize == 0 : "unexpected custom metadata when none is supported"; @@ -127,7 +127,7 @@ public CreateIndexRequest(StreamInput in) throws IOException { for (int i = 0; i < aliasesSize; i++) { aliases.add(new Alias(in)); } - if (in.getVersion().before(Version.V_7_0_0)) { + if (in.getVersion().before(LegacyESVersion.V_7_0_0)) { in.readBoolean(); // updateAllTypes } waitForActiveShards = ActiveShardCount.readFrom(in); @@ -478,7 +478,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(entry.getKey()); out.writeString(entry.getValue()); } - if (out.getVersion().before(Version.V_6_5_0)) { + if (out.getVersion().before(LegacyESVersion.V_6_5_0)) { // Size of custom index metadata, which is removed out.writeVInt(0); } @@ -486,7 +486,7 @@ public void writeTo(StreamOutput out) throws IOException { for (Alias alias : aliases) { alias.writeTo(out); } - if (out.getVersion().before(Version.V_7_0_0)) { + if (out.getVersion().before(LegacyESVersion.V_7_0_0)) { out.writeBoolean(true); // updateAllTypes } waitForActiveShards.writeTo(out); diff --git a/server/src/main/java/org/opensearch/action/admin/indices/forcemerge/ForceMergeRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/forcemerge/ForceMergeRequest.java index 16435c898f27f..2496348f3e0eb 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/forcemerge/ForceMergeRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/forcemerge/ForceMergeRequest.java @@ -32,6 +32,7 @@ package org.opensearch.action.admin.indices.forcemerge; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.action.support.broadcast.BroadcastRequest; import org.opensearch.common.Nullable; @@ -66,7 +67,7 @@ public static final class Defaults { private boolean onlyExpungeDeletes = Defaults.ONLY_EXPUNGE_DELETES; private boolean flush = Defaults.FLUSH; - private static final Version FORCE_MERGE_UUID_VERSION = Version.V_7_7_0; + private static final Version FORCE_MERGE_UUID_VERSION = LegacyESVersion.V_7_7_0; /** * Force merge UUID to store in the live commit data of a shard under diff --git a/server/src/main/java/org/opensearch/action/admin/indices/get/GetIndexRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/get/GetIndexRequest.java index 52e529447cbf9..84f282c6a2820 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/get/GetIndexRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/get/GetIndexRequest.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.indices.get; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.support.master.info.ClusterInfoRequest; import org.opensearch.common.io.stream.StreamInput; @@ -90,7 +90,7 @@ public GetIndexRequest(StreamInput in) throws IOException { super(in); features = in.readArray(i -> Feature.fromId(i.readByte()), Feature[]::new); humanReadable = in.readBoolean(); - if (in.getVersion().onOrAfter(Version.V_6_4_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) { includeDefaults = in.readBoolean(); } } @@ -156,7 +156,7 @@ public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeArray((o, f) -> o.writeByte(f.id), features); out.writeBoolean(humanReadable); - if (out.getVersion().onOrAfter(Version.V_6_4_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) { out.writeBoolean(includeDefaults); } } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/get/GetIndexResponse.java b/server/src/main/java/org/opensearch/action/admin/indices/get/GetIndexResponse.java index ad846fff279d2..9328a55327d82 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/get/GetIndexResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/get/GetIndexResponse.java @@ -34,7 +34,7 @@ import com.carrotsearch.hppc.cursors.ObjectObjectCursor; import org.apache.lucene.util.CollectionUtil; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionResponse; import org.opensearch.cluster.metadata.AliasMetadata; import org.opensearch.cluster.metadata.MappingMetadata; @@ -144,7 +144,7 @@ public GetIndexResponse(String[] indices, } defaultSettings = defaultSettingsMapBuilder.build(); - if (in.getVersion().onOrAfter(Version.V_7_8_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_8_0)) { ImmutableOpenMap.Builder dataStreamsMapBuilder = ImmutableOpenMap.builder(); int dataStreamsSize = in.readVInt(); for (int i = 0; i < dataStreamsSize; i++) { @@ -260,7 +260,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(indexEntry.key); Settings.writeSettingsToStream(indexEntry.value, out); } - if (out.getVersion().onOrAfter(Version.V_7_8_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_8_0)) { out.writeVInt(dataStreams.size()); for (ObjectObjectCursor indexEntry : dataStreams) { out.writeString(indexEntry.key); diff --git a/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequest.java index c99ae0ca19b7f..9781290e89677 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/mapping/put/PutMappingRequest.java @@ -33,8 +33,8 @@ package org.opensearch.action.admin.indices.mapping.put; import com.carrotsearch.hppc.ObjectHashSet; +import org.opensearch.LegacyESVersion; import org.opensearch.OpenSearchGenerationException; -import org.opensearch.Version; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.IndicesRequest; import org.opensearch.action.support.IndicesOptions; @@ -99,16 +99,16 @@ public PutMappingRequest(StreamInput in) throws IOException { indicesOptions = IndicesOptions.readIndicesOptions(in); type = in.readOptionalString(); source = in.readString(); - if (in.getVersion().before(Version.V_7_0_0)) { + if (in.getVersion().before(LegacyESVersion.V_7_0_0)) { in.readBoolean(); // updateAllTypes } concreteIndex = in.readOptionalWriteable(Index::new); - if (in.getVersion().onOrAfter(Version.V_6_7_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { origin = in.readOptionalString(); } else { origin = null; } - if (in.getVersion().onOrAfter(Version.V_7_9_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_9_0)) { writeIndexOnly = in.readBoolean(); } } @@ -357,14 +357,14 @@ public void writeTo(StreamOutput out) throws IOException { indicesOptions.writeIndicesOptions(out); out.writeOptionalString(type); out.writeString(source); - if (out.getVersion().before(Version.V_7_0_0)) { + if (out.getVersion().before(LegacyESVersion.V_7_0_0)) { out.writeBoolean(true); // updateAllTypes } out.writeOptionalWriteable(concreteIndex); - if (out.getVersion().onOrAfter(Version.V_6_7_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { out.writeOptionalString(origin); } - if (out.getVersion().onOrAfter(Version.V_7_9_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_9_0)) { out.writeBoolean(writeIndexOnly); } } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/open/OpenIndexRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/open/OpenIndexRequest.java index 4c5cdd11ea31c..dd997c189d78a 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/open/OpenIndexRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/open/OpenIndexRequest.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.indices.open; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.IndicesRequest; import org.opensearch.action.support.ActiveShardCount; @@ -59,7 +59,7 @@ public OpenIndexRequest(StreamInput in) throws IOException { super(in); indices = in.readStringArray(); indicesOptions = IndicesOptions.readIndicesOptions(in); - if (in.getVersion().onOrAfter(Version.V_6_1_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_6_1_0)) { waitForActiveShards = ActiveShardCount.readFrom(in); } } @@ -168,7 +168,7 @@ public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeStringArray(indices); indicesOptions.writeIndicesOptions(out); - if (out.getVersion().onOrAfter(Version.V_6_1_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_6_1_0)) { waitForActiveShards.writeTo(out); } } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/open/OpenIndexResponse.java b/server/src/main/java/org/opensearch/action/admin/indices/open/OpenIndexResponse.java index aa751d81e54e1..5c7b4828d6056 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/open/OpenIndexResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/open/OpenIndexResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.indices.open; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.support.master.ShardsAcknowledgedResponse; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; @@ -54,7 +54,7 @@ public class OpenIndexResponse extends ShardsAcknowledgedResponse { } public OpenIndexResponse(StreamInput in) throws IOException { - super(in, in.getVersion().onOrAfter(Version.V_6_1_0), true); + super(in, in.getVersion().onOrAfter(LegacyESVersion.V_6_1_0), true); } public OpenIndexResponse(boolean acknowledged, boolean shardsAcknowledged) { @@ -64,7 +64,7 @@ public OpenIndexResponse(boolean acknowledged, boolean shardsAcknowledged) { @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - if (out.getVersion().onOrAfter(Version.V_6_1_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_6_1_0)) { writeShardsAcknowledged(out); } } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/rollover/MaxSizeCondition.java b/server/src/main/java/org/opensearch/action/admin/indices/rollover/MaxSizeCondition.java index 65cd983c9021e..01c8cff49bdd0 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/rollover/MaxSizeCondition.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/rollover/MaxSizeCondition.java @@ -32,6 +32,7 @@ package org.opensearch.action.admin.indices.rollover; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; @@ -66,7 +67,7 @@ public Result evaluate(Stats stats) { @Override boolean includedInVersion(Version version) { - return version.onOrAfter(Version.V_6_1_0); + return version.onOrAfter(LegacyESVersion.V_6_1_0); } @Override diff --git a/server/src/main/java/org/opensearch/action/admin/indices/rollover/RolloverResponse.java b/server/src/main/java/org/opensearch/action/admin/indices/rollover/RolloverResponse.java index 30f1055a8a26a..b460a779f0b99 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/rollover/RolloverResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/rollover/RolloverResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.indices.rollover; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.support.master.ShardsAcknowledgedResponse; import org.opensearch.common.ParseField; import org.opensearch.common.io.stream.StreamInput; @@ -89,8 +89,8 @@ public final class RolloverResponse extends ShardsAcknowledgedResponse implement private final boolean shardsAcknowledged; RolloverResponse(StreamInput in) throws IOException { - super(in, false, in.getVersion().onOrAfter(Version.V_6_4_0)); - if (in.getVersion().onOrAfter(Version.V_6_4_0)) { + super(in, false, in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)); + if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) { oldIndex = in.readString(); newIndex = in.readString(); int conditionSize = in.readVInt(); @@ -169,7 +169,7 @@ public boolean isShardsAcknowledged() { @Override public void writeTo(StreamOutput out) throws IOException { - if (out.getVersion().onOrAfter(Version.V_6_4_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) { super.writeTo(out); out.writeString(oldIndex); out.writeString(newIndex); diff --git a/server/src/main/java/org/opensearch/action/admin/indices/settings/get/GetSettingsRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/settings/get/GetSettingsRequest.java index d3eb63d09eccf..69be3e34383b8 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/settings/get/GetSettingsRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/settings/get/GetSettingsRequest.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.indices.settings.get; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.IndicesRequest; import org.opensearch.action.ValidateActions; @@ -83,7 +83,7 @@ public GetSettingsRequest(StreamInput in) throws IOException { indicesOptions = IndicesOptions.readIndicesOptions(in); names = in.readStringArray(); humanReadable = in.readBoolean(); - if (in.getVersion().onOrAfter(Version.V_6_4_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) { includeDefaults = in.readBoolean(); } } @@ -95,7 +95,7 @@ public void writeTo(StreamOutput out) throws IOException { indicesOptions.writeIndicesOptions(out); out.writeStringArray(names); out.writeBoolean(humanReadable); - if (out.getVersion().onOrAfter(Version.V_6_4_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) { out.writeBoolean(includeDefaults); } } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/shards/IndicesShardStoresResponse.java b/server/src/main/java/org/opensearch/action/admin/indices/shards/IndicesShardStoresResponse.java index 8695f2910e058..64b0e2f536737 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/shards/IndicesShardStoresResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/shards/IndicesShardStoresResponse.java @@ -34,8 +34,8 @@ import com.carrotsearch.hppc.cursors.IntObjectCursor; import com.carrotsearch.hppc.cursors.ObjectObjectCursor; +import org.opensearch.LegacyESVersion; import org.opensearch.OpenSearchException; -import org.opensearch.Version; import org.opensearch.action.ActionResponse; import org.opensearch.action.support.DefaultShardOperationFailedException; import org.opensearch.cluster.node.DiscoveryNode; @@ -123,7 +123,7 @@ private void writeTo(StreamOutput out) throws IOException { public StoreStatus(StreamInput in) throws IOException { node = new DiscoveryNode(in); - if (in.getVersion().before(Version.V_6_0_0_alpha1)) { + if (in.getVersion().before(LegacyESVersion.V_6_0_0_alpha1)) { // legacy version in.readLong(); } @@ -177,7 +177,7 @@ public AllocationStatus getAllocationStatus() { @Override public void writeTo(StreamOutput out) throws IOException { node.writeTo(out); - if (out.getVersion().before(Version.V_6_0_0_alpha1)) { + if (out.getVersion().before(LegacyESVersion.V_6_0_0_alpha1)) { // legacy version out.writeLong(-1L); } @@ -241,11 +241,11 @@ public Failure(String nodeId, String index, int shardId, Throwable reason) { } private Failure(StreamInput in) throws IOException { - if (in.getVersion().before(Version.V_7_4_0)) { + if (in.getVersion().before(LegacyESVersion.V_7_4_0)) { nodeId = in.readString(); } readFrom(in, this); - if (in.getVersion().onOrAfter(Version.V_7_4_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_4_0)) { nodeId = in.readString(); } } @@ -260,11 +260,11 @@ static Failure readFailure(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { - if (out.getVersion().before(Version.V_7_4_0)) { + if (out.getVersion().before(LegacyESVersion.V_7_4_0)) { out.writeString(nodeId); } super.writeTo(out); - if (out.getVersion().onOrAfter(Version.V_7_4_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_4_0)) { out.writeString(nodeId); } } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/shrink/ResizeAction.java b/server/src/main/java/org/opensearch/action/admin/indices/shrink/ResizeAction.java index 7abb34037f033..e4d6a079d14d2 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/shrink/ResizeAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/shrink/ResizeAction.java @@ -32,6 +32,7 @@ package org.opensearch.action.admin.indices.shrink; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.action.ActionType; @@ -39,7 +40,7 @@ public class ResizeAction extends ActionType { public static final ResizeAction INSTANCE = new ResizeAction(); public static final String NAME = "indices:admin/resize"; - public static final Version COMPATIBILITY_VERSION = Version.V_6_1_0; // TODO remove this once it's backported + public static final Version COMPATIBILITY_VERSION = LegacyESVersion.V_6_1_0; // TODO remove this once it's backported private ResizeAction() { super(NAME, ResizeResponse::new); diff --git a/server/src/main/java/org/opensearch/action/admin/indices/shrink/ResizeRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/shrink/ResizeRequest.java index 49225064f64bf..6acf2a6ff1197 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/shrink/ResizeRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/shrink/ResizeRequest.java @@ -31,7 +31,7 @@ package org.opensearch.action.admin.indices.shrink; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.IndicesRequest; import org.opensearch.action.admin.indices.alias.Alias; @@ -80,7 +80,7 @@ public ResizeRequest(StreamInput in) throws IOException { } else { type = ResizeType.SHRINK; // BWC this used to be shrink only } - if (in.getVersion().before(Version.V_6_4_0)) { + if (in.getVersion().before(LegacyESVersion.V_6_4_0)) { copySettings = null; } else { copySettings = in.readOptionalBoolean(); @@ -123,13 +123,13 @@ public void writeTo(StreamOutput out) throws IOException { targetIndexRequest.writeTo(out); out.writeString(sourceIndex); if (out.getVersion().onOrAfter(ResizeAction.COMPATIBILITY_VERSION)) { - if (type == ResizeType.CLONE && out.getVersion().before(Version.V_7_4_0)) { - throw new IllegalArgumentException("can't send clone request to a node that's older than " + Version.V_7_4_0); + if (type == ResizeType.CLONE && out.getVersion().before(LegacyESVersion.V_7_4_0)) { + throw new IllegalArgumentException("can't send clone request to a node that's older than " + LegacyESVersion.V_7_4_0); } out.writeEnum(type); } // noinspection StatementWithEmptyBody - if (out.getVersion().before(Version.V_6_4_0)) { + if (out.getVersion().before(LegacyESVersion.V_6_4_0)) { } else { out.writeOptionalBoolean(copySettings); diff --git a/server/src/main/java/org/opensearch/action/admin/indices/stats/CommonStatsFlags.java b/server/src/main/java/org/opensearch/action/admin/indices/stats/CommonStatsFlags.java index 114be59e38505..5b0c4ce0f6ec4 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/stats/CommonStatsFlags.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/stats/CommonStatsFlags.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.indices.stats; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; import org.opensearch.common.io.stream.Writeable; @@ -77,7 +77,7 @@ public CommonStatsFlags(StreamInput in) throws IOException { fieldDataFields = in.readStringArray(); completionDataFields = in.readStringArray(); includeSegmentFileSizes = in.readBoolean(); - if (in.getVersion().onOrAfter(Version.V_7_2_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_2_0)) { includeUnloadedSegments = in.readBoolean(); } } @@ -95,7 +95,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeStringArrayNullable(fieldDataFields); out.writeStringArrayNullable(completionDataFields); out.writeBoolean(includeSegmentFileSizes); - if (out.getVersion().onOrAfter(Version.V_7_2_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_2_0)) { out.writeBoolean(includeUnloadedSegments); } } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/stats/ShardStats.java b/server/src/main/java/org/opensearch/action/admin/indices/stats/ShardStats.java index e7f5d3053519e..3a2d8ded9e8db 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/stats/ShardStats.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/stats/ShardStats.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.indices.stats; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.cluster.routing.ShardRouting; import org.opensearch.common.Nullable; import org.opensearch.common.io.stream.StreamInput; @@ -79,10 +79,10 @@ public ShardStats(StreamInput in) throws IOException { statePath = in.readString(); dataPath = in.readString(); isCustomDataPath = in.readBoolean(); - if (in.getVersion().onOrAfter(Version.V_6_0_0_alpha1)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_6_0_0_alpha1)) { seqNoStats = in.readOptionalWriteable(SeqNoStats::new); } - if (in.getVersion().onOrAfter(Version.V_6_7_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { retentionLeaseStats = in.readOptionalWriteable(RetentionLeaseStats::new); } } @@ -145,10 +145,10 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(statePath); out.writeString(dataPath); out.writeBoolean(isCustomDataPath); - if (out.getVersion().onOrAfter(Version.V_6_0_0_alpha1)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_6_0_0_alpha1)) { out.writeOptionalWriteable(seqNoStats); } - if (out.getVersion().onOrAfter(Version.V_6_7_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_6_7_0)) { out.writeOptionalWriteable(retentionLeaseStats); } } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequest.java b/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequest.java index 093f096c6dcdb..63d8af0655e46 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/put/PutIndexTemplateRequest.java @@ -31,9 +31,9 @@ package org.opensearch.action.admin.indices.template.put; +import org.opensearch.LegacyESVersion; import org.opensearch.OpenSearchGenerationException; import org.opensearch.OpenSearchParseException; -import org.opensearch.Version; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.IndicesRequest; import org.opensearch.action.admin.indices.alias.Alias; @@ -105,7 +105,7 @@ public PutIndexTemplateRequest(StreamInput in) throws IOException { cause = in.readString(); name = in.readString(); - if (in.getVersion().onOrAfter(Version.V_6_0_0_alpha1)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_6_0_0_alpha1)) { indexPatterns = in.readStringList(); } else { indexPatterns = Collections.singletonList(in.readString()); @@ -119,7 +119,7 @@ public PutIndexTemplateRequest(StreamInput in) throws IOException { String mappingSource = in.readString(); mappings.put(type, mappingSource); } - if (in.getVersion().before(Version.V_6_5_0)) { + if (in.getVersion().before(LegacyESVersion.V_6_5_0)) { // Used to be used for custom index metadata int customSize = in.readVInt(); assert customSize == 0 : "expected not to have any custom metadata"; @@ -496,7 +496,7 @@ public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeString(cause); out.writeString(name); - if (out.getVersion().onOrAfter(Version.V_6_0_0_alpha1)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_6_0_0_alpha1)) { out.writeStringCollection(indexPatterns); } else { out.writeString(indexPatterns.size() > 0 ? indexPatterns.get(0) : ""); @@ -509,7 +509,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(entry.getKey()); out.writeString(entry.getValue()); } - if (out.getVersion().before(Version.V_6_5_0)) { + if (out.getVersion().before(LegacyESVersion.V_6_5_0)) { out.writeVInt(0); } out.writeVInt(aliases.size()); diff --git a/server/src/main/java/org/opensearch/action/admin/indices/validate/query/QueryExplanation.java b/server/src/main/java/org/opensearch/action/admin/indices/validate/query/QueryExplanation.java index 69b67fd6e67a7..f07746175de9e 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/validate/query/QueryExplanation.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/validate/query/QueryExplanation.java @@ -32,7 +32,7 @@ package org.opensearch.action.admin.indices.validate.query; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.common.ParseField; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; @@ -94,7 +94,7 @@ public class QueryExplanation implements Writeable, ToXContentFragment { private String error; public QueryExplanation(StreamInput in) throws IOException { - if (in.getVersion().onOrAfter(Version.V_6_4_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) { index = in.readOptionalString(); } else { index = in.readString(); @@ -136,7 +136,7 @@ public String getExplanation() { @Override public void writeTo(StreamOutput out) throws IOException { - if (out.getVersion().onOrAfter(Version.V_6_4_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_6_4_0)) { out.writeOptionalString(index); } else { out.writeString(index); diff --git a/server/src/main/java/org/opensearch/action/bulk/BulkItemResponse.java b/server/src/main/java/org/opensearch/action/bulk/BulkItemResponse.java index df18d353cced8..bf1f76ef52971 100644 --- a/server/src/main/java/org/opensearch/action/bulk/BulkItemResponse.java +++ b/server/src/main/java/org/opensearch/action/bulk/BulkItemResponse.java @@ -33,8 +33,8 @@ package org.opensearch.action.bulk; import org.opensearch.ExceptionsHelper; +import org.opensearch.LegacyESVersion; import org.opensearch.OpenSearchException; -import org.opensearch.Version; import org.opensearch.action.DocWriteRequest.OpType; import org.opensearch.action.DocWriteResponse; import org.opensearch.action.delete.DeleteResponse; @@ -256,7 +256,7 @@ public Failure(StreamInput in) throws IOException { cause = in.readException(); status = ExceptionsHelper.status(cause); seqNo = in.readZLong(); - if (in.getVersion().onOrAfter(Version.V_7_6_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_6_0)) { term = in.readVLong(); } else { term = SequenceNumbers.UNASSIGNED_PRIMARY_TERM; @@ -271,7 +271,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalString(id); out.writeException(cause); out.writeZLong(seqNo); - if (out.getVersion().onOrAfter(Version.V_7_6_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_6_0)) { out.writeVLong(term); } out.writeBoolean(aborted); diff --git a/server/src/main/java/org/opensearch/action/bulk/BulkShardRequest.java b/server/src/main/java/org/opensearch/action/bulk/BulkShardRequest.java index 5fe2b1c4f71a5..85f450d259b19 100644 --- a/server/src/main/java/org/opensearch/action/bulk/BulkShardRequest.java +++ b/server/src/main/java/org/opensearch/action/bulk/BulkShardRequest.java @@ -34,6 +34,7 @@ import org.apache.lucene.util.Accountable; import org.apache.lucene.util.RamUsageEstimator; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.action.support.replication.ReplicatedWriteRequest; import org.opensearch.action.support.replication.ReplicationRequest; @@ -48,7 +49,7 @@ public class BulkShardRequest extends ReplicatedWriteRequest implements Accountable { - public static final Version COMPACT_SHARD_ID_VERSION = Version.V_7_9_0; + public static final Version COMPACT_SHARD_ID_VERSION = LegacyESVersion.V_7_9_0; private static final long SHALLOW_SIZE = RamUsageEstimator.shallowSizeOfInstance(BulkShardRequest.class); private final BulkItemRequest[] items; diff --git a/server/src/main/java/org/opensearch/action/bulk/BulkShardResponse.java b/server/src/main/java/org/opensearch/action/bulk/BulkShardResponse.java index f4a28071bca41..c1d4e3863ec63 100644 --- a/server/src/main/java/org/opensearch/action/bulk/BulkShardResponse.java +++ b/server/src/main/java/org/opensearch/action/bulk/BulkShardResponse.java @@ -32,6 +32,7 @@ package org.opensearch.action.bulk; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.action.DocWriteResponse; import org.opensearch.action.support.WriteResponse; @@ -44,7 +45,7 @@ public class BulkShardResponse extends ReplicationResponse implements WriteResponse { - private static final Version COMPACT_SHARD_ID_VERSION = Version.V_7_9_0; + private static final Version COMPACT_SHARD_ID_VERSION = LegacyESVersion.V_7_9_0; private final ShardId shardId; private final BulkItemResponse[] responses; diff --git a/server/src/main/java/org/opensearch/action/bulk/TransportBulkAction.java b/server/src/main/java/org/opensearch/action/bulk/TransportBulkAction.java index c38ecb0594b06..7aba9a40f05a0 100644 --- a/server/src/main/java/org/opensearch/action/bulk/TransportBulkAction.java +++ b/server/src/main/java/org/opensearch/action/bulk/TransportBulkAction.java @@ -36,6 +36,7 @@ import org.apache.logging.log4j.Logger; import org.apache.lucene.util.SparseFixedBitSet; import org.opensearch.Assertions; +import org.opensearch.LegacyESVersion; import org.opensearch.OpenSearchParseException; import org.opensearch.ExceptionsHelper; import org.opensearch.ResourceAlreadyExistsException; @@ -414,7 +415,7 @@ void createIndex(String index, createIndexRequest.index(index); createIndexRequest.cause("auto(bulk api)"); createIndexRequest.masterNodeTimeout(timeout); - if (minNodeVersion.onOrAfter(Version.V_7_8_0)) { + if (minNodeVersion.onOrAfter(LegacyESVersion.V_7_8_0)) { client.execute(AutoCreateAction.INSTANCE, createIndexRequest, listener); } else { client.admin().indices().create(createIndexRequest, listener); diff --git a/server/src/main/java/org/opensearch/action/delete/DeleteRequest.java b/server/src/main/java/org/opensearch/action/delete/DeleteRequest.java index ade10c30ef8b2..1ec1ee93da029 100644 --- a/server/src/main/java/org/opensearch/action/delete/DeleteRequest.java +++ b/server/src/main/java/org/opensearch/action/delete/DeleteRequest.java @@ -33,7 +33,7 @@ package org.opensearch.action.delete; import org.apache.lucene.util.RamUsageEstimator; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.CompositeIndicesRequest; import org.opensearch.action.DocWriteRequest; @@ -90,12 +90,12 @@ public DeleteRequest(@Nullable ShardId shardId, StreamInput in) throws IOExcepti type = in.readString(); id = in.readString(); routing = in.readOptionalString(); - if (in.getVersion().before(Version.V_7_0_0)) { + if (in.getVersion().before(LegacyESVersion.V_7_0_0)) { in.readOptionalString(); // _parent } version = in.readLong(); versionType = VersionType.fromValue(in.readByte()); - if (in.getVersion().onOrAfter(Version.V_6_6_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) { ifSeqNo = in.readZLong(); ifPrimaryTerm = in.readVLong(); } else { @@ -341,12 +341,12 @@ private void writeBody(StreamOutput out) throws IOException { out.writeString(type()); out.writeString(id); out.writeOptionalString(routing()); - if (out.getVersion().before(Version.V_7_0_0)) { + if (out.getVersion().before(LegacyESVersion.V_7_0_0)) { out.writeOptionalString(null); // _parent } out.writeLong(version); out.writeByte(versionType.getValue()); - if (out.getVersion().onOrAfter(Version.V_6_6_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) { out.writeZLong(ifSeqNo); out.writeVLong(ifPrimaryTerm); } else if (ifSeqNo != UNASSIGNED_SEQ_NO || ifPrimaryTerm != UNASSIGNED_PRIMARY_TERM) { diff --git a/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilities.java b/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilities.java index 807a5ce959029..9a0a8a139d5ea 100644 --- a/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilities.java +++ b/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilities.java @@ -32,7 +32,7 @@ package org.opensearch.action.fieldcaps; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.common.ParseField; import org.opensearch.common.Strings; import org.opensearch.common.io.stream.StreamInput; @@ -119,7 +119,7 @@ public FieldCapabilities(String name, String type, this.indices = in.readOptionalStringArray(); this.nonSearchableIndices = in.readOptionalStringArray(); this.nonAggregatableIndices = in.readOptionalStringArray(); - if (in.getVersion().onOrAfter(Version.V_7_6_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_6_0)) { meta = in.readMap(StreamInput::readString, i -> i.readSet(StreamInput::readString)); } else { meta = Collections.emptyMap(); @@ -135,7 +135,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalStringArray(indices); out.writeOptionalStringArray(nonSearchableIndices); out.writeOptionalStringArray(nonAggregatableIndices); - if (out.getVersion().onOrAfter(Version.V_7_6_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_6_0)) { out.writeMap(meta, StreamOutput::writeString, (o, set) -> o.writeCollection(set, StreamOutput::writeString)); } } diff --git a/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilitiesIndexRequest.java b/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilitiesIndexRequest.java index 2047ca2a38fd5..4b08c74c09bcf 100644 --- a/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilitiesIndexRequest.java +++ b/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilitiesIndexRequest.java @@ -32,7 +32,7 @@ package org.opensearch.action.fieldcaps; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.IndicesRequest; @@ -64,13 +64,13 @@ public class FieldCapabilitiesIndexRequest extends ActionRequest implements Indi shardId = in.readOptionalWriteable(ShardId::new); index = in.readOptionalString(); fields = in.readStringArray(); - if (in.getVersion().onOrAfter(Version.V_6_2_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_6_2_0)) { originalIndices = OriginalIndices.readOriginalIndices(in); } else { originalIndices = OriginalIndices.NONE; } - indexFilter = in.getVersion().onOrAfter(Version.V_7_9_0) ? in.readOptionalNamedWriteable(QueryBuilder.class) : null; - nowInMillis = in.getVersion().onOrAfter(Version.V_7_9_0) ? in.readLong() : 0L; + indexFilter = in.getVersion().onOrAfter(LegacyESVersion.V_7_9_0) ? in.readOptionalNamedWriteable(QueryBuilder.class) : null; + nowInMillis = in.getVersion().onOrAfter(LegacyESVersion.V_7_9_0) ? in.readLong() : 0L; } FieldCapabilitiesIndexRequest(String[] fields, @@ -129,10 +129,10 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalWriteable(shardId); out.writeOptionalString(index); out.writeStringArray(fields); - if (out.getVersion().onOrAfter(Version.V_6_2_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_6_2_0)) { OriginalIndices.writeOriginalIndices(originalIndices, out); } - if (out.getVersion().onOrAfter(Version.V_7_9_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_9_0)) { out.writeOptionalNamedWriteable(indexFilter); out.writeLong(nowInMillis); } diff --git a/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilitiesIndexResponse.java b/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilitiesIndexResponse.java index 93f23b06a7f0b..097f8fcb16377 100644 --- a/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilitiesIndexResponse.java +++ b/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilitiesIndexResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.fieldcaps; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionResponse; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; @@ -60,7 +60,7 @@ public class FieldCapabilitiesIndexResponse extends ActionResponse implements Wr super(in); this.indexName = in.readString(); this.responseMap = in.readMap(StreamInput::readString, IndexFieldCapabilities::new); - this.canMatch = in.getVersion().onOrAfter(Version.V_7_9_0) ? in.readBoolean() : true; + this.canMatch = in.getVersion().onOrAfter(LegacyESVersion.V_7_9_0) ? in.readBoolean() : true; } /** @@ -93,7 +93,7 @@ public IndexFieldCapabilities getField(String field) { public void writeTo(StreamOutput out) throws IOException { out.writeString(indexName); out.writeMap(responseMap, StreamOutput::writeString, (valueOut, fc) -> fc.writeTo(valueOut)); - if (out.getVersion().onOrAfter(Version.V_7_9_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_9_0)) { out.writeBoolean(canMatch); } } diff --git a/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilitiesRequest.java b/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilitiesRequest.java index 90d6a75068987..f19d98b0c674f 100644 --- a/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilitiesRequest.java +++ b/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilitiesRequest.java @@ -32,7 +32,7 @@ package org.opensearch.action.fieldcaps; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.IndicesRequest; @@ -69,13 +69,13 @@ public FieldCapabilitiesRequest(StreamInput in) throws IOException { indices = in.readStringArray(); indicesOptions = IndicesOptions.readIndicesOptions(in); mergeResults = in.readBoolean(); - if (in.getVersion().onOrAfter(Version.V_7_2_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_2_0)) { includeUnmapped = in.readBoolean(); } else { includeUnmapped = false; } - indexFilter = in.getVersion().onOrAfter(Version.V_7_9_0) ? in.readOptionalNamedWriteable(QueryBuilder.class) : null; - nowInMillis = in.getVersion().onOrAfter(Version.V_7_9_0) ? in.readOptionalLong() : null; + indexFilter = in.getVersion().onOrAfter(LegacyESVersion.V_7_9_0) ? in.readOptionalNamedWriteable(QueryBuilder.class) : null; + nowInMillis = in.getVersion().onOrAfter(LegacyESVersion.V_7_9_0) ? in.readOptionalLong() : null; } public FieldCapabilitiesRequest() { @@ -107,10 +107,10 @@ public void writeTo(StreamOutput out) throws IOException { out.writeStringArray(indices); indicesOptions.writeIndicesOptions(out); out.writeBoolean(mergeResults); - if (out.getVersion().onOrAfter(Version.V_7_2_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_2_0)) { out.writeBoolean(includeUnmapped); } - if (out.getVersion().onOrAfter(Version.V_7_9_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_9_0)) { out.writeOptionalNamedWriteable(indexFilter); out.writeOptionalLong(nowInMillis); } diff --git a/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilitiesResponse.java b/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilitiesResponse.java index f219f7e805a29..65feff094d596 100644 --- a/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilitiesResponse.java +++ b/server/src/main/java/org/opensearch/action/fieldcaps/FieldCapabilitiesResponse.java @@ -32,7 +32,7 @@ package org.opensearch.action.fieldcaps; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionResponse; import org.opensearch.common.ParseField; import org.opensearch.common.Strings; @@ -82,7 +82,7 @@ private FieldCapabilitiesResponse(String[] indices, Map readField(StreamInput in) throws I @Override public void writeTo(StreamOutput out) throws IOException { - if (out.getVersion().onOrAfter(Version.V_7_2_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_2_0)) { out.writeStringArray(indices); } out.writeMap(responseMap, StreamOutput::writeString, FieldCapabilitiesResponse::writeField); diff --git a/server/src/main/java/org/opensearch/action/fieldcaps/IndexFieldCapabilities.java b/server/src/main/java/org/opensearch/action/fieldcaps/IndexFieldCapabilities.java index ec10f28f4feca..1f5b867515b13 100644 --- a/server/src/main/java/org/opensearch/action/fieldcaps/IndexFieldCapabilities.java +++ b/server/src/main/java/org/opensearch/action/fieldcaps/IndexFieldCapabilities.java @@ -32,7 +32,7 @@ package org.opensearch.action.fieldcaps; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; import org.opensearch.common.io.stream.Writeable; @@ -74,7 +74,7 @@ public class IndexFieldCapabilities implements Writeable { } IndexFieldCapabilities(StreamInput in) throws IOException { - if (in.getVersion().onOrAfter(Version.V_7_7_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) { this.name = in.readString(); this.type = in.readString(); this.isSearchable = in.readBoolean(); @@ -95,7 +95,7 @@ public class IndexFieldCapabilities implements Writeable { @Override public void writeTo(StreamOutput out) throws IOException { - if (out.getVersion().onOrAfter(Version.V_7_7_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) { out.writeString(name); out.writeString(type); out.writeBoolean(isSearchable); diff --git a/server/src/main/java/org/opensearch/action/get/GetRequest.java b/server/src/main/java/org/opensearch/action/get/GetRequest.java index 8cd01b51d725b..1edf23d0a6473 100644 --- a/server/src/main/java/org/opensearch/action/get/GetRequest.java +++ b/server/src/main/java/org/opensearch/action/get/GetRequest.java @@ -32,7 +32,7 @@ package org.opensearch.action.get; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.RealtimeRequest; import org.opensearch.action.ValidateActions; @@ -88,7 +88,7 @@ public GetRequest() { type = in.readString(); id = in.readString(); routing = in.readOptionalString(); - if (in.getVersion().before(Version.V_7_0_0)) { + if (in.getVersion().before(LegacyESVersion.V_7_0_0)) { in.readOptionalString(); } preference = in.readOptionalString(); @@ -296,7 +296,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(type); out.writeString(id); out.writeOptionalString(routing); - if (out.getVersion().before(Version.V_7_0_0)) { + if (out.getVersion().before(LegacyESVersion.V_7_0_0)) { out.writeOptionalString(null); } out.writeOptionalString(preference); diff --git a/server/src/main/java/org/opensearch/action/get/MultiGetRequest.java b/server/src/main/java/org/opensearch/action/get/MultiGetRequest.java index e52093a24f819..03e89e98edc14 100644 --- a/server/src/main/java/org/opensearch/action/get/MultiGetRequest.java +++ b/server/src/main/java/org/opensearch/action/get/MultiGetRequest.java @@ -32,8 +32,8 @@ package org.opensearch.action.get; +import org.opensearch.LegacyESVersion; import org.opensearch.OpenSearchParseException; -import org.opensearch.Version; import org.opensearch.action.ActionRequest; import org.opensearch.action.ActionRequestValidationException; import org.opensearch.action.CompositeIndicesRequest; @@ -101,7 +101,7 @@ public Item(StreamInput in) throws IOException { type = in.readOptionalString(); id = in.readString(); routing = in.readOptionalString(); - if (in.getVersion().before(Version.V_7_0_0)) { + if (in.getVersion().before(LegacyESVersion.V_7_0_0)) { in.readOptionalString(); // _parent } storedFields = in.readOptionalStringArray(); @@ -216,7 +216,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalString(type); out.writeString(id); out.writeOptionalString(routing); - if (out.getVersion().before(Version.V_7_0_0)) { + if (out.getVersion().before(LegacyESVersion.V_7_0_0)) { out.writeOptionalString(null); // _parent } out.writeOptionalStringArray(storedFields); diff --git a/server/src/main/java/org/opensearch/action/index/IndexRequest.java b/server/src/main/java/org/opensearch/action/index/IndexRequest.java index b94e641610b05..646b015d86c9f 100644 --- a/server/src/main/java/org/opensearch/action/index/IndexRequest.java +++ b/server/src/main/java/org/opensearch/action/index/IndexRequest.java @@ -33,6 +33,7 @@ package org.opensearch.action.index; import org.apache.lucene.util.RamUsageEstimator; +import org.opensearch.LegacyESVersion; import org.opensearch.OpenSearchGenerationException; import org.opensearch.Version; import org.opensearch.action.ActionRequestValidationException; @@ -145,10 +146,10 @@ public IndexRequest(@Nullable ShardId shardId, StreamInput in) throws IOExceptio type = in.readOptionalString(); id = in.readOptionalString(); routing = in.readOptionalString(); - if (in.getVersion().before(Version.V_7_0_0)) { + if (in.getVersion().before(LegacyESVersion.V_7_0_0)) { in.readOptionalString(); // _parent } - if (in.getVersion().before(Version.V_6_0_0_alpha1)) { + if (in.getVersion().before(LegacyESVersion.V_6_0_0_alpha1)) { in.readOptionalString(); // timestamp in.readOptionalTimeValue(); // ttl } @@ -157,10 +158,10 @@ public IndexRequest(@Nullable ShardId shardId, StreamInput in) throws IOExceptio version = in.readLong(); versionType = VersionType.fromValue(in.readByte()); pipeline = in.readOptionalString(); - if (in.getVersion().onOrAfter(Version.V_7_5_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_5_0)) { finalPipeline = in.readOptionalString(); } - if (in.getVersion().onOrAfter(Version.V_7_5_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_5_0)) { isPipelineResolved = in.readBoolean(); } isRetry = in.readBoolean(); @@ -170,14 +171,14 @@ public IndexRequest(@Nullable ShardId shardId, StreamInput in) throws IOExceptio } else { contentType = null; } - if (in.getVersion().onOrAfter(Version.V_6_6_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) { ifSeqNo = in.readZLong(); ifPrimaryTerm = in.readVLong(); } else { ifSeqNo = UNASSIGNED_SEQ_NO; ifPrimaryTerm = UNASSIGNED_PRIMARY_TERM; } - if (in.getVersion().onOrAfter(Version.V_7_10_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_10_0)) { requireAlias = in.readBoolean(); } else { requireAlias = false; @@ -701,7 +702,7 @@ public void process(Version indexCreatedVersion, @Nullable MappingMetadata mappi assert ifPrimaryTerm == UNASSIGNED_PRIMARY_TERM; autoGeneratedTimestamp = Math.max(0, System.currentTimeMillis()); // extra paranoia String uid; - if (indexCreatedVersion.onOrAfter(Version.V_6_0_0_beta1)) { + if (indexCreatedVersion.onOrAfter(LegacyESVersion.V_6_0_0_beta1)) { uid = UUIDs.base64UUID(); } else { uid = UUIDs.legacyBase64UUID(); @@ -716,7 +717,7 @@ public void resolveRouting(Metadata metadata) { } public void checkAutoIdWithOpTypeCreateSupportedByVersion(Version version) { - if (id == null && opType == OpType.CREATE && version.before(Version.V_7_5_0)) { + if (id == null && opType == OpType.CREATE && version.before(LegacyESVersion.V_7_5_0)) { throw new IllegalArgumentException("optype create not supported for indexing requests without explicit id until all nodes " + "are on version 7.5.0 or higher"); } @@ -742,10 +743,10 @@ private void writeBody(StreamOutput out) throws IOException { out.writeOptionalString(type()); out.writeOptionalString(id); out.writeOptionalString(routing); - if (out.getVersion().before(Version.V_7_0_0)) { + if (out.getVersion().before(LegacyESVersion.V_7_0_0)) { out.writeOptionalString(null); // _parent } - if (out.getVersion().before(Version.V_6_0_0_alpha1)) { + if (out.getVersion().before(LegacyESVersion.V_6_0_0_alpha1)) { // Serialize a fake timestamp. 5.x expect this value to be set by the #process method so we can't use null. // On the other hand, indices created on 5.x do not index the timestamp field. Therefore passing a 0 (or any value) for // the transport layer OK as it will be ignored. @@ -757,10 +758,10 @@ private void writeBody(StreamOutput out) throws IOException { out.writeLong(version); out.writeByte(versionType.getValue()); out.writeOptionalString(pipeline); - if (out.getVersion().onOrAfter(Version.V_7_5_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_5_0)) { out.writeOptionalString(finalPipeline); } - if (out.getVersion().onOrAfter(Version.V_7_5_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_5_0)) { out.writeBoolean(isPipelineResolved); } out.writeBoolean(isRetry); @@ -771,7 +772,7 @@ private void writeBody(StreamOutput out) throws IOException { } else { out.writeBoolean(false); } - if (out.getVersion().onOrAfter(Version.V_6_6_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_6_6_0)) { out.writeZLong(ifSeqNo); out.writeVLong(ifPrimaryTerm); } else if (ifSeqNo != UNASSIGNED_SEQ_NO || ifPrimaryTerm != UNASSIGNED_PRIMARY_TERM) { @@ -780,7 +781,7 @@ private void writeBody(StreamOutput out) throws IOException { "sequence number based compare and write is not supported until all nodes are on version 7.0 or higher. " + "Stream version [" + out.getVersion() + "]"); } - if (out.getVersion().onOrAfter(Version.V_7_10_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_10_0)) { out.writeBoolean(requireAlias); } } diff --git a/server/src/main/java/org/opensearch/action/ingest/SimulateDocumentBaseResult.java b/server/src/main/java/org/opensearch/action/ingest/SimulateDocumentBaseResult.java index 888bc03359090..91a63c384486e 100644 --- a/server/src/main/java/org/opensearch/action/ingest/SimulateDocumentBaseResult.java +++ b/server/src/main/java/org/opensearch/action/ingest/SimulateDocumentBaseResult.java @@ -31,8 +31,8 @@ package org.opensearch.action.ingest; +import org.opensearch.LegacyESVersion; import org.opensearch.OpenSearchException; -import org.opensearch.Version; import org.opensearch.common.ParseField; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; @@ -97,7 +97,7 @@ public SimulateDocumentBaseResult(Exception failure) { * Read from a stream. */ public SimulateDocumentBaseResult(StreamInput in) throws IOException { - if (in.getVersion().onOrAfter(Version.V_7_4_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_4_0)) { failure = in.readException(); ingestDocument = in.readOptionalWriteable(WriteableIngestDocument::new); } else { @@ -113,7 +113,7 @@ public SimulateDocumentBaseResult(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { - if (out.getVersion().onOrAfter(Version.V_7_4_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_4_0)) { out.writeException(failure); out.writeOptionalWriteable(ingestDocument); } else { diff --git a/server/src/main/java/org/opensearch/action/ingest/SimulateProcessorResult.java b/server/src/main/java/org/opensearch/action/ingest/SimulateProcessorResult.java index ae42eb7c018e5..1f34f201c4501 100644 --- a/server/src/main/java/org/opensearch/action/ingest/SimulateProcessorResult.java +++ b/server/src/main/java/org/opensearch/action/ingest/SimulateProcessorResult.java @@ -31,8 +31,8 @@ package org.opensearch.action.ingest; +import org.opensearch.LegacyESVersion; import org.opensearch.OpenSearchException; -import org.opensearch.Version; import org.opensearch.common.ParseField; import org.opensearch.common.collect.Tuple; import org.opensearch.common.io.stream.StreamInput; @@ -189,12 +189,12 @@ public SimulateProcessorResult(String type, String processorTag, String descript this.processorTag = in.readString(); this.ingestDocument = in.readOptionalWriteable(WriteableIngestDocument::new); this.failure = in.readException(); - if (in.getVersion().onOrAfter(Version.V_7_9_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_9_0)) { this.description = in.readOptionalString(); } else { this.description = null; } - if (in.getVersion().onOrAfter(Version.V_7_10_0)) { + if (in.getVersion().onOrAfter(LegacyESVersion.V_7_10_0)) { this.type = in.readString(); boolean hasConditional = in.readBoolean(); if (hasConditional) { @@ -213,10 +213,10 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(processorTag); out.writeOptionalWriteable(ingestDocument); out.writeException(failure); - if (out.getVersion().onOrAfter(Version.V_7_9_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_9_0)) { out.writeOptionalString(description); } - if (out.getVersion().onOrAfter(Version.V_7_10_0)) { + if (out.getVersion().onOrAfter(LegacyESVersion.V_7_10_0)) { out.writeString(type); out.writeBoolean(conditionalWithResult != null); if (conditionalWithResult != null) { diff --git a/server/src/main/java/org/opensearch/action/ingest/WriteableIngestDocument.java b/server/src/main/java/org/opensearch/action/ingest/WriteableIngestDocument.java index 47f1cc4eae50e..0faf5328025ea 100644 --- a/server/src/main/java/org/opensearch/action/ingest/WriteableIngestDocument.java +++ b/server/src/main/java/org/opensearch/action/ingest/WriteableIngestDocument.java @@ -32,7 +32,7 @@ package org.opensearch.action.ingest; -import org.opensearch.Version; +import org.opensearch.LegacyESVersion; import org.opensearch.common.ParseField; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; @@ -125,7 +125,7 @@ final class WriteableIngestDocument implements Writeable, ToXContentFragment { WriteableIngestDocument(StreamInput in) throws IOException { Map sourceAndMetadata = in.readMap(); Map ingestMetadata = in.readMap(); - if (in.getVersion().before(Version.V_6_0_0_beta1)) { + if (in.getVersion().before(LegacyESVersion.V_6_0_0_beta1)) { ingestMetadata.computeIfPresent("timestamp", (k, o) -> { Date date = (Date) o; return date.toInstant().atZone(ZoneId.systemDefault()); diff --git a/server/src/main/java/org/opensearch/action/main/MainResponse.java b/server/src/main/java/org/opensearch/action/main/MainResponse.java index f61f7439ae855..ef686c44209ce 100644 --- a/server/src/main/java/org/opensearch/action/main/MainResponse.java +++ b/server/src/main/java/org/opensearch/action/main/MainResponse.java @@ -33,6 +33,7 @@ package org.opensearch.action.main; import org.opensearch.Build; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.action.ActionResponse; import org.opensearch.cluster.ClusterName; @@ -64,7 +65,7 @@ public class MainResponse extends ActionResponse implements ToXContentObject { clusterName = new ClusterName(in); clusterUuid = in.readString(); build = Build.readBuild(in); - if (in.getVersion().before(Version.V_7_0_0)) { + if (in.getVersion().before(LegacyESVersion.V_7_0_0)) { in.readBoolean(); } } @@ -105,7 +106,7 @@ public void writeTo(StreamOutput out) throws IOException { clusterName.writeTo(out); out.writeString(clusterUuid); Build.writeBuild(build, out); - if (out.getVersion().before(Version.V_7_0_0)) { + if (out.getVersion().before(LegacyESVersion.V_7_0_0)) { out.writeBoolean(true); } } diff --git a/server/src/main/java/org/opensearch/action/resync/ResyncReplicationRequest.java b/server/src/main/java/org/opensearch/action/resync/ResyncReplicationRequest.java index 062f4a0d9a744..eef72246b4ba2 100644 --- a/server/src/main/java/org/opensearch/action/resync/ResyncReplicationRequest.java +++ b/server/src/main/java/org/opensearch/action/resync/ResyncReplicationRequest.java @@ -31,6 +31,7 @@ package org.opensearch.action.resync; +import org.opensearch.LegacyESVersion; import org.opensearch.Version; import org.opensearch.action.index.IndexRequest; import org.opensearch.action.support.replication.ReplicatedWriteRequest; @@ -56,7 +57,7 @@ public final class ResyncReplicationRequest extends ReplicatedWriteRequest searchPhaseResults, Version version) { - boolean includeContextUUID = version.onOrAfter(Version.V_7_7_0); + boolean includeContextUUID = version.onOrAfter(LegacyESVersion.V_7_7_0); try (RAMOutputStream out = new RAMOutputStream()) { if (includeContextUUID) { out.writeString(INCLUDE_CONTEXT_UUID); diff --git a/server/src/main/java/org/opensearch/action/support/IndicesOptions.java b/server/src/main/java/org/opensearch/action/support/IndicesOptions.java index 178a0e25abe76..3f752723fd7d1 100644 --- a/server/src/main/java/org/opensearch/action/support/IndicesOptions.java +++ b/server/src/main/java/org/opensearch/action/support/IndicesOptions.java @@ -31,8 +31,8 @@ package org.opensearch.action.support; +import org.opensearch.LegacyESVersion; import org.opensearch.OpenSearchParseException; -import org.opensearch.Version; import org.opensearch.common.ParseField; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; @@ -246,12 +246,12 @@ public EnumSet getExpandWildcards() { public void writeIndicesOptions(StreamOutput out) throws IOException { EnumSet