From b18ae14555a51e523eda0dced028cc58c3329b47 Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Tue, 14 Jan 2014 21:38:58 +0100 Subject: [PATCH] Removed old serialization logic (<= 1.0-RC1) in readFrom and writeTo methods. --- .../reroute/ClusterRerouteRequest.java | 5 +-- .../ClusterUpdateSettingsRequest.java | 5 +-- .../cluster/stats/ClusterStatsIndices.java | 21 +++------ .../cluster/stats/ClusterStatsNodes.java | 12 ++--- .../admin/indices/flush/FlushRequest.java | 7 --- .../indices/flush/ShardFlushRequest.java | 7 --- .../mapping/delete/DeleteMappingRequest.java | 5 +-- .../indices/optimize/OptimizeRequest.java | 7 --- .../optimize/ShardOptimizeRequest.java | 7 --- .../settings/put/UpdateSettingsRequest.java | 5 +-- .../admin/indices/stats/CommonStats.java | 45 +++++++------------ .../admin/indices/stats/CommonStatsFlags.java | 9 +--- .../delete/DeleteIndexTemplateRequest.java | 11 ----- .../get/GetIndexTemplatesRequest.java | 13 +----- .../template/put/PutIndexTemplateRequest.java | 11 ----- .../query/ShardValidateQueryRequest.java | 13 +----- .../warmer/delete/DeleteWarmerRequest.java | 4 +- .../indices/warmer/put/PutWarmerRequest.java | 5 +-- .../action/bulk/BulkRequest.java | 9 +--- .../action/count/ShardCountRequest.java | 11 +---- .../action/explain/ExplainRequest.java | 13 +----- .../action/mlt/MoreLikeThisRequest.java | 9 +--- .../support/master/AcknowledgedRequest.java | 23 +--------- .../action/update/UpdateRequest.java | 9 +--- .../action/index/MappingUpdatedAction.java | 21 +++------ .../index/NodeMappingRefreshAction.java | 9 +--- .../action/shard/ShardStateAction.java | 9 +--- .../cluster/metadata/MappingMetaData.java | 11 +---- .../cluster/metadata/MetaData.java | 8 +--- .../elasticsearch/index/engine/Segment.java | 17 ++----- .../index/engine/SegmentsStats.java | 9 +--- .../org/elasticsearch/monitor/fs/FsStats.java | 13 +----- .../elasticsearch/monitor/jvm/JvmInfo.java | 13 ++---- .../elasticsearch/monitor/jvm/JvmStats.java | 13 +----- .../monitor/process/ProcessInfo.java | 9 +--- .../elasticsearch/search/suggest/Suggest.java | 9 +--- .../suggest/phrase/PhraseSuggestion.java | 11 ----- .../delete/DeleteWarmerRequestTests.java | 24 +--------- .../warmer/put/PutWarmerRequestTests.java | 24 +--------- 39 files changed, 91 insertions(+), 375 deletions(-) diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteRequest.java b/src/main/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteRequest.java index 16b05948c37..a0a7939dddf 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteRequest.java @@ -20,7 +20,6 @@ package org.elasticsearch.action.admin.cluster.reroute; import org.elasticsearch.ElasticsearchParseException; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.support.master.AcknowledgedRequest; import org.elasticsearch.cluster.routing.allocation.command.AllocationCommand; @@ -111,7 +110,7 @@ public class ClusterRerouteRequest extends AcknowledgedRequest { @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - if (out.getVersion().onOrBefore(Version.V_0_90_3)) { - out.writeBoolean(false); // refresh flag - } out.writeBoolean(full); out.writeBoolean(force); } @@ -97,9 +93,6 @@ public class FlushRequest extends BroadcastOperationRequest { @Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); - if (in.getVersion().onOrBefore(Version.V_0_90_3)) { - in.readBoolean(); // refresh flag - } full = in.readBoolean(); force = in.readBoolean(); } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/flush/ShardFlushRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/flush/ShardFlushRequest.java index a5e21cee70b..f98ea265991 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/flush/ShardFlushRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/flush/ShardFlushRequest.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.admin.indices.flush; -import org.elasticsearch.Version; import org.elasticsearch.action.support.broadcast.BroadcastShardOperationRequest; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -54,9 +53,6 @@ class ShardFlushRequest extends BroadcastShardOperationRequest { @Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); - if (in.getVersion().onOrBefore(Version.V_0_90_3)) { - in.readBoolean(); // refresh flag - } full = in.readBoolean(); force = in.readBoolean(); } @@ -64,9 +60,6 @@ class ShardFlushRequest extends BroadcastShardOperationRequest { @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - if (out.getVersion().onOrBefore(Version.V_0_90_3)) { - out.writeBoolean(false); // refresh flag - } out.writeBoolean(full); out.writeBoolean(force); } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/mapping/delete/DeleteMappingRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/mapping/delete/DeleteMappingRequest.java index e342a5d7673..e023b880105 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/mapping/delete/DeleteMappingRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/mapping/delete/DeleteMappingRequest.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.admin.indices.mapping.delete; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.action.support.master.AcknowledgedRequest; @@ -127,7 +126,7 @@ public class DeleteMappingRequest extends AcknowledgedRequest maxNumSegments = in.readInt(); onlyExpungeDeletes = in.readBoolean(); flush = in.readBoolean(); - if (in.getVersion().onOrBefore(Version.V_0_90_3)) { - in.readBoolean(); // old refresh flag - } } public void writeTo(StreamOutput out) throws IOException { @@ -148,8 +144,5 @@ public class OptimizeRequest extends BroadcastOperationRequest out.writeInt(maxNumSegments); out.writeBoolean(onlyExpungeDeletes); out.writeBoolean(flush); - if (out.getVersion().onOrBefore(Version.V_0_90_3)) { - out.writeBoolean(false); // old refresh flag - } } } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/optimize/ShardOptimizeRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/optimize/ShardOptimizeRequest.java index 8edaf708491..4cd66305604 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/optimize/ShardOptimizeRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/optimize/ShardOptimizeRequest.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.admin.indices.optimize; -import org.elasticsearch.Version; import org.elasticsearch.action.support.broadcast.BroadcastShardOperationRequest; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -70,9 +69,6 @@ class ShardOptimizeRequest extends BroadcastShardOperationRequest { maxNumSegments = in.readInt(); onlyExpungeDeletes = in.readBoolean(); flush = in.readBoolean(); - if (in.getVersion().onOrBefore(Version.V_0_90_3)) { - in.readBoolean(); // old refresh flag - } } @Override @@ -82,8 +78,5 @@ class ShardOptimizeRequest extends BroadcastShardOperationRequest { out.writeInt(maxNumSegments); out.writeBoolean(onlyExpungeDeletes); out.writeBoolean(flush); - if (out.getVersion().onOrBefore(Version.V_0_90_3)) { - out.writeBoolean(false); // old refresh flag - } } } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/settings/put/UpdateSettingsRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/settings/put/UpdateSettingsRequest.java index d00a929bd96..9be19a9c7e3 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/settings/put/UpdateSettingsRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/settings/put/UpdateSettingsRequest.java @@ -20,7 +20,6 @@ package org.elasticsearch.action.admin.indices.settings.put; import org.elasticsearch.ElasticsearchGenerationException; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.action.support.master.AcknowledgedRequest; @@ -146,7 +145,7 @@ public class UpdateSettingsRequest extends AcknowledgedRequest entry : mappings.entrySet()) { out.writeString(entry.getKey()); diff --git a/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ShardValidateQueryRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ShardValidateQueryRequest.java index 634a6e766df..d4d13ca289b 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ShardValidateQueryRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/validate/query/ShardValidateQueryRequest.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.admin.indices.validate.query; -import org.elasticsearch.Version; import org.elasticsearch.action.support.broadcast.BroadcastShardOperationRequest; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Strings; @@ -96,12 +95,7 @@ class ShardValidateQueryRequest extends BroadcastShardOperationRequest { } explain = in.readBoolean(); - - if (in.getVersion().onOrAfter(Version.V_0_90_6)) { - nowInMillis = in.readVLong(); - } else { - nowInMillis = System.currentTimeMillis(); - } + nowInMillis = in.readVLong(); } @Override @@ -123,9 +117,6 @@ class ShardValidateQueryRequest extends BroadcastShardOperationRequest { } out.writeBoolean(explain); - - if (out.getVersion().onOrAfter(Version.V_0_90_6)) { - out.writeVLong(nowInMillis); - } + out.writeVLong(nowInMillis); } } diff --git a/src/main/java/org/elasticsearch/action/admin/indices/warmer/delete/DeleteWarmerRequest.java b/src/main/java/org/elasticsearch/action/admin/indices/warmer/delete/DeleteWarmerRequest.java index 3c79b104517..c72688449f3 100644 --- a/src/main/java/org/elasticsearch/action/admin/indices/warmer/delete/DeleteWarmerRequest.java +++ b/src/main/java/org/elasticsearch/action/admin/indices/warmer/delete/DeleteWarmerRequest.java @@ -129,7 +129,7 @@ public class DeleteWarmerRequest extends AcknowledgedRequest { searchRequest = new SearchRequest(); searchRequest.readFrom(in); } - readTimeout(in, Version.V_0_90_6); + readTimeout(in); } @Override @@ -119,6 +118,6 @@ public class PutWarmerRequest extends AcknowledgedRequest { out.writeBoolean(true); searchRequest.writeTo(out); } - writeTimeout(out, Version.V_0_90_6); + writeTimeout(out); } } diff --git a/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java b/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java index 2927419fb7b..4c9504a25ba 100644 --- a/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java +++ b/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java @@ -21,7 +21,6 @@ package org.elasticsearch.action.bulk; import com.google.common.collect.Lists; import org.elasticsearch.ElasticsearchIllegalArgumentException; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.WriteConsistencyLevel; @@ -495,9 +494,7 @@ public class BulkRequest extends ActionRequest { } } refresh = in.readBoolean(); - if (in.getVersion().after(Version.V_0_90_7)) { - timeout = TimeValue.readTimeValue(in); - } + timeout = TimeValue.readTimeValue(in); } @Override @@ -517,8 +514,6 @@ public class BulkRequest extends ActionRequest { request.writeTo(out); } out.writeBoolean(refresh); - if (out.getVersion().after(Version.V_0_90_7)) { - timeout.writeTo(out); - } + timeout.writeTo(out); } } diff --git a/src/main/java/org/elasticsearch/action/count/ShardCountRequest.java b/src/main/java/org/elasticsearch/action/count/ShardCountRequest.java index ef06bfdf96a..f0e0afaac30 100644 --- a/src/main/java/org/elasticsearch/action/count/ShardCountRequest.java +++ b/src/main/java/org/elasticsearch/action/count/ShardCountRequest.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.count; -import org.elasticsearch.Version; import org.elasticsearch.action.support.broadcast.BroadcastShardOperationRequest; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Strings; @@ -99,11 +98,7 @@ class ShardCountRequest extends BroadcastShardOperationRequest { filteringAliases[i] = in.readString(); } } - if (in.getVersion().onOrAfter(Version.V_0_90_6)) { - nowInMillis = in.readVLong(); - } else { - nowInMillis = System.currentTimeMillis(); - } + nowInMillis = in.readVLong(); } @Override @@ -125,8 +120,6 @@ class ShardCountRequest extends BroadcastShardOperationRequest { } else { out.writeVInt(0); } - if (out.getVersion().onOrAfter(Version.V_0_90_6)) { - out.writeVLong(nowInMillis); - } + out.writeVLong(nowInMillis); } } diff --git a/src/main/java/org/elasticsearch/action/explain/ExplainRequest.java b/src/main/java/org/elasticsearch/action/explain/ExplainRequest.java index 2fea9a5277d..7898e4783cb 100644 --- a/src/main/java/org/elasticsearch/action/explain/ExplainRequest.java +++ b/src/main/java/org/elasticsearch/action/explain/ExplainRequest.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.explain; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.ValidateActions; import org.elasticsearch.action.support.QuerySourceBuilder; @@ -199,12 +198,7 @@ public class ExplainRequest extends SingleShardOperationRequest } fetchSourceContext = FetchSourceContext.optionalReadFromStream(in); - - if (in.getVersion().onOrAfter(Version.V_0_90_6)) { - nowInMillis = in.readVLong(); - } else { - nowInMillis = System.currentTimeMillis(); - } + nowInMillis = in.readVLong(); } @Override @@ -224,9 +218,6 @@ public class ExplainRequest extends SingleShardOperationRequest } FetchSourceContext.optionalWriteToStream(fetchSourceContext, out); - - if (out.getVersion().onOrAfter(Version.V_0_90_6)) { - out.writeVLong(nowInMillis); - } + out.writeVLong(nowInMillis); } } diff --git a/src/main/java/org/elasticsearch/action/mlt/MoreLikeThisRequest.java b/src/main/java/org/elasticsearch/action/mlt/MoreLikeThisRequest.java index bbd109bbd88..09d8f82f457 100644 --- a/src/main/java/org/elasticsearch/action/mlt/MoreLikeThisRequest.java +++ b/src/main/java/org/elasticsearch/action/mlt/MoreLikeThisRequest.java @@ -21,7 +21,6 @@ package org.elasticsearch.action.mlt; import org.elasticsearch.ElasticsearchGenerationException; import org.elasticsearch.ElasticsearchIllegalArgumentException; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.ValidateActions; @@ -592,9 +591,7 @@ public class MoreLikeThisRequest extends ActionRequest { searchSize = in.readVInt(); searchFrom = in.readVInt(); - if (in.getVersion().onOrAfter(Version.V_0_90_1)) { - routing = in.readOptionalString(); - } + routing = in.readOptionalString(); } @Override @@ -662,8 +659,6 @@ public class MoreLikeThisRequest extends ActionRequest { out.writeVInt(searchSize); out.writeVInt(searchFrom); - if (out.getVersion().onOrAfter(Version.V_0_90_1)) { - out.writeOptionalString(routing); - } + out.writeOptionalString(routing); } } diff --git a/src/main/java/org/elasticsearch/action/support/master/AcknowledgedRequest.java b/src/main/java/org/elasticsearch/action/support/master/AcknowledgedRequest.java index 66295652a3c..56ce2b38535 100644 --- a/src/main/java/org/elasticsearch/action/support/master/AcknowledgedRequest.java +++ b/src/main/java/org/elasticsearch/action/support/master/AcknowledgedRequest.java @@ -18,7 +18,6 @@ */ package org.elasticsearch.action.support.master; -import org.elasticsearch.Version; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.unit.TimeValue; @@ -75,31 +74,13 @@ public abstract class AcknowledgedRequest * Reads the timeout value */ protected void readTimeout(StreamInput in) throws IOException { - readTimeout(in, null); - } - - /** - * Reads the timeout value if on or after the specified min version or if the version is null. - */ - protected void readTimeout(StreamInput in, Version minVersion) throws IOException { - if (minVersion == null || in.getVersion().onOrAfter(minVersion)) { - timeout = readTimeValue(in); - } + timeout = readTimeValue(in); } /** * writes the timeout value */ protected void writeTimeout(StreamOutput out) throws IOException { - writeTimeout(out, null); - } - - /** - * writes the timeout value if on or after the specified min version or if the version is null. - */ - protected void writeTimeout(StreamOutput out, Version minVersion) throws IOException { - if (minVersion == null || out.getVersion().onOrAfter(minVersion)) { - timeout.writeTo(out); - } + timeout.writeTo(out); } } diff --git a/src/main/java/org/elasticsearch/action/update/UpdateRequest.java b/src/main/java/org/elasticsearch/action/update/UpdateRequest.java index b9b9eb76dad..97650430c9d 100644 --- a/src/main/java/org/elasticsearch/action/update/UpdateRequest.java +++ b/src/main/java/org/elasticsearch/action/update/UpdateRequest.java @@ -20,7 +20,6 @@ package org.elasticsearch.action.update; import com.google.common.collect.Maps; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.WriteConsistencyLevel; import org.elasticsearch.action.index.IndexRequest; @@ -603,9 +602,7 @@ public class UpdateRequest extends InstanceShardOperationRequest upsertRequest = new IndexRequest(); upsertRequest.readFrom(in); } - if (in.getVersion().onOrAfter(Version.V_0_90_2)) { - docAsUpsert = in.readBoolean(); - } + docAsUpsert = in.readBoolean(); version = in.readLong(); versionType = VersionType.fromValue(in.readByte()); } @@ -651,9 +648,7 @@ public class UpdateRequest extends InstanceShardOperationRequest upsertRequest.id(id); upsertRequest.writeTo(out); } - if (out.getVersion().onOrAfter(Version.V_0_90_2)) { - out.writeBoolean(docAsUpsert); - } + out.writeBoolean(docAsUpsert); out.writeLong(version); out.writeByte(versionType.getValue()); } diff --git a/src/main/java/org/elasticsearch/cluster/action/index/MappingUpdatedAction.java b/src/main/java/org/elasticsearch/cluster/action/index/MappingUpdatedAction.java index c2718947e88..a7df8e995a7 100644 --- a/src/main/java/org/elasticsearch/cluster/action/index/MappingUpdatedAction.java +++ b/src/main/java/org/elasticsearch/cluster/action/index/MappingUpdatedAction.java @@ -20,7 +20,6 @@ package org.elasticsearch.cluster.action.index; import org.elasticsearch.ElasticsearchException; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.ActionResponse; @@ -174,13 +173,9 @@ public class MappingUpdatedAction extends TransportMasterNodeOperationAction { public static MetaData readFrom(StreamInput in) throws IOException { Builder builder = new Builder(); builder.version = in.readLong(); - if (in.getVersion().after(Version.V_0_90_7)) { - builder.uuid = in.readString(); - } + builder.uuid = in.readString(); builder.transientSettings(readSettingsFromStream(in)); builder.persistentSettings(readSettingsFromStream(in)); int size = in.readVInt(); @@ -1362,9 +1360,7 @@ public class MetaData implements Iterable { public static void writeTo(MetaData metaData, StreamOutput out) throws IOException { out.writeLong(metaData.version); - if (out.getVersion().after(Version.V_0_90_7)) { - out.writeString(metaData.uuid); - } + out.writeString(metaData.uuid); writeSettingsToStream(metaData.transientSettings(), out); writeSettingsToStream(metaData.persistentSettings(), out); out.writeVInt(metaData.indices.size()); diff --git a/src/main/java/org/elasticsearch/index/engine/Segment.java b/src/main/java/org/elasticsearch/index/engine/Segment.java index 48a75de741e..42bd593b05e 100644 --- a/src/main/java/org/elasticsearch/index/engine/Segment.java +++ b/src/main/java/org/elasticsearch/index/engine/Segment.java @@ -19,7 +19,6 @@ package org.elasticsearch.index.engine; -import org.elasticsearch.Version; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -141,12 +140,8 @@ public class Segment implements Streamable { sizeInBytes = in.readLong(); version = in.readOptionalString(); compound = in.readOptionalBoolean(); - if (in.getVersion().onOrAfter(Version.V_0_90_6)) { - mergeId = in.readOptionalString(); - } - if (in.getVersion().after(Version.V_0_90_8)) { - memoryInBytes = in.readLong(); - } + mergeId = in.readOptionalString(); + memoryInBytes = in.readLong(); } @Override @@ -159,11 +154,7 @@ public class Segment implements Streamable { out.writeLong(sizeInBytes); out.writeOptionalString(version); out.writeOptionalBoolean(compound); - if (out.getVersion().onOrAfter(Version.V_0_90_6)) { - out.writeOptionalString(mergeId); - } - if (out.getVersion().after(Version.V_0_90_8)) { - out.writeLong(memoryInBytes); - } + out.writeOptionalString(mergeId); + out.writeLong(memoryInBytes); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/index/engine/SegmentsStats.java b/src/main/java/org/elasticsearch/index/engine/SegmentsStats.java index 0eba89c2187..968edee9297 100644 --- a/src/main/java/org/elasticsearch/index/engine/SegmentsStats.java +++ b/src/main/java/org/elasticsearch/index/engine/SegmentsStats.java @@ -19,7 +19,6 @@ package org.elasticsearch.index.engine; -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; @@ -98,16 +97,12 @@ public class SegmentsStats implements Streamable, ToXContent { @Override public void readFrom(StreamInput in) throws IOException { count = in.readVLong(); - if (in.getVersion().after(Version.V_0_90_8)) { - memoryInBytes = in.readLong(); - } + memoryInBytes = in.readLong(); } @Override public void writeTo(StreamOutput out) throws IOException { out.writeVLong(count); - if (out.getVersion().after(Version.V_0_90_8)) { - out.writeLong(memoryInBytes); - } + out.writeLong(memoryInBytes); } } \ No newline at end of file diff --git a/src/main/java/org/elasticsearch/monitor/fs/FsStats.java b/src/main/java/org/elasticsearch/monitor/fs/FsStats.java index b4edf192d7b..4b7bedee7f2 100644 --- a/src/main/java/org/elasticsearch/monitor/fs/FsStats.java +++ b/src/main/java/org/elasticsearch/monitor/fs/FsStats.java @@ -20,7 +20,6 @@ package org.elasticsearch.monitor.fs; import com.google.common.collect.Iterators; -import org.elasticsearch.Version; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Strings; import org.elasticsearch.common.io.stream.StreamInput; @@ -65,11 +64,7 @@ public class FsStats implements Iterable, Streamable, ToXContent { @Override public void readFrom(StreamInput in) throws IOException { - if (in.getVersion().after(Version.V_0_90_7)) { - path = in.readOptionalString(); - } else { - path = in.readString(); - } + path = in.readOptionalString(); mount = in.readOptionalString(); dev = in.readOptionalString(); total = in.readLong(); @@ -85,11 +80,7 @@ public class FsStats implements Iterable, Streamable, ToXContent { @Override public void writeTo(StreamOutput out) throws IOException { - if (out.getVersion().after(Version.V_0_90_7)) { - out.writeOptionalString(path); // total aggregates do not have a path - } else { - out.writeString(path); - } + out.writeOptionalString(path); // total aggregates do not have a path out.writeOptionalString(mount); out.writeOptionalString(dev); out.writeLong(total); diff --git a/src/main/java/org/elasticsearch/monitor/jvm/JvmInfo.java b/src/main/java/org/elasticsearch/monitor/jvm/JvmInfo.java index ceb61bda238..31cbd67eb15 100644 --- a/src/main/java/org/elasticsearch/monitor/jvm/JvmInfo.java +++ b/src/main/java/org/elasticsearch/monitor/jvm/JvmInfo.java @@ -19,7 +19,6 @@ package org.elasticsearch.monitor.jvm; -import org.elasticsearch.Version; import org.elasticsearch.common.Strings; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -357,10 +356,8 @@ public class JvmInfo implements Streamable, Serializable, ToXContent { } mem = new Mem(); mem.readFrom(in); - if (in.getVersion().after(Version.V_0_90_9)) { - gcCollectors = in.readStringArray(); - memoryPools = in.readStringArray(); - } + gcCollectors = in.readStringArray(); + memoryPools = in.readStringArray(); } @Override @@ -383,10 +380,8 @@ public class JvmInfo implements Streamable, Serializable, ToXContent { out.writeString(entry.getValue()); } mem.writeTo(out); - if (out.getVersion().after(Version.V_0_90_9)) { - out.writeStringArray(gcCollectors); - out.writeStringArray(memoryPools); - } + out.writeStringArray(gcCollectors); + out.writeStringArray(memoryPools); } public static class Mem implements Streamable, Serializable { diff --git a/src/main/java/org/elasticsearch/monitor/jvm/JvmStats.java b/src/main/java/org/elasticsearch/monitor/jvm/JvmStats.java index 7c5cd085561..97fd85bf974 100644 --- a/src/main/java/org/elasticsearch/monitor/jvm/JvmStats.java +++ b/src/main/java/org/elasticsearch/monitor/jvm/JvmStats.java @@ -20,7 +20,6 @@ package org.elasticsearch.monitor.jvm; import com.google.common.collect.Iterators; -import org.elasticsearch.Version; import org.elasticsearch.common.Booleans; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; @@ -822,11 +821,7 @@ public class JvmStats implements Streamable, Serializable, ToXContent { heapUsed = in.readVLong(); nonHeapCommitted = in.readVLong(); nonHeapUsed = in.readVLong(); - - if (in.getVersion().onOrAfter(Version.V_0_90_7)) { - heapMax = in.readVLong(); - } - + heapMax = in.readVLong(); pools = new MemoryPool[in.readVInt()]; for (int i = 0; i < pools.length; i++) { pools[i] = MemoryPool.readMemoryPool(in); @@ -839,11 +834,7 @@ public class JvmStats implements Streamable, Serializable, ToXContent { out.writeVLong(heapUsed); out.writeVLong(nonHeapCommitted); out.writeVLong(nonHeapUsed); - - if (out.getVersion().onOrAfter(Version.V_0_90_7)) { - out.writeVLong(heapMax); - } - + out.writeVLong(heapMax); out.writeVInt(pools.length); for (MemoryPool pool : pools) { pool.writeTo(out); diff --git a/src/main/java/org/elasticsearch/monitor/process/ProcessInfo.java b/src/main/java/org/elasticsearch/monitor/process/ProcessInfo.java index a21675c7fe0..8607f94d89c 100644 --- a/src/main/java/org/elasticsearch/monitor/process/ProcessInfo.java +++ b/src/main/java/org/elasticsearch/monitor/process/ProcessInfo.java @@ -19,7 +19,6 @@ package org.elasticsearch.monitor.process; -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; @@ -122,9 +121,7 @@ public class ProcessInfo implements Streamable, Serializable, ToXContent { refreshInterval = in.readLong(); id = in.readLong(); maxFileDescriptors = in.readLong(); - if (in.getVersion().after(Version.V_0_90_7)) { - mlockall = in.readBoolean(); - } + mlockall = in.readBoolean(); } @Override @@ -132,8 +129,6 @@ public class ProcessInfo implements Streamable, Serializable, ToXContent { out.writeLong(refreshInterval); out.writeLong(id); out.writeLong(maxFileDescriptors); - if (out.getVersion().after(Version.V_0_90_7)) { - out.writeBoolean(mlockall); - } + out.writeBoolean(mlockall); } } diff --git a/src/main/java/org/elasticsearch/search/suggest/Suggest.java b/src/main/java/org/elasticsearch/search/suggest/Suggest.java index c3b2ed8dda3..6eafdfe4849 100644 --- a/src/main/java/org/elasticsearch/search/suggest/Suggest.java +++ b/src/main/java/org/elasticsearch/search/suggest/Suggest.java @@ -21,7 +21,6 @@ package org.elasticsearch.search.suggest; import org.apache.lucene.util.CollectionUtil; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.ElasticsearchIllegalStateException; -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; @@ -571,18 +570,14 @@ public class Suggest implements Iterable @Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); - // If the other side is older than 0.90.4 then it shouldn't be sending suggestions of this type but just in case - // we're going to assume that they are regular suggestions so we won't read anything. - if (in.getVersion().before(Version.V_0_90_4)) { - return; - } cutoffScore = in.readDouble(); } @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - // If the other side of the message is older than 0.90.4 it'll interpret these suggestions as regular suggestions - // so we have to pretend to be one which we can do by just calling the superclass writeTo and doing nothing else - if (out.getVersion().before(Version.V_0_90_4)) { - return; - } out.writeDouble(cutoffScore); } } diff --git a/src/test/java/org/elasticsearch/action/admin/indices/warmer/delete/DeleteWarmerRequestTests.java b/src/test/java/org/elasticsearch/action/admin/indices/warmer/delete/DeleteWarmerRequestTests.java index 386abbd3efb..d277ed1a959 100644 --- a/src/test/java/org/elasticsearch/action/admin/indices/warmer/delete/DeleteWarmerRequestTests.java +++ b/src/test/java/org/elasticsearch/action/admin/indices/warmer/delete/DeleteWarmerRequestTests.java @@ -33,29 +33,7 @@ import static org.hamcrest.CoreMatchers.equalTo; public class DeleteWarmerRequestTests extends ElasticsearchTestCase { @Test - public void testDeleteWarmerTimeoutBwComp_Pre0906Format() throws Exception { - DeleteWarmerRequest outRequest = new DeleteWarmerRequest("warmer1"); - outRequest.timeout(TimeValue.timeValueMillis(1000)); - - ByteArrayOutputStream outBuffer = new ByteArrayOutputStream(); - OutputStreamStreamOutput out = new OutputStreamStreamOutput(outBuffer); - out.setVersion(Version.V_0_90_0); - outRequest.writeTo(out); - - ByteArrayInputStream esInBuffer = new ByteArrayInputStream(outBuffer.toByteArray()); - InputStreamStreamInput esBuffer = new InputStreamStreamInput(esInBuffer); - esBuffer.setVersion(Version.V_0_90_0); - DeleteWarmerRequest inRequest = new DeleteWarmerRequest(); - inRequest.readFrom(esBuffer); - - assertThat(inRequest.names()[0], equalTo("warmer1")); - //timeout is default as we don't read it from the received buffer - assertThat(inRequest.timeout().millis(), equalTo(new DeleteWarmerRequest().timeout().millis())); - - } - - @Test - public void testDeleteWarmerTimeoutBwComp_Post0906Format() throws Exception { + public void testDeleteWarmerTimeout() throws Exception { DeleteWarmerRequest outRequest = new DeleteWarmerRequest("warmer1"); outRequest.timeout(TimeValue.timeValueMillis(1000)); diff --git a/src/test/java/org/elasticsearch/action/admin/indices/warmer/put/PutWarmerRequestTests.java b/src/test/java/org/elasticsearch/action/admin/indices/warmer/put/PutWarmerRequestTests.java index f08f3a998c9..9379c0896ff 100644 --- a/src/test/java/org/elasticsearch/action/admin/indices/warmer/put/PutWarmerRequestTests.java +++ b/src/test/java/org/elasticsearch/action/admin/indices/warmer/put/PutWarmerRequestTests.java @@ -32,33 +32,11 @@ import java.io.ByteArrayOutputStream; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.Matchers.is; public class PutWarmerRequestTests extends ElasticsearchTestCase { @Test - public void testPutWarmerTimeoutBwComp_Pre0906Format() throws Exception { - PutWarmerRequest outRequest = new PutWarmerRequest("warmer1"); - outRequest.timeout(TimeValue.timeValueMillis(1000)); - - ByteArrayOutputStream outBuffer = new ByteArrayOutputStream(); - OutputStreamStreamOutput out = new OutputStreamStreamOutput(outBuffer); - out.setVersion(Version.V_0_90_0); - outRequest.writeTo(out); - - ByteArrayInputStream esInBuffer = new ByteArrayInputStream(outBuffer.toByteArray()); - InputStreamStreamInput esBuffer = new InputStreamStreamInput(esInBuffer); - esBuffer.setVersion(Version.V_0_90_0); - PutWarmerRequest inRequest = new PutWarmerRequest(); - inRequest.readFrom(esBuffer); - - assertThat(inRequest.name(), equalTo("warmer1")); - //timeout is default as we don't read it from the received buffer - assertThat(inRequest.timeout().millis(), equalTo(new PutWarmerRequest().timeout().millis())); - } - - @Test - public void testPutWarmerTimeoutBwComp_Post0906Format() throws Exception { + public void testPutWarmerTimeout() throws Exception { PutWarmerRequest outRequest = new PutWarmerRequest("warmer1"); outRequest.timeout(TimeValue.timeValueMillis(1000));