diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/AbstractTransportGetResourcesAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/AbstractTransportGetResourcesAction.java index 0a0567923836c..41e2605d9dba3 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/AbstractTransportGetResourcesAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/AbstractTransportGetResourcesAction.java @@ -42,7 +42,6 @@ import java.util.List; import java.util.Objects; import java.util.Set; -import java.util.function.Supplier; import static org.elasticsearch.xpack.core.ClientHelper.executeAsyncWithOrigin; @@ -62,8 +61,9 @@ public abstract class AbstractTransportGetResourcesAction request, Client client, NamedXContentRegistry xContentRegistry) { - super(actionName, transportService, request, actionFilters); + Writeable.Reader request, Client client, + NamedXContentRegistry xContentRegistry) { + super(actionName, transportService, actionFilters, request); this.client = Objects.requireNonNull(client); this.xContentRegistry = Objects.requireNonNull(xContentRegistry); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/DeleteExpiredDataAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/DeleteExpiredDataAction.java index 7a294860179b1..cc290bf987e0c 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/DeleteExpiredDataAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/DeleteExpiredDataAction.java @@ -33,6 +33,10 @@ public static class Request extends ActionRequest { public Request() {} + public Request(StreamInput in) throws IOException { + super(in); + } + @Override public ActionRequestValidationException validate() { return null; diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/DeleteModelSnapshotAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/DeleteModelSnapshotAction.java index c97739ac77ee8..8f8b2af9700e0 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/DeleteModelSnapshotAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/DeleteModelSnapshotAction.java @@ -42,6 +42,12 @@ public static class Request extends ActionRequest { public Request() { } + public Request(StreamInput in) throws IOException { + super(in); + jobId = in.readString(); + snapshotId = in.readString(); + } + public Request(String jobId, String snapshotId) { this.jobId = ExceptionsHelper.requireNonNull(jobId, Job.ID.getPreferredName()); this.snapshotId = ExceptionsHelper.requireNonNull(snapshotId, ModelSnapshotField.SNAPSHOT_ID.getPreferredName()); @@ -62,9 +68,7 @@ public ActionRequestValidationException validate() { @Override public void readFrom(StreamInput in) throws IOException { - super.readFrom(in); - jobId = in.readString(); - snapshotId = in.readString(); + 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/ml/action/ValidateDetectorAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/ValidateDetectorAction.java index 6a33fa1fdbd6d..d584bd18dc716 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/ValidateDetectorAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/ValidateDetectorAction.java @@ -13,7 +13,6 @@ import org.elasticsearch.client.ElasticsearchClient; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; @@ -28,12 +27,7 @@ public class ValidateDetectorAction extends ActionType { public static final String NAME = "cluster:admin/xpack/ml/job/validate/detector"; protected ValidateDetectorAction() { - super(NAME); - } - - @Override - public Writeable.Reader getResponseReader() { - return AcknowledgedResponse::new; + super(NAME, AcknowledgedResponse::new); } public static class RequestBuilder extends ActionRequestBuilder { @@ -61,6 +55,11 @@ public Request(Detector detector) { this.detector = detector; } + public Request(StreamInput in) throws IOException { + super(in); + detector = new Detector(in); + } + public Detector getDetector() { return detector; } @@ -78,8 +77,7 @@ public void writeTo(StreamOutput out) throws IOException { @Override public void readFrom(StreamInput in) throws IOException { - super.readFrom(in); - detector = new Detector(in); + 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/ml/action/ValidateJobConfigAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/ValidateJobConfigAction.java index f6abae83eef2d..473ea57505587 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/ValidateJobConfigAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/ValidateJobConfigAction.java @@ -78,6 +78,11 @@ public Request(Job job) { this.job = job; } + public Request(StreamInput in) throws IOException { + super(in); + job = new Job(in); + } + public Job getJob() { return job; } @@ -95,8 +100,7 @@ public void writeTo(StreamOutput out) throws IOException { @Override public void readFrom(StreamInput in) throws IOException { - super.readFrom(in); - job = new Job(in); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/action/ValidateDetectorActionRequestTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/action/ValidateDetectorActionRequestTests.java index d49908b1f1bae..993ed466777f5 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/action/ValidateDetectorActionRequestTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/action/ValidateDetectorActionRequestTests.java @@ -5,12 +5,13 @@ */ package org.elasticsearch.xpack.core.ml.action; +import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.test.AbstractStreamableXContentTestCase; +import org.elasticsearch.test.AbstractSerializingTestCase; import org.elasticsearch.xpack.core.ml.action.ValidateDetectorAction.Request; import org.elasticsearch.xpack.core.ml.job.config.Detector; -public class ValidateDetectorActionRequestTests extends AbstractStreamableXContentTestCase { +public class ValidateDetectorActionRequestTests extends AbstractSerializingTestCase { @Override protected Request createTestInstance() { @@ -24,13 +25,13 @@ protected Request createTestInstance() { } @Override - protected boolean supportsUnknownFields() { - return false; + protected Writeable.Reader instanceReader() { + return Request::new; } @Override - protected Request createBlankInstance() { - return new Request(); + protected boolean supportsUnknownFields() { + return false; } @Override diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/action/ValidateJobConfigActionRequestTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/action/ValidateJobConfigActionRequestTests.java index ac2d559c29aa1..f9226b336079d 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/action/ValidateJobConfigActionRequestTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/action/ValidateJobConfigActionRequestTests.java @@ -6,6 +6,7 @@ package org.elasticsearch.xpack.core.ml.action; import org.elasticsearch.common.bytes.BytesReference; +import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.xcontent.DeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.common.xcontent.ToXContent; @@ -13,7 +14,7 @@ import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentType; -import org.elasticsearch.test.AbstractStreamableTestCase; +import org.elasticsearch.test.AbstractWireSerializingTestCase; import org.elasticsearch.xpack.core.ml.action.ValidateJobConfigAction.Request; import org.elasticsearch.xpack.core.ml.job.config.Job; @@ -23,7 +24,7 @@ import static org.elasticsearch.xpack.core.ml.job.config.JobTests.buildJobBuilder; import static org.elasticsearch.xpack.core.ml.job.config.JobTests.randomValidJobId; -public class ValidateJobConfigActionRequestTests extends AbstractStreamableTestCase { +public class ValidateJobConfigActionRequestTests extends AbstractWireSerializingTestCase { @Override protected Request createTestInstance() { @@ -31,8 +32,8 @@ protected Request createTestInstance() { } @Override - protected Request createBlankInstance() { - return new Request(); + protected Writeable.Reader instanceReader() { + return Request::new; } public void testParseRequest_InvalidCreateSetting() throws IOException { diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteCalendarAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteCalendarAction.java index 918637a7c4936..1205590a8095d 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteCalendarAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteCalendarAction.java @@ -38,7 +38,7 @@ public class TransportDeleteCalendarAction extends HandledTransportAction