From 2ccc223ff761043807683f34b29c693af6c94d95 Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Wed, 17 May 2017 17:27:09 +0200 Subject: 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). --- .../org/elasticsearch/ElasticsearchException.java | 8 +- core/src/main/java/org/elasticsearch/Version.java | 93 +++++++++------------ .../ClusterAllocationExplainRequest.java | 4 +- .../cluster/shards/ClusterSearchShardsRequest.java | 4 +- .../shards/ClusterSearchShardsResponse.java | 4 +- .../storedscripts/GetStoredScriptResponse.java | 4 +- .../storedscripts/PutStoredScriptRequest.java | 4 +- .../admin/indices/analyze/AnalyzeResponse.java | 4 +- .../indices/validate/query/QueryExplanation.java | 4 +- .../validate/query/ValidateQueryRequest.java | 4 +- .../action/bulk/BulkItemResponse.java | 5 +- .../action/bulk/TransportShardBulkAction.java | 4 +- .../action/fieldstats/FieldStats.java | 6 +- .../action/fieldstats/FieldStatsResponse.java | 4 +- .../action/fieldstats/FieldStatsShardResponse.java | 2 +- .../elasticsearch/action/index/IndexRequest.java | 6 +- .../action/ingest/PutPipelineRequest.java | 4 +- .../action/ingest/SimulatePipelineRequest.java | 4 +- .../action/search/SearchTransportService.java | 2 +- .../action/termvectors/TermVectorsRequest.java | 4 +- .../java/org/elasticsearch/cluster/NamedDiff.java | 2 +- .../org/elasticsearch/cluster/NamedDiffable.java | 2 +- .../cluster/SnapshotDeletionsInProgress.java | 2 +- .../elasticsearch/cluster/SnapshotsInProgress.java | 2 +- .../elasticsearch/cluster/node/DiscoveryNode.java | 3 +- .../routing/allocation/NodeAllocationResult.java | 4 +- .../common/transport/TransportAddress.java | 8 +- .../elasticsearch/gateway/GatewayMetaState.java | 4 +- .../elasticsearch/index/query/InnerHitBuilder.java | 4 +- .../index/query/MoreLikeThisQueryBuilder.java | 4 +- .../index/query/QueryStringQueryBuilder.java | 12 +-- .../index/query/RangeQueryBuilder.java | 4 +- .../index/query/SimpleQueryStringBuilder.java | 16 ++-- .../elasticsearch/index/refresh/RefreshStats.java | 11 +-- .../index/reindex/AbstractBulkByScrollRequest.java | 6 +- .../index/reindex/BulkByScrollTask.java | 8 +- .../elasticsearch/index/reindex/RemoteInfo.java | 4 +- .../ingest/PipelineConfiguration.java | 4 +- .../java/org/elasticsearch/monitor/os/OsStats.java | 4 +- .../java/org/elasticsearch/plugins/PluginInfo.java | 4 +- .../main/java/org/elasticsearch/script/Script.java | 8 +- .../org/elasticsearch/script/ScriptMetaData.java | 4 +- .../elasticsearch/script/StoredScriptSource.java | 4 +- .../bucket/terms/support/IncludeExclude.java | 8 +- .../search/builder/SearchSourceBuilder.java | 4 +- .../highlight/AbstractHighlighterBuilder.java | 8 +- .../elasticsearch/search/internal/AliasFilter.java | 4 +- .../search/internal/ShardSearchLocalRequest.java | 4 +- .../org/elasticsearch/snapshots/SnapshotInfo.java | 2 +- .../org/elasticsearch/transport/TcpTransport.java | 10 ++- .../elasticsearch/ExceptionSerializationTests.java | 2 +- .../test/java/org/elasticsearch/VersionTests.java | 43 +++++----- .../shards/ClusterSearchShardsResponseTests.java | 2 +- .../storedscripts/PutStoredScriptRequestTests.java | 2 +- .../indices/create/CreateIndexRequestTests.java | 4 +- .../mapping/put/PutMappingRequestTests.java | 2 +- .../template/put/PutIndexTemplateRequestTests.java | 2 +- .../action/fieldstats/FieldStatsRequestTests.java | 2 +- .../action/index/IndexRequestTests.java | 2 +- .../action/ingest/PutPipelineRequestTests.java | 2 +- .../ingest/SimulatePipelineRequestTests.java | 2 +- .../action/termvectors/TermVectorsUnitTests.java | 2 +- .../cluster/node/DiscoveryNodeTests.java | 8 +- .../serialization/ClusterSerializationTests.java | 2 +- .../common/io/stream/BytesStreamsTests.java | 2 +- .../discovery/zen/ZenDiscoveryUnitTests.java | 4 +- .../elasticsearch/fieldstats/FieldStatsTests.java | 2 +- .../index/IndexSortSettingsTests.java | 2 +- .../index/analysis/PreBuiltAnalyzerTests.java | 4 +- .../index/engine/InternalEngineTests.java | 2 +- .../elasticsearch/index/mapper/MapperTests.java | 2 +- .../index/query/MoreLikeThisQueryBuilderTests.java | 2 +- .../index/refresh/RefreshStatsTests.java | 11 --- .../index/reindex/BulkByScrollTaskStatusTests.java | 2 +- .../ingest/PipelineConfigurationTests.java | 4 +- .../src/test/resources/indices/bwc/index-5.2.2.zip | Bin 0 -> 503810 bytes .../src/test/resources/indices/bwc/index-5.3.2.zip | Bin 0 -> 399870 bytes core/src/test/resources/indices/bwc/repo-5.2.2.zip | Bin 0 -> 246750 bytes core/src/test/resources/indices/bwc/repo-5.3.2.zip | Bin 0 -> 190884 bytes 79 files changed, 213 insertions(+), 239 deletions(-) create mode 100644 core/src/test/resources/indices/bwc/index-5.2.2.zip create mode 100644 core/src/test/resources/indices/bwc/index-5.3.2.zip create mode 100644 core/src/test/resources/indices/bwc/repo-5.2.2.zip create mode 100644 core/src/test/resources/indices/bwc/repo-5.3.2.zip (limited to 'core/src') diff --git a/core/src/main/java/org/elasticsearch/ElasticsearchException.java b/core/src/main/java/org/elasticsearch/ElasticsearchException.java index b6ed2cb7a2..ae575af61c 100644 --- a/core/src/main/java/org/elasticsearch/ElasticsearchException.java +++ b/core/src/main/java/org/elasticsearch/ElasticsearchException.java @@ -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>> 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 exceptionClass; final CheckedFunction constructor; diff --git a/core/src/main/java/org/elasticsearch/Version.java b/core/src/main/java/org/elasticsearch/Version.java index d23417df07..44b989a378 100644 --- a/core/src/main/java/org/elasticsearch/Version.java +++ b/core/src/main/java/org/elasticsearch/Version.java @@ -55,33 +55,25 @@ public class Version implements Comparable { 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 { 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 { 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 { /** * 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; diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainRequest.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainRequest.java index d80e58232a..aea1ee57dc 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainRequest.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainRequest.java @@ -249,8 +249,8 @@ public class ClusterAllocationExplainRequest extends MasterNodeRequest(); 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 entry : indicesAndFilters.entrySet()) { out.writeString(entry.getKey()); diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/GetStoredScriptResponse.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/GetStoredScriptResponse.java index b8302a03c2..2dc0ed870c 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/GetStoredScriptResponse.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/GetStoredScriptResponse.java @@ -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()); diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/PutStoredScriptRequest.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/PutStoredScriptRequest.java index f6a9e05539..ca26df75de 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/PutStoredScriptRequest.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/PutStoredScriptRequest.java @@ -123,7 +123,7 @@ public class PutStoredScriptRequest extends AcknowledgedRequest 1 ? positionLength : null); } out.writeOptionalString(type); diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/validate/query/QueryExplanation.java b/core/src/main/java/org/elasticsearch/action/admin/indices/validate/query/QueryExplanation.java index f03bb49fda..df9c12c95f 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/validate/query/QueryExplanation.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/validate/query/QueryExplanation.java @@ -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); diff --git a/core/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ValidateQueryRequest.java b/core/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ValidateQueryRequest.java index 18ccf1ede7..5953a5548c 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ValidateQueryRequest.java +++ b/core/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ValidateQueryRequest.java @@ -154,7 +154,7 @@ public class ValidateQueryRequest extends BroadcastRequest } 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 } 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); } } diff --git a/core/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java b/core/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java index 68cede5d25..0ddd01187a 100644 --- a/core/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java +++ b/core/src/main/java/org/elasticsearch/action/bulk/BulkItemResponse.java @@ -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()); diff --git a/core/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java b/core/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java index 4e1419099b..5b99ed02cf 100644 --- a/core/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java +++ b/core/src/main/java/org/elasticsearch/action/bulk/TransportShardBulkAction.java @@ -415,10 +415,10 @@ public class TransportShardBulkAction extends TransportWriteAction 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 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) { diff --git a/core/src/main/java/org/elasticsearch/action/fieldstats/FieldStatsResponse.java b/core/src/main/java/org/elasticsearch/action/fieldstats/FieldStatsResponse.java index f126c73d04..2046aeddc1 100644 --- a/core/src/main/java/org/elasticsearch/action/fieldstats/FieldStatsResponse.java +++ b/core/src/main/java/org/elasticsearch/action/fieldstats/FieldStatsResponse.java @@ -93,7 +93,7 @@ public class FieldStatsResponse extends BroadcastResponse { for (Map.Entry> 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 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); } diff --git a/core/src/main/java/org/elasticsearch/action/fieldstats/FieldStatsShardResponse.java b/core/src/main/java/org/elasticsearch/action/fieldstats/FieldStatsShardResponse.java index 133a94e69a..d2f3a7d5e4 100644 --- a/core/src/main/java/org/elasticsearch/action/fieldstats/FieldStatsShardResponse.java +++ b/core/src/main/java/org/elasticsearch/action/fieldstats/FieldStatsShardResponse.java @@ -68,7 +68,7 @@ public class FieldStatsShardResponse extends BroadcastShardResponse { public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); final Map > 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} */ diff --git a/core/src/main/java/org/elasticsearch/action/index/IndexRequest.java b/core/src/main/java/org/elasticsearch/action/index/IndexRequest.java index 41780ca0c7..ee9a5b2dfe 100644 --- a/core/src/main/java/org/elasticsearch/action/index/IndexRequest.java +++ b/core/src/main/java/org/elasticsearch/action/index/IndexRequest.java @@ -534,7 +534,7 @@ public class IndexRequest extends ReplicatedWriteRequest 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 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 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); } } diff --git a/core/src/main/java/org/elasticsearch/action/ingest/PutPipelineRequest.java b/core/src/main/java/org/elasticsearch/action/ingest/PutPipelineRequest.java index f5d5ab2d34..394349ca01 100644 --- a/core/src/main/java/org/elasticsearch/action/ingest/PutPipelineRequest.java +++ b/core/src/main/java/org/elasticsearch/action/ingest/PutPipelineRequest.java @@ -80,7 +80,7 @@ public class PutPipelineRequest extends AcknowledgedRequest 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 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); } } diff --git a/core/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineRequest.java b/core/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineRequest.java index 170af18968..30beb32681 100644 --- a/core/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineRequest.java +++ b/core/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineRequest.java @@ -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); } } diff --git a/core/src/main/java/org/elasticsearch/action/search/SearchTransportService.java b/core/src/main/java/org/elasticsearch/action/search/SearchTransportService.java index 2ecfc213f9..9dd2125d5e 100644 --- a/core/src/main/java/org/elasticsearch/action/search/SearchTransportService.java +++ b/core/src/main/java/org/elasticsearch/action/search/SearchTransportService.java @@ -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 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) { /** diff --git a/core/src/main/java/org/elasticsearch/action/termvectors/TermVectorsRequest.java b/core/src/main/java/org/elasticsearch/action/termvectors/TermVectorsRequest.java index de2577f573..0fe83e2144 100644 --- a/core/src/main/java/org/elasticsearch/action/termvectors/TermVectorsRequest.java +++ b/core/src/main/java/org/elasticsearch/action/termvectors/TermVectorsRequest.java @@ -499,7 +499,7 @@ public class TermVectorsRequest extends SingleShardRequest 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 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); } } diff --git a/core/src/main/java/org/elasticsearch/cluster/NamedDiff.java b/core/src/main/java/org/elasticsearch/cluster/NamedDiff.java index 9da3167ae8..b7f2a96688 100644 --- a/core/src/main/java/org/elasticsearch/cluster/NamedDiff.java +++ b/core/src/main/java/org/elasticsearch/cluster/NamedDiff.java @@ -30,7 +30,7 @@ public interface NamedDiff> extends Diff, 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(); } } diff --git a/core/src/main/java/org/elasticsearch/cluster/NamedDiffable.java b/core/src/main/java/org/elasticsearch/cluster/NamedDiffable.java index 0797442209..b548b49fe1 100644 --- a/core/src/main/java/org/elasticsearch/cluster/NamedDiffable.java +++ b/core/src/main/java/org/elasticsearch/cluster/NamedDiffable.java @@ -30,6 +30,6 @@ public interface NamedDiffable extends Diffable, 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(); } } diff --git a/core/src/main/java/org/elasticsearch/cluster/SnapshotDeletionsInProgress.java b/core/src/main/java/org/elasticsearch/cluster/SnapshotDeletionsInProgress.java index 446f4ae074..e0336f61e3 100644 --- a/core/src/main/java/org/elasticsearch/cluster/SnapshotDeletionsInProgress.java +++ b/core/src/main/java/org/elasticsearch/cluster/SnapshotDeletionsInProgress.java @@ -40,7 +40,7 @@ public class SnapshotDeletionsInProgress extends AbstractNamedDiffable 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 entries; diff --git a/core/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java b/core/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java index 5b8d391889..53ac626820 100644 --- a/core/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java +++ b/core/src/main/java/org/elasticsearch/cluster/SnapshotsInProgress.java @@ -51,7 +51,7 @@ public class SnapshotsInProgress extends AbstractNamedDiffable 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) { diff --git a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java index caafb82c65..a651d957a9 100644 --- a/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java +++ b/core/src/main/java/org/elasticsearch/cluster/node/DiscoveryNode.java @@ -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 diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/NodeAllocationResult.java b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/NodeAllocationResult.java index 3740ded306..0d3fe2df92 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/allocation/NodeAllocationResult.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/allocation/NodeAllocationResult.java @@ -80,7 +80,7 @@ public class NodeAllocationResult implements ToXContent, Writeable, Comparable 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()); } } diff --git a/core/src/main/java/org/elasticsearch/index/query/InnerHitBuilder.java b/core/src/main/java/org/elasticsearch/index/query/InnerHitBuilder.java index b6eb84b03b..768f7e7fd0 100644 --- a/core/src/main/java/org/elasticsearch/index/query/InnerHitBuilder.java +++ b/core/src/main/java/org/elasticsearch/index/query/InnerHitBuilder.java @@ -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); diff --git a/core/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilder.java index 553adf88b7..7889dee26d 100644 --- a/core/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilder.java +++ b/core/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilder.java @@ -228,7 +228,7 @@ public class MoreLikeThisQueryBuilder extends AbstractQueryBuilder 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 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(); diff --git a/core/src/main/java/org/elasticsearch/index/query/SimpleQueryStringBuilder.java b/core/src/main/java/org/elasticsearch/index/query/SimpleQueryStringBuilder.java index 8312d56c3f..2efa4e815a 100644 --- a/core/src/main/java/org/elasticsearch/index/query/SimpleQueryStringBuilder.java +++ b/core/src/main/java/org/elasticsearch/index/query/SimpleQueryStringBuilder.java @@ -157,19 +157,19 @@ public class SimpleQueryStringBuilder extends AbstractQueryBuilder 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 + "]"); } } } diff --git a/core/src/main/java/org/elasticsearch/index/reindex/BulkByScrollTask.java b/core/src/main/java/org/elasticsearch/index/reindex/BulkByScrollTask.java index 18c6dac920..284fea7a38 100644 --- a/core/src/main/java/org/elasticsearch/index/reindex/BulkByScrollTask.java +++ b/core/src/main/java/org/elasticsearch/index/reindex/BulkByScrollTask.java @@ -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); diff --git a/core/src/main/java/org/elasticsearch/index/reindex/RemoteInfo.java b/core/src/main/java/org/elasticsearch/index/reindex/RemoteInfo.java index 878a9c61e4..105afcc95b 100644 --- a/core/src/main/java/org/elasticsearch/index/reindex/RemoteInfo.java +++ b/core/src/main/java/org/elasticsearch/index/reindex/RemoteInfo.java @@ -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); } diff --git a/core/src/main/java/org/elasticsearch/ingest/PipelineConfiguration.java b/core/src/main/java/org/elasticsearch/ingest/PipelineConfiguration.java index d58d76fb10..1d7ba958f1 100644 --- a/core/src/main/java/org/elasticsearch/ingest/PipelineConfiguration.java +++ b/core/src/main/java/org/elasticsearch/ingest/PipelineConfiguration.java @@ -118,7 +118,7 @@ public final class PipelineConfiguration extends AbstractDiffable entry : scripts.entrySet()) { diff --git a/core/src/main/java/org/elasticsearch/script/StoredScriptSource.java b/core/src/main/java/org/elasticsearch/script/StoredScriptSource.java index b4e6e257eb..7236e6eab3 100644 --- a/core/src/main/java/org/elasticsearch/script/StoredScriptSource.java +++ b/core/src/main/java/org/elasticsearch/script/StoredScriptSource.java @@ -365,7 +365,7 @@ public class StoredScriptSource extends AbstractDiffable 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 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") diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/support/IncludeExclude.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/support/IncludeExclude.java index aabe5f585d..46e371a3df 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/support/IncludeExclude.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/support/IncludeExclude.java @@ -64,8 +64,8 @@ public class IncludeExclude implements Writeable, ToXContent { public static final ParseField PARTITION_FIELD = new ParseField("partition"); public static final ParseField NUM_PARTITIONS_FIELD = new ParseField("num_partitions"); // Needed to add this seed for a deterministic term hashing policy - // otherwise tests fail to get expected results and worse, shards - // can disagree on which terms hash to the required partition. + // otherwise tests fail to get expected results and worse, shards + // can disagree on which terms hash to the required partition. private static final int HASH_PARTITIONING_SEED = 31; // for parsing purposes only @@ -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); } diff --git a/core/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java b/core/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java index 37d7eb5b02..98c4f11059 100644 --- a/core/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java +++ b/core/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java @@ -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); } } diff --git a/core/src/main/java/org/elasticsearch/search/fetch/subphase/highlight/AbstractHighlighterBuilder.java b/core/src/main/java/org/elasticsearch/search/fetch/subphase/highlight/AbstractHighlighterBuilder.java index 3a3c1cfd66..e5db6639ad 100644 --- a/core/src/main/java/org/elasticsearch/search/fetch/subphase/highlight/AbstractHighlighterBuilder.java +++ b/core/src/main/java/org/elasticsearch/search/fetch/subphase/highlight/AbstractHighlighterBuilder.java @@ -128,14 +128,14 @@ public abstract class AbstractHighlighterBuilder, 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 COMPARATOR = diff --git a/core/src/main/java/org/elasticsearch/transport/TcpTransport.java b/core/src/main/java/org/elasticsearch/transport/TcpTransport.java index ba355e4147..5713cc27c0 100644 --- a/core/src/main/java/org/elasticsearch/transport/TcpTransport.java +++ b/core/src/main/java/org/elasticsearch/transport/TcpTransport.java @@ -1324,9 +1324,15 @@ public abstract class TcpTransport 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); diff --git a/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java b/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java index c0430001bb..106c24982a 100644 --- a/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java +++ b/core/src/test/java/org/elasticsearch/ExceptionSerializationTests.java @@ -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()); diff --git a/core/src/test/java/org/elasticsearch/VersionTests.java b/core/src/test/java/org/elasticsearch/VersionTests.java index 06a4fe117f..96a0c9aa81 100644 --- a/core/src/test/java/org/elasticsearch/VersionTests.java +++ b/core/src/test/java/org/elasticsearch/VersionTests.java @@ -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); diff --git a/core/src/test/java/org/elasticsearch/action/admin/cluster/shards/ClusterSearchShardsResponseTests.java b/core/src/test/java/org/elasticsearch/action/admin/cluster/shards/ClusterSearchShardsResponseTests.java index 5181e943c2..90eb7cdcfd 100644 --- a/core/src/test/java/org/elasticsearch/action/admin/cluster/shards/ClusterSearchShardsResponseTests.java +++ b/core/src/test/java/org/elasticsearch/action/admin/cluster/shards/ClusterSearchShardsResponseTests.java @@ -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()); diff --git a/core/src/test/java/org/elasticsearch/action/admin/cluster/storedscripts/PutStoredScriptRequestTests.java b/core/src/test/java/org/elasticsearch/action/admin/cluster/storedscripts/PutStoredScriptRequestTests.java index 5f3e107942..aec8349ea8 100644 --- a/core/src/test/java/org/elasticsearch/action/admin/cluster/storedscripts/PutStoredScriptRequestTests.java +++ b/core/src/test/java/org/elasticsearch/action/admin/cluster/storedscripts/PutStoredScriptRequestTests.java @@ -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(); diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequestTests.java b/core/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequestTests.java index 590eba3666..97e1bf2930 100644 --- a/core/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequestTests.java +++ b/core/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequestTests.java @@ -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(); diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequestTests.java b/core/src/test/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequestTests.java index fd7f830e59..2870b04fdb 100644 --- a/core/src/test/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequestTests.java +++ b/core/src/test/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequestTests.java @@ -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(); diff --git a/core/src/test/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateRequestTests.java b/core/src/test/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateRequestTests.java index 48b2ae79cf..453efb2a60 100644 --- a/core/src/test/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateRequestTests.java +++ b/core/src/test/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateRequestTests.java @@ -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(); diff --git a/core/src/test/java/org/elasticsearch/action/fieldstats/FieldStatsRequestTests.java b/core/src/test/java/org/elasticsearch/action/fieldstats/FieldStatsRequestTests.java index f1cbaa9df3..309e844505 100644 --- a/core/src/test/java/org/elasticsearch/action/fieldstats/FieldStatsRequestTests.java +++ b/core/src/test/java/org/elasticsearch/action/fieldstats/FieldStatsRequestTests.java @@ -113,7 +113,7 @@ public class FieldStatsRequestTests extends ESTestCase { FieldStatsShardResponse deserialized = new FieldStatsShardResponse(); deserialized.readFrom(input); final Map> 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(); diff --git a/core/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java b/core/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java index 4fb1d0c648..73a44ff145 100644 --- a/core/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java +++ b/core/src/test/java/org/elasticsearch/action/index/IndexRequestTests.java @@ -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(); diff --git a/core/src/test/java/org/elasticsearch/action/ingest/PutPipelineRequestTests.java b/core/src/test/java/org/elasticsearch/action/ingest/PutPipelineRequestTests.java index 01aed87947..37a15c5b35 100644 --- a/core/src/test/java/org/elasticsearch/action/ingest/PutPipelineRequestTests.java +++ b/core/src/test/java/org/elasticsearch/action/ingest/PutPipelineRequestTests.java @@ -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(); diff --git a/core/src/test/java/org/elasticsearch/action/ingest/SimulatePipelineRequestTests.java b/core/src/test/java/org/elasticsearch/action/ingest/SimulatePipelineRequestTests.java index e3ca936bb8..ecd0256b11 100644 --- a/core/src/test/java/org/elasticsearch/action/ingest/SimulatePipelineRequestTests.java +++ b/core/src/test/java/org/elasticsearch/action/ingest/SimulatePipelineRequestTests.java @@ -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(); diff --git a/core/src/test/java/org/elasticsearch/action/termvectors/TermVectorsUnitTests.java b/core/src/test/java/org/elasticsearch/action/termvectors/TermVectorsUnitTests.java index e034cff3f1..2018218cc5 100644 --- a/core/src/test/java/org/elasticsearch/action/termvectors/TermVectorsUnitTests.java +++ b/core/src/test/java/org/elasticsearch/action/termvectors/TermVectorsUnitTests.java @@ -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(); diff --git a/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodeTests.java b/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodeTests.java index 548f9d407c..91b7a18236 100644 --- a/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodeTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/node/DiscoveryNodeTests.java @@ -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 } } diff --git a/core/src/test/java/org/elasticsearch/cluster/serialization/ClusterSerializationTests.java b/core/src/test/java/org/elasticsearch/cluster/serialization/ClusterSerializationTests.java index 4e77741694..3b2fb365ca 100644 --- a/core/src/test/java/org/elasticsearch/cluster/serialization/ClusterSerializationTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/serialization/ClusterSerializationTests.java @@ -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())); diff --git a/core/src/test/java/org/elasticsearch/common/io/stream/BytesStreamsTests.java b/core/src/test/java/org/elasticsearch/common/io/stream/BytesStreamsTests.java index b67000e2b2..34a48862e1 100644 --- a/core/src/test/java/org/elasticsearch/common/io/stream/BytesStreamsTests.java +++ b/core/src/test/java/org/elasticsearch/common/io/stream/BytesStreamsTests.java @@ -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 */ diff --git a/core/src/test/java/org/elasticsearch/discovery/zen/ZenDiscoveryUnitTests.java b/core/src/test/java/org/elasticsearch/discovery/zen/ZenDiscoveryUnitTests.java index b961b6d6fb..65856add56 100644 --- a/core/src/test/java/org/elasticsearch/discovery/zen/ZenDiscoveryUnitTests.java +++ b/core/src/test/java/org/elasticsearch/discovery/zen/ZenDiscoveryUnitTests.java @@ -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() { diff --git a/core/src/test/java/org/elasticsearch/fieldstats/FieldStatsTests.java b/core/src/test/java/org/elasticsearch/fieldstats/FieldStatsTests.java index ee1f654642..2fa56fa34a 100644 --- a/core/src/test/java/org/elasticsearch/fieldstats/FieldStatsTests.java +++ b/core/src/test/java/org/elasticsearch/fieldstats/FieldStatsTests.java @@ -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); } } } diff --git a/core/src/test/java/org/elasticsearch/index/IndexSortSettingsTests.java b/core/src/test/java/org/elasticsearch/index/IndexSortSettingsTests.java index af3fdf9adb..74ec1cc02d 100644 --- a/core/src/test/java/org/elasticsearch/index/IndexSortSettingsTests.java +++ b/core/src/test/java/org/elasticsearch/index/IndexSortSettingsTests.java @@ -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")); diff --git a/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerTests.java b/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerTests.java index 214515d170..b20972aded 100644 --- a/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerTests.java +++ b/core/src/test/java/org/elasticsearch/index/analysis/PreBuiltAnalyzerTests.java @@ -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)); diff --git a/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java b/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java index 7dc94d972c..e72f68e1d2 100644 --- a/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java +++ b/core/src/test/java/org/elasticsearch/index/engine/InternalEngineTests.java @@ -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))) diff --git a/core/src/test/java/org/elasticsearch/index/mapper/MapperTests.java b/core/src/test/java/org/elasticsearch/index/mapper/MapperTests.java index b42bda0a5a..72b1c95d8b 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/MapperTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/MapperTests.java @@ -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"); diff --git a/core/src/test/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilderTests.java index d19e8e32ff..ec34f6d87e 100644 --- a/core/src/test/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilderTests.java @@ -336,7 +336,7 @@ public class MoreLikeThisQueryBuilderTests extends AbstractQueryTestCase 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()); - } } diff --git a/core/src/test/java/org/elasticsearch/index/reindex/BulkByScrollTaskStatusTests.java b/core/src/test/java/org/elasticsearch/index/reindex/BulkByScrollTaskStatusTests.java index 982198c8fe..e2bf25ce1b 100644 --- a/core/src/test/java/org/elasticsearch/index/reindex/BulkByScrollTaskStatusTests.java +++ b/core/src/test/java/org/elasticsearch/index/reindex/BulkByScrollTaskStatusTests.java @@ -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); diff --git a/core/src/test/java/org/elasticsearch/ingest/PipelineConfigurationTests.java b/core/src/test/java/org/elasticsearch/ingest/PipelineConfigurationTests.java index f41d01b32c..6ca6b0ea8c 100644 --- a/core/src/test/java/org/elasticsearch/ingest/PipelineConfigurationTests.java +++ b/core/src/test/java/org/elasticsearch/ingest/PipelineConfigurationTests.java @@ -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()); diff --git a/core/src/test/resources/indices/bwc/index-5.2.2.zip b/core/src/test/resources/indices/bwc/index-5.2.2.zip new file mode 100644 index 0000000000..63f7e72821 Binary files /dev/null and b/core/src/test/resources/indices/bwc/index-5.2.2.zip differ diff --git a/core/src/test/resources/indices/bwc/index-5.3.2.zip b/core/src/test/resources/indices/bwc/index-5.3.2.zip new file mode 100644 index 0000000000..f0bed79b79 Binary files /dev/null and b/core/src/test/resources/indices/bwc/index-5.3.2.zip differ diff --git a/core/src/test/resources/indices/bwc/repo-5.2.2.zip b/core/src/test/resources/indices/bwc/repo-5.2.2.zip new file mode 100644 index 0000000000..0a9a2771e8 Binary files /dev/null and b/core/src/test/resources/indices/bwc/repo-5.2.2.zip differ diff --git a/core/src/test/resources/indices/bwc/repo-5.3.2.zip b/core/src/test/resources/indices/bwc/repo-5.3.2.zip new file mode 100644 index 0000000000..82c50dd6fc Binary files /dev/null and b/core/src/test/resources/indices/bwc/repo-5.3.2.zip differ -- cgit v1.2.3