Fix Version based BWC and set correct minCompatVersion (#24732)

Approaching the release of 6.0 we need to sort out the usage of
`Version#minimumCompatibilityVersion` which was still set to 5.0.0.
Now this change moves it to the latest released version of 5.x (5.4 at this point)
to ensure we are compatible with the latest minor of the previous major. This change
also removes all the `_UNRELEASED` from the versions that where released and drops versions
that were never released and are not expected to be released (bugfixes in minors that are not
the latest in the previous major).
This commit is contained in:
Simon Willnauer 2017-05-17 17:27:09 +02:00 committed by GitHub
parent 0189a65e6b
commit 2ccc223ff7
86 changed files with 221 additions and 247 deletions

View File

@ -133,7 +133,7 @@ public class ElasticsearchException extends RuntimeException implements ToXConte
super(in.readOptionalString(), in.readException());
readStackTrace(this, in);
headers.putAll(in.readMapOfLists(StreamInput::readString, StreamInput::readString));
if (in.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_3_0)) {
metadata.putAll(in.readMapOfLists(StreamInput::readString, StreamInput::readString));
} else {
for (Iterator<Map.Entry<String, List<String>>> iterator = headers.entrySet().iterator(); iterator.hasNext(); ) {
@ -284,7 +284,7 @@ public class ElasticsearchException extends RuntimeException implements ToXConte
out.writeOptionalString(this.getMessage());
out.writeException(this.getCause());
writeStackTraces(this, out);
if (out.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_3_0)) {
out.writeMapOfLists(headers, StreamOutput::writeString, StreamOutput::writeString);
out.writeMapOfLists(metadata, StreamOutput::writeString, StreamOutput::writeString);
} else {
@ -985,11 +985,11 @@ public class ElasticsearchException extends RuntimeException implements ToXConte
STATUS_EXCEPTION(org.elasticsearch.ElasticsearchStatusException.class, org.elasticsearch.ElasticsearchStatusException::new, 145,
UNKNOWN_VERSION_ADDED),
TASK_CANCELLED_EXCEPTION(org.elasticsearch.tasks.TaskCancelledException.class,
org.elasticsearch.tasks.TaskCancelledException::new, 146, Version.V_5_1_1_UNRELEASED),
org.elasticsearch.tasks.TaskCancelledException::new, 146, Version.V_5_1_1),
SHARD_LOCK_OBTAIN_FAILED_EXCEPTION(org.elasticsearch.env.ShardLockObtainFailedException.class,
org.elasticsearch.env.ShardLockObtainFailedException::new, 147, Version.V_5_0_2),
UNKNOWN_NAMED_OBJECT_EXCEPTION(org.elasticsearch.common.xcontent.NamedXContentRegistry.UnknownNamedObjectException.class,
org.elasticsearch.common.xcontent.NamedXContentRegistry.UnknownNamedObjectException::new, 148, Version.V_5_2_0_UNRELEASED);
org.elasticsearch.common.xcontent.NamedXContentRegistry.UnknownNamedObjectException::new, 148, Version.V_5_2_0);
final Class<? extends ElasticsearchException> exceptionClass;
final CheckedFunction<StreamInput, ? extends ElasticsearchException, IOException> constructor;

View File

