Skip to content

Commit da1ba68

Browse files
authored
remove 6.3.x constants (#42087)
relates to refactoring effort #41164.
1 parent cbf1150 commit da1ba68

File tree

46 files changed

+110
-841
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

+110
-841
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ public static class Builder {
226226
private String jobId;
227227

228228
// 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;
229+
private Version minVersion = Version.fromString("6.3.0");
230230

231231
private Date timestamp;
232232
private String description;

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: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -224,45 +224,26 @@ 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();
242234

243235
final String version;
244-
if (in.getVersion().onOrAfter(Version.V_7_0_0)) {
245-
version = in.readString();
246-
} else {
247-
version = in.getVersion().toString();
248-
}
236+
version = in.readString();
249237
return new Build(flavor, type, hash, date, snapshot, version);
250238
}
251239

252240
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 = build.type();
258-
out.writeString(buildType.displayName());
259-
}
241+
out.writeString(build.flavor().displayName());
242+
out.writeString(build.type().displayName());
260243
out.writeString(build.shortHash());
261244
out.writeString(build.date());
262245
out.writeBoolean(build.isSnapshot());
263-
if (out.getVersion().onOrAfter(Version.V_7_0_0)) {
264-
out.writeString(build.getQualifiedVersion());
265-
}
246+
out.writeString(build.getQualifiedVersion());
266247
}
267248

