From ea4bff1d43b6ff7dae70d9e841457790a74b3e9d Mon Sep 17 00:00:00 2001 From: Tanguy Leroux Date: Wed, 11 Oct 2017 17:56:24 +0200 Subject: [PATCH] [Monitoring] Align MonitoringBulkDoc serialization with 6.0 (elastic/x-pack-elasticsearch#2736) The version used in serialization must be aligned with 6.0/6.x. Original commit: elastic/x-pack-elasticsearch@db63b91bc61884cb390262163b1cf425c08004dd --- .../monitoring/action/MonitoringBulkDoc.java | 20 +++++++++---------- .../action/MonitoringBulkRequestTests.java | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkDoc.java b/plugin/src/main/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkDoc.java index 3e92019c10d..6ad0a289704 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkDoc.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkDoc.java @@ -55,16 +55,16 @@ public class MonitoringBulkDoc implements Writeable { public static MonitoringBulkDoc readFrom(StreamInput in) throws IOException { final MonitoredSystem system = MonitoredSystem.fromSystem(in.readOptionalString()); - if (in.getVersion().before(Version.V_7_0_0_alpha1)) { - in.readOptionalString(); // Monitoring version, removed in 7.0 - in.readOptionalString(); // Cluster UUID, removed in 7.0 + if (in.getVersion().before(Version.V_6_0_0_rc1)) { + in.readOptionalString(); // Monitoring version, removed in 6.0 rc1 + in.readOptionalString(); // Cluster UUID, removed in 6.0 rc1 } final long timestamp = in.readVLong(); - if (in.getVersion().before(Version.V_7_0_0_alpha1)) { - in.readOptionalWriteable(MonitoringDoc.Node::new);// Source node, removed in 7.0 - MonitoringIndex.readFrom(in);// Monitoring index, removed in 7.0 + if (in.getVersion().before(Version.V_6_0_0_rc1)) { + in.readOptionalWriteable(MonitoringDoc.Node::new);// Source node, removed in 6.0 rc1 + MonitoringIndex.readFrom(in);// Monitoring index, removed in 6.0 rc1 } final String type = in.readOptionalString(); @@ -73,7 +73,7 @@ public class MonitoringBulkDoc implements Writeable { final XContentType xContentType = (source != BytesArray.EMPTY) ? XContentType.readFrom(in) : XContentType.JSON; long interval = 0L; - if (in.getVersion().onOrAfter(Version.V_7_0_0_alpha1)) { + if (in.getVersion().onOrAfter(Version.V_6_0_0_rc1)) { interval = in.readVLong(); } return new MonitoringBulkDoc(system, type, id, timestamp, interval, source, xContentType); @@ -82,12 +82,12 @@ public class MonitoringBulkDoc implements Writeable { @Override public void writeTo(StreamOutput out) throws IOException { out.writeOptionalString(system.getSystem()); - if (out.getVersion().before(Version.V_7_0_0_alpha1)) { + if (out.getVersion().before(Version.V_6_0_0_rc1)) { out.writeOptionalString(MonitoringTemplateUtils.TEMPLATE_VERSION); out.writeOptionalString(null); } out.writeVLong(timestamp); - if (out.getVersion().before(Version.V_7_0_0_alpha1)) { + if (out.getVersion().before(Version.V_6_0_0_rc1)) { out.writeOptionalWriteable(null); MonitoringIndex.IGNORED_DATA.writeTo(out); } @@ -97,7 +97,7 @@ public class MonitoringBulkDoc implements Writeable { if (source != BytesArray.EMPTY) { xContentType.writeTo(out); } - if (out.getVersion().onOrAfter(Version.V_7_0_0_alpha1)) { + if (out.getVersion().onOrAfter(Version.V_6_0_0_rc1)) { out.writeVLong(interval); } } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkRequestTests.java b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkRequestTests.java index d1f82030085..9bb925bcaae 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkRequestTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/monitoring/action/MonitoringBulkRequestTests.java @@ -260,7 +260,7 @@ public class MonitoringBulkRequestTests extends ESTestCase { originalRequest.add(randomMonitoringBulkDoc()); } - final Version version = randomVersionBetween(random(), Version.V_5_0_0, Version.V_7_0_0_alpha1); + final Version version = randomVersionBetween(random(), Version.V_5_0_0, Version.V_6_0_0_rc1); final BytesStreamOutput out = new BytesStreamOutput(); out.setVersion(version); @@ -290,7 +290,7 @@ public class MonitoringBulkRequestTests extends ESTestCase { assertThat(deserialized.getSource(), equalTo(original.getSource())); assertThat(deserialized.getXContentType(), equalTo(original.getXContentType())); - if (version.onOrAfter(Version.V_7_0_0_alpha1)) { + if (version.onOrAfter(Version.V_6_0_0_rc1)) { assertThat(deserialized.getInterval(), equalTo(original.getInterval())); } else { assertThat(deserialized.getInterval(), equalTo(0L));