diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/graph/GraphExploreRequest.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/graph/GraphExploreRequest.java index c1a682757d1..6c3bc0e6b81 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/graph/GraphExploreRequest.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/graph/GraphExploreRequest.java @@ -121,6 +121,31 @@ public class GraphExploreRequest extends ActionRequest implements IndicesRequest return this; } + public GraphExploreRequest(StreamInput in) throws IOException { + super(in); + + indices = in.readStringArray(); + indicesOptions = IndicesOptions.readIndicesOptions(in); + types = in.readStringArray(); + routing = in.readOptionalString(); + timeout = in.readOptionalTimeValue(); + sampleSize = in.readInt(); + sampleDiversityField = in.readOptionalString(); + maxDocsPerDiversityValue = in.readInt(); + + useSignificance = in.readBoolean(); + returnDetailedInfo = in.readBoolean(); + + int numHops = in.readInt(); + Hop parentHop = null; + for (int i = 0; i < numHops; i++) { + Hop hop = new Hop(parentHop); + hop.readFrom(in); + hops.add(hop); + parentHop = hop; + } + } + public String routing() { return this.routing; } @@ -164,29 +189,7 @@ public class GraphExploreRequest extends ActionRequest implements IndicesRequest @Override public void readFrom(StreamInput in) throws IOException { - super.readFrom(in); - - indices = in.readStringArray(); - indicesOptions = IndicesOptions.readIndicesOptions(in); - types = in.readStringArray(); - routing = in.readOptionalString(); - timeout = in.readOptionalTimeValue(); - sampleSize = in.readInt(); - sampleDiversityField = in.readOptionalString(); - maxDocsPerDiversityValue = in.readInt(); - - useSignificance = in.readBoolean(); - returnDetailedInfo = in.readBoolean(); - - int numHops = in.readInt(); - Hop parentHop = null; - for (int i = 0; i < numHops; i++) { - Hop hop = new Hop(parentHop); - hop.readFrom(in); - hops.add(hop); - parentHop = hop; - } - + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/watcher/DeleteWatchRequest.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/watcher/DeleteWatchRequest.java index 4a458b69a75..d29e1013c97 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/watcher/DeleteWatchRequest.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/watcher/DeleteWatchRequest.java @@ -22,14 +22,18 @@ public class DeleteWatchRequest extends ActionRequest { private String id; private long version = Versions.MATCH_ANY; - public DeleteWatchRequest() { - this(null); - } + public DeleteWatchRequest() {} public DeleteWatchRequest(String id) { this.id = id; } + public DeleteWatchRequest(StreamInput in) throws IOException { + super(in); + id = in.readString(); + version = in.readLong(); + } + /** * @return The name of the watch to be deleted */ @@ -57,9 +61,7 @@ public class DeleteWatchRequest extends ActionRequest { @Override public void readFrom(StreamInput in) throws IOException { - super.readFrom(in); - id = in.readString(); - version = in.readLong(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/watcher/DeleteWatchResponse.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/watcher/DeleteWatchResponse.java index 740b318dc48..527a1be5de7 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/watcher/DeleteWatchResponse.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/watcher/DeleteWatchResponse.java @@ -33,6 +33,12 @@ public class DeleteWatchResponse extends ActionResponse implements ToXContentObj public DeleteWatchResponse() {} + public DeleteWatchResponse(String id, long version, boolean found) { + this.id = id; + this.version = version; + this.found = found; + } + public DeleteWatchResponse(StreamInput in) throws IOException { super(in); id = in.readString(); @@ -40,12 +46,6 @@ public class DeleteWatchResponse extends ActionResponse implements ToXContentObj found = in.readBoolean(); } - public DeleteWatchResponse(String id, long version, boolean found) { - this.id = id; - this.version = version; - this.found = found; - } - public String getId() { return id; } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/graph/action/GraphExploreAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/graph/action/GraphExploreAction.java index 461ee39d8ed..58814604243 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/graph/action/GraphExploreAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/graph/action/GraphExploreAction.java @@ -16,4 +16,4 @@ public class GraphExploreAction extends ActionType { private GraphExploreAction() { super(NAME, GraphExploreResponse::new); } -} \ No newline at end of file +} diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/monitoring/action/MonitoringBulkDoc.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/monitoring/action/MonitoringBulkDoc.java index 9ddc2c6d9ec..cf7dd817ec4 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/monitoring/action/MonitoringBulkDoc.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/monitoring/action/MonitoringBulkDoc.java @@ -49,34 +49,31 @@ public class MonitoringBulkDoc implements Writeable { this.xContentType = Objects.requireNonNull(xContentType); } - /** - * Read from a stream. - */ - public static MonitoringBulkDoc readFrom(StreamInput in) throws IOException { - final MonitoredSystem system = MonitoredSystem.fromSystem(in.readOptionalString()); + public MonitoringBulkDoc (StreamInput in) throws IOException { + this.system = MonitoredSystem.fromSystem(in.readOptionalString()); 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(); + this.timestamp = in.readVLong(); 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(); - final String id = in.readOptionalString(); - final BytesReference source = in.readBytesReference(); - final XContentType xContentType = (source != BytesArray.EMPTY) ? in.readEnum(XContentType.class) : XContentType.JSON; + this.type = in.readOptionalString(); + this.id = in.readOptionalString(); + this.source = in.readBytesReference(); + this.xContentType = (source != BytesArray.EMPTY) ? in.readEnum(XContentType.class) : XContentType.JSON; long interval = 0L; if (in.getVersion().onOrAfter(Version.V_6_0_0_rc1)) { interval = in.readVLong(); } - return new MonitoringBulkDoc(system, type, id, timestamp, interval, source, xContentType); + this.intervalMillis = interval; } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/monitoring/action/MonitoringBulkRequest.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/monitoring/action/MonitoringBulkRequest.java index 12c4e0b7ee3..77f4ecfdbf2 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/monitoring/action/MonitoringBulkRequest.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/monitoring/action/MonitoringBulkRequest.java @@ -32,6 +32,13 @@ public class MonitoringBulkRequest extends ActionRequest { private final List docs = new ArrayList<>(); + public MonitoringBulkRequest() {} + + public MonitoringBulkRequest(StreamInput in) throws IOException { + super(in); + docs.addAll(in.readList(MonitoringBulkDoc::new)); + } + /** * @return the list of {@link MonitoringBulkDoc} to be indexed */ @@ -97,8 +104,7 @@ public class MonitoringBulkRequest extends ActionRequest { @Override public void readFrom(StreamInput in) throws IOException { - super.readFrom(in); - docs.addAll(in.readList(MonitoringBulkDoc::readFrom)); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/GetRollupCapsAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/GetRollupCapsAction.java index 98044abadb2..10ce1138728 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/GetRollupCapsAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/GetRollupCapsAction.java @@ -51,14 +51,18 @@ public class GetRollupCapsAction extends ActionType { +public class GetRollupCapsActionRequestTests extends AbstractWireSerializingTestCase { @Override protected GetRollupCapsAction.Request createTestInstance() { @@ -38,8 +39,8 @@ public class GetRollupCapsActionRequestTests extends AbstractStreamableTestCase< } @Override - protected GetRollupCapsAction.Request createBlankInstance() { - return new GetRollupCapsAction.Request(); + protected Writeable.Reader instanceReader() { + return GetRollupCapsAction.Request::new; } public void testNoIndexMetaData() { diff --git a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/GetRollupIndexCapsActionRequestTests.java b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/GetRollupIndexCapsActionRequestTests.java index e9d5d6153b1..9878d460448 100644 --- a/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/GetRollupIndexCapsActionRequestTests.java +++ b/x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/action/GetRollupIndexCapsActionRequestTests.java @@ -10,7 +10,8 @@ import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.MappingMetaData; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.common.collect.ImmutableOpenMap; -import org.elasticsearch.test.AbstractStreamableTestCase; +import org.elasticsearch.common.io.stream.Writeable; +import org.elasticsearch.test.AbstractWireSerializingTestCase; import org.elasticsearch.xpack.core.rollup.ConfigTestHelpers; import org.elasticsearch.xpack.core.rollup.RollupField; import org.elasticsearch.xpack.core.rollup.action.GetRollupIndexCapsAction; @@ -27,7 +28,7 @@ import static org.elasticsearch.xpack.rollup.action.TransportGetRollupIndexCapsA import static org.hamcrest.Matchers.equalTo; -public class GetRollupIndexCapsActionRequestTests extends AbstractStreamableTestCase { +public class GetRollupIndexCapsActionRequestTests extends AbstractWireSerializingTestCase { @Override protected GetRollupIndexCapsAction.Request createTestInstance() { @@ -38,11 +39,10 @@ public class GetRollupIndexCapsActionRequestTests extends AbstractStreamableTest } @Override - protected GetRollupIndexCapsAction.Request createBlankInstance() { - return new GetRollupIndexCapsAction.Request(); + protected Writeable.Reader instanceReader() { + return GetRollupIndexCapsAction.Request::new; } - public void testNoIndicesByRollup() { ImmutableOpenMap indices = new ImmutableOpenMap.Builder().build(); Map caps = getCapsByRollupIndex(Collections.singletonList("foo"), indices); diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/delete/TransportDeleteWatchAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/delete/TransportDeleteWatchAction.java index cee48d4c8e8..6b3b5703bdc 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/delete/TransportDeleteWatchAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/delete/TransportDeleteWatchAction.java @@ -34,7 +34,7 @@ public class TransportDeleteWatchAction extends HandledTransportAction