Skip to content

Commit 166612b

Browse files
committed
[Remove] LegacyESVersion.V_7_6_* and V_7_7_* constants
Removes all usages of LegacyESVersion.V_7_6_ and LegacyESVersion.V_7_7_ version constants along with ancient API logic. Signed-off-by: Nicholas Walter Knize <[email protected]>
1 parent ec34737 commit 166612b

File tree

59 files changed

+216
-652
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+216
-652
lines changed

modules/analysis-common/src/main/java/org/opensearch/analysis/common/CommonAnalysisModulePlugin.java

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
import org.apache.lucene.analysis.tr.TurkishAnalyzer;
125125
import org.apache.lucene.analysis.util.ElisionFilter;
126126
import org.apache.lucene.util.SetOnce;
127-
import org.opensearch.LegacyESVersion;
127+
import org.opensearch.Version;
128128
import org.opensearch.client.Client;
129129
import org.opensearch.cluster.metadata.IndexNameExpressionResolver;
130130
import org.opensearch.cluster.service.ClusterService;
@@ -347,7 +347,12 @@ public Map<String, AnalysisProvider<TokenizerFactory>> getTokenizers() {
347347
tokenizers.put("simple_pattern_split", SimplePatternSplitTokenizerFactory::new);
348348
tokenizers.put("thai", ThaiTokenizerFactory::new);
349349
tokenizers.put("nGram", (IndexSettings indexSettings, Environment environment, String name, Settings settings) -> {
350-
if (indexSettings.getIndexVersionCreated().onOrAfter(LegacyESVersion.V_7_6_0)) {
350+
if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_3_0_0)) {
351+
throw new IllegalArgumentException(
352+
"The [nGram] tokenizer name was deprecated pre 1.0. "
353+
+ "Please use the tokenizer name to [ngram] for indices created in versions 3.0 or higher instead."
354+
);
355+
} else {
351356
deprecationLogger.deprecate(
352357
"nGram_tokenizer_deprecation",
353358
"The [nGram] tokenizer name is deprecated and will be removed in a future version. "
@@ -358,7 +363,12 @@ public Map<String, AnalysisProvider<TokenizerFactory>> getTokenizers() {
358363
});
359364
tokenizers.put("ngram", NGramTokenizerFactory::new);
360365
tokenizers.put("edgeNGram", (IndexSettings indexSettings, Environment environment, String name, Settings settings) -> {
361-
if (indexSettings.getIndexVersionCreated().onOrAfter(LegacyESVersion.V_7_6_0)) {
366+
if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_3_0_0)) {
367+
throw new IllegalArgumentException(
368+
"The [edgeNGram] tokenizer name was deprecated pre 1.0. "
369+
+ "Please use the tokenizer name to [edge_ngram] for indices created in versions 3.0 or higher instead."
370+
);
371+
} else {
362372
deprecationLogger.deprecate(
363373
"edgeNGram_tokenizer_deprecation",
364374
"The [edgeNGram] tokenizer name is deprecated and will be removed in a future version. "
@@ -606,7 +616,12 @@ public List<PreConfiguredTokenizer> getPreConfiguredTokenizers() {
606616

607617
// Temporary shim for aliases. TODO deprecate after they are moved
608618
tokenizers.add(PreConfiguredTokenizer.openSearchVersion("nGram", (version) -> {
609-
if (version.onOrAfter(LegacyESVersion.V_7_6_0)) {
619+
if (version.onOrAfter(Version.V_3_0_0)) {
620+
throw new IllegalArgumentException(
621+
"The [nGram] tokenizer name was deprecated pre 1.0. "
622+
+ "Please use the tokenizer name to [ngram] for indices created in versions 3.0 or higher instead."
623+
);
624+
} else {
610625
deprecationLogger.deprecate(
611626
"nGram_tokenizer_deprecation",
612627
"The [nGram] tokenizer name is deprecated and will be removed in a future version. "
@@ -616,7 +631,12 @@ public List<PreConfiguredTokenizer> getPreConfiguredTokenizers() {
616631
return new NGramTokenizer();
617632
}));
618633
tokenizers.add(PreConfiguredTokenizer.openSearchVersion("edgeNGram", (version) -> {
619-
if (version.onOrAfter(LegacyESVersion.V_7_6_0)) {
634+
if (version.onOrAfter(Version.V_3_0_0)) {
635+
throw new IllegalArgumentException(
636+
"The [edgeNGram] tokenizer name was deprecated pre 1.0. "
637+
+ "Please use the tokenizer name to [edge_ngram] for indices created in versions 3.0 or higher instead."
638+
);
639+
} else {
620640
deprecationLogger.deprecate(
621641
"edgeNGram_tokenizer_deprecation",
622642
"The [edgeNGram] tokenizer name is deprecated and will be removed in a future version. "

modules/analysis-common/src/main/java/org/opensearch/analysis/common/ConcatenateGraphTokenFilterFactory.java

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import org.apache.lucene.analysis.TokenStream;
1212
import org.apache.lucene.analysis.miscellaneous.ConcatenateGraphFilter;
1313
import org.apache.lucene.util.automaton.TooComplexToDeterminizeException;
14-
import org.opensearch.LegacyESVersion;
1514
import org.opensearch.common.settings.Settings;
1615
import org.opensearch.env.Environment;
1716
import org.opensearch.index.IndexSettings;
@@ -24,11 +23,6 @@
2423
* max_graph_expansions is 100 as the default value of 10_000 seems to be unnecessarily large and preserve_separator is false.
2524
*
2625
* <ul>
27-
* <li>preserve_separator:
28-
* For LegacyESVersion lesser than {@link LegacyESVersion#V_7_6_0} i.e. lucene versions lesser
29-
* than {@link org.apache.lucene.util.Version#LUCENE_8_4_0}
30-
* Whether {@link ConcatenateGraphFilter#SEP_LABEL} should separate the input tokens in the concatenated token.
31-
* </li>
3226
* <li>token_separator:
3327
* Separator to use for concatenation. Must be a String with a single character or empty.
3428
* If not present, {@link ConcatenateGraphTokenFilterFactory#DEFAULT_TOKEN_SEPARATOR} will be used.
@@ -59,17 +53,11 @@ public class ConcatenateGraphTokenFilterFactory extends AbstractTokenFilterFacto
5953
ConcatenateGraphTokenFilterFactory(IndexSettings indexSettings, Environment environment, String name, Settings settings) {
6054
super(indexSettings, name, settings);
6155

62-
if (indexSettings.getIndexVersionCreated().onOrAfter(LegacyESVersion.V_7_6_0)) { // i.e. Lucene 8.4.0
63-
String separator = settings.get("token_separator", DEFAULT_TOKEN_SEPARATOR);
64-
if (separator.length() > 1) {
65-
throw new IllegalArgumentException("token_separator must be either empty or a single character");
66-
}
67-
tokenSeparator = separator.length() == 0 ? null : separator.charAt(0); // null means no separator while concatenating
68-
} else {
69-
boolean preserveSep = settings.getAsBoolean("preserve_separator", ConcatenateGraphFilter.DEFAULT_PRESERVE_SEP);
70-
tokenSeparator = preserveSep ? ConcatenateGraphFilter.DEFAULT_TOKEN_SEPARATOR : null;
56+
String separator = settings.get("token_separator", DEFAULT_TOKEN_SEPARATOR);
57+
if (separator.length() > 1) {
58+
throw new IllegalArgumentException("token_separator must be either empty or a single character");
7159
}
72-
60+
tokenSeparator = separator.length() == 0 ? null : separator.charAt(0); // null means no separator while concatenating
7361
maxGraphExpansions = settings.getAsInt("max_graph_expansions", DEFAULT_MAX_GRAPH_EXPANSIONS);
7462
preservePositionIncrements = settings.getAsBoolean("preserve_position_increments", DEFAULT_PRESERVE_POSITION_INCREMENTS);
7563
}

modules/geo/src/main/java/org/opensearch/geo/search/aggregations/bucket/composite/GeoTileGridValuesSourceBuilder.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
package org.opensearch.geo.search.aggregations.bucket.composite;
3434

3535
import org.apache.lucene.index.IndexReader;
36-
import org.opensearch.LegacyESVersion;
3736
import org.opensearch.common.ParseField;
3837
import org.opensearch.common.geo.GeoBoundingBox;
3938
import org.opensearch.common.geo.GeoPoint;
@@ -175,9 +174,7 @@ public static void register(ValuesSourceRegistry.Builder builder) {
175174
public GeoTileGridValuesSourceBuilder(StreamInput in) throws IOException {
176175
super(in);
177176
this.precision = in.readInt();
178-
if (in.getVersion().onOrAfter(LegacyESVersion.V_7_6_0)) {
179-
this.geoBoundingBox = new GeoBoundingBox(in);
180-
}
177+
this.geoBoundingBox = new GeoBoundingBox(in);
181178
}
182179

183180
public GeoTileGridValuesSourceBuilder precision(int precision) {
@@ -198,9 +195,7 @@ public GeoTileGridValuesSourceBuilder format(String format) {
198195
@Override
199196
protected void innerWriteTo(StreamOutput out) throws IOException {
200197
out.writeInt(precision);
201-
if (out.getVersion().onOrAfter(LegacyESVersion.V_7_6_0)) {
202-
geoBoundingBox.writeTo(out);
203-
}
198+
geoBoundingBox.writeTo(out);
204199
}
205200

206201
@Override

modules/geo/src/main/java/org/opensearch/geo/search/aggregations/bucket/geogrid/GeoGridAggregationBuilder.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
package org.opensearch.geo.search.aggregations.bucket.geogrid;
3434

35-
import org.opensearch.LegacyESVersion;
3635
import org.opensearch.OpenSearchException;
3736
import org.opensearch.common.ParseField;
3837
import org.opensearch.common.geo.GeoBoundingBox;
@@ -125,9 +124,7 @@ public GeoGridAggregationBuilder(StreamInput in) throws IOException {
125124
precision = in.readVInt();
126125
requiredSize = in.readVInt();
127126
shardSize = in.readVInt();
128-
if (in.getVersion().onOrAfter(LegacyESVersion.V_7_6_0)) {
129-
geoBoundingBox = new GeoBoundingBox(in);
130-
}
127+
geoBoundingBox = new GeoBoundingBox(in);
131128
}
132129

133130
@Override
@@ -140,9 +137,7 @@ protected void innerWriteTo(StreamOutput out) throws IOException {
140137
out.writeVInt(precision);
141138
out.writeVInt(requiredSize);
142139
out.writeVInt(shardSize);
143-
if (out.getVersion().onOrAfter(LegacyESVersion.V_7_6_0)) {
144-
geoBoundingBox.writeTo(out);
145-
}
140+
geoBoundingBox.writeTo(out);
146141
}
147142

148143
/**

modules/rank-eval/src/main/java/org/opensearch/index/rankeval/RankEvalRequest.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
package org.opensearch.index.rankeval;
3434

35-
import org.opensearch.LegacyESVersion;
3635
import org.opensearch.action.ActionRequest;
3736
import org.opensearch.action.ActionRequestValidationException;
3837
import org.opensearch.action.IndicesRequest;
@@ -69,9 +68,7 @@ public RankEvalRequest(RankEvalSpec rankingEvaluationSpec, String[] indices) {
6968
rankingEvaluationSpec = new RankEvalSpec(in);
7069
indices = in.readStringArray();
7170
indicesOptions = IndicesOptions.readIndicesOptions(in);
72-
if (in.getVersion().onOrAfter(LegacyESVersion.V_7_6_0)) {
73-
searchType = SearchType.fromId(in.readByte());
74-
}
71+
searchType = SearchType.fromId(in.readByte());
7572
}
7673

7774
RankEvalRequest() {}
@@ -150,9 +147,7 @@ public void writeTo(StreamOutput out) throws IOException {
150147
rankingEvaluationSpec.writeTo(out);
151148
out.writeStringArray(indices);
152149
indicesOptions.writeIndicesOptions(out);
153-
if (out.getVersion().onOrAfter(LegacyESVersion.V_7_6_0)) {
154-
out.writeByte(searchType.id());
155-
}
150+
out.writeByte(searchType.id());
156151
}
157152

158153
@Override

qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/RecoveryIT.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -764,12 +764,8 @@ public void testAutoExpandIndicesDuringRollingUpgrade() throws Exception {
764764

765765
final int numberOfReplicas = Integer.parseInt(
766766
getIndexSettingsAsMap(indexName).get(IndexMetadata.SETTING_NUMBER_OF_REPLICAS).toString());
767-
if (minimumNodeVersion.onOrAfter(LegacyESVersion.V_7_6_0)) {
768-
assertEquals(nodes.size() - 2, numberOfReplicas);
769-
ensureGreen(indexName);
770-
} else {
771-
assertEquals(nodes.size() - 1, numberOfReplicas);
772-
}
767+
assertEquals(nodes.size() - 2, numberOfReplicas);
768+
ensureGreen(indexName);
773769
}
774770

775771
public void testSoftDeletesDisabledWarning() throws Exception {

server/src/main/java/org/opensearch/LegacyESVersion.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@
4848
*/
4949
public class LegacyESVersion extends Version {
5050

51-
public static final LegacyESVersion V_7_6_0 = new LegacyESVersion(7060099, org.apache.lucene.util.Version.LUCENE_8_4_0);
52-
public static final LegacyESVersion V_7_6_1 = new LegacyESVersion(7060199, org.apache.lucene.util.Version.LUCENE_8_4_0);
53-
public static final LegacyESVersion V_7_6_2 = new LegacyESVersion(7060299, org.apache.lucene.util.Version.LUCENE_8_4_0);
54-
public static final LegacyESVersion V_7_7_0 = new LegacyESVersion(7070099, org.apache.lucene.util.Version.LUCENE_8_5_1);
55-
public static final LegacyESVersion V_7_7_1 = new LegacyESVersion(7070199, org.apache.lucene.util.Version.LUCENE_8_5_1);
5651
public static final LegacyESVersion V_7_8_0 = new LegacyESVersion(7080099, org.apache.lucene.util.Version.LUCENE_8_5_1);
5752
public static final LegacyESVersion V_7_8_1 = new LegacyESVersion(7080199, org.apache.lucene.util.Version.LUCENE_8_5_1);
5853
public static final LegacyESVersion V_7_9_0 = new LegacyESVersion(7090099, org.apache.lucene.util.Version.LUCENE_8_6_0);

server/src/main/java/org/opensearch/action/admin/cluster/node/info/NodesInfoRequest.java

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
package org.opensearch.action.admin.cluster.node.info;
3434

35-
import org.opensearch.LegacyESVersion;
3635
import org.opensearch.action.support.nodes.BaseNodesRequest;
3736
import org.opensearch.common.io.stream.StreamInput;
3837
import org.opensearch.common.io.stream.StreamOutput;
@@ -63,22 +62,7 @@ public class NodesInfoRequest extends BaseNodesRequest<NodesInfoRequest> {
6362
public NodesInfoRequest(StreamInput in) throws IOException {
6463
super(in);
6564
requestedMetrics.clear();
66-
if (in.getVersion().before(LegacyESVersion.V_7_7_0)) {
67-
// prior to version 8.x, a NodesInfoRequest was serialized as a list
68-
// of booleans in a fixed order
69-
optionallyAddMetric(in.readBoolean(), Metric.SETTINGS.metricName());
70-
optionallyAddMetric(in.readBoolean(), Metric.OS.metricName());
71-
optionallyAddMetric(in.readBoolean(), Metric.PROCESS.metricName());
72-
optionallyAddMetric(in.readBoolean(), Metric.JVM.metricName());
73-
optionallyAddMetric(in.readBoolean(), Metric.THREAD_POOL.metricName());
74-
optionallyAddMetric(in.readBoolean(), Metric.TRANSPORT.metricName());
75-
optionallyAddMetric(in.readBoolean(), Metric.HTTP.metricName());
76-
optionallyAddMetric(in.readBoolean(), Metric.PLUGINS.metricName());
77-
optionallyAddMetric(in.readBoolean(), Metric.INGEST.metricName());
78-
optionallyAddMetric(in.readBoolean(), Metric.INDICES.metricName());
79-
} else {
80-
requestedMetrics.addAll(Arrays.asList(in.readStringArray()));
81-
}
65+
requestedMetrics.addAll(Arrays.asList(in.readStringArray()));
8266
}
8367

8468
/**
@@ -165,22 +149,7 @@ private void optionallyAddMetric(boolean addMetric, String metricName) {
165149
@Override
166150
public void writeTo(StreamOutput out) throws IOException {
167151
super.writeTo(out);
168-
if (out.getVersion().before(LegacyESVersion.V_7_7_0)) {
169-
// prior to version 8.x, a NodesInfoRequest was serialized as a list
170-
// of booleans in a fixed order
171-
out.writeBoolean(Metric.SETTINGS.containedIn(requestedMetrics));
172-
out.writeBoolean(Metric.OS.containedIn(requestedMetrics));
173-
out.writeBoolean(Metric.PROCESS.containedIn(requestedMetrics));
174-
out.writeBoolean(Metric.JVM.containedIn(requestedMetrics));
175-
out.writeBoolean(Metric.THREAD_POOL.containedIn(requestedMetrics));
176-
out.writeBoolean(Metric.TRANSPORT.containedIn(requestedMetrics));
177-
out.writeBoolean(Metric.HTTP.containedIn(requestedMetrics));
178-
out.writeBoolean(Metric.PLUGINS.containedIn(requestedMetrics));
179-
out.writeBoolean(Metric.INGEST.containedIn(requestedMetrics));
180-
out.writeBoolean(Metric.INDICES.containedIn(requestedMetrics));
181-
} else {
182-
out.writeStringArray(requestedMetrics.toArray(new String[0]));
183-
}
152+
out.writeStringArray(requestedMetrics.toArray(new String[0]));
184153
}
185154

186155
/**

server/src/main/java/org/opensearch/action/admin/cluster/node/reload/NodesReloadSecureSettingsRequest.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
package org.opensearch.action.admin.cluster.node.reload;
3434

35-
import org.opensearch.LegacyESVersion;
3635
import org.opensearch.action.support.nodes.BaseNodesRequest;
3736
import org.opensearch.common.io.stream.StreamInput;
3837

@@ -68,18 +67,16 @@ public NodesReloadSecureSettingsRequest() {
6867

6968
public NodesReloadSecureSettingsRequest(StreamInput in) throws IOException {
7069
super(in);
71-
if (in.getVersion().onOrAfter(LegacyESVersion.V_7_7_0)) {
72-
final BytesReference bytesRef = in.readOptionalBytesReference();
73-
if (bytesRef != null) {
74-
byte[] bytes = BytesReference.toBytes(bytesRef);
75-
try {
76-
this.secureSettingsPassword = new SecureString(CharArrays.utf8BytesToChars(bytes));
77-
} finally {
78-
Arrays.fill(bytes, (byte) 0);
79-
}
80-
} else {
81-
this.secureSettingsPassword = null;
70+
final BytesReference bytesRef = in.readOptionalBytesReference();
71+
if (bytesRef != null) {
72+
byte[] bytes = BytesReference.toBytes(bytesRef);
73+
try {
74+
this.secureSettingsPassword = new SecureString(CharArrays.utf8BytesToChars(bytes));
75+
} finally {
76+
Arrays.fill(bytes, (byte) 0);
8277
}
78+
} else {
79+
this.secureSettingsPassword = null;
8380
}
8481
}
8582

server/src/main/java/org/opensearch/action/admin/cluster/node/stats/NodesStatsRequest.java

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
package org.opensearch.action.admin.cluster.node.stats;
3434

35-
import org.opensearch.LegacyESVersion;
3635
import org.opensearch.action.admin.indices.stats.CommonStatsFlags;
3736
import org.opensearch.action.support.nodes.BaseNodesRequest;
3837
import org.opensearch.common.io.stream.StreamInput;
@@ -64,22 +63,7 @@ public NodesStatsRequest(StreamInput in) throws IOException {
6463

6564
indices = new CommonStatsFlags(in);
6665
requestedMetrics.clear();
67-
if (in.getVersion().before(LegacyESVersion.V_7_7_0)) {
68-
optionallyAddMetric(in.readBoolean(), Metric.OS.metricName());
69-
optionallyAddMetric(in.readBoolean(), Metric.PROCESS.metricName());
70-
optionallyAddMetric(in.readBoolean(), Metric.JVM.metricName());
71-
optionallyAddMetric(in.readBoolean(), Metric.THREAD_POOL.metricName());
72-
optionallyAddMetric(in.readBoolean(), Metric.FS.metricName());
73-
optionallyAddMetric(in.readBoolean(), Metric.TRANSPORT.metricName());
74-
optionallyAddMetric(in.readBoolean(), Metric.HTTP.metricName());
75-
optionallyAddMetric(in.readBoolean(), Metric.BREAKER.metricName());
76-
optionallyAddMetric(in.readBoolean(), Metric.SCRIPT.metricName());
77-
optionallyAddMetric(in.readBoolean(), Metric.DISCOVERY.metricName());
78-
optionallyAddMetric(in.readBoolean(), Metric.INGEST.metricName());
79-
optionallyAddMetric(in.readBoolean(), Metric.ADAPTIVE_SELECTION.metricName());
80-
} else {
81-
requestedMetrics.addAll(in.readStringList());
82-
}
66+
requestedMetrics.addAll(in.readStringList());
8367
}
8468

8569
/**
@@ -200,22 +184,7 @@ private void optionallyAddMetric(boolean includeMetric, String metricName) {
200184
public void writeTo(StreamOutput out) throws IOException {
201185
super.writeTo(out);
202186
indices.writeTo(out);
203-
if (out.getVersion().before(LegacyESVersion.V_7_7_0)) {
204-
out.writeBoolean(Metric.OS.containedIn(requestedMetrics));
205-
out.writeBoolean(Metric.PROCESS.containedIn(requestedMetrics));
206-
out.writeBoolean(Metric.JVM.containedIn(requestedMetrics));
207-
out.writeBoolean(Metric.THREAD_POOL.containedIn(requestedMetrics));
208-
out.writeBoolean(Metric.FS.containedIn(requestedMetrics));
209-
out.writeBoolean(Metric.TRANSPORT.containedIn(requestedMetrics));
210-
out.writeBoolean(Metric.HTTP.containedIn(requestedMetrics));
211-
out.writeBoolean(Metric.BREAKER.containedIn(requestedMetrics));
212-
out.writeBoolean(Metric.SCRIPT.containedIn(requestedMetrics));
213-
out.writeBoolean(Metric.DISCOVERY.containedIn(requestedMetrics));
214-
out.writeBoolean(Metric.INGEST.containedIn(requestedMetrics));
215-
out.writeBoolean(Metric.ADAPTIVE_SELECTION.containedIn(requestedMetrics));
216-
} else {
217-
out.writeStringArray(requestedMetrics.toArray(new String[0]));
218-
}
187+
out.writeStringArray(requestedMetrics.toArray(new String[0]));
219188
}
220189

221190
/**

0 commit comments

Comments
 (0)