@ -55,33 +55,25 @@ public class Version implements Comparable<Version> {
public static final Version V_5_0_1 = new Version(V_5_0_1_ID, org.apache.lucene.util.Version.LUCENE_6_2_1);
public static final int V_5_0_2_ID = 5000299;
public static final Version V_5_0_2 = new Version(V_5_0_2_ID, org.apache.lucene.util.Version.LUCENE_6_2_1);
public static final int V_5_0_3_ID_UNRELEASED = 5000399;
public static final Version V_5_0_3_UNRELEASED = new Version(V_5_0_3_ID_UNRELEASED, org.apache.lucene.util.Version.LUCENE_6_3_0);
// no version constant for 5.1.0 due to inadvertent release
public static final int V_5_1_1_ID_UNRELEASED = 5010199;
public static final Version V_5_1_1_UNRELEASED = new Version(V_5_1_1_ID_UNRELEASED, org.apache.lucene.util.Version.LUCENE_6_3_0);
public static final int V_5_1_2_ID_UNRELEASED = 5010299;
public static final Version V_5_1_2_UNRELEASED = new Version(V_5_1_2_ID_UNRELEASED, org.apache.lucene.util.Version.LUCENE_6_3_0);
public static final int V_5_1_3_ID_UNRELEASED = 5010399;
public static final Version V_5_1_3_UNRELEASED = new Version(V_5_1_3_ID_UNRELEASED, org.apache.lucene.util.Version.LUCENE_6_3_0);
public static final int V_5_2_0_ID_UNRELEASED = 5020099;
public static final Version V_5_2_0_UNRELEASED = new Version(V_5_2_0_ID_UNRELEASED, org.apache.lucene.util.Version.LUCENE_6_4_0);
public static final int V_5_2_1_ID_UNRELEASED = 5020199;
public static final Version V_5_2_1_UNRELEASED = new Version(V_5_2_1_ID_UNRELEASED, org.apache.lucene.util.Version.LUCENE_6_4_1);
public static final int V_5_2_2_ID_UNRELEASED = 5020299;
public static final Version V_5_2_2_UNRELEASED = new Version(V_5_2_2_ID_UNRELEASED, org.apache.lucene.util.Version.LUCENE_6_4_1);
public static final int V_5_2_3_ID_UNRELEASED = 5020399;
public static final Version V_5_2_3_UNRELEASED = new Version(V_5_2_3_ID_UNRELEASED, org.apache.lucene.util.Version.LUCENE_6_4_1);
public static final int V_5_3_0_ID_UNRELEASED = 5030099;
public static final Version V_5_3_0_UNRELEASED = new Version(V_5_3_0_ID_UNRELEASED, org.apache.lucene.util.Version.LUCENE_6_4_1);
public static final int V_5_3_1_ID_UNRELEASED = 5030199;
public static final Version V_5_3_1_UNRELEASED = new Version(V_5_3_1_ID_UNRELEASED, org.apache.lucene.util.Version.LUCENE_6_4_2);
public static final int V_5_3_2_ID_UNRELEASED = 5030299;
public static final Version V_5_3_2_UNRELEASED = new Version(V_5_3_2_ID_UNRELEASED, org.apache.lucene.util.Version.LUCENE_6_4_2);
public static final int V_5_4_0_ID_UNRELEASED = 5040099;
public static final Version V_5_4_0_UNRELEASED = new Version(V_5_4_0_ID_UNRELEASED, org.apache.lucene.util.Version.LUCENE_6_5_0);
public static final int V_5_4_1_ID_UNRELEASED = 5040199;
public static final Version V_5_4_1_UNRELEASED = new Version(V_5_4_1_ID_UNRELEASED, org.apache.lucene.util.Version.LUCENE_6_5_1);
public static final int V_5_1_1_ID = 5010199;
public static final Version V_5_1_1 = new Version(V_5_1_1_ID, org.apache.lucene.util.Version.LUCENE_6_3_0);
public static final int V_5_1_2_ID = 5010299;
public static final Version V_5_1_2 = new Version(V_5_1_2_ID, org.apache.lucene.util.Version.LUCENE_6_3_0);
public static final int V_5_2_0_ID = 5020099;
public static final Version V_5_2_0 = new Version(V_5_2_0_ID, org.apache.lucene.util.Version.LUCENE_6_4_0);
public static final int V_5_2_1_ID = 5020199;
public static final Version V_5_2_1 = new Version(V_5_2_1_ID, org.apache.lucene.util.Version.LUCENE_6_4_1);
public static final int V_5_2_2_ID = 5020299;
public static final Version V_5_2_2 = new Version(V_5_2_2_ID, org.apache.lucene.util.Version.LUCENE_6_4_1);
public static final int V_5_3_0_ID = 5030099;
public static final Version V_5_3_0 = new Version(V_5_3_0_ID, org.apache.lucene.util.Version.LUCENE_6_4_1);
public static final int V_5_3_1_ID = 5030199;
public static final Version V_5_3_1 = new Version(V_5_3_1_ID, org.apache.lucene.util.Version.LUCENE_6_4_2);
public static final int V_5_3_2_ID = 5030299;
public static final Version V_5_3_2 = new Version(V_5_3_2_ID, org.apache.lucene.util.Version.LUCENE_6_4_2);
public static final int V_5_4_0_ID = 5040099;
public static final Version V_5_4_0 = new Version(V_5_4_0_ID, org.apache.lucene.util.Version.LUCENE_6_5_0);
public static final int V_5_5_0_ID_UNRELEASED = 5050099;
public static final Version V_5_5_0_UNRELEASED = new Version(V_5_5_0_ID_UNRELEASED, org.apache.lucene.util.Version.LUCENE_6_5_0);
public static final int V_6_0_0_alpha1_ID_UNRELEASED = 6000001;
@ -111,32 +103,24 @@ public class Version implements Comparable<Version> {
return V_6_0_0_alpha1_UNRELEASED;
case V_5_5_0_ID_UNRELEASED:
return V_5_5_0_UNRELEASED;
case V_5_4_1_ID_UNRELEASED:
return V_5_4_1_UNRELEASED;
case V_5_4_0_ID_UNRELEASED:
return V_5_4_0_UNRELEASED;
case V_5_3_2_ID_UNRELEASED:
return V_5_3_2_UNRELEASED;
case V_5_3_1_ID_UNRELEASED:
return V_5_3_1_UNRELEASED;
case V_5_3_0_ID_UNRELEASED:
return V_5_3_0_UNRELEASED;
case V_5_2_3_ID_UNRELEASED:
return V_5_2_3_UNRELEASED;
case V_5_2_2_ID_UNRELEASED:
return V_5_2_2_UNRELEASED;
case V_5_2_1_ID_UNRELEASED:
return V_5_2_1_UNRELEASED;
case V_5_2_0_ID_UNRELEASED:
return V_5_2_0_UNRELEASED;
case V_5_1_3_ID_UNRELEASED:
return V_5_1_3_UNRELEASED;
case V_5_1_2_ID_UNRELEASED:
return V_5_1_2_UNRELEASED;
case V_5_1_1_ID_UNRELEASED:
return V_5_1_1_UNRELEASED;
case V_5_0_3_ID_UNRELEASED:
return V_5_0_3_UNRELEASED;
case V_5_4_0_ID:
return V_5_4_0;
case V_5_3_2_ID:
return V_5_3_2;
case V_5_3_1_ID:
return V_5_3_1;
case V_5_3_0_ID:
return V_5_3_0;
case V_5_2_2_ID:
return V_5_2_2;
case V_5_2_1_ID:
return V_5_2_1;
case V_5_2_0_ID:
return V_5_2_0;
case V_5_1_2_ID:
return V_5_1_2;
case V_5_1_1_ID:
return V_5_1_1;
case V_5_0_2_ID:
return V_5_0_2;
case V_5_0_1_ID:
@ -296,7 +280,7 @@ public class Version implements Comparable<Version> {
final int bwcMinor;
if (this.onOrAfter(Version.V_6_0_0_alpha1_UNRELEASED)) {
bwcMajor = major - 1;
bwcMinor = 0; // TODO we have to move this to the latest released minor of the last major but for now we just keep
bwcMinor = 4;
} else {
bwcMajor = major;
bwcMinor = 0;
@ -306,7 +290,8 @@ public class Version implements Comparable<Version> {
/**
* Returns the minimum created index version that this version supports. Indices created with lower versions
* can't be used with this version.
* can't be used with this version. This should also be used for file based serialization backwards compatibility ie. on serialization
* code that is used to read / write file formats like transaction logs, cluster state, and index metadata.
*/
public Version minimumIndexCompatibilityVersion() {
final int bwcMajor;

View File

@ -249,8 +249,8 @@ public class ClusterAllocationExplainRequest extends MasterNodeRequest<ClusterAl
}
private void checkVersion(Version version) {
if (version.before(Version.V_5_2_0_UNRELEASED)) {
throw new IllegalArgumentException("cannot explain shards in a mixed-cluster with pre-" + Version.V_5_2_0_UNRELEASED +
if (version.before(Version.V_5_2_0)) {
throw new IllegalArgumentException("cannot explain shards in a mixed-cluster with pre-" + Version.V_5_2_0 +
" nodes, node version [" + version + "]");
}
}

View File

@ -134,7 +134,7 @@ public class ClusterSearchShardsRequest extends MasterNodeReadRequest<ClusterSea
routing = in.readOptionalString();
preference = in.readOptionalString();
if (in.getVersion().onOrBefore(Version.V_5_1_1_UNRELEASED)) {
if (in.getVersion().onOrBefore(Version.V_5_1_1)) {
//types
in.readStringArray();
}
@ -153,7 +153,7 @@ public class ClusterSearchShardsRequest extends MasterNodeReadRequest<ClusterSea
out.writeOptionalString(routing);
out.writeOptionalString(preference);
if (out.getVersion().onOrBefore(Version.V_5_1_1_UNRELEASED)) {
if (out.getVersion().onOrBefore(Version.V_5_1_1)) {
//types
out.writeStringArray(Strings.EMPTY_ARRAY);
}

View File

@ -73,7 +73,7 @@ public class ClusterSearchShardsResponse extends ActionResponse implements ToXCo
for (int i = 0; i < nodes.length; i++) {
nodes[i] = new DiscoveryNode(in);
}
if (in.getVersion().onOrAfter(Version.V_5_1_1_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_1_1)) {
int size = in.readVInt();
indicesAndFilters = new HashMap<>();
for (int i = 0; i < size; i++) {
@ -95,7 +95,7 @@ public class ClusterSearchShardsResponse extends ActionResponse implements ToXCo
for (DiscoveryNode node : nodes) {
node.writeTo(out);
}
if (out.getVersion().onOrAfter(Version.V_5_1_1_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_1_1)) {
out.writeVInt(indicesAndFilters.size());
for (Map.Entry<String, AliasFilter> entry : indicesAndFilters.entrySet()) {
out.writeString(entry.getKey());

View File

@ -59,7 +59,7 @@ public class GetStoredScriptResponse extends ActionResponse implements ToXConten
super.readFrom(in);
if (in.readBoolean()) {
if (in.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_3_0)) {
source = new StoredScriptSource(in);
} else {
source = new StoredScriptSource(in.readString());
@ -78,7 +78,7 @@ public class GetStoredScriptResponse extends ActionResponse implements ToXConten
} else {
out.writeBoolean(true);
if (out.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_3_0)) {
source.writeTo(out);
} else {
out.writeString(source.getCode());

View File

@ -123,7 +123,7 @@ public class PutStoredScriptRequest extends AcknowledgedRequest<PutStoredScriptR
id = in.readOptionalString();
content = in.readBytesReference();
if (in.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_3_0)) {
xContentType = XContentType.readFrom(in);
} else {
xContentType = XContentFactory.xContentType(content);
@ -137,7 +137,7 @@ public class PutStoredScriptRequest extends AcknowledgedRequest<PutStoredScriptR
out.writeString(lang == null ? "" : lang);
out.writeOptionalString(id);
out.writeBytesReference(content);
if (out.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_3_0)) {
xContentType.writeTo(out);
}
}

View File

@ -117,7 +117,7 @@ public class AnalyzeResponse extends ActionResponse implements Iterable<AnalyzeR
startOffset = in.readInt();
endOffset = in.readInt();
position = in.readVInt();
if (in.getVersion().onOrAfter(Version.V_5_2_0_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_2_0)) {
Integer len = in.readOptionalVInt();
if (len != null) {
positionLength = len;
@ -135,7 +135,7 @@ public class AnalyzeResponse extends ActionResponse implements Iterable<AnalyzeR
out.writeInt(startOffset);
out.writeInt(endOffset);
out.writeVInt(position);
if (out.getVersion().onOrAfter(Version.V_5_2_0_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_2_0)) {
out.writeOptionalVInt(positionLength > 1 ? positionLength : null);
}
out.writeOptionalString(type);

View File

@ -76,7 +76,7 @@ public class QueryExplanation implements Streamable {
@Override
public void readFrom(StreamInput in) throws IOException {
index = in.readString();
if (in.getVersion().onOrAfter(Version.V_5_4_0_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_4_0)) {
shard = in.readInt();
} else {
shard = RANDOM_SHARD;
@ -89,7 +89,7 @@ public class QueryExplanation implements Streamable {
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeString(index);
if (out.getVersion().onOrAfter(Version.V_5_4_0_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_4_0)) {
out.writeInt(shard);
}
out.writeBoolean(valid);

View File

@ -154,7 +154,7 @@ public class ValidateQueryRequest extends BroadcastRequest<ValidateQueryRequest>
}
explain = in.readBoolean();
rewrite = in.readBoolean();
if (in.getVersion().onOrAfter(Version.V_5_4_0_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_4_0)) {
allShards = in.readBoolean();
}
}
@ -169,7 +169,7 @@ public class ValidateQueryRequest extends BroadcastRequest<ValidateQueryRequest>
}
out.writeBoolean(explain);
out.writeBoolean(rewrite);
if (out.getVersion().onOrAfter(Version.V_5_4_0_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_4_0)) {
out.writeBoolean(allShards);
}
}

View File

@ -37,7 +37,6 @@ import org.elasticsearch.common.xcontent.StatusToXContentObject;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.seqno.SequenceNumbers;
import org.elasticsearch.index.seqno.SequenceNumbersService;
import org.elasticsearch.rest.RestStatus;
@ -421,7 +420,7 @@ public class BulkItemResponse implements Streamable, StatusToXContentObject {
@Override
public void readFrom(StreamInput in) throws IOException {
id = in.readVInt();
if (in.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_3_0)) {
opType = OpType.fromId(in.readByte());
} else {
opType = OpType.fromString(in.readString());
@ -448,7 +447,7 @@ public class BulkItemResponse implements Streamable, StatusToXContentObject {
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(id);
if (out.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_3_0)) {
out.writeByte(opType.getId());
} else {
out.writeString(opType.getLowercase());

View File

@ -415,10 +415,10 @@ public class TransportShardBulkAction extends TransportWriteAction<BulkShardRequ
}
static {
assert Version.CURRENT.minimumCompatibilityVersion().after(Version.V_5_0_0) == false:
assert Version.CURRENT.minimumCompatibilityVersion().after(Version.V_6_0_0_alpha1_UNRELEASED) == false:
"Remove logic handling NoOp result from primary response; see TODO in replicaItemExecutionMode" +
" as the current minimum compatible version [" +
Version.CURRENT.minimumCompatibilityVersion() + "] is after 5.0";
Version.CURRENT.minimumCompatibilityVersion() + "] is after 6.0";
}
/**

View File

@ -323,14 +323,14 @@ public abstract class FieldStats<T> implements Writeable, ToXContent {
out.writeLong(sumTotalTermFreq);
out.writeBoolean(isSearchable);
out.writeBoolean(isAggregatable);
if (out.getVersion().onOrAfter(Version.V_5_2_0_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_2_0)) {
out.writeBoolean(hasMinMax);
if (hasMinMax) {
writeMinMax(out);
}
} else {
assert hasMinMax : "cannot serialize null min/max fieldstats in a mixed-cluster " +
"with pre-" + Version.V_5_2_0_UNRELEASED + " nodes, remote version [" + out.getVersion() + "]";
"with pre-" + Version.V_5_2_0 + " nodes, remote version [" + out.getVersion() + "]";
writeMinMax(out);
}
}
@ -705,7 +705,7 @@ public abstract class FieldStats<T> implements Writeable, ToXContent {
boolean isSearchable = in.readBoolean();
boolean isAggregatable = in.readBoolean();
boolean hasMinMax = true;
if (in.getVersion().onOrAfter(Version.V_5_2_0_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_2_0)) {
hasMinMax = in.readBoolean();
}
switch (type) {

View File

@ -93,7 +93,7 @@ public class FieldStatsResponse extends BroadcastResponse {
for (Map.Entry<String, Map<String, FieldStats>> entry1 : indicesMergedFieldStats.entrySet()) {
out.writeString(entry1.getKey());
int size = entry1.getValue().size();
if (out.getVersion().before(Version.V_5_2_0_UNRELEASED)) {
if (out.getVersion().before(Version.V_5_2_0)) {
// filter fieldstats without min/max information
for (FieldStats stats : entry1.getValue().values()) {
if (stats.hasMinMax() == false) {
@ -103,7 +103,7 @@ public class FieldStatsResponse extends BroadcastResponse {
}
out.writeVInt(size);
for (Map.Entry<String, FieldStats> entry2 : entry1.getValue().entrySet()) {
if (entry2.getValue().hasMinMax() || out.getVersion().onOrAfter(Version.V_5_2_0_UNRELEASED)) {
if (entry2.getValue().hasMinMax() || out.getVersion().onOrAfter(Version.V_5_2_0)) {
out.writeString(entry2.getKey());
entry2.getValue().writeTo(out);
}

View File

@ -68,7 +68,7 @@ public class FieldStatsShardResponse extends BroadcastShardResponse {
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
final Map<String, FieldStats<?> > stats;
if (out.getVersion().before(Version.V_5_2_0_UNRELEASED)) {
if (out.getVersion().before(Version.V_5_2_0)) {
/**
* FieldStats with null min/max are not (de)serializable in versions prior to {@link Version.V_5_2_0_UNRELEASED}
*/

View File

@ -534,7 +534,7 @@ public class IndexRequest extends ReplicatedWriteRequest<IndexRequest> implement
pipeline = in.readOptionalString();
isRetry = in.readBoolean();
autoGeneratedTimestamp = in.readLong();
if (in.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_3_0)) {
contentType = in.readOptionalWriteable(XContentType::readFrom);
} else {
contentType = XContentFactory.xContentType(source);
@ -558,7 +558,7 @@ public class IndexRequest extends ReplicatedWriteRequest<IndexRequest> implement
out.writeBytesReference(source);
out.writeByte(opType.getId());
// ES versions below 5.1.2 don't know about resolveVersionDefaults but resolve the version eagerly (which messes with validation).
if (out.getVersion().before(Version.V_5_1_2_UNRELEASED)) {
if (out.getVersion().before(Version.V_5_1_2)) {
out.writeLong(resolveVersionDefaults());
} else {
out.writeLong(version);
@ -567,7 +567,7 @@ public class IndexRequest extends ReplicatedWriteRequest<IndexRequest> implement
out.writeOptionalString(pipeline);
out.writeBoolean(isRetry);
out.writeLong(autoGeneratedTimestamp);
if (out.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_3_0)) {
out.writeOptionalWriteable(contentType);
}
}

View File

@ -80,7 +80,7 @@ public class PutPipelineRequest extends AcknowledgedRequest<PutPipelineRequest>
super.readFrom(in);
id = in.readString();
source = in.readBytesReference();
if (in.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_3_0)) {
xContentType = XContentType.readFrom(in);
} else {
xContentType = XContentFactory.xContentType(source);
@ -92,7 +92,7 @@ public class PutPipelineRequest extends AcknowledgedRequest<PutPipelineRequest>
super.writeTo(out);
out.writeString(id);
out.writeBytesReference(source);
if (out.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_3_0)) {
xContentType.writeTo(out);
}
}

View File

@ -103,7 +103,7 @@ public class SimulatePipelineRequest extends ActionRequest {
id = in.readOptionalString();
verbose = in.readBoolean();
source = in.readBytesReference();
if (in.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_3_0)) {
xContentType = XContentType.readFrom(in);
} else {
xContentType = XContentFactory.xContentType(source);
@ -116,7 +116,7 @@ public class SimulatePipelineRequest extends ActionRequest {
out.writeOptionalString(id);
out.writeBoolean(verbose);
out.writeBytesReference(source);
if (out.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_3_0)) {
xContentType.writeTo(out);
}
}

View File

@ -120,7 +120,7 @@ public class SearchTransportService extends AbstractComponent {
// this used to be the QUERY_AND_FETCH which doesn't exists anymore.
final boolean fetchDocuments = request.numberOfShards() == 1;
Supplier<SearchPhaseResult> supplier = fetchDocuments ? QueryFetchSearchResult::new : QuerySearchResult::new;
if (connection.getVersion().before(Version.V_5_3_0_UNRELEASED) && fetchDocuments) {
if (connection.getVersion().before(Version.V_5_3_0) && fetchDocuments) {
// this is a BWC layer for pre 5.3 indices
if (request.scroll() != null) {
/**

View File

@ -499,7 +499,7 @@ public class TermVectorsRequest extends SingleShardRequest<TermVectorsRequest> i
if (in.readBoolean()) {
doc = in.readBytesReference();
if (in.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_3_0)) {
xContentType = XContentType.readFrom(in);
} else {
xContentType = XContentFactory.xContentType(doc);
@ -544,7 +544,7 @@ public class TermVectorsRequest extends SingleShardRequest<TermVectorsRequest> i
out.writeBoolean(doc != null);
if (doc != null) {
out.writeBytesReference(doc);
if (out.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_3_0)) {
xContentType.writeTo(out);
}
}

View File

@ -30,7 +30,7 @@ public interface NamedDiff<T extends Diffable<T>> extends Diff<T>, NamedWriteabl
* The minimal version of the recipient this custom object can be sent to
*/
default Version getMinimalSupportedVersion() {
return Version.CURRENT.minimumCompatibilityVersion();
return Version.CURRENT.minimumIndexCompatibilityVersion();
}
}

View File

@ -30,6 +30,6 @@ public interface NamedDiffable<T> extends Diffable<T>, NamedWriteable {
* The minimal version of the recipient this custom object can be sent to
*/
default Version getMinimalSupportedVersion() {
return Version.CURRENT.minimumCompatibilityVersion();
return Version.CURRENT.minimumIndexCompatibilityVersion();
}
}

View File

@ -40,7 +40,7 @@ public class SnapshotDeletionsInProgress extends AbstractNamedDiffable<Custom> i
public static final String TYPE = "snapshot_deletions";
// the version where SnapshotDeletionsInProgress was introduced
public static final Version VERSION_INTRODUCED = Version.V_5_2_0_UNRELEASED;
public static final Version VERSION_INTRODUCED = Version.V_5_2_0;
// the list of snapshot deletion request entries
private final List<Entry> entries;

View File

@ -51,7 +51,7 @@ public class SnapshotsInProgress extends AbstractNamedDiffable<Custom> implement
// a snapshot in progress from a pre 5.2.x node
public static final long UNDEFINED_REPOSITORY_STATE_ID = -2L;
// the version where repository state ids were introduced
private static final Version REPOSITORY_ID_INTRODUCED_VERSION = Version.V_5_2_0_UNRELEASED;
private static final Version REPOSITORY_ID_INTRODUCED_VERSION = Version.V_5_2_0;
@Override
public boolean equals(Object o) {

View File

@ -34,7 +34,6 @@ import java.io.IOException;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.function.Predicate;
@ -222,7 +221,7 @@ public class DiscoveryNode implements Writeable, ToXContent {
this.ephemeralId = in.readString().intern();
this.hostName = in.readString().intern();
this.hostAddress = in.readString().intern();
if (in.getVersion().onOrAfter(Version.V_5_0_3_UNRELEASED)) {
if (in.getVersion().after(Version.V_5_0_2)) {
this.address = new TransportAddress(in);
} else {
// we need to do this to preserve the host information during pinging and joining of a master. Since the version of the

View File

@ -80,7 +80,7 @@ public class NodeAllocationResult implements ToXContent, Writeable, Comparable<N
public NodeAllocationResult(StreamInput in) throws IOException {
node = new DiscoveryNode(in);
shardStoreInfo = in.readOptionalWriteable(ShardStoreInfo::new);
if (in.getVersion().before(Version.V_5_2_1_UNRELEASED)) {
if (in.getVersion().before(Version.V_5_2_1)) {
canAllocateDecision = Decision.readFrom(in);
} else {
canAllocateDecision = in.readOptionalWriteable(Decision::readFrom);
@ -93,7 +93,7 @@ public class NodeAllocationResult implements ToXContent, Writeable, Comparable<N
public void writeTo(StreamOutput out) throws IOException {
node.writeTo(out);
out.writeOptionalWriteable(shardStoreInfo);
if (out.getVersion().before(Version.V_5_2_1_UNRELEASED)) {
if (out.getVersion().before(Version.V_5_2_1)) {
if (canAllocateDecision == null) {
Decision.NO.writeTo(out);
} else {

View File

@ -74,8 +74,8 @@ public final class TransportAddress implements Writeable {
}
/**
* Read from a stream and use the {@code hostString} when creating the InetAddress if the input comes from a version prior
* {@link Version#V_5_0_3_UNRELEASED} as the hostString was not serialized
* Read from a stream and use the {@code hostString} when creating the InetAddress if the input comes from a version on or prior
* {@link Version#V_5_0_2} as the hostString was not serialized
*/
public TransportAddress(StreamInput in, @Nullable String hostString) throws IOException {
if (in.getVersion().before(Version.V_6_0_0_alpha1_UNRELEASED)) { // bwc layer for 5.x where we had more than one transport address
@ -88,7 +88,7 @@ public final class TransportAddress implements Writeable {
final byte[] a = new byte[len]; // 4 bytes (IPv4) or 16 bytes (IPv6)
in.readFully(a);
final InetAddress inetAddress;
if (in.getVersion().onOrAfter(Version.V_5_0_3_UNRELEASED)) {
if (in.getVersion().after(Version.V_5_0_2)) {
String host = in.readString(); // the host string was serialized so we can ignore the passed in version
inetAddress = InetAddress.getByAddress(host, a);
} else {
@ -107,7 +107,7 @@ public final class TransportAddress implements Writeable {
byte[] bytes = address.getAddress().getAddress(); // 4 bytes (IPv4) or 16 bytes (IPv6)
out.writeByte((byte) bytes.length); // 1 byte
out.write(bytes, 0, bytes.length);
if (out.getVersion().onOrAfter(Version.V_5_0_3_UNRELEASED)) {
if (out.getVersion().after(Version.V_5_0_2)) {
out.writeString(address.getHostString());
}
// don't serialize scope ids over the network!!!!

View File

@ -223,7 +223,7 @@ public class GatewayMetaState extends AbstractComponent implements ClusterStateA
final String name = stateFile.getFileName().toString();
if (name.startsWith("metadata-")) {
throw new IllegalStateException("Detected pre 0.19 metadata file please upgrade to a version before "
+ Version.CURRENT.minimumCompatibilityVersion()
+ Version.CURRENT.minimumIndexCompatibilityVersion()
+ " first to upgrade state structures - metadata found: [" + stateFile.getParent().toAbsolutePath());
}
}
@ -294,7 +294,7 @@ public class GatewayMetaState extends AbstractComponent implements ClusterStateA
try (DirectoryStream<Path> stream = Files.newDirectoryStream(stateLocation, "shards-*")) {
for (Path stateFile : stream) {
throw new IllegalStateException("Detected pre 0.19 shard state file please upgrade to a version before "
+ Version.CURRENT.minimumCompatibilityVersion()
+ Version.CURRENT.minimumIndexCompatibilityVersion()
+ " first to upgrade state structures - shard state found: [" + stateFile.getParent().toAbsolutePath());
}
}

View File

@ -213,7 +213,7 @@ public final class InnerHitBuilder extends ToXContentToBytes implements Writeabl
name = in.readOptionalString();
nestedPath = in.readOptionalString();
parentChildType = in.readOptionalString();
if (in.getVersion().onOrAfter(Version.V_5_2_0_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_2_0)) {
ignoreUnmapped = in.readBoolean();
}
from = in.readVInt();
@ -254,7 +254,7 @@ public final class InnerHitBuilder extends ToXContentToBytes implements Writeabl
out.writeOptionalString(name);
out.writeOptionalString(nestedPath);
out.writeOptionalString(parentChildType);
if (out.getVersion().onOrAfter(Version.V_5_2_0_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_2_0)) {
out.writeBoolean(ignoreUnmapped);
}
out.writeVInt(from);

View File

@ -228,7 +228,7 @@ public class MoreLikeThisQueryBuilder extends AbstractQueryBuilder<MoreLikeThisQ
type = in.readOptionalString();
if (in.readBoolean()) {
doc = (BytesReference) in.readGenericValue();
if (in.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_3_0)) {
xContentType = XContentType.readFrom(in);
} else {
xContentType = XContentFactory.xContentType(doc);
@ -250,7 +250,7 @@ public class MoreLikeThisQueryBuilder extends AbstractQueryBuilder<MoreLikeThisQ
out.writeBoolean(doc != null);
if (doc != null) {
out.writeGenericValue(doc);
if (out.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_3_0)) {
xContentType.writeTo(out);
}
} else {

View File

@ -212,11 +212,11 @@ public class QueryStringQueryBuilder extends AbstractQueryBuilder<QueryStringQue
autoGeneratePhraseQueries = in.readBoolean();
allowLeadingWildcard = in.readOptionalBoolean();
analyzeWildcard = in.readOptionalBoolean();
if (in.getVersion().before(Version.V_5_1_1_UNRELEASED)) {
if (in.getVersion().before(Version.V_5_1_1)) {
in.readBoolean(); // lowercase_expanded_terms
}
enablePositionIncrements = in.readBoolean();
if (in.getVersion().before(Version.V_5_1_1_UNRELEASED)) {
if (in.getVersion().before(Version.V_5_1_1)) {
in.readString(); // locale
}
fuzziness = new Fuzziness(in);
@ -232,7 +232,7 @@ public class QueryStringQueryBuilder extends AbstractQueryBuilder<QueryStringQue
timeZone = in.readOptionalTimeZone();
escape = in.readBoolean();
maxDeterminizedStates = in.readVInt();
if (in.getVersion().onOrAfter(Version.V_5_1_1_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_1_1)) {
splitOnWhitespace = in.readBoolean();
useAllFields = in.readOptionalBoolean();
} else {
@ -256,11 +256,11 @@ public class QueryStringQueryBuilder extends AbstractQueryBuilder<QueryStringQue
out.writeBoolean(this.autoGeneratePhraseQueries);
out.writeOptionalBoolean(this.allowLeadingWildcard);
out.writeOptionalBoolean(this.analyzeWildcard);
if (out.getVersion().before(Version.V_5_1_1_UNRELEASED)) {
if (out.getVersion().before(Version.V_5_1_1)) {
out.writeBoolean(true); // lowercase_expanded_terms
}
out.writeBoolean(this.enablePositionIncrements);
if (out.getVersion().before(Version.V_5_1_1_UNRELEASED)) {
if (out.getVersion().before(Version.V_5_1_1)) {
out.writeString(Locale.ROOT.toLanguageTag()); // locale
}
this.fuzziness.writeTo(out);
@ -276,7 +276,7 @@ public class QueryStringQueryBuilder extends AbstractQueryBuilder<QueryStringQue
out.writeOptionalTimeZone(timeZone);
out.writeBoolean(this.escape);
out.writeVInt(this.maxDeterminizedStates);
if (out.getVersion().onOrAfter(Version.V_5_1_1_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_1_1)) {
out.writeBoolean(this.splitOnWhitespace);
out.writeOptionalBoolean(this.useAllFields);
}

View File

@ -112,7 +112,7 @@ public class RangeQueryBuilder extends AbstractQueryBuilder<RangeQueryBuilder> i
if (formatString != null) {
format = Joda.forPattern(formatString);
}
if (in.getVersion().onOrAfter(Version.V_5_2_0_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_2_0)) {
String relationString = in.readOptionalString();
if (relationString != null) {
relation = ShapeRelation.getRelationByName(relationString);
@ -133,7 +133,7 @@ public class RangeQueryBuilder extends AbstractQueryBuilder<RangeQueryBuilder> i
formatString = this.format.format();
}
out.writeOptionalString(formatString);
if (out.getVersion().onOrAfter(Version.V_5_2_0_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_2_0)) {
String relationString = null;
if (this.relation != null) {
relationString = this.relation.getRelationName();

View File

@ -157,19 +157,19 @@ public class SimpleQueryStringBuilder extends AbstractQueryBuilder<SimpleQuerySt
flags = in.readInt();
analyzer = in.readOptionalString();
defaultOperator = Operator.readFromStream(in);
if (in.getVersion().before(Version.V_5_1_1_UNRELEASED)) {
if (in.getVersion().before(Version.V_5_1_1)) {
in.readBoolean(); // lowercase_expanded_terms
}
settings.lenient(in.readBoolean());
if (in.getVersion().onOrAfter(Version.V_5_1_1_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_1_1)) {
this.lenientSet = in.readBoolean();
}
settings.analyzeWildcard(in.readBoolean());
if (in.getVersion().before(Version.V_5_1_1_UNRELEASED)) {
if (in.getVersion().before(Version.V_5_1_1)) {
in.readString(); // locale
}
minimumShouldMatch = in.readOptionalString();
if (in.getVersion().onOrAfter(Version.V_5_1_1_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_1_1)) {
settings.quoteFieldSuffix(in.readOptionalString());
useAllFields = in.readOptionalBoolean();
}
@ -186,19 +186,19 @@ public class SimpleQueryStringBuilder extends AbstractQueryBuilder<SimpleQuerySt
out.writeInt(flags);
out.writeOptionalString(analyzer);
defaultOperator.writeTo(out);
if (out.getVersion().before(Version.V_5_1_1_UNRELEASED)) {
if (out.getVersion().before(Version.V_5_1_1)) {
out.writeBoolean(true); // lowercase_expanded_terms
}
out.writeBoolean(settings.lenient());
if (out.getVersion().onOrAfter(Version.V_5_1_1_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_1_1)) {
out.writeBoolean(lenientSet);
}
out.writeBoolean(settings.analyzeWildcard());
if (out.getVersion().before(Version.V_5_1_1_UNRELEASED)) {
if (out.getVersion().before(Version.V_5_1_1)) {
out.writeString(Locale.ROOT.toLanguageTag()); // locale
}
out.writeOptionalString(minimumShouldMatch);
if (out.getVersion().onOrAfter(Version.V_5_1_1_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_1_1)) {
out.writeOptionalString(settings.quoteFieldSuffix());
out.writeOptionalBoolean(useAllFields);
}

View File

@ -19,7 +19,6 @@
package org.elasticsearch.index.refresh;
import org.elasticsearch.Version;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Streamable;
@ -106,20 +105,14 @@ public class RefreshStats implements Streamable, ToXContent {
public void readFrom(StreamInput in) throws IOException {
total = in.readVLong();
totalTimeInMillis = in.readVLong();
if (in.getVersion().onOrAfter(Version.V_5_2_0_UNRELEASED)) {
listeners = in.readVInt();
} else {
listeners = 0;
}
listeners = in.readVInt();
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeVLong(total);
out.writeVLong(totalTimeInMillis);
if (out.getVersion().onOrAfter(Version.V_5_2_0_UNRELEASED)) {
out.writeVInt(listeners);
}
out.writeVInt(listeners);
}
@Override

View File

@ -402,7 +402,7 @@ public abstract class AbstractBulkByScrollRequest<Self extends AbstractBulkByScr
retryBackoffInitialTime = new TimeValue(in);
maxRetries = in.readVInt();
requestsPerSecond = in.readFloat();
if (in.getVersion().onOrAfter(Version.V_5_1_1_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_1_1)) {
slices = in.readVInt();
} else {
slices = 1;
@ -421,12 +421,12 @@ public abstract class AbstractBulkByScrollRequest<Self extends AbstractBulkByScr
retryBackoffInitialTime.writeTo(out);
out.writeVInt(maxRetries);
out.writeFloat(requestsPerSecond);
if (out.getVersion().onOrAfter(Version.V_5_1_1_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_1_1)) {
out.writeVInt(slices);
} else {
if (slices > 1) {
throw new IllegalArgumentException("Attempting to send sliced reindex-style request to a node that doesn't support "
+ "it. Version is [" + out.getVersion() + "] but must be [" + Version.V_5_1_1_UNRELEASED + "]");
+ "it. Version is [" + out.getVersion() + "] but must be [" + Version.V_5_1_1 + "]");
}
}
}

View File

@ -189,7 +189,7 @@ public abstract class BulkByScrollTask extends CancellableTask {
}
public Status(StreamInput in) throws IOException {
if (in.getVersion().onOrAfter(Version.V_5_1_1_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_1_1)) {
sliceId = in.readOptionalVInt();
} else {
sliceId = null;
@ -207,7 +207,7 @@ public abstract class BulkByScrollTask extends CancellableTask {
requestsPerSecond = in.readFloat();
reasonCancelled = in.readOptionalString();
throttledUntil = new TimeValue(in);
if (in.getVersion().onOrAfter(Version.V_5_1_1_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_1_1)) {
sliceStatuses = in.readList(stream -> stream.readOptionalWriteable(StatusOrException::new));
} else {
sliceStatuses = emptyList();
@ -216,7 +216,7 @@ public abstract class BulkByScrollTask extends CancellableTask {
@Override
public void writeTo(StreamOutput out) throws IOException {
if (out.getVersion().onOrAfter(Version.V_5_1_1_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_1_1)) {
out.writeOptionalVInt(sliceId);
}
out.writeVLong(total);
@ -232,7 +232,7 @@ public abstract class BulkByScrollTask extends CancellableTask {
out.writeFloat(requestsPerSecond);
out.writeOptionalString(reasonCancelled);
throttledUntil.writeTo(out);
if (out.getVersion().onOrAfter(Version.V_5_1_1_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_1_1)) {
out.writeVInt(sliceStatuses.size());
for (StatusOrException sliceStatus : sliceStatuses) {
out.writeOptionalWriteable(sliceStatus);

View File

@ -90,7 +90,7 @@ public class RemoteInfo implements Writeable {
headers.put(in.readString(), in.readString());
}
this.headers = unmodifiableMap(headers);
if (in.getVersion().onOrAfter(Version.V_5_2_0_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_2_0)) {
socketTimeout = new TimeValue(in);
connectTimeout = new TimeValue(in);
} else {
@ -112,7 +112,7 @@ public class RemoteInfo implements Writeable {
out.writeString(header.getKey());
out.writeString(header.getValue());
}
if (out.getVersion().onOrAfter(Version.V_5_2_0_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_2_0)) {
socketTimeout.writeTo(out);
connectTimeout.writeTo(out);
}

View File

@ -118,7 +118,7 @@ public final class PipelineConfiguration extends AbstractDiffable<PipelineConfig
}
public static PipelineConfiguration readFrom(StreamInput in) throws IOException {
if (in.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_3_0)) {
return new PipelineConfiguration(in.readString(), in.readBytesReference(), XContentType.readFrom(in));
} else {
final String id = in.readString();
@ -135,7 +135,7 @@ public final class PipelineConfiguration extends AbstractDiffable<PipelineConfig
public void writeTo(StreamOutput out) throws IOException {
out.writeString(id);
out.writeBytesReference(config);
if (out.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_3_0)) {
xContentType.writeTo(out);
}
}

View File

@ -52,7 +52,7 @@ public class OsStats implements Writeable, ToXContent {
this.cpu = new Cpu(in);
this.mem = new Mem(in);
this.swap = new Swap(in);
if (in.getVersion().onOrAfter(Version.V_5_1_1_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_1_1)) {
this.cgroup = in.readOptionalWriteable(Cgroup::new);
} else {
this.cgroup = null;
@ -65,7 +65,7 @@ public class OsStats implements Writeable, ToXContent {
cpu.writeTo(out);
mem.writeTo(out);
swap.writeTo(out);
if (out.getVersion().onOrAfter(Version.V_5_1_1_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_1_1)) {
out.writeOptionalWriteable(cgroup);
}
}

View File

@ -81,7 +81,7 @@ public class PluginInfo implements Writeable, ToXContent {
this.description = in.readString();
this.version = in.readString();
this.classname = in.readString();
if (in.getVersion().onOrAfter(Version.V_5_4_0_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_4_0)) {
hasNativeController = in.readBoolean();
} else {
hasNativeController = false;
@ -94,7 +94,7 @@ public class PluginInfo implements Writeable, ToXContent {
out.writeString(description);
out.writeString(version);
out.writeString(classname);
if (out.getVersion().onOrAfter(Version.V_5_4_0_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_4_0)) {
out.writeBoolean(hasNativeController);
}
}

View File

@ -485,7 +485,7 @@ public final class Script implements ToXContentObject, Writeable {
public Script(StreamInput in) throws IOException {
// Version 5.3 allows lang to be an optional parameter for stored scripts and expects
// options to be null for stored and file scripts.
if (in.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_3_0)) {
this.type = ScriptType.readFrom(in);
this.lang = in.readOptionalString();
this.idOrCode = in.readString();
@ -496,7 +496,7 @@ public final class Script implements ToXContentObject, Writeable {
// Version 5.1 to 5.3 (exclusive) requires all Script members to be non-null and supports the potential
// for more options than just XContentType. Reorders the read in contents to be in
// same order as the constructor.
} else if (in.getVersion().onOrAfter(Version.V_5_1_1_UNRELEASED)) {
} else if (in.getVersion().onOrAfter(Version.V_5_1_1)) {
this.type = ScriptType.readFrom(in);
this.lang = in.readString();
@ -554,7 +554,7 @@ public final class Script implements ToXContentObject, Writeable {
public void writeTo(StreamOutput out) throws IOException {
// Version 5.3+ allows lang to be an optional parameter for stored scripts and expects
// options to be null for stored and file scripts.
if (out.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_3_0)) {
type.writeTo(out);
out.writeOptionalString(lang);
out.writeString(idOrCode);
@ -565,7 +565,7 @@ public final class Script implements ToXContentObject, Writeable {
// Version 5.1 to 5.3 (exclusive) requires all Script members to be non-null and supports the potential
// for more options than just XContentType. Reorders the written out contents to be in
// same order as the constructor.
} else if (out.getVersion().onOrAfter(Version.V_5_1_1_UNRELEASED)) {
} else if (out.getVersion().onOrAfter(Version.V_5_1_1)) {
type.writeTo(out);
if (lang == null) {

View File

@ -329,7 +329,7 @@ public final class ScriptMetaData implements MetaData.Custom, Writeable, ToXCont
// Split the id to find the language then use StoredScriptSource to parse the
// expected BytesReference after which a new StoredScriptSource is created
// with the appropriate language and options.
if (in.getVersion().before(Version.V_5_3_0_UNRELEASED)) {
if (in.getVersion().before(Version.V_5_3_0)) {
int split = id.indexOf('#');
if (split == -1) {
@ -353,7 +353,7 @@ public final class ScriptMetaData implements MetaData.Custom, Writeable, ToXCont
public void writeTo(StreamOutput out) throws IOException {
// Version 5.3+ will output the contents of the scripts' Map using
// StoredScriptSource to stored the language, code, and options.
if (out.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_3_0)) {
out.writeVInt(scripts.size());
for (Map.Entry<String, StoredScriptSource> entry : scripts.entrySet()) {

View File

@ -365,7 +365,7 @@ public class StoredScriptSource extends AbstractDiffable<StoredScriptSource> imp
* only the code parameter will be read in as a bytes reference.
*/
public StoredScriptSource(StreamInput in) throws IOException {
if (in.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_3_0)) {
this.lang = in.readString();
this.code = in.readString();
@SuppressWarnings("unchecked")
@ -385,7 +385,7 @@ public class StoredScriptSource extends AbstractDiffable<StoredScriptSource> imp
*/
@Override
public void writeTo(StreamOutput out) throws IOException {
if (out.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_3_0)) {
out.writeString(lang);
out.writeString(code);
@SuppressWarnings("unchecked")

View File

@ -427,7 +427,7 @@ public class IncludeExclude implements Writeable, ToXContent {
} else {
excludeValues = null;
}
if (in.getVersion().onOrAfter(Version.V_5_2_0_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_2_0)) {
incNumPartitions = in.readVInt();
incZeroBasedPartition = in.readVInt();
} else {
@ -460,7 +460,7 @@ public class IncludeExclude implements Writeable, ToXContent {
out.writeBytesRef(value);
}
}
if (out.getVersion().onOrAfter(Version.V_5_2_0_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_2_0)) {
out.writeVInt(incNumPartitions);
out.writeVInt(incZeroBasedPartition);
}

View File

@ -220,7 +220,7 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
profile = in.readBoolean();
searchAfterBuilder = in.readOptionalWriteable(SearchAfterBuilder::new);
sliceBuilder = in.readOptionalWriteable(SliceBuilder::new);
if (in.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_3_0)) {
collapse = in.readOptionalWriteable(CollapseBuilder::new);
}
}
@ -271,7 +271,7 @@ public final class SearchSourceBuilder extends ToXContentToBytes implements Writ
out.writeBoolean(profile);
out.writeOptionalWriteable(searchAfterBuilder);
out.writeOptionalWriteable(sliceBuilder);
if (out.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_3_0)) {
out.writeOptionalWriteable(collapse);
}
}

View File

@ -128,14 +128,14 @@ public abstract class AbstractHighlighterBuilder<HB extends AbstractHighlighterB
order(in.readOptionalWriteable(Order::readFromStream));
highlightFilter(in.readOptionalBoolean());
forceSource(in.readOptionalBoolean());
if (in.getVersion().onOrAfter(Version.V_5_4_0_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_4_0)) {
boundaryScannerType(in.readOptionalWriteable(BoundaryScannerType::readFromStream));
}
boundaryMaxScan(in.readOptionalVInt());
if (in.readBoolean()) {
boundaryChars(in.readString().toCharArray());
}
if (in.getVersion().onOrAfter(Version.V_5_4_0_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_4_0)) {
if (in.readBoolean()) {
boundaryScannerLocale(in.readString());
}
@ -167,7 +167,7 @@ public abstract class AbstractHighlighterBuilder<HB extends AbstractHighlighterB
out.writeOptionalWriteable(order);
out.writeOptionalBoolean(highlightFilter);
out.writeOptionalBoolean(forceSource);
if (out.getVersion().onOrAfter(Version.V_5_4_0_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_4_0)) {
out.writeOptionalWriteable(boundaryScannerType);
}
out.writeOptionalVInt(boundaryMaxScan);
@ -176,7 +176,7 @@ public abstract class AbstractHighlighterBuilder<HB extends AbstractHighlighterB
if (hasBounaryChars) {
out.writeString(String.valueOf(boundaryChars));
}
if (out.getVersion().onOrAfter(Version.V_5_4_0_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_4_0)) {
boolean hasBoundaryScannerLocale = boundaryScannerLocale != null;
out.writeBoolean(hasBoundaryScannerLocale);
if (hasBoundaryScannerLocale) {

View File

@ -54,7 +54,7 @@ public final class AliasFilter implements Writeable {
public AliasFilter(StreamInput input) throws IOException {
aliases = input.readStringArray();
if (input.getVersion().onOrAfter(Version.V_5_1_1_UNRELEASED)) {
if (input.getVersion().onOrAfter(Version.V_5_1_1)) {
filter = input.readOptionalNamedWriteable(QueryBuilder.class);
reparseAliases = false;
} else {
@ -90,7 +90,7 @@ public final class AliasFilter implements Writeable {
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeStringArray(aliases);
if (out.getVersion().onOrAfter(Version.V_5_1_1_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_1_1)) {
out.writeOptionalNamedWriteable(filter);
}
}

View File

@ -181,7 +181,7 @@ public class ShardSearchLocalRequest implements ShardSearchRequest {
source = in.readOptionalWriteable(SearchSourceBuilder::new);
types = in.readStringArray();
aliasFilter = new AliasFilter(in);
if (in.getVersion().onOrAfter(Version.V_5_2_0_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_2_0)) {
indexBoost = in.readFloat();
} else {
// Nodes < 5.2.0 doesn't send index boost. Read it from source.
@ -209,7 +209,7 @@ public class ShardSearchLocalRequest implements ShardSearchRequest {
out.writeOptionalWriteable(source);
out.writeStringArray(types);
aliasFilter.writeTo(out);
if (out.getVersion().onOrAfter(Version.V_5_2_0_UNRELEASED)) {
if (out.getVersion().onOrAfter(Version.V_5_2_0)) {
out.writeFloat(indexBoost);
}
if (!asKey) {

View File

@ -69,7 +69,7 @@ public final class SnapshotInfo implements Comparable<SnapshotInfo>, ToXContent,
private static final String TOTAL_SHARDS = "total_shards";
private static final String SUCCESSFUL_SHARDS = "successful_shards";
private static final Version VERSION_INCOMPATIBLE_INTRODUCED = Version.V_5_2_0_UNRELEASED;
private static final Version VERSION_INCOMPATIBLE_INTRODUCED = Version.V_5_2_0;
public static final Version VERBOSE_INTRODUCED = Version.V_5_5_0_UNRELEASED;
private static final Comparator<SnapshotInfo> COMPARATOR =

View File

@ -1324,9 +1324,15 @@ public abstract class TcpTransport<Channel> extends AbstractLifecycleComponent i
}
streamIn = compressor.streamInput(streamIn);
}
if (version.isCompatible(getCurrentVersion()) == false) {
// for handshakes we are compatible with N-2 since otherwise we can't figure out our initial version
// since we are compatible with N-1 and N+1 so we always send our minCompatVersion as the initial version in the
// handshake. This looks odd but it's required to establish the connection correctly we check for real compatibility
// once the connection is established
final Version compatibilityVersion = TransportStatus.isHandshake(status) ? getCurrentVersion().minimumCompatibilityVersion()
: getCurrentVersion();
if (version.isCompatible(compatibilityVersion) == false) {
throw new IllegalStateException("Received message from unsupported version: [" + version
+ "] minimal compatible version is: [" + getCurrentVersion().minimumCompatibilityVersion() + "]");
+ "] minimal compatible version is: [" + compatibilityVersion.minimumCompatibilityVersion() + "]");
}
streamIn = new NamedWriteableAwareStreamInput(streamIn, namedWriteableRegistry);
streamIn.setVersion(version);

View File

@ -972,7 +972,7 @@ public class ExceptionSerializationTests extends ESTestCase {
try (StreamInput in = decoded.streamInput()) {
//randomize the version across released and unreleased ones
Version version = randomFrom(Version.V_5_0_0, Version.V_5_0_1, Version.V_5_0_2,
Version.V_5_0_3_UNRELEASED, Version.V_5_1_1_UNRELEASED, Version.V_5_1_2_UNRELEASED, Version.V_5_2_0_UNRELEASED);
Version.V_5_1_1, Version.V_5_1_2, Version.V_5_2_0);
in.setVersion(version);
ElasticsearchException exception = new ElasticsearchException(in);
assertEquals("test message", exception.getMessage());

View File

@ -33,7 +33,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.Set;
import static org.elasticsearch.Version.V_5_3_0_UNRELEASED;
import static org.elasticsearch.Version.V_5_3_0;
import static org.elasticsearch.Version.V_6_0_0_alpha2_UNRELEASED;
import static org.elasticsearch.test.VersionUtils.randomVersion;
import static org.hamcrest.CoreMatchers.equalTo;
@ -46,30 +46,30 @@ import static org.hamcrest.Matchers.sameInstance;
public class VersionTests extends ESTestCase {
public void testVersionComparison() throws Exception {
assertThat(V_5_3_0_UNRELEASED.before(V_6_0_0_alpha2_UNRELEASED), is(true));
assertThat(V_5_3_0_UNRELEASED.before(V_5_3_0_UNRELEASED), is(false));
assertThat(V_6_0_0_alpha2_UNRELEASED.before(V_5_3_0_UNRELEASED), is(false));
assertThat(V_5_3_0.before(V_6_0_0_alpha2_UNRELEASED), is(true));
assertThat(V_5_3_0.before(V_5_3_0), is(false));
assertThat(V_6_0_0_alpha2_UNRELEASED.before(V_5_3_0), is(false));
assertThat(V_5_3_0_UNRELEASED.onOrBefore(V_6_0_0_alpha2_UNRELEASED), is(true));
assertThat(V_5_3_0_UNRELEASED.onOrBefore(V_5_3_0_UNRELEASED), is(true));
assertThat(V_6_0_0_alpha2_UNRELEASED.onOrBefore(V_5_3_0_UNRELEASED), is(false));
assertThat(V_5_3_0.onOrBefore(V_6_0_0_alpha2_UNRELEASED), is(true));
assertThat(V_5_3_0.onOrBefore(V_5_3_0), is(true));
assertThat(V_6_0_0_alpha2_UNRELEASED.onOrBefore(V_5_3_0), is(false));
assertThat(V_5_3_0_UNRELEASED.after(V_6_0_0_alpha2_UNRELEASED), is(false));
assertThat(V_5_3_0_UNRELEASED.after(V_5_3_0_UNRELEASED), is(false));
assertThat(V_6_0_0_alpha2_UNRELEASED.after(V_5_3_0_UNRELEASED), is(true));
assertThat(V_5_3_0.after(V_6_0_0_alpha2_UNRELEASED), is(false));
assertThat(V_5_3_0.after(V_5_3_0), is(false));
assertThat(V_6_0_0_alpha2_UNRELEASED.after(V_5_3_0), is(true));
assertThat(V_5_3_0_UNRELEASED.onOrAfter(V_6_0_0_alpha2_UNRELEASED), is(false));
assertThat(V_5_3_0_UNRELEASED.onOrAfter(V_5_3_0_UNRELEASED), is(true));
assertThat(V_6_0_0_alpha2_UNRELEASED.onOrAfter(V_5_3_0_UNRELEASED), is(true));
assertThat(V_5_3_0.onOrAfter(V_6_0_0_alpha2_UNRELEASED), is(false));
assertThat(V_5_3_0.onOrAfter(V_5_3_0), is(true));
assertThat(V_6_0_0_alpha2_UNRELEASED.onOrAfter(V_5_3_0), is(true));
assertTrue(Version.fromString("5.0.0-alpha2").onOrAfter(Version.fromString("5.0.0-alpha1")));
assertTrue(Version.fromString("5.0.0").onOrAfter(Version.fromString("5.0.0-beta2")));
assertTrue(Version.fromString("5.0.0-rc1").onOrAfter(Version.fromString("5.0.0-beta24")));
assertTrue(Version.fromString("5.0.0-alpha24").before(Version.fromString("5.0.0-beta0")));
assertThat(V_5_3_0_UNRELEASED, is(lessThan(V_6_0_0_alpha2_UNRELEASED)));
assertThat(V_5_3_0_UNRELEASED.compareTo(V_5_3_0_UNRELEASED), is(0));
assertThat(V_6_0_0_alpha2_UNRELEASED, is(greaterThan(V_5_3_0_UNRELEASED)));
assertThat(V_5_3_0, is(lessThan(V_6_0_0_alpha2_UNRELEASED)));
assertThat(V_5_3_0.compareTo(V_5_3_0), is(0));
assertThat(V_6_0_0_alpha2_UNRELEASED, is(greaterThan(V_5_3_0)));
}
public void testMin() {
@ -100,7 +100,7 @@ public class VersionTests extends ESTestCase {
assertEquals(Version.V_5_0_0, Version.V_6_0_0_alpha2_UNRELEASED.minimumIndexCompatibilityVersion());
assertEquals(Version.fromId(2000099), Version.V_5_0_0.minimumIndexCompatibilityVersion());
assertEquals(Version.fromId(2000099),
Version.V_5_1_1_UNRELEASED.minimumIndexCompatibilityVersion());
Version.V_5_1_1.minimumIndexCompatibilityVersion());
assertEquals(Version.fromId(2000099),
Version.V_5_0_0_alpha1.minimumIndexCompatibilityVersion());
}
@ -157,7 +157,7 @@ public class VersionTests extends ESTestCase {
public void testIndexCreatedVersion() {
// an actual index has a IndexMetaData.SETTING_INDEX_UUID
final Version version = randomFrom(Version.V_5_0_0, Version.V_5_0_2,
Version.V_5_2_0_UNRELEASED, Version.V_6_0_0_alpha2_UNRELEASED);
Version.V_5_2_0, Version.V_6_0_0_alpha2_UNRELEASED);
assertEquals(version, Version.indexCreated(Settings.builder().put(IndexMetaData.SETTING_INDEX_UUID, "foo").put(IndexMetaData.SETTING_VERSION_CREATED, version).build()));
}
@ -311,8 +311,8 @@ public class VersionTests extends ESTestCase {
}
if (other.isAlpha() == false && version.isAlpha() == false
&& other.major == version.major && other.minor == version.minor) {
assertEquals(other.luceneVersion.major, version.luceneVersion.major);
assertEquals(other.luceneVersion.minor, version.luceneVersion.minor);
assertEquals(version + " vs. " + other, other.luceneVersion.major, version.luceneVersion.major);
assertEquals(version + " vs. " + other, other.luceneVersion.minor, version.luceneVersion.minor);
// should we also assert the lucene bugfix version?
}
}
@ -326,11 +326,12 @@ public class VersionTests extends ESTestCase {
public void testIsCompatible() {
assertTrue(isCompatible(Version.CURRENT, Version.CURRENT.minimumCompatibilityVersion()));
assertTrue(isCompatible(Version.V_5_0_0, Version.V_6_0_0_alpha2_UNRELEASED));
assertTrue(isCompatible(Version.V_5_5_0_UNRELEASED, Version.V_6_0_0_alpha2_UNRELEASED));
assertFalse(isCompatible(Version.fromId(2000099), Version.V_6_0_0_alpha2_UNRELEASED));
assertFalse(isCompatible(Version.fromId(2000099), Version.V_5_0_0));
}
public boolean isCompatible(Version left, Version right) {
boolean result = left.isCompatible(right);
assert result == right.isCompatible(left);

View File

@ -93,7 +93,7 @@ public class ClusterSearchShardsResponseTests extends ESTestCase {
assertEquals(clusterSearchShardsGroup.getShardId(), deserializedGroup.getShardId());
assertArrayEquals(clusterSearchShardsGroup.getShards(), deserializedGroup.getShards());
}
if (version.onOrAfter(Version.V_5_1_1_UNRELEASED)) {
if (version.onOrAfter(Version.V_5_1_1)) {
assertEquals(clusterSearchShardsResponse.getIndicesAndFilters(), deserialized.getIndicesAndFilters());
} else {
assertNull(deserialized.getIndicesAndFilters());

View File

@ -51,7 +51,7 @@ public class PutStoredScriptRequestTests extends ESTestCase {
public void testSerializationBwc() throws IOException {
final byte[] rawStreamBytes = Base64.getDecoder().decode("ADwDCG11c3RhY2hlAQZzY3JpcHQCe30A");
final Version version = randomFrom(Version.V_5_0_0, Version.V_5_0_1, Version.V_5_0_2,
Version.V_5_0_3_UNRELEASED, Version.V_5_1_1_UNRELEASED, Version.V_5_1_2_UNRELEASED, Version.V_5_2_0_UNRELEASED);
Version.V_5_1_1, Version.V_5_1_2, Version.V_5_2_0);
try (StreamInput in = StreamInput.wrap(rawStreamBytes)) {
in.setVersion(version);
PutStoredScriptRequest serialized = new PutStoredScriptRequest();

View File

@ -51,8 +51,8 @@ public class CreateIndexRequestTests extends ESTestCase {
public void testSerializationBwc() throws IOException {
final byte[] data = Base64.getDecoder().decode("ADwDAANmb28APAMBB215X3R5cGULeyJ0eXBlIjp7fX0AAAD////+AA==");
final Version version = randomFrom(Version.V_5_0_0, Version.V_5_0_1, Version.V_5_0_2,
Version.V_5_0_3_UNRELEASED, Version.V_5_1_1_UNRELEASED, Version.V_5_1_2_UNRELEASED, Version.V_5_2_0_UNRELEASED);
final Version version = randomFrom(Version.V_5_0_0, Version.V_5_0_1, Version.V_5_0_2, Version.V_5_1_1, Version.V_5_1_2,
Version.V_5_2_0);
try (StreamInput in = StreamInput.wrap(data)) {
in.setVersion(version);
CreateIndexRequest serialized = new CreateIndexRequest();

View File

@ -94,7 +94,7 @@ public class PutMappingRequestTests extends ESTestCase {
public void testSerializationBwc() throws IOException {
final byte[] data = Base64.getDecoder().decode("ADwDAQNmb28MAA8tLS0KZm9vOiAiYmFyIgoAPAMAAAA=");
final Version version = randomFrom(Version.V_5_0_0, Version.V_5_0_1, Version.V_5_0_2,
Version.V_5_0_3_UNRELEASED, Version.V_5_1_1_UNRELEASED, Version.V_5_1_2_UNRELEASED, Version.V_5_2_0_UNRELEASED);
Version.V_5_1_1, Version.V_5_1_2, Version.V_5_2_0);
try (StreamInput in = StreamInput.wrap(data)) {
in.setVersion(version);
PutMappingRequest request = new PutMappingRequest();

View File

@ -89,7 +89,7 @@ public class PutIndexTemplateRequestTests extends ESTestCase {
public void testPutIndexTemplateRequestSerializationXContentBwc() throws IOException {
final byte[] data = Base64.getDecoder().decode("ADwDAANmb28IdGVtcGxhdGUAAAAAAAABA2Jhcg8tLS0KZm9vOiAiYmFyIgoAAAAAAAAAAAAAAAA=");
final Version version = randomFrom(Version.V_5_0_0, Version.V_5_0_1, Version.V_5_0_2,
Version.V_5_0_3_UNRELEASED, Version.V_5_1_1_UNRELEASED, Version.V_5_1_2_UNRELEASED, Version.V_5_2_0_UNRELEASED);
Version.V_5_1_1, Version.V_5_1_2, Version.V_5_2_0);
try (StreamInput in = StreamInput.wrap(data)) {
in.setVersion(version);
PutIndexTemplateRequest request = new PutIndexTemplateRequest();

View File

@ -113,7 +113,7 @@ public class FieldStatsRequestTests extends ESTestCase {
FieldStatsShardResponse deserialized = new FieldStatsShardResponse();
deserialized.readFrom(input);
final Map<String, FieldStats<?>> expected;
if (version.before(Version.V_5_2_0_UNRELEASED)) {
if (version.before(Version.V_5_2_0)) {
expected = deserialized.filterNullMinMax();
} else {
expected = deserialized.getFieldStats();

View File

@ -178,7 +178,7 @@ public class IndexRequestTests extends ESTestCase {
public void testIndexRequestXContentSerializationBwc() throws IOException {
final byte[] data = Base64.getDecoder().decode("AAD////+AgQDZm9vAAAAAQNiYXIBATEAAAAAAnt9AP/////////9AAAA//////////8AAAAAAAA=");
final Version version = randomFrom(Version.V_5_0_0, Version.V_5_0_1, Version.V_5_0_2,
Version.V_5_0_3_UNRELEASED, Version.V_5_1_1_UNRELEASED, Version.V_5_1_2_UNRELEASED, Version.V_5_2_0_UNRELEASED);
Version.V_5_1_1, Version.V_5_1_2, Version.V_5_2_0);
try (StreamInput in = StreamInput.wrap(data)) {
in.setVersion(version);
IndexRequest serialized = new IndexRequest();

View File

@ -49,7 +49,7 @@ public class PutPipelineRequestTests extends ESTestCase {
public void testSerializationBwc() throws IOException {
final byte[] data = Base64.getDecoder().decode("ADwDATECe30=");
final Version version = randomFrom(Version.V_5_0_0, Version.V_5_0_1, Version.V_5_0_2,
Version.V_5_0_3_UNRELEASED, Version.V_5_1_1_UNRELEASED, Version.V_5_1_2_UNRELEASED, Version.V_5_2_0_UNRELEASED);
Version.V_5_1_1, Version.V_5_1_2, Version.V_5_2_0);
try (StreamInput in = StreamInput.wrap(data)) {
in.setVersion(version);
PutPipelineRequest request = new PutPipelineRequest();

View File

@ -74,7 +74,7 @@ public class SimulatePipelineRequestTests extends ESTestCase {
public void testSerializationWithXContentBwc() throws IOException {
final byte[] data = Base64.getDecoder().decode("AAAAAnt9AAA=");
final Version version = randomFrom(Version.V_5_0_0, Version.V_5_0_1, Version.V_5_0_2,
Version.V_5_0_3_UNRELEASED, Version.V_5_1_1_UNRELEASED, Version.V_5_1_2_UNRELEASED, Version.V_5_2_0_UNRELEASED);
Version.V_5_1_1, Version.V_5_1_2, Version.V_5_2_0);
try (StreamInput in = StreamInput.wrap(data)) {
in.setVersion(version);
SimulatePipelineRequest request = new SimulatePipelineRequest();

View File

@ -269,7 +269,7 @@ public class TermVectorsUnitTests extends ESTestCase {
public void testStreamRequestWithXContentBwc() throws IOException {
final byte[] data = Base64.getDecoder().decode("AAABBWluZGV4BHR5cGUCaWQBAnt9AAABDnNvbWVQcmVmZXJlbmNlFgAAAAEA//////////0AAAA=");
final Version version = randomFrom(Version.V_5_0_0, Version.V_5_0_1, Version.V_5_0_2,
Version.V_5_0_3_UNRELEASED, Version.V_5_1_1_UNRELEASED, Version.V_5_1_2_UNRELEASED, Version.V_5_2_0_UNRELEASED);
Version.V_5_1_1, Version.V_5_1_2, Version.V_5_2_0);
try (StreamInput in = StreamInput.wrap(data)) {
in.setVersion(version);
TermVectorsRequest request = new TermVectorsRequest();

View File

@ -76,8 +76,10 @@ public class DiscoveryNodeTests extends ESTestCase {
assertEquals(transportAddress.getAddress(), serialized.getHostAddress());
assertEquals(transportAddress.getAddress(), serialized.getAddress().getAddress());
assertEquals(transportAddress.getPort(), serialized.getAddress().getPort());
assertFalse("if the minimum compatibility version moves past 5.0.3, remove the special casing in DiscoverNode(StreamInput) and " +
"the TransportAddress(StreamInput, String) constructor",
Version.CURRENT.minimumCompatibilityVersion().onOrAfter(Version.V_5_0_3_UNRELEASED));
assertFalse("if the minimum index compatibility version moves past 5.0.3, remove the special casing in DiscoverNode(StreamInput)" +
" and the TransportAddress(StreamInput, String) constructor",
Version.CURRENT.minimumIndexCompatibilityVersion().after(Version.V_5_0_2));
// serialization can happen from an old cluster-state in a full cluster restart
// hence we need to maintain this until we drop index bwc
}
}

View File

@ -139,7 +139,7 @@ public class ClusterSerializationTests extends ESAllocationTestCase {
// serialize with old version
outStream = new BytesStreamOutput();
outStream.setVersion(Version.CURRENT.minimumCompatibilityVersion());
outStream.setVersion(Version.CURRENT.minimumIndexCompatibilityVersion());
diffs.writeTo(outStream);
inStream = outStream.bytes().streamInput();
inStream = new NamedWriteableAwareStreamInput(inStream, new NamedWriteableRegistry(ClusterModule.getNamedWriteables()));

View File

@ -805,7 +805,7 @@ public class BytesStreamsTests extends ESTestCase {
}
assertTrue("If we're not compatible with 5.1.1 we can drop the assertion below",
Version.CURRENT.minimumCompatibilityVersion().onOrBefore(Version.V_5_1_1_UNRELEASED));
Version.CURRENT.minimumIndexCompatibilityVersion().onOrBefore(Version.V_5_1_1));
/* Read -1 as serialized by a version of Elasticsearch that supported writing negative numbers with writeVLong. Note that this
* should be the same test as the first case (when value is negative) but we've kept some bytes so no matter what we do to
* writeVLong in the future we can be sure we can read bytes as written by Elasticsearch before 5.1.2 */

View File

@ -361,8 +361,8 @@ public class ZenDiscoveryUnitTests extends ESTestCase {
IllegalStateException ex = expectThrows(IllegalStateException.class, () ->
request.messageReceived(new MembershipAction.ValidateJoinRequest(stateBuilder.build()), null));
assertEquals("index [test] version not supported: "
+ VersionUtils.getPreviousVersion(Version.CURRENT.minimumCompatibilityVersion())
+ " minimum compatible index version is: " + Version.CURRENT.minimumCompatibilityVersion(), ex.getMessage());
+ VersionUtils.getPreviousVersion(Version.CURRENT.minimumIndexCompatibilityVersion())
+ " minimum compatible index version is: " + Version.CURRENT.minimumIndexCompatibilityVersion(), ex.getMessage());
} else {
AtomicBoolean sendResponse = new AtomicBoolean(false);
request.messageReceived(new MembershipAction.ValidateJoinRequest(stateBuilder.build()), new TransportChannel() {

View File

@ -606,7 +606,7 @@ public class FieldStatsTests extends ESSingleNodeTestCase {
public void testSerialization() throws IOException {
for (Version version : new Version[] {Version.CURRENT, Version.V_5_0_1}){
for (int i = 0; i < 20; i++) {
assertSerialization(randomFieldStats(version.onOrAfter(Version.V_5_2_0_UNRELEASED)), version);
assertSerialization(randomFieldStats(version.onOrAfter(Version.V_5_2_0)), version);
}
}
}

View File

@ -152,7 +152,7 @@ public class IndexSortSettingsTests extends ESTestCase {
.put("index.sort.field", "field1")
.build();
IllegalArgumentException exc =
expectThrows(IllegalArgumentException.class, () -> indexSettings(settings, Version.V_5_4_0_UNRELEASED));
expectThrows(IllegalArgumentException.class, () -> indexSettings(settings, Version.V_5_4_0));
assertThat(exc.getMessage(),
containsString("unsupported index.version.created:5.4.0, " +
"can't set index.sort on versions prior to 6.0.0-alpha1"));

View File

@ -63,8 +63,8 @@ public class PreBuiltAnalyzerTests extends ESSingleNodeTestCase {
assertSame(PreBuiltAnalyzers.ARABIC.getAnalyzer(Version.CURRENT),
PreBuiltAnalyzers.ARABIC.getAnalyzer(Version.CURRENT));
// same lucene version should be cached
assertSame(PreBuiltAnalyzers.ARABIC.getAnalyzer(Version.V_5_2_2_UNRELEASED),
PreBuiltAnalyzers.ARABIC.getAnalyzer(Version.V_5_2_3_UNRELEASED));
assertSame(PreBuiltAnalyzers.ARABIC.getAnalyzer(Version.V_5_2_1),
PreBuiltAnalyzers.ARABIC.getAnalyzer(Version.V_5_2_2));
assertNotSame(PreBuiltAnalyzers.ARABIC.getAnalyzer(Version.V_5_0_0),
PreBuiltAnalyzers.ARABIC.getAnalyzer(Version.V_5_0_1));

View File

@ -1486,7 +1486,7 @@ public class InternalEngineTests extends ESTestCase {
IndexSettings oldSettings = IndexSettingsModule.newIndexSettings("testOld", Settings.builder()
.put(IndexSettings.INDEX_GC_DELETES_SETTING.getKey(), "1h") // make sure this doesn't kick in on us
.put(EngineConfig.INDEX_CODEC_SETTING.getKey(), codecName)
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_5_4_0_UNRELEASED)
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_5_4_0)
.put(MapperService.INDEX_MAPPING_SINGLE_TYPE_SETTING.getKey(), true)
.put(IndexSettings.MAX_REFRESH_LISTENERS_PER_SHARD.getKey(),
between(10, 10 * IndexSettings.MAX_REFRESH_LISTENERS_PER_SHARD.get(Settings.EMPTY)))

View File

@ -56,7 +56,7 @@ public class MapperTests extends ESTestCase {
"As a replacement, you can use an [copy_to] on mapping fields to create your own catch all field.",
e.getMessage());
settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_5_3_0_UNRELEASED).build();
settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_5_3_0).build();
// Create the mapping service with an older index creation version
final MapperService oldMapperService = MapperTestUtils.newMapperService(xContentRegistry(), createTempDir(), settings, "test");

View File

@ -336,7 +336,7 @@ public class MoreLikeThisQueryBuilderTests extends AbstractQueryTestCase<MoreLik
public void testItemSerializationBwc() throws IOException {
final byte[] data = Base64.getDecoder().decode("AQVpbmRleAEEdHlwZQEODXsiZm9vIjoiYmFyIn0A/wD//////////QAAAAAAAAAA");
final Version version = randomFrom(Version.V_5_0_0, Version.V_5_0_1, Version.V_5_0_2,
Version.V_5_0_3_UNRELEASED, Version.V_5_1_1_UNRELEASED, Version.V_5_1_2_UNRELEASED, Version.V_5_2_0_UNRELEASED);
Version.V_5_1_1, Version.V_5_1_2, Version.V_5_2_0);
try (StreamInput in = StreamInput.wrap(data)) {
in.setVersion(version);
Item item = new Item(in);

View File

@ -34,15 +34,4 @@ public class RefreshStatsTests extends AbstractStreamableTestCase<RefreshStats>
protected RefreshStats createBlankInstance() {
return new RefreshStats();
}
public void testPre5Dot2() throws IOException {
// We can drop the compatibility once the assertion just below this list fails
assertTrue(Version.CURRENT.minimumCompatibilityVersion().before(Version.V_5_2_0_UNRELEASED));
RefreshStats instance = createTestInstance();
RefreshStats copied = copyInstance(instance, Version.V_5_1_1_UNRELEASED);
assertEquals(instance.getTotal(), copied.getTotal());
assertEquals(instance.getTotalTimeInMillis(), copied.getTotalTimeInMillis());
assertEquals(0, copied.getListeners());
}
}

View File

@ -75,7 +75,7 @@ public class BulkByScrollTaskStatusTests extends ESTestCase {
assertEquals(expected.getRequestsPerSecond(), actual.getRequestsPerSecond(), 0f);
assertEquals(expected.getReasonCancelled(), actual.getReasonCancelled());
assertEquals(expected.getThrottledUntil(), actual.getThrottledUntil());
if (version.onOrAfter(Version.V_5_1_1_UNRELEASED)) {
if (version.onOrAfter(Version.V_5_1_1)) {
assertThat(actual.getSliceStatuses(), Matchers.hasSize(expected.getSliceStatuses().size()));
for (int i = 0; i < expected.getSliceStatuses().size(); i++) {
BulkByScrollTask.StatusOrException sliceStatus = expected.getSliceStatuses().get(i);

View File

@ -54,9 +54,9 @@ public class PipelineConfigurationTests extends ESTestCase {
public void testSerializationBwc() throws IOException {
final byte[] data = Base64.getDecoder().decode("ATECe30AAAA=");
final Version version = randomFrom(Version.V_5_0_0, Version.V_5_0_1, Version.V_5_0_2,
Version.V_5_0_3_UNRELEASED, Version.V_5_1_1_UNRELEASED, Version.V_5_1_2_UNRELEASED, Version.V_5_2_0_UNRELEASED);
try (StreamInput in = StreamInput.wrap(data)) {
final Version version = randomFrom(Version.V_5_0_0, Version.V_5_0_1, Version.V_5_0_2,
Version.V_5_1_1, Version.V_5_1_2, Version.V_5_2_0);
in.setVersion(version);
PipelineConfiguration configuration = PipelineConfiguration.readFrom(in);
assertEquals(XContentType.JSON, configuration.getXContentType());

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -184,7 +184,7 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBu
}
document = in.readOptionalBytesReference();
if (document != null) {
if (in.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
if (in.getVersion().onOrAfter(Version.V_5_3_0)) {
documentXContentType = XContentType.readFrom(in);
} else {
documentXContentType = XContentFactory.xContentType(document);
@ -210,7 +210,7 @@ public class PercolateQueryBuilder extends AbstractQueryBuilder<PercolateQueryBu
out.writeBoolean(false);
}
out.writeOptionalBytesReference(document);
if (document != null && out.getVersion().onOrAfter(Version.V_5_3_0_UNRELEASED)) {
if (document != null && out.getVersion().onOrAfter(Version.V_5_3_0)) {
documentXContentType.writeTo(out);
}
}

View File

@ -250,7 +250,7 @@ public class PercolateQueryBuilderTests extends AbstractQueryTestCase<PercolateQ
public void testSerializationBwc() throws IOException {
final byte[] data = Base64.getDecoder().decode("P4AAAAAFZmllbGQEdHlwZQAAAAAAAA57ImZvbyI6ImJhciJ9AAAAAA==");
final Version version = randomFrom(Version.V_5_0_0, Version.V_5_0_1, Version.V_5_0_2,
Version.V_5_0_3_UNRELEASED, Version.V_5_1_1_UNRELEASED, Version.V_5_1_2_UNRELEASED, Version.V_5_2_0_UNRELEASED);
Version.V_5_1_1, Version.V_5_1_2, Version.V_5_2_0);
try (StreamInput in = StreamInput.wrap(data)) {
in.setVersion(version);
PercolateQueryBuilder queryBuilder = new PercolateQueryBuilder(in);

View File

@ -159,7 +159,7 @@ public class RoundTripTests extends ESTestCase {
assertEquals(request.getRemoteInfo().getUsername(), tripped.getRemoteInfo().getUsername());
assertEquals(request.getRemoteInfo().getPassword(), tripped.getRemoteInfo().getPassword());
assertEquals(request.getRemoteInfo().getHeaders(), tripped.getRemoteInfo().getHeaders());
if (version.onOrAfter(Version.V_5_2_0_UNRELEASED)) {
if (version.onOrAfter(Version.V_5_2_0)) {
assertEquals(request.getRemoteInfo().getSocketTimeout(), tripped.getRemoteInfo().getSocketTimeout());
assertEquals(request.getRemoteInfo().getConnectTimeout(), tripped.getRemoteInfo().getConnectTimeout());
} else {

View File

@ -140,7 +140,7 @@ public class ClientYamlTestSectionTests extends AbstractClientYamlTestFragmentPa
assertThat(testSection.getSkipSection(), notNullValue());
assertThat(testSection.getSkipSection().getLowerVersion(), equalTo(Version.V_5_0_0));
assertThat(testSection.getSkipSection().getUpperVersion(),
equalTo(Version.V_5_2_0_UNRELEASED));
equalTo(Version.V_5_2_0));
assertThat(testSection.getSkipSection().getReason(), equalTo("Update doesn't return metadata fields, waiting for #3259"));
assertThat(testSection.getExecutableSections().size(), equalTo(2));
DoSection doSection = (DoSection)testSection.getExecutableSections().get(0);

View File

@ -76,7 +76,7 @@ public class SetupSectionTests extends AbstractClientYamlTestFragmentParserTestC
assertThat(setupSection.getSkipSection(), notNullValue());
assertThat(setupSection.getSkipSection().getLowerVersion(), equalTo(Version.V_5_0_0));
assertThat(setupSection.getSkipSection().getUpperVersion(),
equalTo(Version.V_5_3_0_UNRELEASED));
equalTo(Version.V_5_3_0));
assertThat(setupSection.getSkipSection().getReason(), equalTo("Update doesn't return metadata fields, waiting for #3259"));
assertThat(setupSection.getDoSections().size(), equalTo(2));
assertThat(setupSection.getDoSections().get(0).getApiCallSection().getApi(), equalTo("index1"));

View File

@ -62,7 +62,7 @@ public class SkipSectionTests extends AbstractClientYamlTestFragmentParserTestCa
SkipSection skipSection = SkipSection.parse(parser);
assertThat(skipSection, notNullValue());
assertThat(skipSection.getLowerVersion(), equalTo(VersionUtils.getFirstVersion()));
assertThat(skipSection.getUpperVersion(), equalTo(Version.V_5_1_1_UNRELEASED));
assertThat(skipSection.getUpperVersion(), equalTo(Version.V_5_1_1));
assertThat(skipSection.getFeatures().size(), equalTo(0));
assertThat(skipSection.getReason(), equalTo("Delete ignores the parent param"));
}

View File

@ -76,7 +76,7 @@ public class TeardownSectionTests extends AbstractClientYamlTestFragmentParserTe
assertThat(section, notNullValue());
assertThat(section.getSkipSection().isEmpty(), equalTo(false));
assertThat(section.getSkipSection().getLowerVersion(), equalTo(Version.V_5_0_0));
assertThat(section.getSkipSection().getUpperVersion(), equalTo(Version.V_5_3_0_UNRELEASED));
assertThat(section.getSkipSection().getUpperVersion(), equalTo(Version.V_5_3_0));
assertThat(section.getSkipSection().getReason(), equalTo("there is a reason"));
assertThat(section.getDoSections().size(), equalTo(2));
assertThat(section.getDoSections().get(0).getApiCallSection().getApi(), equalTo("delete"));