268249
/**

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +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-
// The below version is missing from the 7.3 JAR
50-
private static final org.apache.lucene.util.Version LUCENE_7_2_1 = org.apache.lucene.util.Version.fromBits(7, 2, 1);
51-
public static final int V_6_3_0_ID = 6030099;
52-
public static final Version V_6_3_0 = new Version(V_6_3_0_ID, org.apache.lucene.util.Version.LUCENE_7_3_1);
53-
public static final int V_6_3_1_ID = 6030199;
54-
public static final Version V_6_3_1 = new Version(V_6_3_1_ID, org.apache.lucene.util.Version.LUCENE_7_3_1);
55-
public static final int V_6_3_2_ID = 6030299;
56-
public static final Version V_6_3_2 = new Version(V_6_3_2_ID, org.apache.lucene.util.Version.LUCENE_7_3_1);
5749
public static final int V_6_4_0_ID = 6040099;
5850
public static final Version V_6_4_0 = new Version(V_6_4_0_ID, org.apache.lucene.util.Version.LUCENE_7_4_0);
5951
public static final int V_6_4_1_ID = 6040199;
@@ -152,12 +144,6 @@ public static Version fromId(int id) {
152144
return V_6_4_1;
153145
case V_6_4_0_ID:
154146
return V_6_4_0;
155-
case V_6_3_2_ID:
156-
return V_6_3_2;
157-
case V_6_3_1_ID:
158-
return V_6_3_1;
159-
case V_6_3_0_ID:
160-
return V_6_3_0;
161147
case V_EMPTY_ID:
162148
return V_EMPTY;
163149
default:

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 & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.apache.logging.log4j.Logger;
2323
import org.apache.logging.log4j.message.ParameterizedMessage;
2424
import org.elasticsearch.ElasticsearchException;
25-
import org.elasticsearch.Version;
2625
import org.elasticsearch.action.ActionListener;
2726
import org.elasticsearch.action.StepListener;
2827
import org.elasticsearch.action.admin.indices.flush.FlushRequest;
@@ -594,28 +593,20 @@ static final class PreSyncedFlushResponse extends TransportResponse {
594593
this.existingSyncId = existingSyncId;
595594
}
596595

597-
boolean includeExistingSyncId(Version version) {
598-
return version.onOrAfter(Version.V_6_3_0);
599-
}
600-
601596
@Override
602597
public void readFrom(StreamInput in) throws IOException {
603598
super.readFrom(in);
604599
commitId = new Engine.CommitId(in);
605600
numDocs = in.readInt();
606-
if (includeExistingSyncId(in.getVersion())) {
607-
existingSyncId = in.readOptionalString();
608-
}
601+
existingSyncId = in.readOptionalString();
609602
}
610603

611604
@Override
612605
public void writeTo(StreamOutput out) throws IOException {
613606
super.writeTo(out);
614607
commitId.writeTo(out);
615608
out.writeInt(numDocs);
616-
if (includeExistingSyncId(out.getVersion())) {
617-
out.writeOptionalString(existingSyncId);
618-
}
609+
out.writeOptionalString(existingSyncId);
619610
}
620611
}
621612

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

Lines changed: 3 additions & 11 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;
@@ -249,15 +249,7 @@ public Query toFilter(ClusterService clusterService, ShardSearchRequest request,
249249

250250
String field = this.field;
251251
boolean useTermQuery = false;
252-
if ("_uid".equals(field)) {
253-
// on new indices, the _id acts as a _uid
254-
field = IdFieldMapper.NAME;
255-
if (context.getIndexSettings().getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) {
256-
throw new IllegalArgumentException("Computing slices on the [_uid] field is illegal for 7.x indices, use [_id] instead");
257-
}
258-
DEPRECATION_LOG.deprecated("Computing slices on the [_uid] field is deprecated for 6.x indices, use [_id] instead");
259-
useTermQuery = true;
260-
} else if (IdFieldMapper.NAME.equals(field)) {
252+
if (IdFieldMapper.NAME.equals(field)) {
261253
useTermQuery = true;
262254
} else if (type.hasDocValues() == false) {
263255
throw new IllegalArgumentException("cannot load numeric doc values on " + field);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public void testSerialization() {
192192
throw new AssertionError();
193193
});
194194
}
195-
195+
196196
public void testFlavorParsing() {
197197
for (final Build.Flavor flavor : Build.Flavor.values()) {
198198
// strict or not should not impact parsing at all here

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()

server/src/test/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequestTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.elasticsearch.common.io.stream.BytesStreamOutput;
2828
import org.elasticsearch.common.io.stream.StreamInput;
2929
import org.elasticsearch.test.ESTestCase;
30+
import org.elasticsearch.test.VersionUtils;
3031

3132
import java.util.Locale;
3233

@@ -59,7 +60,7 @@ public void testBwcSerialization() throws Exception {
5960
for (int runs = 0; runs < randomIntBetween(5, 20); runs++) {
6061
// Generate a random cluster health request in version < 7.2.0 and serializes it
6162
final BytesStreamOutput out = new BytesStreamOutput();
62-
out.setVersion(randomVersionBetween(random(), Version.V_6_3_0, getPreviousVersion(Version.V_7_2_0)));
63+
out.setVersion(randomVersionBetween(random(), VersionUtils.getFirstVersion(), getPreviousVersion(Version.V_7_2_0)));
6364

6465
final ClusterHealthRequest expected = randomRequest();
6566
{
@@ -114,7 +115,7 @@ public void testBwcSerialization() throws Exception {
114115

115116
// Serialize to node in version < 7.2.0
116117
final BytesStreamOutput out = new BytesStreamOutput();
117-
out.setVersion(randomVersionBetween(random(), Version.V_6_3_0, getPreviousVersion(Version.V_7_2_0)));
118+
out.setVersion(randomVersionBetween(random(), VersionUtils.getFirstVersion(), getPreviousVersion(Version.V_7_2_0)));
118119
expected.writeTo(out);
119120

120121
// Deserialize and check the cluster health request

server/src/test/java/org/elasticsearch/common/geo/GeoWKTShapeParserTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ public void testParseMixedDimensionPolyWithHoleStoredZ() throws IOException {
342342
parser.nextToken();
343343

344344
Settings indexSettings = Settings.builder()
345-
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_6_3_0)
345+
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
346346
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)
347347
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
348348
.put(IndexMetaData.SETTING_INDEX_UUID, UUIDs.randomBase64UUID()).build();
@@ -372,7 +372,7 @@ public void testParsePolyWithStoredZ() throws IOException {
372372
parser.nextToken();
373373

374374
Settings indexSettings = Settings.builder()
375-
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_6_3_0)
375+
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
376376
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)
377377
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
378378
.put(IndexMetaData.SETTING_INDEX_UUID, UUIDs.randomBase64UUID()).build();
@@ -393,7 +393,7 @@ public void testParseOpenPolygon() throws IOException {
393393
parser.nextToken();
394394

395395
Settings indexSettings = Settings.builder()
396-
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_6_3_0)
396+
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
397397
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)
398398
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
399399
.put(IndexMetaData.SETTING_INDEX_UUID, UUIDs.randomBase64UUID()).build();

0 commit comments

Comments
 (0)