Skip to content

Commit 8e5812c

Browse files
authored
remove v6.5.x and v6.6.x version constants (#42130)
related to refactoring initiative #41164.
1 parent 9ffed17 commit 8e5812c

File tree

46 files changed

+96
-451
lines changed

Some content is hidden

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

46 files changed

+96
-451
lines changed

qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ public void testSoftDeletes() throws Exception {
917917
mappingsAndSettings.startObject("settings");
918918
mappingsAndSettings.field("number_of_shards", 1);
919919
mappingsAndSettings.field("number_of_replicas", 1);
920-
if (getOldClusterVersion().onOrAfter(Version.V_6_5_0) && randomBoolean()) {
920+
if (randomBoolean()) {
921921
mappingsAndSettings.field("soft_deletes.enabled", true);
922922
}
923923
mappingsAndSettings.endObject();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ public void testRecoveryWithSoftDeletes() throws Exception {
356356
// before timing out
357357
.put(INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "100ms")
358358
.put(SETTING_ALLOCATION_MAX_RETRY.getKey(), "0"); // fail faster
359-
if (getNodeId(v -> v.onOrAfter(Version.V_6_5_0)) != null && randomBoolean()) {
359+
if (randomBoolean()) {
360360
settings.put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true);
361361
}
362362
createIndex(index, settings.build());

server/src/main/java/org/elasticsearch/Version.java

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,6 @@ public class Version implements Comparable<Version>, ToXContentFragment {
4646
*/
4747
public static final int V_EMPTY_ID = 0;
4848
public static final Version V_EMPTY = new Version(V_EMPTY_ID, org.apache.lucene.util.Version.LATEST);
49-
public static final int V_6_5_0_ID = 6050099;
50-
public static final Version V_6_5_0 = new Version(V_6_5_0_ID, org.apache.lucene.util.Version.LUCENE_7_5_0);
51-
public static final int V_6_5_1_ID = 6050199;
52-
public static final Version V_6_5_1 = new Version(V_6_5_1_ID, org.apache.lucene.util.Version.LUCENE_7_5_0);
53-
public static final int V_6_5_2_ID = 6050299;
54-
public static final Version V_6_5_2 = new Version(V_6_5_2_ID, org.apache.lucene.util.Version.LUCENE_7_5_0);
55-
public static final int V_6_5_3_ID = 6050399;
56-
public static final Version V_6_5_3 = new Version(V_6_5_3_ID, org.apache.lucene.util.Version.LUCENE_7_5_0);
57-
public static final int V_6_5_4_ID = 6050499;
58-
public static final Version V_6_5_4 = new Version(V_6_5_4_ID, org.apache.lucene.util.Version.LUCENE_7_5_0);
59-
public static final int V_6_6_0_ID = 6060099;
60-
public static final Version V_6_6_0 = new Version(V_6_6_0_ID, org.apache.lucene.util.Version.LUCENE_7_6_0);
61-
public static final int V_6_6_1_ID = 6060199;
62-
public static final Version V_6_6_1 = new Version(V_6_6_1_ID, org.apache.lucene.util.Version.LUCENE_7_6_0);
63-
public static final int V_6_6_2_ID = 6060299;
64-
public static final Version V_6_6_2 = new Version(V_6_6_2_ID, org.apache.lucene.util.Version.LUCENE_7_6_0);
6549
public static final int V_6_8_0_ID = 6080099;
6650
public static final Version V_6_8_0 = new Version(V_6_8_0_ID, org.apache.lucene.util.Version.LUCENE_7_7_0);
6751
public static final int V_6_8_1_ID = 6080199;
@@ -116,22 +100,6 @@ public static Version fromId(int id) {
116100
return V_6_8_1;
117101
case V_6_8_0_ID:
118102
return V_6_8_0;
119-
case V_6_6_2_ID:
120-
return V_6_6_2;
121-
case V_6_6_1_ID:
122-
return V_6_6_1;
123-
case V_6_6_0_ID:
124-
return V_6_6_0;
125-
case V_6_5_4_ID:
126-
return V_6_5_4;
127-
case V_6_5_3_ID:
128-
return V_6_5_3;
129-
case V_6_5_2_ID:
130-
return V_6_5_2;
131-
case V_6_5_1_ID:
132-
return V_6_5_1;
133-
case V_6_5_0_ID:
134-
return V_6_5_0;
135103
case V_EMPTY_ID:
136104
return V_EMPTY;
137105
default:

server/src/main/java/org/elasticsearch/cluster/coordination/ClusterFormationFailureHelper.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import org.apache.logging.log4j.LogManager;
2222
import org.apache.logging.log4j.Logger;
23-
import org.elasticsearch.Version;
2423
import org.elasticsearch.cluster.ClusterState;
2524
import org.elasticsearch.cluster.coordination.CoordinationMetaData.VotingConfiguration;
2625
import org.elasticsearch.cluster.coordination.CoordinationState.VoteCollection;
@@ -150,8 +149,6 @@ String getDescription() {
150149

151150
if (clusterState.getLastAcceptedConfiguration().isEmpty()) {
152151

153-
// TODO handle the case that there is a 6.x node around here, when rolling upgrades are supported
154-
155152
final String bootstrappingDescription;
156153

157154
if (INITIAL_MASTER_NODES_SETTING.get(Settings.EMPTY).equals(INITIAL_MASTER_NODES_SETTING.get(settings))) {
@@ -164,8 +161,8 @@ String getDescription() {
164161
}
165162

166163
return String.format(Locale.ROOT,
167-
"master not discovered yet, this node has not previously joined a bootstrapped (v%d+) cluster, and %s: %s",
168-
Version.V_6_6_0.major + 1, bootstrappingDescription, discoveryStateIgnoringQuorum);
164+
"master not discovered yet, this node has not previously joined a bootstrapped cluster, and %s: %s",
165+
bootstrappingDescription, discoveryStateIgnoringQuorum);
169166
}
170167

171168
assert clusterState.getLastCommittedConfiguration().isEmpty() == false;

server/src/main/java/org/elasticsearch/cluster/metadata/IndexMetaData.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,10 +1408,10 @@ public static IndexMetaData fromXContent(XContentParser parser) throws IOExcepti
14081408
throw new IllegalArgumentException("Unexpected token " + token);
14091409
}
14101410
}
1411-
if (Assertions.ENABLED && Version.indexCreated(builder.settings).onOrAfter(Version.V_6_5_0)) {
1411+
if (Assertions.ENABLED) {
14121412
assert mappingVersion : "mapping version should be present for indices created on or after 6.5.0";
14131413
}
1414-
if (Assertions.ENABLED && Version.indexCreated(builder.settings).onOrAfter(Version.V_6_5_0)) {
1414+
if (Assertions.ENABLED) {
14151415
assert settingsVersion : "settings version should be present for indices created on or after 6.5.0";
14161416
}
14171417
if (Assertions.ENABLED && Version.indexCreated(builder.settings).onOrAfter(Version.V_7_2_0)) {

server/src/main/java/org/elasticsearch/index/IndexService.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.apache.lucene.store.Directory;
2727
import org.apache.lucene.util.Accountable;
2828
import org.elasticsearch.Assertions;
29-
import org.elasticsearch.Version;
3029
import org.elasticsearch.client.Client;
3130
import org.elasticsearch.cluster.metadata.IndexMetaData;
3231
import org.elasticsearch.cluster.routing.ShardRouting;
@@ -660,9 +659,7 @@ public IndexMetaData getMetaData() {
660659
public synchronized void updateMetaData(final IndexMetaData currentIndexMetaData, final IndexMetaData newIndexMetaData) {
661660
final boolean updateIndexMetaData = indexSettings.updateIndexMetaData(newIndexMetaData);
662661

663-
if (Assertions.ENABLED
664-
&& currentIndexMetaData != null
665-
&& currentIndexMetaData.getCreationVersion().onOrAfter(Version.V_6_5_0)) {
662+
if (Assertions.ENABLED && currentIndexMetaData != null) {
666663
final long currentSettingsVersion = currentIndexMetaData.getSettingsVersion();
667664
final long newSettingsVersion = newIndexMetaData.getSettingsVersion();
668665
if (currentSettingsVersion == newSettingsVersion) {

server/src/main/java/org/elasticsearch/index/IndexSettings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ public IndexSettings(final IndexMetaData indexMetaData, final Settings nodeSetti
458458
generationThresholdSize = scopedSettings.get(INDEX_TRANSLOG_GENERATION_THRESHOLD_SIZE_SETTING);
459459
mergeSchedulerConfig = new MergeSchedulerConfig(this);
460460
gcDeletesInMillis = scopedSettings.get(INDEX_GC_DELETES_SETTING).getMillis();
461-
softDeleteEnabled = version.onOrAfter(Version.V_6_5_0) && scopedSettings.get(INDEX_SOFT_DELETES_SETTING);
461+
softDeleteEnabled = scopedSettings.get(INDEX_SOFT_DELETES_SETTING);
462462
softDeleteRetentionOperations = scopedSettings.get(INDEX_SOFT_DELETES_RETENTION_OPERATIONS_SETTING);
463463
retentionLeaseMillis = scopedSettings.get(INDEX_SOFT_DELETES_RETENTION_LEASE_PERIOD_SETTING).millis();
464464
warmerEnabled = scopedSettings.get(INDEX_WARMER_ENABLED_SETTING);

server/src/main/java/org/elasticsearch/index/mapper/BaseGeoShapeFieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public Mapper.Builder parse(String name, Map<String, Object> node, ParserContext
190190
}
191191
}
192192
final Builder builder;
193-
if (parsedDeprecatedParams || parserContext.indexVersionCreated().before(Version.V_6_6_0)) {
193+
if (parsedDeprecatedParams) {
194194
// Legacy index-based shape
195195
builder = new LegacyGeoShapeFieldMapper.Builder(name, deprecatedParameters);
196196
} else {

server/src/main/java/org/elasticsearch/index/mapper/LegacyGeoShapeFieldMapper.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,6 @@ private void setupFieldTypeDeprecatedParameters(BuilderContext context) {
208208
}
209209
if (deprecatedParameters.tree != null) {
210210
ft.setTree(deprecatedParameters.tree);
211-
} else if (context.indexCreatedVersion().before(Version.V_6_6_0)) {
212-
ft.setTree(DeprecatedParameters.PrefixTrees.GEOHASH);
213211
}
214212
if (deprecatedParameters.treeLevels != null) {
215213
ft.setTreeLevels(deprecatedParameters.treeLevels);
@@ -527,8 +525,7 @@ protected void doXContentBody(XContentBuilder builder, boolean includeDefaults,
527525
super.doXContentBody(builder, includeDefaults, params);
528526

529527
if (includeDefaults
530-
|| (fieldType().tree().equals(indexCreatedVersion.onOrAfter(Version.V_6_6_0) ?
531-
DeprecatedParameters.Defaults.TREE : DeprecatedParameters.PrefixTrees.GEOHASH)) == false) {
528+
|| (fieldType().tree().equals(DeprecatedParameters.Defaults.TREE)) == false) {
532529
builder.field(DeprecatedParameters.Names.TREE.getPreferredName(), fieldType().tree());
533530
}
534531

server/src/main/java/org/elasticsearch/index/mapper/MapperService.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,7 @@ private void assertMappingVersion(
260260
final IndexMetaData currentIndexMetaData,
261261
final IndexMetaData newIndexMetaData,
262262
final Map<String, DocumentMapper> updatedEntries) {
263-
if (Assertions.ENABLED
264-
&& currentIndexMetaData != null
265-
&& currentIndexMetaData.getCreationVersion().onOrAfter(Version.V_6_5_0)) {
263+
if (Assertions.ENABLED && currentIndexMetaData != null) {
266264
if (currentIndexMetaData.getMappingVersion() == newIndexMetaData.getMappingVersion()) {
267265
// if the mapping version is unchanged, then there should not be any updates and all mappings should be the same
268266
assert updatedEntries.isEmpty() : updatedEntries;

server/src/main/java/org/elasticsearch/index/mapper/ParseContext.java

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.apache.lucene.document.Field;
2525
import org.apache.lucene.index.IndexableField;
2626
import org.apache.lucene.util.BytesRef;
27-
import org.elasticsearch.Version;
2827
import org.elasticsearch.common.xcontent.XContentParser;
2928
import org.elasticsearch.index.IndexSettings;
3029

@@ -458,18 +457,10 @@ public Iterable<Document> nonRootDocuments() {
458457
void postParse() {
459458
if (documents.size() > 1) {
460459
docsReversed = true;
461-
if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_6_5_0)) {
462-
/**
463-
* For indices created on or after {@link Version#V_6_5_0} we preserve the order
464-
* of the children while ensuring that parents appear after them.
465-
*/
466-
List<Document> newDocs = reorderParent(documents);
467-
documents.clear();
468-
documents.addAll(newDocs);
469-
} else {
470-
// reverse the order of docs for nested docs support, parent should be last
471-
Collections.reverse(documents);
472-
}
460+
// We preserve the order of the children while ensuring that parents appear after them.
461+
List<Document> newDocs = reorderParent(documents);
462+
documents.clear();
463+
documents.addAll(newDocs);
473464
}
474465
}
475466

server/src/main/java/org/elasticsearch/index/similarity/SimilarityService.java

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,8 @@ private static void validateScoresArePositive(Version indexCreatedVersion, Simil
212212
for (int freq = 1; freq <= 10; ++freq) {
213213
float score = scorer.score(freq, norm);
214214
if (score < 0) {
215-
fail(indexCreatedVersion, "Similarities should not return negative scores:\n" +
216-
scorer.explain(Explanation.match(freq, "term freq"), norm));
217-
break;
215+
throw new IllegalArgumentException("Similarities should not return negative scores:\n" +
216+
scorer.explain(Explanation.match(freq, "term freq"), norm));
218217
}
219218
}
220219
}
@@ -230,10 +229,9 @@ private static void validateScoresDoNotDecreaseWithFreq(Version indexCreatedVers
230229
for (int freq = 1; freq <= 10; ++freq) {
231230
float score = scorer.score(freq, norm);
232231
if (score < previousScore) {
233-
fail(indexCreatedVersion, "Similarity scores should not decrease when term frequency increases:\n" +
234-
scorer.explain(Explanation.match(freq - 1, "term freq"), norm) + "\n" +
235-
scorer.explain(Explanation.match(freq, "term freq"), norm));
236-
break;
232+
throw new IllegalArgumentException("Similarity scores should not decrease when term frequency increases:\n" +
233+
scorer.explain(Explanation.match(freq - 1, "term freq"), norm) + "\n" +
234+
scorer.explain(Explanation.match(freq, "term freq"), norm));
237235
}
238236
previousScore = score;
239237
}
@@ -256,22 +254,12 @@ private static void validateScoresDoNotIncreaseWithNorm(Version indexCreatedVers
256254
}
257255
float score = scorer.score(1, norm);
258256
if (score > previousScore) {
259-
fail(indexCreatedVersion, "Similarity scores should not increase when norm increases:\n" +
260-
scorer.explain(Explanation.match(1, "term freq"), norm - 1) + "\n" +
261-
scorer.explain(Explanation.match(1, "term freq"), norm));
262-
break;
257+
throw new IllegalArgumentException("Similarity scores should not increase when norm increases:\n" +
258+
scorer.explain(Explanation.match(1, "term freq"), norm - 1) + "\n" +
259+
scorer.explain(Explanation.match(1, "term freq"), norm));
263260
}
264261
previousScore = score;
265262
previousNorm = norm;
266263
}
267264
}
268-
269-
private static void fail(Version indexCreatedVersion, String message) {
270-
if (indexCreatedVersion.onOrAfter(Version.V_7_0_0)) {
271-
throw new IllegalArgumentException(message);
272-
} else if (indexCreatedVersion.onOrAfter(Version.V_6_5_0)) {
273-
deprecationLogger.deprecated(message);
274-
}
275-
}
276-
277265
}

server/src/main/java/org/elasticsearch/search/fetch/FetchPhase.java

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.apache.lucene.search.Weight;
3232
import org.apache.lucene.util.BitSet;
3333
import org.elasticsearch.ExceptionsHelper;
34-
import org.elasticsearch.Version;
3534
import org.elasticsearch.common.bytes.BytesReference;
3635
import org.elasticsearch.common.collect.Tuple;
3736
import org.elasticsearch.common.document.DocumentField;
@@ -383,32 +382,19 @@ private SearchHit.NestedIdentity getInternalNestedIdentity(SearchContext context
383382
BitSet parentBits = context.bitsetFilterCache().getBitSetProducer(parentFilter).getBitSet(subReaderContext);
384383

385384
int offset = 0;
386-
if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_6_5_0)) {
387-
/**
388-
* Starts from the previous parent and finds the offset of the
389-
* <code>nestedSubDocID</code> within the nested children. Nested documents
390-
* are indexed in the same order than in the source array so the offset
391-
* of the nested child is the number of nested document with the same parent
392-
* that appear before him.
393-
*/
394-
int previousParent = parentBits.prevSetBit(currentParent);
395-
for (int docId = childIter.advance(previousParent + 1); docId < nestedSubDocId && docId != DocIdSetIterator.NO_MORE_DOCS;
396-
docId = childIter.nextDoc()) {
397-
offset++;
398-
}
399-
currentParent = nestedSubDocId;
400-
} else {
401-
/**
402-
* Nested documents are in reverse order in this version so we start from the current nested document
403-
* and find the number of documents with the same parent that appear after it.
404-
*/
405-
int nextParent = parentBits.nextSetBit(currentParent);
406-
for (int docId = childIter.advance(currentParent + 1); docId < nextParent && docId != DocIdSetIterator.NO_MORE_DOCS;
407-
docId = childIter.nextDoc()) {
408-
offset++;
409-
}
410-
currentParent = nextParent;
385+
/**
386+
* Starts from the previous parent and finds the offset of the
387+
* <code>nestedSubDocID</code> within the nested children. Nested documents
388+
* are indexed in the same order than in the source array so the offset
389+
* of the nested child is the number of nested document with the same parent
390+
* that appear before him.
391+
*/
392+
int previousParent = parentBits.prevSetBit(currentParent);
393+
for (int docId = childIter.advance(previousParent + 1); docId < nestedSubDocId && docId != DocIdSetIterator.NO_MORE_DOCS;
394+
docId = childIter.nextDoc()) {
395+
offset++;
411396
}
397+
currentParent = nestedSubDocId;
412398
current = nestedObjectMapper = nestedParentObjectMapper;
413399
int currentPrefix = current == null ? 0 : current.name().length() + 1;
414400
nestedIdentity = new SearchHit.NestedIdentity(originalName.substring(currentPrefix), offset, nestedIdentity);

server/src/main/java/org/elasticsearch/search/sort/FieldSortBuilder.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -397,10 +397,6 @@ public SortFieldAndFormat build(QueryShardContext context) throws IOException {
397397
Nested nested = null;
398398
if (isUnmapped == false) {
399399
if (nestedSort != null) {
400-
if (context.indexVersionCreated().before(Version.V_6_5_0) && nestedSort.getMaxChildren() != Integer.MAX_VALUE) {
401-
throw new QueryShardException(context,
402-
"max_children is only supported on v6.5.0 or higher");
403-
}
404400
if (nestedSort.getNestedSort() != null && nestedSort.getMaxChildren() != Integer.MAX_VALUE) {
405401
throw new QueryShardException(context,
406402
"max_children is only supported on last level of nested sort");

server/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortBuilder.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.apache.lucene.search.SortField;
2929
import org.apache.lucene.util.BitSet;
3030
import org.elasticsearch.ElasticsearchParseException;
31-
import org.elasticsearch.Version;
3231
import org.elasticsearch.common.ParseField;
3332
import org.elasticsearch.common.ParsingException;
3433
import org.elasticsearch.common.geo.GeoDistance;
@@ -613,10 +612,6 @@ public SortFieldAndFormat build(QueryShardContext context) throws IOException {
613612

614613
final Nested nested;
615614
if (nestedSort != null) {
616-
if (context.indexVersionCreated().before(Version.V_6_5_0) && nestedSort.getMaxChildren() != Integer.MAX_VALUE) {
617-
throw new QueryShardException(context,
618-
"max_children is only supported on v6.5.0 or higher");
619-
}
620615
if (nestedSort.getNestedSort() != null && nestedSort.getMaxChildren() != Integer.MAX_VALUE) {
621616
throw new QueryShardException(context,
622617
"max_children is only supported on last level of nested sort");

0 commit comments

Comments
 (0)