Skip to content

Commit 581d44d

Browse files
committed
remove backcompat handling of 6.2.x versions
relates to refactoring initiative elastic#41164.
1 parent 8270c80 commit 581d44d

File tree

22 files changed

+76
-230
lines changed

22 files changed

+76
-230
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ private enum ElasticsearchExceptionHandle {
10061006
UNKNOWN_NAMED_OBJECT_EXCEPTION(org.elasticsearch.common.xcontent.UnknownNamedObjectException.class,
10071007
org.elasticsearch.common.xcontent.UnknownNamedObjectException::new, 148, UNKNOWN_VERSION_ADDED),
10081008
TOO_MANY_BUCKETS_EXCEPTION(MultiBucketConsumerService.TooManyBucketsException.class,
1009-
MultiBucketConsumerService.TooManyBucketsException::new, 149, Version.V_6_2_0),
1009+
MultiBucketConsumerService.TooManyBucketsException::new, 149, UNKNOWN_VERSION_ADDED),
10101010
COORDINATION_STATE_REJECTED_EXCEPTION(org.elasticsearch.cluster.coordination.CoordinationStateRejectedException.class,
10111011
org.elasticsearch.cluster.coordination.CoordinationStateRejectedException::new, 150, Version.V_7_0_0),
10121012
SNAPSHOT_IN_PROGRESS_EXCEPTION(org.elasticsearch.snapshots.SnapshotInProgressException.class,

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

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,6 @@ public class Version implements Comparable<Version>, ToXContentFragment {
6464
public static final Version V_6_1_4 = new Version(V_6_1_4_ID, org.apache.lucene.util.Version.LUCENE_7_1_0);
6565
// The below version is missing from the 7.3 JAR
6666
private static final org.apache.lucene.util.Version LUCENE_7_2_1 = org.apache.lucene.util.Version.fromBits(7, 2, 1);
67-
public static final int V_6_2_0_ID = 6020099;
68-
public static final Version V_6_2_0 = new Version(V_6_2_0_ID, LUCENE_7_2_1);
69-
public static final int V_6_2_1_ID = 6020199;
70-
public static final Version V_6_2_1 = new Version(V_6_2_1_ID, LUCENE_7_2_1);
71-
public static final int V_6_2_2_ID = 6020299;
72-
public static final Version V_6_2_2 = new Version(V_6_2_2_ID, LUCENE_7_2_1);
73-
public static final int V_6_2_3_ID = 6020399;
74-
public static final Version V_6_2_3 = new Version(V_6_2_3_ID, LUCENE_7_2_1);
75-
public static final int V_6_2_4_ID = 6020499;
76-
public static final Version V_6_2_4 = new Version(V_6_2_4_ID, LUCENE_7_2_1);
7767
public static final int V_6_3_0_ID = 6030099;
7868
public static final Version V_6_3_0 = new Version(V_6_3_0_ID, org.apache.lucene.util.Version.LUCENE_7_3_1);
7969
public static final int V_6_3_1_ID = 6030199;
@@ -192,16 +182,6 @@ public static Version fromId(int id) {
192182
return V_6_3_1;
193183
case V_6_3_0_ID:
194184
return V_6_3_0;
195-
case V_6_2_4_ID:
196-
return V_6_2_4;
197-
case V_6_2_3_ID:
198-
return V_6_2_3;
199-
case V_6_2_2_ID:
200-
return V_6_2_2;
201-
case V_6_2_1_ID:
202-
return V_6_2_1;
203-
case V_6_2_0_ID:
204-
return V_6_2_0;
205185
case V_6_1_4_ID:
206186
return V_6_1_4;
207187
case V_6_1_3_ID:

server/src/main/java/org/elasticsearch/index/store/Store.java

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,23 +1550,8 @@ public void trimUnsafeCommits(final long lastSyncedGlobalCheckpoint, final long
15501550
final IndexCommit lastIndexCommitCommit = existingCommits.get(existingCommits.size() - 1);
15511551
final String translogUUID = lastIndexCommitCommit.getUserData().get(Translog.TRANSLOG_UUID_KEY);
15521552
final IndexCommit startingIndexCommit;
1553-
// We may not have a safe commit if an index was create before v6.2; and if there is a snapshotted commit whose translog
1554-
// are not retained but max_seqno is at most the global checkpoint, we may mistakenly select it as a starting commit.
1555-
// To avoid this issue, we only select index commits whose translog are fully retained.
1556-
if (indexVersionCreated.before(org.elasticsearch.Version.V_6_2_0)) {
1557-
final List<IndexCommit> recoverableCommits = new ArrayList<>();
1558-
for (IndexCommit commit : existingCommits) {
1559-
if (minRetainedTranslogGen <= Long.parseLong(commit.getUserData().get(Translog.TRANSLOG_GENERATION_KEY))) {
1560-
recoverableCommits.add(commit);
1561-
}
1562-
}
1563-
assert recoverableCommits.isEmpty() == false : "No commit point with translog found; " +
1564-
"commits [" + existingCommits + "], minRetainedTranslogGen [" + minRetainedTranslogGen + "]";
1565-
startingIndexCommit = CombinedDeletionPolicy.findSafeCommitPoint(recoverableCommits, lastSyncedGlobalCheckpoint);
1566-
} else {
1567-
// TODO: Asserts the starting commit is a safe commit once peer-recovery sets global checkpoint.
1568-
startingIndexCommit = CombinedDeletionPolicy.findSafeCommitPoint(existingCommits, lastSyncedGlobalCheckpoint);
1569-
}
1553+
// TODO: Asserts the starting commit is a safe commit once peer-recovery sets global checkpoint.
1554+
startingIndexCommit = CombinedDeletionPolicy.findSafeCommitPoint(existingCommits, lastSyncedGlobalCheckpoint);
15701555

15711556
if (translogUUID.equals(startingIndexCommit.getUserData().get(Translog.TRANSLOG_UUID_KEY)) == false) {
15721557
throw new IllegalStateException("starting commit translog uuid ["

server/src/main/java/org/elasticsearch/indices/flush/SyncedFlushService.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -594,10 +594,6 @@ static final class PreSyncedFlushResponse extends TransportResponse {
594594
this.existingSyncId = existingSyncId;
595595
}
596596

597-
boolean includeNumDocs(Version version) {
598-
return version.onOrAfter(Version.V_6_2_2);
599-
}
600-
601597
boolean includeExistingSyncId(Version version) {
602598
return version.onOrAfter(Version.V_6_3_0);
603599
}
@@ -606,11 +602,7 @@ boolean includeExistingSyncId(Version version) {
606602
public void readFrom(StreamInput in) throws IOException {
607603
super.readFrom(in);
608604
commitId = new Engine.CommitId(in);
609-
if (includeNumDocs(in.getVersion())) {
610-
numDocs = in.readInt();
611-
} else {
612-
numDocs = UNKNOWN_NUM_DOCS;
613-
}
605+
numDocs = in.readInt();
614606
if (includeExistingSyncId(in.getVersion())) {
615607
existingSyncId = in.readOptionalString();
616608
}
@@ -620,9 +612,7 @@ public void readFrom(StreamInput in) throws IOException {
620612
public void writeTo(StreamOutput out) throws IOException {
621613
super.writeTo(out);
622614
commitId.writeTo(out);
623-
if (includeNumDocs(out.getVersion())) {
624-
out.writeInt(numDocs);
625-
}
615+
out.writeInt(numDocs);
626616
if (includeExistingSyncId(out.getVersion())) {
627617
out.writeOptionalString(existingSyncId);
628618
}

server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ public void testCircuitBreakingException() throws IOException {
365365
}
366366

367367
public void testTooManyBucketsException() throws IOException {
368-
Version version = VersionUtils.randomVersionBetween(random(), Version.V_6_2_0, Version.CURRENT);
368+
Version version = VersionUtils.randomCompatibleVersion(random(), Version.CURRENT);
369369
MultiBucketConsumerService.TooManyBucketsException ex =
370370
serialize(new MultiBucketConsumerService.TooManyBucketsException("Too many buckets", 100), version);
371371
assertEquals("Too many buckets", ex.getMessage());

server/src/test/java/org/elasticsearch/common/lucene/uid/VersionsTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ public void testLuceneVersionOnUnknownVersions() {
197197
version.luceneVersion);
198198

199199
// between two known versions, should use the lucene version of the previous version
200-
version = Version.fromString("6.2.50");
201-
assertEquals(VersionUtils.getPreviousVersion(Version.V_6_2_4).luceneVersion, version.luceneVersion);
200+
version = Version.fromString("8.0.50");
201+
assertEquals(VersionUtils.getPreviousVersion(Version.V_8_0_0).luceneVersion, version.luceneVersion);
202202

203203
// too old version, major should be the oldest supported lucene version minus 1
204204
version = Version.fromString("5.2.1");

server/src/test/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerTests.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,16 @@ public void testThatInstancesAreCachedAndReused() {
6868
assertSame(PreBuiltAnalyzers.STANDARD.getAnalyzer(Version.CURRENT),
6969
PreBuiltAnalyzers.STANDARD.getAnalyzer(Version.CURRENT));
7070
// same es version should be cached
71-
assertSame(PreBuiltAnalyzers.STANDARD.getAnalyzer(Version.V_6_2_1),
72-
PreBuiltAnalyzers.STANDARD.getAnalyzer(Version.V_6_2_1));
71+
Version versionA = randomVersion(random());
72+
Version versionB = randomValueOtherThan(versionA, () -> randomVersion(random()));
73+
assertSame(PreBuiltAnalyzers.STANDARD.getAnalyzer(versionA),
74+
PreBuiltAnalyzers.STANDARD.getAnalyzer(versionA));
7375
assertNotSame(PreBuiltAnalyzers.STANDARD.getAnalyzer(Version.V_6_0_0),
7476
PreBuiltAnalyzers.STANDARD.getAnalyzer(Version.V_6_0_1));
7577

7678
// Same Lucene version should be cached:
77-
assertSame(PreBuiltAnalyzers.STOP.getAnalyzer(Version.V_6_2_1),
78-
PreBuiltAnalyzers.STOP.getAnalyzer(Version.V_6_2_2));
79+
assertSame(PreBuiltAnalyzers.STOP.getAnalyzer(Version.V_7_2_0),
80+
PreBuiltAnalyzers.STOP.getAnalyzer(Version.V_8_0_0));
7981
}
8082

8183
public void testThatAnalyzersAreUsedInMapping() throws IOException {

server/src/test/java/org/elasticsearch/search/slice/SliceBuilderTests.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
import org.elasticsearch.search.internal.AliasFilter;
6464
import org.elasticsearch.search.internal.ShardSearchRequest;
6565
import org.elasticsearch.test.ESTestCase;
66+
import org.elasticsearch.test.VersionUtils;
6667

6768
import java.io.IOException;
6869
import java.util.ArrayList;
@@ -461,7 +462,7 @@ public void testSerializationBackcompat() throws IOException {
461462

462463
SliceBuilder copy62 = copyWriteable(sliceBuilder,
463464
new NamedWriteableRegistry(Collections.emptyList()),
464-
SliceBuilder::new, Version.V_6_2_0);
465+
SliceBuilder::new, VersionUtils.getPreviousVersion(Version.V_6_3_0));
465466
assertEquals(sliceBuilder, copy62);
466467

467468
SliceBuilder copy63 = copyWriteable(copy62,
@@ -496,7 +497,8 @@ public void testToFilterWithRouting() throws IOException {
496497
assertEquals(new DocValuesSliceQuery("field", 6, 10), query);
497498
query = builder.toFilter(clusterService, createRequest(1, Strings.EMPTY_ARRAY, "foo"), context, Version.CURRENT);
498499
assertEquals(new DocValuesSliceQuery("field", 6, 10), query);
499-
query = builder.toFilter(clusterService, createRequest(1, Strings.EMPTY_ARRAY, "foo"), context, Version.V_6_2_0);
500+
query = builder.toFilter(clusterService, createRequest(1, Strings.EMPTY_ARRAY, "foo"), context,
501+
VersionUtils.getPreviousVersion(Version.V_6_3_0));
500502
assertEquals(new DocValuesSliceQuery("field", 1, 2), query);
501503
}
502504
}

test/framework/src/test/java/org/elasticsearch/test/rest/yaml/section/ClientYamlTestSectionTests.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.elasticsearch.common.ParsingException;
2424
import org.elasticsearch.common.xcontent.XContentParser;
2525
import org.elasticsearch.common.xcontent.yaml.YamlXContent;
26+
import org.elasticsearch.test.VersionUtils;
2627

2728
import java.io.IOException;
2829
import java.util.Map;
@@ -93,7 +94,7 @@ public void testParseTestSectionWithDoSetAndSkipSectionsNoSkip() throws Exceptio
9394
parser = createParser(YamlXContent.yamlXContent,
9495
"\"First test section\": \n" +
9596
" - skip:\n" +
96-
" version: \"6.0.0 - 6.2.0\"\n" +
97+
" version: \"" + VersionUtils.getPreviousVersion() + " - " + Version.CURRENT + "\"\n" +
9798
" reason: \"Update doesn't return metadata fields, waiting for #3259\"\n" +
9899
" - do :\n" +
99100
" catch: missing\n" +
@@ -108,9 +109,9 @@ public void testParseTestSectionWithDoSetAndSkipSectionsNoSkip() throws Exceptio
108109
assertThat(testSection, notNullValue());
109110
assertThat(testSection.getName(), equalTo("First test section"));
110111
assertThat(testSection.getSkipSection(), notNullValue());
111-
assertThat(testSection.getSkipSection().getLowerVersion(), equalTo(Version.V_6_0_0));
112+
assertThat(testSection.getSkipSection().getLowerVersion(), equalTo(VersionUtils.getPreviousVersion()));
112113
assertThat(testSection.getSkipSection().getUpperVersion(),
113-
equalTo(Version.V_6_2_0));
114+
equalTo(Version.CURRENT));
114115
assertThat(testSection.getSkipSection().getReason(), equalTo("Update doesn't return metadata fields, waiting for #3259"));
115116
assertThat(testSection.getExecutableSections().size(), equalTo(2));
116117
DoSection doSection = (DoSection)testSection.getExecutableSections().get(0);

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/UpdateJobAction.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,7 @@ public void readFrom(StreamInput in) throws IOException {
9292
super.readFrom(in);
9393
jobId = in.readString();
9494
update = new JobUpdate(in);
95-
if (in.getVersion().onOrAfter(Version.V_6_2_2)) {
96-
isInternal = in.readBoolean();
97-
} else {
98-
isInternal = false;
99-
}
95+
isInternal = in.readBoolean();
10096
if (in.getVersion().onOrAfter(Version.V_6_3_0) && in.getVersion().before(Version.V_7_0_0)) {
10197
in.readBoolean(); // was waitForAck
10298
}
@@ -107,9 +103,7 @@ public void writeTo(StreamOutput out) throws IOException {
107103
super.writeTo(out);
108104
out.writeString(jobId);
109105
update.writeTo(out);
110-
if (out.getVersion().onOrAfter(Version.V_6_2_2)) {
111-
out.writeBoolean(isInternal);
112-
}
106+
out.writeBoolean(isInternal);
113107
if (out.getVersion().onOrAfter(Version.V_6_3_0) && out.getVersion().before(Version.V_7_0_0)) {
114108
out.writeBoolean(false); // was waitForAck
115109
}

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/UpdateProcessAction.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,8 @@ public Request(StreamInput in) throws IOException {
121121
if (in.readBoolean()) {
122122
detectorUpdates = in.readList(JobUpdate.DetectorUpdate::new);
123123
}
124-
if (in.getVersion().onOrAfter(Version.V_6_2_0)) {
125-
filter = in.readOptionalWriteable(MlFilter::new);
126-
updateScheduledEvents = in.readBoolean();
127-
}
124+
filter = in.readOptionalWriteable(MlFilter::new);
125+
updateScheduledEvents = in.readBoolean();
128126
}
129127

130128
@Override
@@ -136,10 +134,8 @@ public void writeTo(StreamOutput out) throws IOException {
136134
if (hasDetectorUpdates) {
137135
out.writeList(detectorUpdates);
138136
}
139-
if (out.getVersion().onOrAfter(Version.V_6_2_0)) {
140-
out.writeOptionalWriteable(filter);
141-
out.writeBoolean(updateScheduledEvents);
142-
}
137+
out.writeOptionalWriteable(filter);
138+
out.writeBoolean(updateScheduledEvents);
143139
}
144140

145141
public Request(String jobId, ModelPlotConfig modelPlotConfig, List<JobUpdate.DetectorUpdate> detectorUpdates, MlFilter filter,

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/datafeed/DatafeedConfig.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -222,16 +222,8 @@ public DatafeedConfig(StreamInput in) throws IOException {
222222
}
223223
this.scrollSize = in.readOptionalVInt();
224224
this.chunkingConfig = in.readOptionalWriteable(ChunkingConfig::new);
225-
if (in.getVersion().onOrAfter(Version.V_6_2_0)) {
226-
this.headers = Collections.unmodifiableMap(in.readMap(StreamInput::readString, StreamInput::readString));
227-
} else {
228-
this.headers = Collections.emptyMap();
229-
}
230-
if (in.getVersion().onOrAfter(Version.V_6_6_0)) {
231-
delayedDataCheckConfig = in.readOptionalWriteable(DelayedDataCheckConfig::new);
232-
} else {
233-
delayedDataCheckConfig = DelayedDataCheckConfig.defaultDelayedDataCheckConfig();
234-
}
225+
this.headers = Collections.unmodifiableMap(in.readMap(StreamInput::readString, StreamInput::readString));
226+
delayedDataCheckConfig = in.readOptionalWriteable(DelayedDataCheckConfig::new);
235227
}
236228

237229
/**
@@ -432,9 +424,7 @@ public void writeTo(StreamOutput out) throws IOException {
432424
}
433425
out.writeOptionalVInt(scrollSize);
434426
out.writeOptionalWriteable(chunkingConfig);
435-
if (out.getVersion().onOrAfter(Version.V_6_2_0)) {
436-
out.writeMap(headers, StreamOutput::writeString, StreamOutput::writeString);
437-
}
427+
out.writeMap(headers, StreamOutput::writeString, StreamOutput::writeString);
438428
if (out.getVersion().onOrAfter(Version.V_6_6_0)) {
439429
out.writeOptionalWriteable(delayedDataCheckConfig);
440430
}

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/AnalysisConfig.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66
package org.elasticsearch.xpack.core.ml.job.config;
77

8-
import org.elasticsearch.Version;
98
import org.elasticsearch.common.ParseField;
109
import org.elasticsearch.common.Strings;
1110
import org.elasticsearch.common.io.stream.StreamInput;
@@ -126,11 +125,7 @@ public AnalysisConfig(StreamInput in) throws IOException {
126125
bucketSpan = in.readTimeValue();
127126
categorizationFieldName = in.readOptionalString();
128127
categorizationFilters = in.readBoolean() ? Collections.unmodifiableList(in.readStringList()) : null;
129-
if (in.getVersion().onOrAfter(Version.V_6_2_0)) {
130-
categorizationAnalyzerConfig = in.readOptionalWriteable(CategorizationAnalyzerConfig::new);
131-
} else {
132-
categorizationAnalyzerConfig = null;
133-
}
128+
categorizationAnalyzerConfig = in.readOptionalWriteable(CategorizationAnalyzerConfig::new);
134129
latency = in.readOptionalTimeValue();
135130
summaryCountFieldName = in.readOptionalString();
136131
detectors = Collections.unmodifiableList(in.readList(Detector::new));
@@ -149,9 +144,7 @@ public void writeTo(StreamOutput out) throws IOException {
149144
} else {
150145
out.writeBoolean(false);
151146
}
152-
if (out.getVersion().onOrAfter(Version.V_6_2_0)) {
153-
out.writeOptionalWriteable(categorizationAnalyzerConfig);
154-
}
147+
out.writeOptionalWriteable(categorizationAnalyzerConfig);
155148
out.writeOptionalTimeValue(latency);
156149
out.writeOptionalString(summaryCountFieldName);
157150
out.writeList(detectors);

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/Bucket.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,8 @@ public Bucket(StreamInput in) throws IOException {
138138
if (in.getVersion().before(Version.V_6_5_0)) {
139139
in.readList(Bucket::readOldPerPartitionNormalization);
140140
}
141-
if (in.getVersion().onOrAfter(Version.V_6_2_0)) {
142-
scheduledEvents = in.readStringList();
143-
if (scheduledEvents.isEmpty()) {
144-
scheduledEvents = Collections.emptyList();
145-
}
146-
} else {
141+
scheduledEvents = in.readStringList();
142+
if (scheduledEvents.isEmpty()) {
147143
scheduledEvents = Collections.emptyList();
148144
}
149145
}
@@ -164,9 +160,7 @@ public void writeTo(StreamOutput out) throws IOException {
164160
if (out.getVersion().before(Version.V_6_5_0)) {
165161
out.writeList(Collections.emptyList());
166162
}
167-
if (out.getVersion().onOrAfter(Version.V_6_2_0)) {
168-
out.writeStringCollection(scheduledEvents);
169-
}
163+
out.writeStringCollection(scheduledEvents);
170164
}
171165

172166
@Override

0 commit comments

Comments
 (0)