Skip to content

Commit a4e102d

Browse files
committed
remove 6.3.x constants
relates to refactoring effort elastic#41164.
1 parent f42dcf2 commit a4e102d

File tree

48 files changed

+137
-903
lines changed

Some content is hidden

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

48 files changed

+137
-903
lines changed

client/rest-high-level/src/main/java/org/elasticsearch/client/ml/job/process/ModelSnapshot.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,7 @@ public boolean equals(Object other) {
224224

225225
public static class Builder {
226226
private String jobId;
227-
228-
// Stored snapshot documents created prior to 6.3.0 will have no value for min_version.
229-
private Version minVersion = Version.V_6_3_0;
230-
227+
private Version minVersion;
231228
private Date timestamp;
232229
private String description;
233230
private String snapshotId;

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

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
package org.elasticsearch.index.rankeval;
2121

22-
import org.elasticsearch.Version;
2322
import org.elasticsearch.action.ActionRequest;
2423
import org.elasticsearch.action.ActionRequestValidationException;
2524
import org.elasticsearch.action.IndicesRequest;
@@ -51,18 +50,8 @@ public RankEvalRequest(RankEvalSpec rankingEvaluationSpec, String[] indices) {
5150
RankEvalRequest(StreamInput in) throws IOException {
5251
super.readFrom(in);
5352
rankingEvaluationSpec = new RankEvalSpec(in);
54-
if (in.getVersion().onOrAfter(Version.V_6_3_0)) {
55-
indices = in.readStringArray();
56-
indicesOptions = IndicesOptions.readIndicesOptions(in);
57-
} else {
58-
// readStringArray uses readVInt for size, we used readInt in 6.2
59-
int indicesSize = in.readInt();
60-
String[] indices = new String[indicesSize];
61-
for (int i = 0; i < indicesSize; i++) {
62-
indices[i] = in.readString();
63-
}
64-
// no indices options yet
65-
}
53+
indices = in.readStringArray();
54+
indicesOptions = IndicesOptions.readIndicesOptions(in);
6655
}
6756

6857
RankEvalRequest() {
@@ -131,17 +120,8 @@ public void readFrom(StreamInput in) throws IOException {
131120
public void writeTo(StreamOutput out) throws IOException {
132121
super.writeTo(out);
133122
rankingEvaluationSpec.writeTo(out);
134-
if (out.getVersion().onOrAfter(Version.V_6_3_0)) {
135-
out.writeStringArray(indices);
136-
indicesOptions.writeIndicesOptions(out);
137-
} else {
138-
// writeStringArray uses writeVInt for size, we used writeInt in 6.2
139-
out.writeInt(indices.length);
140-
for (String index : indices) {
141-
out.writeString(index);
142-
}
143-
// no indices options yet
144-
}
123+
out.writeStringArray(indices);
124+
indicesOptions.writeIndicesOptions(out);
145125
}
146126

147127
@Override

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

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -224,18 +224,10 @@ public String date() {
224224
public static Build readBuild(StreamInput in) throws IOException {
225225
final Flavor flavor;
226226
final Type type;
227-
if (in.getVersion().onOrAfter(Version.V_6_3_0)) {
228-
// be lenient when reading on the wire, the enumeration values from other versions might be different than what we know
229-
flavor = Flavor.fromDisplayName(in.readString(), false);
230-
} else {
231-
flavor = Flavor.OSS;
232-
}
233-
if (in.getVersion().onOrAfter(Version.V_6_3_0)) {
234-
// be lenient when reading on the wire, the enumeration values from other versions might be different than what we know
235-
type = Type.fromDisplayName(in.readString(), false);
236-
} else {
237-
type = Type.UNKNOWN;
238-
}
227+
// be lenient when reading on the wire, the enumeration values from other versions might be different than what we know
228+
flavor = Flavor.fromDisplayName(in.readString(), false);
229+
// be lenient when reading on the wire, the enumeration values from other versions might be different than what we know
230+
type = Type.fromDisplayName(in.readString(), false);
239231
String hash = in.readString();
240232
String date = in.readString();
241233
boolean snapshot = in.readBoolean();
@@ -250,18 +242,14 @@ public static Build readBuild(StreamInput in) throws IOException {
250242
}
251243

252244
public static void writeBuild(Build build, StreamOutput out) throws IOException {
253-
if (out.getVersion().onOrAfter(Version.V_6_3_0)) {
254-
out.writeString(build.flavor().displayName());
255-
}
256-
if (out.getVersion().onOrAfter(Version.V_6_3_0)) {
257-
final Type buildType;
258-
if (out.getVersion().before(Version.V_6_7_0) && build.type() == Type.DOCKER) {
259-
buildType = Type.TAR;
260-
} else {
261-
buildType = build.type();
262-
}
263-
out.writeString(buildType.displayName());
245+
out.writeString(build.flavor().displayName());
246+
final Type buildType;
247+
if (out.getVersion().before(Version.V_6_7_0) && build.type() == Type.DOCKER) {
248+
buildType = Type.TAR;
249+
} else {
250+
buildType = build.type();
264251
}
252+
out.writeString(buildType.displayName());
265253
out.writeString(build.shortHash());
266254
out.writeString(build.date());
267255
out.writeBoolean(build.isSnapshot());

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,6 @@ public class Version implements Comparable<Version>, ToXContentFragment {
7474
public static final Version V_6_2_3 = new Version(V_6_2_3_ID, LUCENE_7_2_1);
7575
public static final int V_6_2_4_ID = 6020499;
7676
public static final Version V_6_2_4 = new Version(V_6_2_4_ID, LUCENE_7_2_1);
77-
public static final int V_6_3_0_ID = 6030099;
78-
public static final Version V_6_3_0 = new Version(V_6_3_0_ID, org.apache.lucene.util.Version.LUCENE_7_3_1);
79-
public static final int V_6_3_1_ID = 6030199;
80-
public static final Version V_6_3_1 = new Version(V_6_3_1_ID, org.apache.lucene.util.Version.LUCENE_7_3_1);
81-
public static final int V_6_3_2_ID = 6030299;
82-
public static final Version V_6_3_2 = new Version(V_6_3_2_ID, org.apache.lucene.util.Version.LUCENE_7_3_1);
8377
public static final int V_6_4_0_ID = 6040099;
8478
public static final Version V_6_4_0 = new Version(V_6_4_0_ID, org.apache.lucene.util.Version.LUCENE_7_4_0);
8579
public static final int V_6_4_1_ID = 6040199;
@@ -186,12 +180,6 @@ public static Version fromId(int id) {
186180
return V_6_4_1;
187181
case V_6_4_0_ID:
188182
return V_6_4_0;
189-
case V_6_3_2_ID:
190-
return V_6_3_2;
191-
case V_6_3_1_ID:
192-
return V_6_3_1;
193-
case V_6_3_0_ID:
194-
return V_6_3_0;
195183
case V_6_2_4_ID:
196184
return V_6_2_4;
197185
case V_6_2_3_ID:

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

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
package org.elasticsearch.index.mapper;
2121

2222
import org.apache.logging.log4j.LogManager;
23-
import org.elasticsearch.Version;
2423
import org.elasticsearch.common.logging.DeprecationLogger;
2524
import org.elasticsearch.common.regex.Regex;
2625
import org.elasticsearch.common.xcontent.ToXContentObject;
@@ -160,8 +159,7 @@ public static XContentFieldType fromString(String value) {
160159
public abstract String defaultMappingType();
161160
}
162161

163-
public static DynamicTemplate parse(String name, Map<String, Object> conf,
164-
Version indexVersionCreated) throws MapperParsingException {
162+
public static DynamicTemplate parse(String name, Map<String, Object> conf) throws MapperParsingException {
165163
String match = null;
166164
String pathMatch = null;
167165
String unmatch = null;
@@ -207,18 +205,16 @@ public static DynamicTemplate parse(String name, Map<String, Object> conf,
207205

208206
final MatchType matchType = MatchType.fromString(matchPattern);
209207

210-
if (indexVersionCreated.onOrAfter(Version.V_6_3_0)) {
211-
// Validate that the pattern
212-
for (String regex : new String[] { pathMatch, match, pathUnmatch, unmatch }) {
213-
if (regex == null) {
214-
continue;
215-
}
216-
try {
217-
matchType.matches(regex, "");
218-
} catch (IllegalArgumentException e) {
219-
throw new IllegalArgumentException("Pattern [" + regex + "] of type [" + matchType
220-
+ "] is invalid. Cannot create dynamic template [" + name + "].", e);
221-
}
208+
// Validate that the pattern
209+
for (String regex : new String[] { pathMatch, match, pathUnmatch, unmatch }) {
210+
if (regex == null) {
211+
continue;
212+
}
213+
try {
214+
matchType.matches(regex, "");
215+
} catch (IllegalArgumentException e) {
216+
throw new IllegalArgumentException("Pattern [" + regex + "] of type [" + matchType
217+
+ "] is invalid. Cannot create dynamic template [" + name + "].", e);
222218
}
223219
}
224220

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ protected boolean processField(RootObjectMapper.Builder builder, String fieldNam
173173
Map.Entry<String, Object> entry = tmpl.entrySet().iterator().next();
174174
String templateName = entry.getKey();
175175
Map<String, Object> templateParams = (Map<String, Object>) entry.getValue();
176-
DynamicTemplate template = DynamicTemplate.parse(templateName, templateParams, indexVersionCreated);
176+
DynamicTemplate template = DynamicTemplate.parse(templateName, templateParams);
177177
if (template != null) {
178178
templates.add(template);
179179
}

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -598,10 +598,6 @@ boolean includeNumDocs(Version version) {
598598
return version.onOrAfter(Version.V_6_2_2);
599599
}
600600

601-
boolean includeExistingSyncId(Version version) {
602-
return version.onOrAfter(Version.V_6_3_0);
603-
}
604-
605601
@Override
606602
public void readFrom(StreamInput in) throws IOException {
607603
super.readFrom(in);
@@ -611,9 +607,7 @@ public void readFrom(StreamInput in) throws IOException {
611607
} else {
612608
numDocs = UNKNOWN_NUM_DOCS;
613609
}
614-
if (includeExistingSyncId(in.getVersion())) {
615-
existingSyncId = in.readOptionalString();
616-
}
610+
existingSyncId = in.readOptionalString();
617611
}
618612

619613
@Override
@@ -623,9 +617,7 @@ public void writeTo(StreamOutput out) throws IOException {
623617
if (includeNumDocs(out.getVersion())) {
624618
out.writeInt(numDocs);
625619
}
626-
if (includeExistingSyncId(out.getVersion())) {
627-
out.writeOptionalString(existingSyncId);
628-
}
620+
out.writeOptionalString(existingSyncId);
629621
}
630622
}
631623

server/src/main/java/org/elasticsearch/search/slice/SliceBuilder.java

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
/**
5656
* A slice builder allowing to split a scroll in multiple partitions.
57-
* If the provided field is the "_uid" it uses a {@link org.elasticsearch.search.slice.TermsSliceQuery}
57+
* If the provided field is the "_id" it uses a {@link org.elasticsearch.search.slice.TermsSliceQuery}
5858
* to do the slicing. The slicing is done at the shard level first and then each shard is split into multiple slices.
5959
* For instance if the number of shards is equal to 2 and the user requested 4 slices
6060
* then the slices 0 and 2 are assigned to the first shard and the slices 1 and 3 are assigned to the second shard.
@@ -79,7 +79,7 @@ public class SliceBuilder implements Writeable, ToXContentObject {
7979
PARSER.declareInt(SliceBuilder::setMax, MAX_FIELD);
8080
}
8181

82-
/** Name of field to slice against (_uid by default) */
82+
/** Name of field to slice against (_id by default) */
8383
private String field = IdFieldMapper.NAME;
8484
/** The id of the slice */
8585
private int id = -1;
@@ -106,22 +106,14 @@ public SliceBuilder(String field, int id, int max) {
106106

107107
public SliceBuilder(StreamInput in) throws IOException {
108108
String field = in.readString();
109-
if ("_uid".equals(field) && in.getVersion().before(Version.V_6_3_0)) {
110-
// This is safe because _id and _uid are handled the same way in #toFilter
111-
field = IdFieldMapper.NAME;
112-
}
113109
this.field = field;
114110
this.id = in.readVInt();
115111
this.max = in.readVInt();
116112
}
117113

118114
@Override
119115
public void writeTo(StreamOutput out) throws IOException {
120-
if (IdFieldMapper.NAME.equals(field) && out.getVersion().before(Version.V_6_3_0)) {
121-
out.writeString("_uid");
122-
} else {
123-
out.writeString(field);
124-
}
116+
out.writeString(field);
125117
out.writeVInt(id);
126118
out.writeVInt(max);
127119
}
@@ -257,15 +249,7 @@ public Query toFilter(ClusterService clusterService, ShardSearchRequest request,
257249

258250
String field = this.field;
259251
boolean useTermQuery = false;
260-
if ("_uid".equals(field)) {
261-
// on new indices, the _id acts as a _uid
262-
field = IdFieldMapper.NAME;
263-
if (context.getIndexSettings().getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) {
264-
throw new IllegalArgumentException("Computing slices on the [_uid] field is illegal for 7.x indices, use [_id] instead");
265-
}
266-
DEPRECATION_LOG.deprecated("Computing slices on the [_uid] field is deprecated for 6.x indices, use [_id] instead");
267-
useTermQuery = true;
268-
} else if (IdFieldMapper.NAME.equals(field)) {
252+
if (IdFieldMapper.NAME.equals(field)) {
269253
useTermQuery = true;
270254
} else if (type.hasDocValues() == false) {
271255
throw new IllegalArgumentException("cannot load numeric doc values on " + field);

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -199,30 +199,19 @@ public void testSerializationBWC() throws IOException {
199199
randomAlphaOfLength(6), randomAlphaOfLength(6), randomBoolean(), randomAlphaOfLength(6)));
200200

201201
final List<Version> versions = Version.getDeclaredVersions(Version.class);
202-
final Version pre63Version = randomFrom(versions.stream().filter(v -> v.before(Version.V_6_3_0)).collect(Collectors.toList()));
203-
final Version post63Pre67Version = randomFrom(versions.stream()
204-
.filter(v -> v.onOrAfter(Version.V_6_3_0) && v.before(Version.V_6_7_0)).collect(Collectors.toList()));
205202
final Version post67Pre70Version = randomFrom(versions.stream()
206203
.filter(v -> v.onOrAfter(Version.V_6_7_0) && v.before(Version.V_7_0_0)).collect(Collectors.toList()));
207204
final Version post70Version = randomFrom(versions.stream().filter(v -> v.onOrAfter(Version.V_7_0_0)).collect(Collectors.toList()));
208205

209-
final WriteableBuild pre63 = copyWriteable(dockerBuild, writableRegistry(), WriteableBuild::new, pre63Version);
210-
final WriteableBuild post63pre67 = copyWriteable(dockerBuild, writableRegistry(), WriteableBuild::new, post63Pre67Version);
211206
final WriteableBuild post67pre70 = copyWriteable(dockerBuild, writableRegistry(), WriteableBuild::new, post67Pre70Version);
212207
final WriteableBuild post70 = copyWriteable(dockerBuild, writableRegistry(), WriteableBuild::new, post70Version);
213208

214-
assertThat(pre63.build.flavor(), equalTo(Build.Flavor.OSS));
215-
assertThat(post63pre67.build.flavor(), equalTo(dockerBuild.build.flavor()));
216209
assertThat(post67pre70.build.flavor(), equalTo(dockerBuild.build.flavor()));
217210
assertThat(post70.build.flavor(), equalTo(dockerBuild.build.flavor()));
218211

219-
assertThat(pre63.build.type(), equalTo(Build.Type.UNKNOWN));
220-
assertThat(post63pre67.build.type(), equalTo(Build.Type.TAR));
221212
assertThat(post67pre70.build.type(), equalTo(dockerBuild.build.type()));
222213
assertThat(post70.build.type(), equalTo(dockerBuild.build.type()));
223214

224-
assertThat(pre63.build.getQualifiedVersion(), equalTo(pre63Version.toString()));
225-
assertThat(post63pre67.build.getQualifiedVersion(), equalTo(post63Pre67Version.toString()));
226215
assertThat(post67pre70.build.getQualifiedVersion(), equalTo(post67Pre70Version.toString()));
227216
assertThat(post70.build.getQualifiedVersion(), equalTo(dockerBuild.build.getQualifiedVersion()));
228217
}

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

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
import java.util.Map;
3737
import java.util.Set;
3838

39-
import static org.elasticsearch.Version.V_6_3_0;
40-
import static org.elasticsearch.Version.V_7_0_0;
4139
import static org.elasticsearch.test.VersionUtils.allVersions;
4240
import static org.elasticsearch.test.VersionUtils.randomVersion;
4341
import static org.hamcrest.CoreMatchers.equalTo;
@@ -50,30 +48,32 @@
5048
public class VersionTests extends ESTestCase {
5149

5250
public void testVersionComparison() throws Exception {
53-
assertThat(V_6_3_0.before(V_7_0_0), is(true));
54-
assertThat(V_6_3_0.before(V_6_3_0), is(false));
55-
assertThat(V_7_0_0.before(V_6_3_0), is(false));
51+
Version V_7_2_0 = Version.fromString("7.2.0");
52+
Version V_8_0_0 = Version.fromString("8.0.0");
53+
assertThat(V_7_2_0.before(V_8_0_0), is(true));
54+
assertThat(V_7_2_0.before(V_7_2_0), is(false));
55+
assertThat(V_8_0_0.before(V_7_2_0), is(false));
5656

57-
assertThat(V_6_3_0.onOrBefore(V_7_0_0), is(true));
58-
assertThat(V_6_3_0.onOrBefore(V_6_3_0), is(true));
59-
assertThat(V_7_0_0.onOrBefore(V_6_3_0), is(false));
57+
assertThat(V_7_2_0.onOrBefore(V_8_0_0), is(true));
58+
assertThat(V_7_2_0.onOrBefore(V_7_2_0), is(true));
59+
assertThat(V_8_0_0.onOrBefore(V_7_2_0), is(false));
6060

61-
assertThat(V_6_3_0.after(V_7_0_0), is(false));
62-
assertThat(V_6_3_0.after(V_6_3_0), is(false));
63-
assertThat(V_7_0_0.after(V_6_3_0), is(true));
61+
assertThat(V_7_2_0.after(V_8_0_0), is(false));
62+
assertThat(V_7_2_0.after(V_7_2_0), is(false));
63+
assertThat(V_8_0_0.after(V_7_2_0), is(true));
6464

65-
assertThat(V_6_3_0.onOrAfter(V_7_0_0), is(false));
66-
assertThat(V_6_3_0.onOrAfter(V_6_3_0), is(true));
67-
assertThat(V_7_0_0.onOrAfter(V_6_3_0), is(true));
65+
assertThat(V_7_2_0.onOrAfter(V_8_0_0), is(false));
66+
assertThat(V_7_2_0.onOrAfter(V_7_2_0), is(true));
67+
assertThat(V_8_0_0.onOrAfter(V_7_2_0), is(true));
6868

6969
assertTrue(Version.fromString("5.0.0-alpha2").onOrAfter(Version.fromString("5.0.0-alpha1")));
7070
assertTrue(Version.fromString("5.0.0").onOrAfter(Version.fromString("5.0.0-beta2")));
7171
assertTrue(Version.fromString("5.0.0-rc1").onOrAfter(Version.fromString("5.0.0-beta24")));
7272
assertTrue(Version.fromString("5.0.0-alpha24").before(Version.fromString("5.0.0-beta0")));
7373

74-
assertThat(V_6_3_0, is(lessThan(V_7_0_0)));
75-
assertThat(V_6_3_0.compareTo(V_6_3_0), is(0));
76-
assertThat(V_7_0_0, is(greaterThan(V_6_3_0)));
74+
assertThat(V_7_2_0, is(lessThan(V_8_0_0)));
75+
assertThat(V_7_2_0.compareTo(V_7_2_0), is(0));
76+
assertThat(V_8_0_0, is(greaterThan(V_7_2_0)));
7777
}
7878

7979
public void testMin() {
@@ -182,7 +182,7 @@ public void testMinCompatVersion() {
182182

183183
Version major56x = Version.fromString("5.6.0");
184184
assertThat(Version.V_6_5_0.minimumCompatibilityVersion(), equalTo(major56x));
185-
assertThat(Version.V_6_3_1.minimumCompatibilityVersion(), equalTo(major56x));
185+
assertThat(Version.fromString("6.3.1").minimumCompatibilityVersion(), equalTo(major56x));
186186

187187
// from 7.0 on we are supporting the latest minor of the previous major... this might fail once we add a new version ie. 5.x is
188188
// released since we need to bump the supported minor in Version#minimumCompatibilityVersion()

0 commit comments

Comments
 (0)