diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/AbstractHlrcWriteableXContentTestCase.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/AbstractHlrcWriteableXContentTestCase.java new file mode 100644 index 0000000000000..432c2db99643b --- /dev/null +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/AbstractHlrcWriteableXContentTestCase.java @@ -0,0 +1,70 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.elasticsearch.client; + +import org.elasticsearch.common.io.stream.Writeable; +import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.XContentParser; +import org.elasticsearch.test.AbstractSerializingTestCase; + +import java.io.IOException; + +import static org.elasticsearch.test.AbstractXContentTestCase.xContentTester; + +/** + * @deprecated Use {@link AbstractResponseTestCase} instead of this class. + */ +// TODO: Remove and change subclasses to use AbstractResponseTestCase instead +@Deprecated +public abstract class AbstractHlrcWriteableXContentTestCase + extends AbstractSerializingTestCase { + + /** + * Generic test that creates new instance of HLRC request/response from the test instance and checks + * both for equality and asserts equality on the two queries. + */ + public final void testHlrcFromXContent() throws IOException { + xContentTester(this::createParser, this::createTestInstance, getToXContentParams(), + p -> convertHlrcToInternal(doHlrcParseInstance(p))) + .numberOfTestRuns(NUMBER_OF_TEST_RUNS) + .supportsUnknownFields(supportsUnknownFields()) + .shuffleFieldsExceptions(getShuffleFieldsExceptions()) + .randomFieldsExcludeFilter(getRandomFieldsExcludeFilter()) + .assertEqualsConsumer(this::assertEqualInstances) + .assertToXContentEquivalence(true) + .test(); + } + + /** + * Parses to a new HLRC instance using the provided {@link XContentParser} + */ + public abstract H doHlrcParseInstance(XContentParser parser) throws IOException; + + /** + * Converts a HLRC instance to a XPack instance + */ + public abstract T convertHlrcToInternal(H instance); + + //TODO this would be final ideally: why do both responses need to parse from xcontent, only one (H) should? I think that T#fromXContent + //are only there for testing and could go away? Then the additional testHlrcFromXContent is also no longer needed. + @Override + protected T doParseInstance(XContentParser parser) throws IOException { + return convertHlrcToInternal(doHlrcParseInstance(parser)); + } +} diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/license/PutLicenseResponseTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/license/PutLicenseResponseTests.java index efb7ed98b366f..2422403659199 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/license/PutLicenseResponseTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/license/PutLicenseResponseTests.java @@ -18,8 +18,9 @@ */ package org.elasticsearch.client.license; +import org.elasticsearch.client.AbstractHlrcWriteableXContentTestCase; +import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.client.AbstractHlrcStreamableXContentTestCase; import org.elasticsearch.protocol.xpack.license.LicensesStatus; import java.io.IOException; @@ -29,8 +30,8 @@ import java.util.function.Function; import java.util.function.Predicate; -public class PutLicenseResponseTests extends AbstractHlrcStreamableXContentTestCase< - org.elasticsearch.protocol.xpack.license.PutLicenseResponse, org.elasticsearch.client.license.PutLicenseResponse> { +public class PutLicenseResponseTests extends AbstractHlrcWriteableXContentTestCase< + org.elasticsearch.protocol.xpack.license.PutLicenseResponse, PutLicenseResponse> { @Override public org.elasticsearch.client.license.PutLicenseResponse doHlrcParseInstance(XContentParser parser) throws IOException { @@ -96,8 +97,8 @@ private static Map randomAckMessages() { } @Override - protected org.elasticsearch.protocol.xpack.license.PutLicenseResponse createBlankInstance() { - return new org.elasticsearch.protocol.xpack.license.PutLicenseResponse(); + protected Writeable.Reader instanceReader() { + return org.elasticsearch.protocol.xpack.license.PutLicenseResponse::new; } @Override diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/license/StartBasicResponseTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/license/StartBasicResponseTests.java index 69f831cff188e..a22b40d7e6e63 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/license/StartBasicResponseTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/license/StartBasicResponseTests.java @@ -18,10 +18,11 @@ */ package org.elasticsearch.client.license; +import org.elasticsearch.client.AbstractHlrcWriteableXContentTestCase; import org.elasticsearch.common.Strings; +import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.license.PostStartBasicResponse; -import org.elasticsearch.client.AbstractHlrcStreamableXContentTestCase; import java.io.IOException; import java.util.Collections; @@ -29,8 +30,8 @@ import java.util.Map; import java.util.function.Predicate; -public class StartBasicResponseTests extends - AbstractHlrcStreamableXContentTestCase { +public class StartBasicResponseTests extends AbstractHlrcWriteableXContentTestCase< + PostStartBasicResponse, StartBasicResponse> { @Override public org.elasticsearch.client.license.StartBasicResponse doHlrcParseInstance(XContentParser parser) throws IOException { @@ -44,8 +45,8 @@ public PostStartBasicResponse convertHlrcToInternal(org.elasticsearch.client.lic } @Override - protected PostStartBasicResponse createBlankInstance() { - return new PostStartBasicResponse(); + protected Writeable.Reader instanceReader() { + return PostStartBasicResponse::new; } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/delete/DeleteRepositoryAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/delete/DeleteRepositoryAction.java index a31984e222793..205521a6b6f48 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/delete/DeleteRepositoryAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/delete/DeleteRepositoryAction.java @@ -21,6 +21,7 @@ import org.elasticsearch.action.Action; import org.elasticsearch.action.support.master.AcknowledgedResponse; +import org.elasticsearch.common.io.stream.Writeable; /** * Unregister repository action @@ -36,7 +37,12 @@ private DeleteRepositoryAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/delete/TransportDeleteRepositoryAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/delete/TransportDeleteRepositoryAction.java index 48b9bdaa4511b..bc3c5c329ef1e 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/delete/TransportDeleteRepositoryAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/delete/TransportDeleteRepositoryAction.java @@ -29,10 +29,13 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.io.IOException; + /** * Transport action for unregister repository operation */ @@ -54,9 +57,14 @@ protected String executor() { return ThreadPool.Names.SAME; } + @Override + protected AcknowledgedResponse read(StreamInput in) throws IOException { + return new AcknowledgedResponse(in); + } + @Override protected AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/put/PutRepositoryAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/put/PutRepositoryAction.java index 7c98f591e0e1d..ea021f6ba674b 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/put/PutRepositoryAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/put/PutRepositoryAction.java @@ -21,6 +21,7 @@ import org.elasticsearch.action.Action; import org.elasticsearch.action.support.master.AcknowledgedResponse; +import org.elasticsearch.common.io.stream.Writeable; /** * Register repository action @@ -36,7 +37,12 @@ private PutRepositoryAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/put/TransportPutRepositoryAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/put/TransportPutRepositoryAction.java index a10e5c878a7c9..9c96f3a4ab660 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/put/TransportPutRepositoryAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/repositories/put/TransportPutRepositoryAction.java @@ -29,10 +29,13 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.io.IOException; + /** * Transport action for register repository operation */ @@ -54,9 +57,14 @@ protected String executor() { return ThreadPool.Names.SAME; } + @Override + protected AcknowledgedResponse read(StreamInput in) throws IOException { + return new AcknowledgedResponse(in); + } + @Override protected AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteAction.java index 06b083e3414b2..c341618729cd0 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteAction.java @@ -20,6 +20,7 @@ package org.elasticsearch.action.admin.cluster.reroute; import org.elasticsearch.action.Action; +import org.elasticsearch.common.io.stream.Writeable; public class ClusterRerouteAction extends Action { @@ -32,6 +33,11 @@ private ClusterRerouteAction() { @Override public ClusterRerouteResponse newResponse() { - return new ClusterRerouteResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return ClusterRerouteResponse::new; } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteResponse.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteResponse.java index 652a794e0f1cb..95ec34acc6b69 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteResponse.java @@ -35,11 +35,13 @@ */ public class ClusterRerouteResponse extends AcknowledgedResponse implements ToXContentObject { - private ClusterState state; - private RoutingExplanations explanations; - - ClusterRerouteResponse() { + private final ClusterState state; + private final RoutingExplanations explanations; + ClusterRerouteResponse(StreamInput in) throws IOException { + super(in); + state = ClusterState.readFrom(in, null); + explanations = RoutingExplanations.readFrom(in); } ClusterRerouteResponse(boolean acknowledged, ClusterState state, RoutingExplanations explanations) { @@ -59,13 +61,6 @@ public RoutingExplanations getExplanations() { return this.explanations; } - @Override - public void readFrom(StreamInput in) throws IOException { - super.readFrom(in); - state = ClusterState.readFrom(in, null); - explanations = RoutingExplanations.readFrom(in); - } - @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/reroute/TransportClusterRerouteAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/reroute/TransportClusterRerouteAction.java index 4b51145204a61..0be91f6050813 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/reroute/TransportClusterRerouteAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/reroute/TransportClusterRerouteAction.java @@ -46,9 +46,11 @@ import org.elasticsearch.common.collect.ImmutableOpenIntMap; import org.elasticsearch.common.collect.ImmutableOpenMap; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -80,7 +82,12 @@ protected ClusterBlockException checkBlock(ClusterRerouteRequest request, Cluste @Override protected ClusterRerouteResponse newResponse() { - return new ClusterRerouteResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + protected ClusterRerouteResponse read(StreamInput in) throws IOException { + return new ClusterRerouteResponse(in); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/settings/ClusterUpdateSettingsAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/settings/ClusterUpdateSettingsAction.java index af6a87f5a57e6..c23a05338f299 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/settings/ClusterUpdateSettingsAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/settings/ClusterUpdateSettingsAction.java @@ -20,6 +20,7 @@ package org.elasticsearch.action.admin.cluster.settings; import org.elasticsearch.action.Action; +import org.elasticsearch.common.io.stream.Writeable; public class ClusterUpdateSettingsAction extends Action { @@ -32,6 +33,11 @@ private ClusterUpdateSettingsAction() { @Override public ClusterUpdateSettingsResponse newResponse() { - return new ClusterUpdateSettingsResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return ClusterUpdateSettingsResponse::new; } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/settings/ClusterUpdateSettingsResponse.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/settings/ClusterUpdateSettingsResponse.java index 4e925b398b6d5..5023e16249a4c 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/settings/ClusterUpdateSettingsResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/settings/ClusterUpdateSettingsResponse.java @@ -31,6 +31,8 @@ import java.io.IOException; import java.util.Objects; +import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg; + /** * A response for a cluster update settings action. */ @@ -40,23 +42,22 @@ public class ClusterUpdateSettingsResponse extends AcknowledgedResponse { private static final ParseField TRANSIENT = new ParseField("transient"); private static final ConstructingObjectParser PARSER = new ConstructingObjectParser<>( - "cluster_update_settings_response", true, a -> new ClusterUpdateSettingsResponse((boolean) a[0])); + "cluster_update_settings_response", true, args -> { + return new ClusterUpdateSettingsResponse((boolean) args[0], (Settings) args[1], (Settings) args[2]); + }); static { declareAcknowledgedField(PARSER); - PARSER.declareObject((r, p) -> r.persistentSettings = p, (p, c) -> Settings.fromXContent(p), PERSISTENT); - PARSER.declareObject((r, t) -> r.transientSettings = t, (p, c) -> Settings.fromXContent(p), TRANSIENT); + PARSER.declareObject(constructorArg(), (p, c) -> Settings.fromXContent(p), TRANSIENT); + PARSER.declareObject(constructorArg(), (p, c) -> Settings.fromXContent(p), PERSISTENT); } - Settings transientSettings; - Settings persistentSettings; - - ClusterUpdateSettingsResponse() { - this.persistentSettings = Settings.EMPTY; - this.transientSettings = Settings.EMPTY; - } + final Settings transientSettings; + final Settings persistentSettings; - ClusterUpdateSettingsResponse(boolean acknowledged) { - super(acknowledged); + ClusterUpdateSettingsResponse(StreamInput in) throws IOException { + super(in); + transientSettings = Settings.readSettingsFromStream(in); + persistentSettings = Settings.readSettingsFromStream(in); } ClusterUpdateSettingsResponse(boolean acknowledged, Settings transientSettings, Settings persistentSettings) { @@ -65,13 +66,6 @@ public class ClusterUpdateSettingsResponse extends AcknowledgedResponse { this.transientSettings = transientSettings; } - @Override - public void readFrom(StreamInput in) throws IOException { - super.readFrom(in); - transientSettings = Settings.readSettingsFromStream(in); - persistentSettings = Settings.readSettingsFromStream(in); - } - public Settings getTransientSettings() { return transientSettings; } diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/settings/TransportClusterUpdateSettingsAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/settings/TransportClusterUpdateSettingsAction.java index cf34094290a87..0e520217e77c2 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/settings/TransportClusterUpdateSettingsAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/settings/TransportClusterUpdateSettingsAction.java @@ -36,10 +36,13 @@ import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Priority; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.io.IOException; + public class TransportClusterUpdateSettingsAction extends TransportMasterNodeAction { @@ -81,7 +84,12 @@ protected ClusterBlockException checkBlock(ClusterUpdateSettingsRequest request, @Override protected ClusterUpdateSettingsResponse newResponse() { - return new ClusterUpdateSettingsResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + protected ClusterUpdateSettingsResponse read(StreamInput in) throws IOException { + return new ClusterUpdateSettingsResponse(in); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/delete/DeleteSnapshotAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/delete/DeleteSnapshotAction.java index 64f4e60fb2d0e..1413f0df0686a 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/delete/DeleteSnapshotAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/delete/DeleteSnapshotAction.java @@ -21,6 +21,7 @@ import org.elasticsearch.action.Action; import org.elasticsearch.action.support.master.AcknowledgedResponse; +import org.elasticsearch.common.io.stream.Writeable; /** * Delete snapshot action @@ -36,7 +37,12 @@ private DeleteSnapshotAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/delete/TransportDeleteSnapshotAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/delete/TransportDeleteSnapshotAction.java index 140d480242dc0..0664a0fa75d11 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/delete/TransportDeleteSnapshotAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/delete/TransportDeleteSnapshotAction.java @@ -29,10 +29,13 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.snapshots.SnapshotsService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.io.IOException; + /** * Transport action for delete snapshot operation */ @@ -53,9 +56,14 @@ protected String executor() { return ThreadPool.Names.GENERIC; } + @Override + protected AcknowledgedResponse read(StreamInput in) throws IOException { + return new AcknowledgedResponse(in); + } + @Override protected AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/DeleteStoredScriptAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/DeleteStoredScriptAction.java index 7ba8ee0754fed..1e07090ea01c4 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/DeleteStoredScriptAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/DeleteStoredScriptAction.java @@ -21,6 +21,7 @@ import org.elasticsearch.action.Action; import org.elasticsearch.action.support.master.AcknowledgedResponse; +import org.elasticsearch.common.io.stream.Writeable; public class DeleteStoredScriptAction extends Action { @@ -33,6 +34,11 @@ private DeleteStoredScriptAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/PutStoredScriptAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/PutStoredScriptAction.java index 8e5475283c2bc..7168667af0e1c 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/PutStoredScriptAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/PutStoredScriptAction.java @@ -21,6 +21,7 @@ import org.elasticsearch.action.Action; import org.elasticsearch.action.support.master.AcknowledgedResponse; +import org.elasticsearch.common.io.stream.Writeable; public class PutStoredScriptAction extends Action { @@ -28,14 +29,17 @@ public class PutStoredScriptAction extends Action { public static final PutStoredScriptAction INSTANCE = new PutStoredScriptAction(); public static final String NAME = "cluster:admin/script/put"; - private PutStoredScriptAction() { super(NAME); } - @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/TransportDeleteStoredScriptAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/TransportDeleteStoredScriptAction.java index 085850f118777..3e1a043a79855 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/TransportDeleteStoredScriptAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/TransportDeleteStoredScriptAction.java @@ -29,10 +29,13 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.script.ScriptService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.io.IOException; + public class TransportDeleteStoredScriptAction extends TransportMasterNodeAction { private final ScriptService scriptService; @@ -51,9 +54,14 @@ protected String executor() { return ThreadPool.Names.SAME; } + @Override + protected AcknowledgedResponse read(StreamInput in) throws IOException { + return new AcknowledgedResponse(in); + } + @Override protected AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/TransportPutStoredScriptAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/TransportPutStoredScriptAction.java index 99fa3979d87d0..d7594567f8464 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/TransportPutStoredScriptAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/TransportPutStoredScriptAction.java @@ -29,10 +29,13 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.script.ScriptService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.io.IOException; + public class TransportPutStoredScriptAction extends TransportMasterNodeAction { private final ScriptService scriptService; @@ -51,9 +54,14 @@ protected String executor() { return ThreadPool.Names.SAME; } + @Override + protected AcknowledgedResponse read(StreamInput in) throws IOException { + return new AcknowledgedResponse(in); + } + @Override protected AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesAction.java index 7f7743f81730a..38b1844e73a14 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesAction.java @@ -21,6 +21,7 @@ import org.elasticsearch.action.Action; import org.elasticsearch.action.support.master.AcknowledgedResponse; +import org.elasticsearch.common.io.stream.Writeable; public class IndicesAliasesAction extends Action { @@ -33,6 +34,11 @@ private IndicesAliasesAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/TransportIndicesAliasesAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/alias/TransportIndicesAliasesAction.java index 9f9b055e132b1..cf7904c9c3fe2 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/TransportIndicesAliasesAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/alias/TransportIndicesAliasesAction.java @@ -38,11 +38,13 @@ import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.collect.ImmutableOpenMap; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.index.Index; import org.elasticsearch.rest.action.admin.indices.AliasesNotFoundException; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; @@ -82,9 +84,14 @@ protected String executor() { return ThreadPool.Names.SAME; } + @Override + protected AcknowledgedResponse read(StreamInput in) throws IOException { + return new AcknowledgedResponse(in); + } + @Override protected AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexAction.java index 5c3d60dd44013..2d87b75273c25 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexAction.java @@ -20,6 +20,7 @@ package org.elasticsearch.action.admin.indices.close; import org.elasticsearch.action.Action; +import org.elasticsearch.common.io.stream.Writeable; public class CloseIndexAction extends Action { @@ -32,6 +33,11 @@ private CloseIndexAction() { @Override public CloseIndexResponse newResponse() { - return new CloseIndexResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return CloseIndexResponse::new; } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexResponse.java b/server/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexResponse.java index b44d10721815d..925b9dd4d5231 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/close/CloseIndexResponse.java @@ -40,9 +40,15 @@ public class CloseIndexResponse extends ShardsAcknowledgedResponse { - private List indices; + private final List indices; - CloseIndexResponse() { + CloseIndexResponse(StreamInput in) throws IOException { + super(in, in.getVersion().onOrAfter(Version.V_7_2_0)); + if (in.getVersion().onOrAfter(Version.V_7_3_0)) { + indices = unmodifiableList(in.readList(IndexResult::new)); + } else { + indices = unmodifiableList(emptyList()); + } } public CloseIndexResponse(final boolean acknowledged, final boolean shardsAcknowledged, final List indices) { @@ -54,19 +60,6 @@ public List getIndices() { return indices; } - @Override - public void readFrom(StreamInput in) throws IOException { - super.readFrom(in); - if (in.getVersion().onOrAfter(Version.V_7_2_0)) { - readShardsAcknowledged(in); - } - if (in.getVersion().onOrAfter(Version.V_7_3_0)) { - indices = unmodifiableList(in.readList(IndexResult::new)); - } else { - indices = unmodifiableList(emptyList()); - } - } - @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/close/TransportCloseIndexAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/close/TransportCloseIndexAction.java index 3c231d13845b2..71489e1f11b82 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/close/TransportCloseIndexAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/close/TransportCloseIndexAction.java @@ -31,6 +31,7 @@ import org.elasticsearch.cluster.metadata.MetaDataIndexStateService; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Setting.Property; @@ -40,6 +41,7 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.io.IOException; import java.util.Collections; /** @@ -78,7 +80,12 @@ protected String executor() { @Override protected CloseIndexResponse newResponse() { - return new CloseIndexResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + protected CloseIndexResponse read(StreamInput in) throws IOException { + return new CloseIndexResponse(in); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexAction.java index 3993ea7256f61..fd55ec4bf0bf1 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexAction.java @@ -20,6 +20,7 @@ package org.elasticsearch.action.admin.indices.create; import org.elasticsearch.action.Action; +import org.elasticsearch.common.io.stream.Writeable; public class CreateIndexAction extends Action { @@ -32,6 +33,11 @@ private CreateIndexAction() { @Override public CreateIndexResponse newResponse() { - return new CreateIndexResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return CreateIndexResponse::new; } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexResponse.java b/server/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexResponse.java index 79192693620dd..54142c2a90465 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexResponse.java @@ -52,22 +52,18 @@ protected static void declareFields(Constructing objectParser.declareField(constructorArg(), (parser, context) -> parser.textOrNull(), INDEX, ObjectParser.ValueType.STRING_OR_NULL); } - private String index; + private final String index; - public CreateIndexResponse() {} + protected CreateIndexResponse(StreamInput in) throws IOException { + super(in, true); + index = in.readString(); + } - protected CreateIndexResponse(boolean acknowledged, boolean shardsAcknowledged, String index) { + public CreateIndexResponse(boolean acknowledged, boolean shardsAcknowledged, String index) { super(acknowledged, shardsAcknowledged); this.index = index; } - @Override - public void readFrom(StreamInput in) throws IOException { - super.readFrom(in); - readShardsAcknowledged(in); - index = in.readString(); - } - @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/create/TransportCreateIndexAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/create/TransportCreateIndexAction.java index 03bbd0903a6d5..6cc97f3d80b1a 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/create/TransportCreateIndexAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/create/TransportCreateIndexAction.java @@ -29,9 +29,12 @@ import org.elasticsearch.cluster.metadata.MetaDataCreateIndexService; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.io.IOException; + /** * Create index action. */ @@ -56,7 +59,12 @@ protected String executor() { @Override protected CreateIndexResponse newResponse() { - return new CreateIndexResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + protected CreateIndexResponse read(StreamInput in) throws IOException { + return new CreateIndexResponse(in); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexAction.java index 6fde9089cef62..9bb7b2d880a2b 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/delete/DeleteIndexAction.java @@ -21,6 +21,7 @@ import org.elasticsearch.action.Action; import org.elasticsearch.action.support.master.AcknowledgedResponse; +import org.elasticsearch.common.io.stream.Writeable; public class DeleteIndexAction extends Action { @@ -33,6 +34,11 @@ private DeleteIndexAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/delete/TransportDeleteIndexAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/delete/TransportDeleteIndexAction.java index 50f65312afbf0..c9fd558850ba1 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/delete/TransportDeleteIndexAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/delete/TransportDeleteIndexAction.java @@ -32,11 +32,13 @@ import org.elasticsearch.cluster.metadata.MetaDataDeleteIndexService; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.index.Index; import org.elasticsearch.tasks.Task; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.io.IOException; import java.util.Arrays; import java.util.HashSet; import java.util.Set; @@ -65,9 +67,14 @@ protected String executor() { return ThreadPool.Names.SAME; } + @Override + protected AcknowledgedResponse read(StreamInput in) throws IOException { + return new AcknowledgedResponse(in); + } + @Override protected AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingAction.java index ac845e6644c7b..a4cc37f552ee0 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingAction.java @@ -21,6 +21,7 @@ import org.elasticsearch.action.Action; import org.elasticsearch.action.support.master.AcknowledgedResponse; +import org.elasticsearch.common.io.stream.Writeable; public class PutMappingAction extends Action { @@ -33,6 +34,11 @@ private PutMappingAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/TransportPutMappingAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/TransportPutMappingAction.java index a271a6c819928..aa519bdc3bdb3 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/TransportPutMappingAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/TransportPutMappingAction.java @@ -33,11 +33,13 @@ import org.elasticsearch.cluster.metadata.MetaDataMappingService; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.io.IOException; import java.util.Objects; import java.util.Optional; @@ -70,9 +72,14 @@ protected String executor() { return ThreadPool.Names.SAME; } + @Override + protected AcknowledgedResponse read(StreamInput in) throws IOException { + return new AcknowledgedResponse(in); + } + @Override protected AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/open/OpenIndexAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/open/OpenIndexAction.java index ea6f1eb6afd95..6d53a3a72d3e9 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/open/OpenIndexAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/open/OpenIndexAction.java @@ -20,6 +20,7 @@ package org.elasticsearch.action.admin.indices.open; import org.elasticsearch.action.Action; +import org.elasticsearch.common.io.stream.Writeable; public class OpenIndexAction extends Action { @@ -32,6 +33,11 @@ private OpenIndexAction() { @Override public OpenIndexResponse newResponse() { - return new OpenIndexResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return OpenIndexResponse::new; } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/open/OpenIndexResponse.java b/server/src/main/java/org/elasticsearch/action/admin/indices/open/OpenIndexResponse.java index 91f27e8c0c3f7..c7abd0367b319 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/open/OpenIndexResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/open/OpenIndexResponse.java @@ -39,19 +39,14 @@ public class OpenIndexResponse extends ShardsAcknowledgedResponse { declareAcknowledgedAndShardsAcknowledgedFields(PARSER); } - public OpenIndexResponse() { + public OpenIndexResponse(StreamInput in) throws IOException { + super(in, true); } public OpenIndexResponse(boolean acknowledged, boolean shardsAcknowledged) { super(acknowledged, shardsAcknowledged); } - @Override - public void readFrom(StreamInput in) throws IOException { - super.readFrom(in); - readShardsAcknowledged(in); - } - @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/open/TransportOpenIndexAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/open/TransportOpenIndexAction.java index b9323933f7601..0ab61e922b9b2 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/open/TransportOpenIndexAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/open/TransportOpenIndexAction.java @@ -32,11 +32,14 @@ import org.elasticsearch.cluster.metadata.MetaDataIndexStateService; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.index.Index; import org.elasticsearch.tasks.Task; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.io.IOException; + /** * Open index action */ @@ -64,7 +67,12 @@ protected String executor() { @Override protected OpenIndexResponse newResponse() { - return new OpenIndexResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + protected OpenIndexResponse read(StreamInput in) throws IOException { + return new OpenIndexResponse(in); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverAction.java index 0bcd4eefe0762..091dc1e09e1a9 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverAction.java @@ -20,6 +20,7 @@ package org.elasticsearch.action.admin.indices.rollover; import org.elasticsearch.action.Action; +import org.elasticsearch.common.io.stream.Writeable; public class RolloverAction extends Action { @@ -32,6 +33,11 @@ private RolloverAction() { @Override public RolloverResponse newResponse() { - return new RolloverResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return RolloverResponse::new; } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverResponse.java b/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverResponse.java index cd58253d5e7c2..3c0431c7ea6c9 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverResponse.java @@ -65,13 +65,27 @@ public final class RolloverResponse extends ShardsAcknowledgedResponse implement declareAcknowledgedAndShardsAcknowledgedFields(PARSER); } - private String oldIndex; - private String newIndex; - private Map conditionStatus; - private boolean dryRun; - private boolean rolledOver; - - RolloverResponse() { + private final String oldIndex; + private final String newIndex; + private final Map conditionStatus; + private final boolean dryRun; + private final boolean rolledOver; + // Needs to be duplicated, because shardsAcknowledged gets (de)serailized as last field whereas + // in other subclasses of ShardsAcknowledgedResponse this field (de)serailized as first field. + private final boolean shardsAcknowledged; + + RolloverResponse(StreamInput in) throws IOException { + super(in, false); + oldIndex = in.readString(); + newIndex = in.readString(); + int conditionSize = in.readVInt(); + conditionStatus = new HashMap<>(conditionSize); + for (int i = 0; i < conditionSize; i++) { + conditionStatus.put(in.readString(), in.readBoolean()); + } + dryRun = in.readBoolean(); + rolledOver = in.readBoolean(); + shardsAcknowledged = in.readBoolean(); } public RolloverResponse(String oldIndex, String newIndex, Map conditionResults, @@ -82,6 +96,7 @@ public RolloverResponse(String oldIndex, String newIndex, Map c this.dryRun = dryRun; this.rolledOver = rolledOver; this.conditionStatus = conditionResults; + this.shardsAcknowledged = shardsAcknowledged; } /** @@ -120,18 +135,8 @@ public boolean isRolledOver() { } @Override - public void readFrom(StreamInput in) throws IOException { - super.readFrom(in); - oldIndex = in.readString(); - newIndex = in.readString(); - int conditionSize = in.readVInt(); - conditionStatus = new HashMap<>(conditionSize); - for (int i = 0; i < conditionSize; i++) { - conditionStatus.put(in.readString(), in.readBoolean()); - } - dryRun = in.readBoolean(); - rolledOver = in.readBoolean(); - readShardsAcknowledged(in); + public boolean isShardsAcknowledged() { + return shardsAcknowledged; } @Override @@ -146,7 +151,7 @@ public void writeTo(StreamOutput out) throws IOException { } out.writeBoolean(dryRun); out.writeBoolean(rolledOver); - writeShardsAcknowledged(out); + out.writeBoolean(shardsAcknowledged); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/TransportRolloverAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/TransportRolloverAction.java index 97f769d18bbb1..4c2dbc7223d25 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/TransportRolloverAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/rollover/TransportRolloverAction.java @@ -46,11 +46,13 @@ import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.index.shard.DocsStats; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.io.IOException; import java.util.Collection; import java.util.List; import java.util.Locale; @@ -91,7 +93,12 @@ protected String executor() { @Override protected RolloverResponse newResponse() { - return new RolloverResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + protected RolloverResponse read(StreamInput in) throws IOException { + return new RolloverResponse(in); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/settings/put/TransportUpdateSettingsAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/settings/put/TransportUpdateSettingsAction.java index 9de0343365ea5..bc0f96301c086 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/settings/put/TransportUpdateSettingsAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/settings/put/TransportUpdateSettingsAction.java @@ -33,10 +33,13 @@ import org.elasticsearch.cluster.metadata.MetaDataUpdateSettingsService; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.index.Index; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.io.IOException; + public class TransportUpdateSettingsAction extends TransportMasterNodeAction { private final MetaDataUpdateSettingsService updateSettingsService; @@ -73,9 +76,14 @@ protected ClusterBlockException checkBlock(UpdateSettingsRequest request, Cluste indexNameExpressionResolver.concreteIndexNames(state, request)); } + @Override + protected AcknowledgedResponse read(StreamInput in) throws IOException { + return new AcknowledgedResponse(in); + } + @Override protected AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/settings/put/UpdateSettingsAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/settings/put/UpdateSettingsAction.java index eb6574fb53094..acf07668ad344 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/settings/put/UpdateSettingsAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/settings/put/UpdateSettingsAction.java @@ -21,6 +21,7 @@ import org.elasticsearch.action.Action; import org.elasticsearch.action.support.master.AcknowledgedResponse; +import org.elasticsearch.common.io.stream.Writeable; public class UpdateSettingsAction extends Action { @@ -33,6 +34,11 @@ private UpdateSettingsAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/shrink/ResizeAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/shrink/ResizeAction.java index 42226570c0930..6169d4a200108 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/shrink/ResizeAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/shrink/ResizeAction.java @@ -20,6 +20,7 @@ package org.elasticsearch.action.admin.indices.shrink; import org.elasticsearch.action.Action; +import org.elasticsearch.common.io.stream.Writeable; public class ResizeAction extends Action { @@ -32,6 +33,11 @@ private ResizeAction() { @Override public ResizeResponse newResponse() { - return new ResizeResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return ResizeResponse::new; } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/shrink/ResizeResponse.java b/server/src/main/java/org/elasticsearch/action/admin/indices/shrink/ResizeResponse.java index ffe59f1e3ae18..c017c8dc9fa90 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/shrink/ResizeResponse.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/shrink/ResizeResponse.java @@ -20,9 +20,12 @@ package org.elasticsearch.action.admin.indices.shrink; import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.xcontent.ConstructingObjectParser; import org.elasticsearch.common.xcontent.XContentParser; +import java.io.IOException; + /** * A response for a resize index action, either shrink or split index. */ @@ -35,7 +38,8 @@ public final class ResizeResponse extends CreateIndexResponse { declareFields(PARSER); } - ResizeResponse() { + ResizeResponse(StreamInput in) throws IOException { + super(in); } public ResizeResponse(boolean acknowledged, boolean shardsAcknowledged, String index) { diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/shrink/ShrinkAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/shrink/ShrinkAction.java index a2c689ba360ee..3aef52f1636e4 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/shrink/ShrinkAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/shrink/ShrinkAction.java @@ -20,6 +20,7 @@ package org.elasticsearch.action.admin.indices.shrink; import org.elasticsearch.action.Action; +import org.elasticsearch.common.io.stream.Writeable; public class ShrinkAction extends Action { @@ -32,6 +33,11 @@ private ShrinkAction() { @Override public ResizeResponse newResponse() { - return new ResizeResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return ResizeResponse::new; } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/shrink/TransportResizeAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/shrink/TransportResizeAction.java index ff4e643a08227..b1c4d3b831443 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/shrink/TransportResizeAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/shrink/TransportResizeAction.java @@ -35,6 +35,7 @@ import org.elasticsearch.cluster.metadata.MetaDataCreateIndexService; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.index.IndexSettings; @@ -43,6 +44,7 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.io.IOException; import java.util.Locale; import java.util.Objects; import java.util.Set; @@ -81,7 +83,12 @@ protected String executor() { @Override protected ResizeResponse newResponse() { - return new ResizeResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + protected ResizeResponse read(StreamInput in) throws IOException { + return new ResizeResponse(in); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/template/delete/DeleteIndexTemplateAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/template/delete/DeleteIndexTemplateAction.java index a8614277b409d..2f3dd877f8a9d 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/template/delete/DeleteIndexTemplateAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/template/delete/DeleteIndexTemplateAction.java @@ -21,6 +21,7 @@ import org.elasticsearch.action.Action; import org.elasticsearch.action.support.master.AcknowledgedResponse; +import org.elasticsearch.common.io.stream.Writeable; public class DeleteIndexTemplateAction extends Action { @@ -33,6 +34,11 @@ private DeleteIndexTemplateAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/template/delete/TransportDeleteIndexTemplateAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/template/delete/TransportDeleteIndexTemplateAction.java index b2421ed5174e5..a296988019f88 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/template/delete/TransportDeleteIndexTemplateAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/template/delete/TransportDeleteIndexTemplateAction.java @@ -30,9 +30,12 @@ import org.elasticsearch.cluster.metadata.MetaDataIndexTemplateService; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.io.IOException; + /** * Delete index action. */ @@ -56,9 +59,14 @@ protected String executor() { return ThreadPool.Names.SAME; } + @Override + protected AcknowledgedResponse read(StreamInput in) throws IOException { + return new AcknowledgedResponse(in); + } + @Override protected AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateAction.java index 1edc49e991453..9af753bbfdcb8 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateAction.java @@ -21,6 +21,7 @@ import org.elasticsearch.action.Action; import org.elasticsearch.action.support.master.AcknowledgedResponse; +import org.elasticsearch.common.io.stream.Writeable; public class PutIndexTemplateAction extends Action { @@ -33,6 +34,11 @@ private PutIndexTemplateAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/template/put/TransportPutIndexTemplateAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/template/put/TransportPutIndexTemplateAction.java index 0202d67814888..9351e90f9822f 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/template/put/TransportPutIndexTemplateAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/template/put/TransportPutIndexTemplateAction.java @@ -31,11 +31,14 @@ import org.elasticsearch.cluster.metadata.MetaDataIndexTemplateService; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.settings.IndexScopedSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.io.IOException; + /** * Put index template action. */ @@ -61,9 +64,14 @@ protected String executor() { return ThreadPool.Names.SAME; } + @Override + protected AcknowledgedResponse read(StreamInput in) throws IOException { + return new AcknowledgedResponse(in); + } + @Override protected AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/TransportUpgradeSettingsAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/TransportUpgradeSettingsAction.java index 645c67b3fdc05..a31c6425fb7ea 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/TransportUpgradeSettingsAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/TransportUpgradeSettingsAction.java @@ -32,9 +32,12 @@ import org.elasticsearch.cluster.metadata.MetaDataUpdateSettingsService; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.io.IOException; + public class TransportUpgradeSettingsAction extends TransportMasterNodeAction { private final MetaDataUpdateSettingsService updateSettingsService; @@ -59,9 +62,14 @@ protected ClusterBlockException checkBlock(UpgradeSettingsRequest request, Clust return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE); } + @Override + protected AcknowledgedResponse read(StreamInput in) throws IOException { + return new AcknowledgedResponse(in); + } + @Override protected AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeSettingsAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeSettingsAction.java index 9b1ff0f616a54..f830ebff3dd82 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeSettingsAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/upgrade/post/UpgradeSettingsAction.java @@ -21,6 +21,7 @@ import org.elasticsearch.action.Action; import org.elasticsearch.action.support.master.AcknowledgedResponse; +import org.elasticsearch.common.io.stream.Writeable; public class UpgradeSettingsAction extends Action { @@ -33,6 +34,11 @@ private UpgradeSettingsAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } } diff --git a/server/src/main/java/org/elasticsearch/action/ingest/DeletePipelineAction.java b/server/src/main/java/org/elasticsearch/action/ingest/DeletePipelineAction.java index 902614a3e83b3..c2842340ba44e 100644 --- a/server/src/main/java/org/elasticsearch/action/ingest/DeletePipelineAction.java +++ b/server/src/main/java/org/elasticsearch/action/ingest/DeletePipelineAction.java @@ -21,6 +21,7 @@ import org.elasticsearch.action.Action; import org.elasticsearch.action.support.master.AcknowledgedResponse; +import org.elasticsearch.common.io.stream.Writeable; public class DeletePipelineAction extends Action { @@ -33,6 +34,11 @@ public DeletePipelineAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } } diff --git a/server/src/main/java/org/elasticsearch/action/ingest/DeletePipelineTransportAction.java b/server/src/main/java/org/elasticsearch/action/ingest/DeletePipelineTransportAction.java index 0b5145ff18cb9..647bf35a01acd 100644 --- a/server/src/main/java/org/elasticsearch/action/ingest/DeletePipelineTransportAction.java +++ b/server/src/main/java/org/elasticsearch/action/ingest/DeletePipelineTransportAction.java @@ -28,10 +28,13 @@ import org.elasticsearch.cluster.block.ClusterBlockLevel; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.ingest.IngestService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.io.IOException; + public class DeletePipelineTransportAction extends TransportMasterNodeAction { private final IngestService ingestService; @@ -49,9 +52,14 @@ protected String executor() { return ThreadPool.Names.SAME; } + @Override + protected AcknowledgedResponse read(StreamInput in) throws IOException { + return new AcknowledgedResponse(in); + } + @Override protected AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/ingest/PutPipelineAction.java b/server/src/main/java/org/elasticsearch/action/ingest/PutPipelineAction.java index 4ebcff127cccd..b614c847b4f76 100644 --- a/server/src/main/java/org/elasticsearch/action/ingest/PutPipelineAction.java +++ b/server/src/main/java/org/elasticsearch/action/ingest/PutPipelineAction.java @@ -21,6 +21,7 @@ import org.elasticsearch.action.Action; import org.elasticsearch.action.support.master.AcknowledgedResponse; +import org.elasticsearch.common.io.stream.Writeable; public class PutPipelineAction extends Action { @@ -33,6 +34,11 @@ public PutPipelineAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } } diff --git a/server/src/main/java/org/elasticsearch/action/ingest/PutPipelineTransportAction.java b/server/src/main/java/org/elasticsearch/action/ingest/PutPipelineTransportAction.java index be1528a354bc3..ef9158b93468a 100644 --- a/server/src/main/java/org/elasticsearch/action/ingest/PutPipelineTransportAction.java +++ b/server/src/main/java/org/elasticsearch/action/ingest/PutPipelineTransportAction.java @@ -32,11 +32,13 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.ingest.IngestInfo; import org.elasticsearch.ingest.IngestService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.io.IOException; import java.util.HashMap; import java.util.Map; @@ -62,9 +64,14 @@ protected String executor() { return ThreadPool.Names.SAME; } + @Override + protected AcknowledgedResponse read(StreamInput in) throws IOException { + return new AcknowledgedResponse(in); + } + @Override protected AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/support/master/AcknowledgedResponse.java b/server/src/main/java/org/elasticsearch/action/support/master/AcknowledgedResponse.java index 21a0d3f21a804..4e1540fd995e1 100644 --- a/server/src/main/java/org/elasticsearch/action/support/master/AcknowledgedResponse.java +++ b/server/src/main/java/org/elasticsearch/action/support/master/AcknowledgedResponse.java @@ -45,9 +45,11 @@ protected static void declareAcknowledgedField( ObjectParser.ValueType.BOOLEAN); } - protected boolean acknowledged; + protected final boolean acknowledged; - public AcknowledgedResponse() { + public AcknowledgedResponse(StreamInput in) throws IOException { + super(in); + acknowledged = in.readBoolean(); } public AcknowledgedResponse(boolean acknowledged) { @@ -64,8 +66,7 @@ public final boolean isAcknowledged() { @Override public void readFrom(StreamInput in) throws IOException { - super.readFrom(in); - acknowledged = in.readBoolean(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/support/master/ShardsAcknowledgedResponse.java b/server/src/main/java/org/elasticsearch/action/support/master/ShardsAcknowledgedResponse.java index 21ff8fe644997..e088f4414a217 100644 --- a/server/src/main/java/org/elasticsearch/action/support/master/ShardsAcknowledgedResponse.java +++ b/server/src/main/java/org/elasticsearch/action/support/master/ShardsAcknowledgedResponse.java @@ -42,10 +42,15 @@ protected static void declareAcknowledged ObjectParser.ValueType.BOOLEAN); } - private boolean shardsAcknowledged; - - - protected ShardsAcknowledgedResponse() { + private final boolean shardsAcknowledged; + + protected ShardsAcknowledgedResponse(StreamInput in, boolean readShardsAcknowledged) throws IOException { + super(in); + if (readShardsAcknowledged) { + this.shardsAcknowledged = in.readBoolean(); + } else { + this.shardsAcknowledged = false; + } } protected ShardsAcknowledgedResponse(boolean acknowledged, boolean shardsAcknowledged) { @@ -63,10 +68,6 @@ public boolean isShardsAcknowledged() { return shardsAcknowledged; } - protected void readShardsAcknowledged(StreamInput in) throws IOException { - shardsAcknowledged = in.readBoolean(); - } - protected void writeShardsAcknowledged(StreamOutput out) throws IOException { out.writeBoolean(shardsAcknowledged); } @@ -80,14 +81,14 @@ protected void addCustomFields(XContentBuilder builder, Params params) throws IO public boolean equals(Object o) { if (super.equals(o)) { ShardsAcknowledgedResponse that = (ShardsAcknowledgedResponse) o; - return shardsAcknowledged == that.shardsAcknowledged; + return isShardsAcknowledged() == that.isShardsAcknowledged(); } return false; } @Override public int hashCode() { - return Objects.hash(super.hashCode(), shardsAcknowledged); + return Objects.hash(super.hashCode(), isShardsAcknowledged()); } } diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/settings/ClusterUpdateSettingsResponseTests.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/settings/ClusterUpdateSettingsResponseTests.java index 485b2dc3fb4d1..da3157840e2e5 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/settings/ClusterUpdateSettingsResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/settings/ClusterUpdateSettingsResponseTests.java @@ -19,18 +19,19 @@ package org.elasticsearch.action.admin.cluster.settings; +import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings.Builder; import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.test.AbstractStreamableXContentTestCase; +import org.elasticsearch.test.AbstractSerializingTestCase; import java.util.List; import java.util.Set; import java.util.function.Predicate; -public class ClusterUpdateSettingsResponseTests extends AbstractStreamableXContentTestCase { +public class ClusterUpdateSettingsResponseTests extends AbstractSerializingTestCase { @Override protected ClusterUpdateSettingsResponse doParseInstance(XContentParser parser) { @@ -93,8 +94,7 @@ protected ClusterUpdateSettingsResponse createTestInstance() { } @Override - protected ClusterUpdateSettingsResponse createBlankInstance() { - return new ClusterUpdateSettingsResponse(); + protected Writeable.Reader instanceReader() { + return ClusterUpdateSettingsResponse::new; } - } diff --git a/server/src/test/java/org/elasticsearch/action/admin/indices/close/CloseIndexResponseTests.java b/server/src/test/java/org/elasticsearch/action/admin/indices/close/CloseIndexResponseTests.java index 1a41b591d2d14..01fc1c0343e2c 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/indices/close/CloseIndexResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/indices/close/CloseIndexResponseTests.java @@ -90,11 +90,10 @@ public void testSerialization() throws Exception { try (BytesStreamOutput out = new BytesStreamOutput()) { response.writeTo(out); - final CloseIndexResponse deserializedResponse = new CloseIndexResponse(); try (StreamInput in = out.bytes().streamInput()) { - deserializedResponse.readFrom(in); + final CloseIndexResponse deserializedResponse = new CloseIndexResponse(in); + assertCloseIndexResponse(deserializedResponse, response); } - assertCloseIndexResponse(deserializedResponse, response); } } @@ -105,12 +104,11 @@ public void testBwcSerialization() throws Exception { out.setVersion(randomVersionBetween(random(), Version.V_7_0_0, getPreviousVersion(Version.V_7_2_0))); response.writeTo(out); - final AcknowledgedResponse deserializedResponse = new AcknowledgedResponse(); try (StreamInput in = out.bytes().streamInput()) { in.setVersion(out.getVersion()); - deserializedResponse.readFrom(in); + final AcknowledgedResponse deserializedResponse = new AcknowledgedResponse(in); + assertThat(deserializedResponse.isAcknowledged(), equalTo(response.isAcknowledged())); } - assertThat(deserializedResponse.isAcknowledged(), equalTo(response.isAcknowledged())); } } { @@ -118,12 +116,11 @@ public void testBwcSerialization() throws Exception { try (BytesStreamOutput out = new BytesStreamOutput()) { response.writeTo(out); - final CloseIndexResponse deserializedResponse = new CloseIndexResponse(); try (StreamInput in = out.bytes().streamInput()) { in.setVersion(randomVersionBetween(random(), Version.V_7_0_0, getPreviousVersion(Version.V_7_2_0))); - deserializedResponse.readFrom(in); + final CloseIndexResponse deserializedResponse = new CloseIndexResponse(in); + assertThat(deserializedResponse.isAcknowledged(), equalTo(response.isAcknowledged())); } - assertThat(deserializedResponse.isAcknowledged(), equalTo(response.isAcknowledged())); } } { @@ -132,17 +129,16 @@ public void testBwcSerialization() throws Exception { Version version = randomVersionBetween(random(), Version.V_7_2_0, Version.CURRENT); out.setVersion(version); response.writeTo(out); - final CloseIndexResponse deserializedResponse = new CloseIndexResponse(); try (StreamInput in = out.bytes().streamInput()) { in.setVersion(version); - deserializedResponse.readFrom(in); - } - assertThat(deserializedResponse.isAcknowledged(), equalTo(response.isAcknowledged())); - assertThat(deserializedResponse.isShardsAcknowledged(), equalTo(response.isShardsAcknowledged())); - if (version.onOrAfter(Version.V_7_3_0)) { - assertThat(deserializedResponse.getIndices(), hasSize(response.getIndices().size())); - } else { - assertThat(deserializedResponse.getIndices(), empty()); + final CloseIndexResponse deserializedResponse = new CloseIndexResponse(in); + assertThat(deserializedResponse.isAcknowledged(), equalTo(response.isAcknowledged())); + assertThat(deserializedResponse.isShardsAcknowledged(), equalTo(response.isShardsAcknowledged())); + if (version.onOrAfter(Version.V_7_3_0)) { + assertThat(deserializedResponse.getIndices(), hasSize(response.getIndices().size())); + } else { + assertThat(deserializedResponse.getIndices(), empty()); + } } } } diff --git a/server/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexResponseTests.java b/server/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexResponseTests.java index c0685d5d17d29..d93fd984079be 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/indices/create/CreateIndexResponseTests.java @@ -20,13 +20,14 @@ package org.elasticsearch.action.admin.indices.create; import org.elasticsearch.common.Strings; +import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.json.JsonXContent; -import org.elasticsearch.test.AbstractStreamableXContentTestCase; +import org.elasticsearch.test.AbstractSerializingTestCase; import java.io.IOException; -public class CreateIndexResponseTests extends AbstractStreamableXContentTestCase { +public class CreateIndexResponseTests extends AbstractSerializingTestCase { @Override protected CreateIndexResponse createTestInstance() { @@ -37,8 +38,8 @@ protected CreateIndexResponse createTestInstance() { } @Override - protected CreateIndexResponse createBlankInstance() { - return new CreateIndexResponse(); + protected Writeable.Reader instanceReader() { + return CreateIndexResponse::new; } @Override diff --git a/server/src/test/java/org/elasticsearch/action/admin/indices/open/OpenIndexResponseTests.java b/server/src/test/java/org/elasticsearch/action/admin/indices/open/OpenIndexResponseTests.java index 2ed86ca5d3be6..8e4326f169cb2 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/indices/open/OpenIndexResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/indices/open/OpenIndexResponseTests.java @@ -19,10 +19,11 @@ package org.elasticsearch.action.admin.indices.open; +import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.test.AbstractStreamableXContentTestCase; +import org.elasticsearch.test.AbstractSerializingTestCase; -public class OpenIndexResponseTests extends AbstractStreamableXContentTestCase { +public class OpenIndexResponseTests extends AbstractSerializingTestCase { @Override protected OpenIndexResponse doParseInstance(XContentParser parser){ @@ -37,8 +38,8 @@ protected OpenIndexResponse createTestInstance() { } @Override - protected OpenIndexResponse createBlankInstance() { - return new OpenIndexResponse(); + protected Writeable.Reader instanceReader() { + return OpenIndexResponse::new; } @Override diff --git a/server/src/test/java/org/elasticsearch/action/admin/indices/rollover/RolloverResponseTests.java b/server/src/test/java/org/elasticsearch/action/admin/indices/rollover/RolloverResponseTests.java index a38de844626dc..51bcbc6168f4e 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/indices/rollover/RolloverResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/indices/rollover/RolloverResponseTests.java @@ -19,11 +19,11 @@ package org.elasticsearch.action.admin.indices.rollover; - +import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.test.AbstractStreamableXContentTestCase; +import org.elasticsearch.test.AbstractSerializingTestCase; import java.util.ArrayList; import java.util.HashMap; @@ -32,7 +32,7 @@ import java.util.function.Predicate; import java.util.function.Supplier; -public class RolloverResponseTests extends AbstractStreamableXContentTestCase { +public class RolloverResponseTests extends AbstractSerializingTestCase { @Override protected RolloverResponse createTestInstance() { @@ -61,8 +61,8 @@ private static Map randomResults(boolean allowNoItems) { } @Override - protected RolloverResponse createBlankInstance() { - return new RolloverResponse(); + protected Writeable.Reader instanceReader() { + return RolloverResponse::new; } @Override diff --git a/server/src/test/java/org/elasticsearch/action/admin/indices/shrink/ResizeResponseTests.java b/server/src/test/java/org/elasticsearch/action/admin/indices/shrink/ResizeResponseTests.java index 3e522e451011b..b663e187c78b9 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/indices/shrink/ResizeResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/indices/shrink/ResizeResponseTests.java @@ -20,10 +20,11 @@ package org.elasticsearch.action.admin.indices.shrink; import org.elasticsearch.common.Strings; +import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.test.AbstractStreamableXContentTestCase; +import org.elasticsearch.test.AbstractSerializingTestCase; -public class ResizeResponseTests extends AbstractStreamableXContentTestCase { +public class ResizeResponseTests extends AbstractSerializingTestCase { public void testToXContent() { ResizeResponse response = new ResizeResponse(true, false, "index_name"); @@ -45,8 +46,8 @@ protected ResizeResponse createTestInstance() { } @Override - protected ResizeResponse createBlankInstance() { - return new ResizeResponse(); + protected Writeable.Reader instanceReader() { + return ResizeResponse::new; } @Override diff --git a/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTookTests.java b/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTookTests.java index 89ccbefb00e59..fbf32578d8044 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTookTests.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTookTests.java @@ -105,7 +105,7 @@ private TransportBulkAction createAction(boolean controlled, AtomicLong expected @Override public void doExecute(Action action, Request request, ActionListener listener) { - listener.onResponse((Response)new CreateIndexResponse()); + listener.onResponse((Response)new CreateIndexResponse(false, false, null)); } }; diff --git a/server/src/test/java/org/elasticsearch/action/support/master/ShardsAcknowledgedResponseTests.java b/server/src/test/java/org/elasticsearch/action/support/master/ShardsAcknowledgedResponseTests.java new file mode 100644 index 0000000000000..ca998c268fb86 --- /dev/null +++ b/server/src/test/java/org/elasticsearch/action/support/master/ShardsAcknowledgedResponseTests.java @@ -0,0 +1,64 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.elasticsearch.action.support.master; + +import org.elasticsearch.Version; +import org.elasticsearch.common.io.stream.NamedWriteableRegistry; +import org.elasticsearch.common.io.stream.StreamInput; +import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.test.ESTestCase; + +import java.io.IOException; +import java.util.List; + +import static org.hamcrest.Matchers.is; + +public class ShardsAcknowledgedResponseTests extends ESTestCase { + + public void testSerialization() throws Exception { + ShardsAcknowledgedResponse testInstance = new TestImpl(true, true); + + ShardsAcknowledgedResponse result = + copyWriteable(testInstance, new NamedWriteableRegistry(List.of()), in -> new TestImpl(in, true), Version.CURRENT); + assertThat(result.isAcknowledged(), is(true)); + assertThat(result.isShardsAcknowledged(), is(true)); + + result = copyWriteable(testInstance, new NamedWriteableRegistry(List.of()), in -> new TestImpl(in, false), Version.CURRENT); + assertThat(result.isAcknowledged(), is(true)); + assertThat(result.isShardsAcknowledged(), is(false)); + } + + private static class TestImpl extends ShardsAcknowledgedResponse { + + private TestImpl(StreamInput in, boolean readShardsAcknowledged) throws IOException { + super(in, readShardsAcknowledged); + } + + private TestImpl(boolean acknowledged, boolean shardsAcknowledged) { + super(acknowledged, shardsAcknowledged); + } + + @Override + public void writeTo(StreamOutput out) throws IOException { + super.writeTo(out); + writeShardsAcknowledged(out); + } + } + +} diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportDeleteAutoFollowPatternAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportDeleteAutoFollowPatternAction.java index 3062aa46d05d6..b77dad83f614e 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportDeleteAutoFollowPatternAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportDeleteAutoFollowPatternAction.java @@ -18,12 +18,14 @@ import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.ccr.AutoFollowMetadata; import org.elasticsearch.xpack.core.ccr.AutoFollowMetadata.AutoFollowPattern; import org.elasticsearch.xpack.core.ccr.action.DeleteAutoFollowPatternAction; +import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -44,9 +46,14 @@ protected String executor() { return ThreadPool.Names.SAME; } + @Override + protected AcknowledgedResponse read(StreamInput in) throws IOException { + return new AcknowledgedResponse(in); + } + @Override protected AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportPauseFollowAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportPauseFollowAction.java index 2c420f83d6e15..3a3a3a82be784 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportPauseFollowAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportPauseFollowAction.java @@ -16,12 +16,14 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.persistent.PersistentTasksCustomMetaData; import org.elasticsearch.persistent.PersistentTasksService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.ccr.action.PauseFollowAction; +import java.io.IOException; import java.util.List; import java.util.stream.Collectors; @@ -47,9 +49,14 @@ protected String executor() { return ThreadPool.Names.SAME; } + @Override + protected AcknowledgedResponse read(StreamInput in) throws IOException { + return new AcknowledgedResponse(in); + } + @Override protected AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportPutAutoFollowPatternAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportPutAutoFollowPatternAction.java index a218ec2dcaa7c..8809f65fc3991 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportPutAutoFollowPatternAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportPutAutoFollowPatternAction.java @@ -21,6 +21,7 @@ import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.license.LicenseUtils; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; @@ -29,6 +30,7 @@ import org.elasticsearch.xpack.core.ccr.AutoFollowMetadata.AutoFollowPattern; import org.elasticsearch.xpack.core.ccr.action.PutAutoFollowPatternAction; +import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -63,9 +65,14 @@ protected String executor() { return ThreadPool.Names.SAME; } + @Override + protected AcknowledgedResponse read(StreamInput in) throws IOException { + return new AcknowledgedResponse(in); + } + @Override protected AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportResumeFollowAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportResumeFollowAction.java index ec71c93a33f30..5ee7a445605a7 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportResumeFollowAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportResumeFollowAction.java @@ -22,6 +22,7 @@ import org.elasticsearch.cluster.routing.allocation.decider.ShardsLimitAllocationDecider; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.ByteSizeUnit; @@ -100,9 +101,14 @@ protected String executor() { return ThreadPool.Names.SAME; } + @Override + protected AcknowledgedResponse read(StreamInput in) throws IOException { + return new AcknowledgedResponse(in); + } + @Override protected AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportUnfollowAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportUnfollowAction.java index e6c889ca6e3c1..e6521975b157e 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportUnfollowAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportUnfollowAction.java @@ -25,6 +25,7 @@ import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.index.Index; @@ -40,6 +41,7 @@ import org.elasticsearch.xpack.ccr.CcrSettings; import org.elasticsearch.xpack.core.ccr.action.UnfollowAction; +import java.io.IOException; import java.util.Collection; import java.util.Map; import java.util.Objects; @@ -72,9 +74,14 @@ protected String executor() { return ThreadPool.Names.SAME; } + @Override + protected AcknowledgedResponse read(StreamInput in) throws IOException { + return new AcknowledgedResponse(in); + } + @Override protected AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + 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/license/DeleteLicenseAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/DeleteLicenseAction.java index c0dbb02aed719..261f0318c985f 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/DeleteLicenseAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/DeleteLicenseAction.java @@ -7,6 +7,7 @@ import org.elasticsearch.action.Action; import org.elasticsearch.action.support.master.AcknowledgedResponse; +import org.elasticsearch.common.io.stream.Writeable; public class DeleteLicenseAction extends Action { @@ -19,6 +20,11 @@ private DeleteLicenseAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/PostStartBasicAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/PostStartBasicAction.java index 864bfa2b7780f..446ff45501bd6 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/PostStartBasicAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/PostStartBasicAction.java @@ -6,6 +6,7 @@ package org.elasticsearch.license; import org.elasticsearch.action.Action; +import org.elasticsearch.common.io.stream.Writeable; public class PostStartBasicAction extends Action { @@ -18,6 +19,11 @@ private PostStartBasicAction() { @Override public PostStartBasicResponse newResponse() { - return new PostStartBasicResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return PostStartBasicResponse::new; } } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/PostStartBasicResponse.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/PostStartBasicResponse.java index 40e910430e31c..84cbcdef102e5 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/PostStartBasicResponse.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/PostStartBasicResponse.java @@ -26,8 +26,8 @@ public class PostStartBasicResponse extends AcknowledgedResponse implements Stat private static final ParseField ERROR_MESSAGE_FIELD = new ParseField("error_message"); private static final ParseField MESSAGE_FIELD = new ParseField("message"); - private Map acknowledgeMessages; - private String acknowledgeMessage; + private final Map acknowledgeMessages; + private final String acknowledgeMessage; public enum Status { GENERATED_BASIC(true, null, RestStatus.OK), @@ -57,9 +57,24 @@ RestStatus getRestStatus() { } } - private Status status; + private final Status status; - public PostStartBasicResponse() { + public PostStartBasicResponse(StreamInput in) throws IOException { + super(in); + status = in.readEnum(Status.class); + acknowledgeMessage = in.readOptionalString(); + int size = in.readVInt(); + Map acknowledgeMessages = new HashMap<>(size); + for (int i = 0; i < size; i++) { + String feature = in.readString(); + int nMessages = in.readVInt(); + String[] messages = new String[nMessages]; + for (int j = 0; j < nMessages; j++) { + messages[j] = in.readString(); + } + acknowledgeMessages.put(feature, messages); + } + this.acknowledgeMessages = acknowledgeMessages; } PostStartBasicResponse(Status status) { @@ -77,25 +92,6 @@ public Status getStatus() { return status; } - @Override - public void readFrom(StreamInput in) throws IOException { - super.readFrom(in); - status = in.readEnum(Status.class); - acknowledgeMessage = in.readOptionalString(); - int size = in.readVInt(); - Map acknowledgeMessages = new HashMap<>(size); - for (int i = 0; i < size; i++) { - String feature = in.readString(); - int nMessages = in.readVInt(); - String[] messages = new String[nMessages]; - for (int j = 0; j < nMessages; j++) { - messages[j] = in.readString(); - } - acknowledgeMessages.put(feature, messages); - } - this.acknowledgeMessages = acknowledgeMessages; - } - @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/PutLicenseAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/PutLicenseAction.java index 497b203f4136d..263b0a4c556e1 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/PutLicenseAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/PutLicenseAction.java @@ -6,6 +6,7 @@ package org.elasticsearch.license; import org.elasticsearch.action.Action; +import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.protocol.xpack.license.PutLicenseResponse; public class PutLicenseAction extends Action { @@ -19,6 +20,11 @@ private PutLicenseAction() { @Override public PutLicenseResponse newResponse() { - return new PutLicenseResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return PutLicenseResponse::new; } } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/TransportDeleteLicenseAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/TransportDeleteLicenseAction.java index 6e138edb53f00..30f8f1e5298c5 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/TransportDeleteLicenseAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/TransportDeleteLicenseAction.java @@ -17,10 +17,13 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.protocol.xpack.license.DeleteLicenseRequest; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.io.IOException; + public class TransportDeleteLicenseAction extends TransportMasterNodeAction { private final LicenseService licenseService; @@ -39,9 +42,14 @@ protected String executor() { return ThreadPool.Names.MANAGEMENT; } + @Override + protected AcknowledgedResponse read(StreamInput in) throws IOException { + return new AcknowledgedResponse(in); + } + @Override protected AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + 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/license/TransportPostStartBasicAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/TransportPostStartBasicAction.java index e03e6201e917c..32a82330f52af 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/TransportPostStartBasicAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/TransportPostStartBasicAction.java @@ -14,9 +14,12 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.io.IOException; + public class TransportPostStartBasicAction extends TransportMasterNodeAction { private final LicenseService licenseService; @@ -37,7 +40,12 @@ protected String executor() { @Override protected PostStartBasicResponse newResponse() { - return new PostStartBasicResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + protected PostStartBasicResponse read(StreamInput in) throws IOException { + return new PostStartBasicResponse(in); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/TransportPutLicenseAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/TransportPutLicenseAction.java index 85338fc6e0179..c8505c3d05ad2 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/TransportPutLicenseAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/TransportPutLicenseAction.java @@ -15,10 +15,13 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.protocol.xpack.license.PutLicenseResponse; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.io.IOException; + public class TransportPutLicenseAction extends TransportMasterNodeAction { private final LicenseService licenseService; @@ -39,7 +42,12 @@ protected String executor() { @Override protected PutLicenseResponse newResponse() { - return new PutLicenseResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + protected PutLicenseResponse read(StreamInput in) throws IOException { + return new PutLicenseResponse(in); } @Override diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/license/PutLicenseResponse.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/license/PutLicenseResponse.java index 1bf4a78cf46ad..eb9eca4f4ddf3 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/license/PutLicenseResponse.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/license/PutLicenseResponse.java @@ -20,11 +20,26 @@ public class PutLicenseResponse extends AcknowledgedResponse { - private LicensesStatus status; - private Map acknowledgeMessages; - private String acknowledgeHeader; + private final LicensesStatus status; + private final Map acknowledgeMessages; + private final String acknowledgeHeader; - public PutLicenseResponse() { + public PutLicenseResponse(StreamInput in) throws IOException { + super(in); + status = LicensesStatus.fromId(in.readVInt()); + acknowledgeHeader = in.readOptionalString(); + int size = in.readVInt(); + Map acknowledgeMessages = new HashMap<>(size); + for (int i = 0; i < size; i++) { + String feature = in.readString(); + int nMessages = in.readVInt(); + String[] messages = new String[nMessages]; + for (int j = 0; j < nMessages; j++) { + messages[j] = in.readString(); + } + acknowledgeMessages.put(feature, messages); + } + this.acknowledgeMessages = acknowledgeMessages; } public PutLicenseResponse(boolean acknowledged, LicensesStatus status) { @@ -51,25 +66,6 @@ public String acknowledgeHeader() { return acknowledgeHeader; } - @Override - public void readFrom(StreamInput in) throws IOException { - super.readFrom(in); - status = LicensesStatus.fromId(in.readVInt()); - acknowledgeHeader = in.readOptionalString(); - int size = in.readVInt(); - Map acknowledgeMessages = new HashMap<>(size); - for (int i = 0; i < size; i++) { - String feature = in.readString(); - int nMessages = in.readVInt(); - String[] messages = new String[nMessages]; - for (int j = 0; j < nMessages; j++) { - messages[j] = in.readString(); - } - acknowledgeMessages.put(feature, messages); - } - this.acknowledgeMessages = acknowledgeMessages; - } - @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/TransportFreezeIndexAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/TransportFreezeIndexAction.java index 91b91ddd04f3c..d4ee0969a6366 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/TransportFreezeIndexAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/action/TransportFreezeIndexAction.java @@ -38,6 +38,7 @@ import org.elasticsearch.common.inject.Inject; 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.settings.Settings; import org.elasticsearch.common.util.CollectionUtils; import org.elasticsearch.index.Index; @@ -86,7 +87,12 @@ protected void doExecute(Task task, FreezeRequest request, ActionListener() { + indexStateService.closeIndices(closeRequest, new ActionListener<>() { @Override public void onResponse(final CloseIndexResponse response) { if (response.isAcknowledged()) { @@ -149,13 +155,13 @@ public void onFailure(final Exception t) { private void toggleFrozenSettings(final Index[] concreteIndices, final FreezeRequest request, final ActionListener listener) { clusterService.submitStateUpdateTask("toggle-frozen-settings", - new AckedClusterStateUpdateTask(Priority.URGENT, request, new ActionListener() { + new AckedClusterStateUpdateTask<>(Priority.URGENT, request, new ActionListener() { @Override public void onResponse(AcknowledgedResponse acknowledgedResponse) { OpenIndexClusterStateUpdateRequest updateRequest = new OpenIndexClusterStateUpdateRequest() .ackTimeout(request.timeout()).masterNodeTimeout(request.masterNodeTimeout()) .indices(concreteIndices).waitForActiveShards(request.waitForActiveShards()); - indexStateService.openIndex(updateRequest, new ActionListener() { + indexStateService.openIndex(updateRequest, new ActionListener<>() { @Override public void onResponse(OpenIndexClusterStateUpdateResponse openIndexClusterStateUpdateResponse) { listener.onResponse(new FreezeResponse(openIndexClusterStateUpdateResponse.isAcknowledged(), @@ -217,8 +223,8 @@ protected ClusterBlockException checkBlock(FreezeRequest request, ClusterState s } public static class FreezeResponse extends OpenIndexResponse { - public FreezeResponse() { - super(); + FreezeResponse(StreamInput in) throws IOException { + super(in); } public FreezeResponse(boolean acknowledged, boolean shardsAcknowledged) { @@ -237,7 +243,12 @@ private FreezeIndexAction() { @Override public FreezeResponse newResponse() { - return new FreezeResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return FreezeResponse::new; } } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/DeleteAutoFollowPatternAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/DeleteAutoFollowPatternAction.java index 5bd767c5c50bb..e23e24d166482 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/DeleteAutoFollowPatternAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/DeleteAutoFollowPatternAction.java @@ -11,6 +11,7 @@ import org.elasticsearch.action.support.master.AcknowledgedResponse; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.io.stream.Writeable; import java.io.IOException; import java.util.Objects; @@ -28,7 +29,12 @@ private DeleteAutoFollowPatternAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } public static class Request extends AcknowledgedRequest { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/PauseFollowAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/PauseFollowAction.java index c20cda9ab4a4a..748eb291f8572 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/PauseFollowAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/PauseFollowAction.java @@ -12,6 +12,7 @@ import org.elasticsearch.action.support.master.MasterNodeRequest; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.io.stream.Writeable; import java.io.IOException; import java.util.Objects; @@ -27,7 +28,12 @@ private PauseFollowAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } public static class Request extends MasterNodeRequest { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/PutAutoFollowPatternAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/PutAutoFollowPatternAction.java index f26e8d7f82a51..716b999975cf7 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/PutAutoFollowPatternAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/PutAutoFollowPatternAction.java @@ -11,6 +11,7 @@ import org.elasticsearch.action.support.master.AcknowledgedResponse; 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.ObjectParser; import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -37,7 +38,12 @@ private PutAutoFollowPatternAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } public static class Request extends AcknowledgedRequest implements ToXContentObject { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/ResumeFollowAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/ResumeFollowAction.java index 547f04889a669..f22d4de0c8bd8 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/ResumeFollowAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/ResumeFollowAction.java @@ -12,6 +12,7 @@ import org.elasticsearch.action.support.master.MasterNodeRequest; 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.ObjectParser; import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -33,7 +34,12 @@ private ResumeFollowAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } public static class Request extends MasterNodeRequest implements ToXContentObject { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/UnfollowAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/UnfollowAction.java index 9bb440cc0895d..e7804eb21be0d 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/UnfollowAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ccr/action/UnfollowAction.java @@ -14,6 +14,7 @@ import org.elasticsearch.action.support.master.AcknowledgedResponse; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.io.stream.Writeable; import java.io.IOException; @@ -30,7 +31,12 @@ private UnfollowAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } public static class Request extends AcknowledgedRequest implements IndicesRequest { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/DeleteDataFrameTransformAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/DeleteDataFrameTransformAction.java index 715fa0f5dc78b..20f16a6a21fd4 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/DeleteDataFrameTransformAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/DeleteDataFrameTransformAction.java @@ -34,11 +34,7 @@ public AcknowledgedResponse newResponse() { @Override public Writeable.Reader getResponseReader() { - return in -> { - AcknowledgedResponse response = new AcknowledgedResponse(); - response.readFrom(in); - return response; - }; + return AcknowledgedResponse::new; } public static class Request extends MasterNodeRequest { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/PutDataFrameTransformAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/PutDataFrameTransformAction.java index f1159725b1a7b..ff9af3ab85fa2 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/PutDataFrameTransformAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/dataframe/action/PutDataFrameTransformAction.java @@ -12,6 +12,7 @@ import org.elasticsearch.action.support.master.AcknowledgedResponse; 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; @@ -39,7 +40,12 @@ private PutDataFrameTransformAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } public static class Request extends AcknowledgedRequest implements ToXContentObject { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/DeleteLifecycleAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/DeleteLifecycleAction.java index ba962d635ee6e..ba0b5598403f5 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/DeleteLifecycleAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/DeleteLifecycleAction.java @@ -13,6 +13,7 @@ import org.elasticsearch.common.ParseField; 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 java.io.IOException; @@ -28,12 +29,18 @@ protected DeleteLifecycleAction() { @Override public Response newResponse() { - return new Response(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return Response::new; } public static class Response extends AcknowledgedResponse implements ToXContentObject { - public Response() { + public Response(StreamInput in) throws IOException { + super(in); } public Response(boolean acknowledged) { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/MoveToStepAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/MoveToStepAction.java index e92502d4ef526..536e8534c9001 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/MoveToStepAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/MoveToStepAction.java @@ -14,6 +14,7 @@ import org.elasticsearch.common.Strings; 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.ConstructingObjectParser; import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -33,12 +34,18 @@ protected MoveToStepAction() { @Override public Response newResponse() { - return new Response(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return Response::new; } public static class Response extends AcknowledgedResponse implements ToXContentObject { - public Response() { + public Response(StreamInput in) throws IOException { + super(in); } public Response(boolean acknowledged) { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/PutLifecycleAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/PutLifecycleAction.java index 09e4d978b6094..5920b5d8ef596 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/PutLifecycleAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/PutLifecycleAction.java @@ -13,6 +13,7 @@ import org.elasticsearch.common.Strings; 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.ConstructingObjectParser; import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -32,12 +33,18 @@ protected PutLifecycleAction() { @Override public Response newResponse() { - return new Response(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return Response::new; } public static class Response extends AcknowledgedResponse implements ToXContentObject { - public Response() { + public Response(StreamInput in) throws IOException { + super(in); } public Response(boolean acknowledged) { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/RetryAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/RetryAction.java index 6af7f2de6f0b7..25cce3e5cf0e9 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/RetryAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/RetryAction.java @@ -15,6 +15,7 @@ import org.elasticsearch.common.Strings; 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 java.io.IOException; @@ -31,12 +32,18 @@ protected RetryAction() { @Override public Response newResponse() { - return new Response(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return Response::new; } public static class Response extends AcknowledgedResponse implements ToXContentObject { - public Response() { + public Response(StreamInput in) throws IOException { + super(in); } public Response(boolean acknowledged) { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/StartILMAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/StartILMAction.java index 5d2f066d60b15..a55d14e3f362c 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/StartILMAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/StartILMAction.java @@ -8,6 +8,7 @@ import org.elasticsearch.action.Action; import org.elasticsearch.action.support.master.AcknowledgedResponse; +import org.elasticsearch.common.io.stream.Writeable; public class StartILMAction extends Action { public static final StartILMAction INSTANCE = new StartILMAction(); @@ -19,7 +20,12 @@ protected StartILMAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/StopILMAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/StopILMAction.java index 63adeabb30f90..fc4a7a469e47b 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/StopILMAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/StopILMAction.java @@ -8,6 +8,7 @@ import org.elasticsearch.action.Action; import org.elasticsearch.action.support.master.AcknowledgedResponse; +import org.elasticsearch.common.io.stream.Writeable; public class StopILMAction extends Action { public static final StopILMAction INSTANCE = new StopILMAction(); @@ -19,7 +20,12 @@ protected StopILMAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/DeleteCalendarAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/DeleteCalendarAction.java index da0756157b0ba..dac62ba09a5f9 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/DeleteCalendarAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/DeleteCalendarAction.java @@ -13,6 +13,7 @@ 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.xpack.core.ml.calendars.Calendar; import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper; @@ -30,7 +31,12 @@ private DeleteCalendarAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } public static class Request extends AcknowledgedRequest { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/DeleteCalendarEventAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/DeleteCalendarEventAction.java index 3e64a54293924..07c1575716c6b 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/DeleteCalendarEventAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/DeleteCalendarEventAction.java @@ -13,6 +13,7 @@ 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.xpack.core.ml.calendars.Calendar; import org.elasticsearch.xpack.core.ml.calendars.ScheduledEvent; import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper; @@ -31,7 +32,12 @@ private DeleteCalendarEventAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } public static class Request extends AcknowledgedRequest { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/DeleteDatafeedAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/DeleteDatafeedAction.java index 73cdbeef44259..4b7de0d912f47 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/DeleteDatafeedAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/DeleteDatafeedAction.java @@ -14,6 +14,7 @@ import org.elasticsearch.common.ParseField; 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.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.xpack.core.ml.datafeed.DatafeedConfig; @@ -33,7 +34,12 @@ private DeleteDatafeedAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } public static class Request extends AcknowledgedRequest implements ToXContentFragment { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/DeleteFilterAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/DeleteFilterAction.java index 3870ad79555ca..6f1a6e72613f7 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/DeleteFilterAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/DeleteFilterAction.java @@ -14,6 +14,7 @@ import org.elasticsearch.common.ParseField; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper; import java.io.IOException; @@ -31,7 +32,12 @@ private DeleteFilterAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } public static class Request extends AcknowledgedRequest { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/DeleteForecastAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/DeleteForecastAction.java index b9f981ae98026..658cc8befeec6 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/DeleteForecastAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/DeleteForecastAction.java @@ -13,6 +13,7 @@ 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.xpack.core.ml.job.config.Job; import org.elasticsearch.xpack.core.ml.job.results.ForecastRequestStats; import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper; @@ -30,7 +31,12 @@ private DeleteForecastAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } public static class Request extends AcknowledgedRequest { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/DeleteJobAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/DeleteJobAction.java index 6b279e0852183..37dcb8450f682 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/DeleteJobAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/DeleteJobAction.java @@ -13,6 +13,7 @@ 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.tasks.Task; import org.elasticsearch.tasks.TaskId; import org.elasticsearch.xpack.core.ml.job.config.Job; @@ -34,7 +35,12 @@ private DeleteJobAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } public static class Request extends AcknowledgedRequest { 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 4bc079b387c0a..1a5181898a4b4 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 @@ -13,6 +13,7 @@ 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.xpack.core.ml.job.config.Job; import org.elasticsearch.xpack.core.ml.job.process.autodetect.state.ModelSnapshotField; import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper; @@ -30,7 +31,12 @@ private DeleteModelSnapshotAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } public static class Request extends ActionRequest { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/FinalizeJobExecutionAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/FinalizeJobExecutionAction.java index 9121ce1b75d9f..4e081ad1ceeed 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/FinalizeJobExecutionAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/FinalizeJobExecutionAction.java @@ -13,6 +13,7 @@ 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 java.io.IOException; @@ -27,7 +28,12 @@ private FinalizeJobExecutionAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } public static class Request extends MasterNodeRequest { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/OpenJobAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/OpenJobAction.java index 4468baac6e5c7..55694894790fa 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/OpenJobAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/OpenJobAction.java @@ -18,6 +18,7 @@ import org.elasticsearch.common.Strings; 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.unit.TimeValue; import org.elasticsearch.common.xcontent.ObjectParser; import org.elasticsearch.common.xcontent.ToXContent; @@ -45,7 +46,12 @@ private OpenJobAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } public static class Request extends MasterNodeRequest implements ToXContentObject { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/SetUpgradeModeAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/SetUpgradeModeAction.java index ac9ae2b084498..b3a595d6d112e 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/SetUpgradeModeAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/SetUpgradeModeAction.java @@ -14,6 +14,7 @@ import org.elasticsearch.common.ParseField; 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.ConstructingObjectParser; import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -32,7 +33,12 @@ private SetUpgradeModeAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } public static class Request extends AcknowledgedRequest implements ToXContentObject { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/StartDatafeedAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/StartDatafeedAction.java index 0ba35e6b521e2..a4a4f4bd40aff 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/StartDatafeedAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/action/StartDatafeedAction.java @@ -17,6 +17,7 @@ import org.elasticsearch.common.ParseField; 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.time.DateMathParser; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.ObjectParser; @@ -53,7 +54,12 @@ private StartDatafeedAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } public static class Request extends MasterNodeRequest implements ToXContentObject { 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 e0d6b8acd849c..84ea265fba649 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,6 +13,7 @@ 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; @@ -32,7 +33,12 @@ protected ValidateDetectorAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } public static class RequestBuilder extends ActionRequestBuilder { 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 99af65f4412e9..48da2603c70ae 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 @@ -13,6 +13,7 @@ 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.XContentParser; import org.elasticsearch.xpack.core.ml.job.config.Job; import org.elasticsearch.xpack.core.ml.job.messages.Messages; @@ -33,7 +34,12 @@ protected ValidateJobConfigAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } public static class RequestBuilder extends ActionRequestBuilder { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/PutRollupJobAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/PutRollupJobAction.java index 6c56e7f6f1f4b..d9900e53eff73 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/PutRollupJobAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/PutRollupJobAction.java @@ -16,6 +16,7 @@ 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; @@ -36,7 +37,12 @@ private PutRollupJobAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } public static class Request extends AcknowledgedRequest implements IndicesRequest, ToXContentObject { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/service/WatcherServiceAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/service/WatcherServiceAction.java index 30b0b54725b5f..4f85df827d705 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/service/WatcherServiceAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/watcher/transport/actions/service/WatcherServiceAction.java @@ -7,6 +7,7 @@ import org.elasticsearch.action.Action; import org.elasticsearch.action.support.master.AcknowledgedResponse; +import org.elasticsearch.common.io.stream.Writeable; public class WatcherServiceAction extends Action { @@ -20,6 +21,11 @@ private WatcherServiceAction() { @Override public AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + public Writeable.Reader getResponseReader() { + return AcknowledgedResponse::new; } } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/action/DeleteLifecycleResponseTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/action/DeleteLifecycleResponseTests.java index b671f72cf99c4..977469401d947 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/action/DeleteLifecycleResponseTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/action/DeleteLifecycleResponseTests.java @@ -5,10 +5,11 @@ */ package org.elasticsearch.xpack.core.indexlifecycle.action; -import org.elasticsearch.test.AbstractStreamableTestCase; +import org.elasticsearch.common.io.stream.Writeable; +import org.elasticsearch.test.AbstractWireSerializingTestCase; import org.elasticsearch.xpack.core.indexlifecycle.action.DeleteLifecycleAction.Response; -public class DeleteLifecycleResponseTests extends AbstractStreamableTestCase { +public class DeleteLifecycleResponseTests extends AbstractWireSerializingTestCase { @Override protected Response createTestInstance() { @@ -16,8 +17,8 @@ protected Response createTestInstance() { } @Override - protected Response createBlankInstance() { - return new Response(); + protected Writeable.Reader instanceReader() { + return Response::new; } @Override diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/action/MoveToStepResponseTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/action/MoveToStepResponseTests.java index 7f9bacd35ac25..3cb47a94a3ad9 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/action/MoveToStepResponseTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/action/MoveToStepResponseTests.java @@ -6,10 +6,11 @@ */ package org.elasticsearch.xpack.core.indexlifecycle.action; -import org.elasticsearch.test.AbstractStreamableTestCase; +import org.elasticsearch.common.io.stream.Writeable; +import org.elasticsearch.test.AbstractWireSerializingTestCase; import org.elasticsearch.xpack.core.indexlifecycle.action.MoveToStepAction.Response; -public class MoveToStepResponseTests extends AbstractStreamableTestCase { +public class MoveToStepResponseTests extends AbstractWireSerializingTestCase { @Override protected Response createTestInstance() { @@ -17,8 +18,8 @@ protected Response createTestInstance() { } @Override - protected Response createBlankInstance() { - return new Response(); + protected Writeable.Reader instanceReader() { + return Response::new; } @Override diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/action/PutLifecycleResponseTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/action/PutLifecycleResponseTests.java index 0c9acb2aa5dd2..713a87459d776 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/action/PutLifecycleResponseTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/action/PutLifecycleResponseTests.java @@ -5,10 +5,11 @@ */ package org.elasticsearch.xpack.core.indexlifecycle.action; -import org.elasticsearch.test.AbstractStreamableTestCase; +import org.elasticsearch.common.io.stream.Writeable; +import org.elasticsearch.test.AbstractWireSerializingTestCase; import org.elasticsearch.xpack.core.indexlifecycle.action.PutLifecycleAction.Response; -public class PutLifecycleResponseTests extends AbstractStreamableTestCase { +public class PutLifecycleResponseTests extends AbstractWireSerializingTestCase { @Override protected Response createTestInstance() { @@ -16,8 +17,8 @@ protected Response createTestInstance() { } @Override - protected Response createBlankInstance() { - return new Response(); + protected Writeable.Reader instanceReader() { + return Response::new; } @Override diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/action/RetryResponseTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/action/RetryResponseTests.java index 24e758f9503c1..aa05f816fb531 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/action/RetryResponseTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/action/RetryResponseTests.java @@ -6,10 +6,11 @@ */ package org.elasticsearch.xpack.core.indexlifecycle.action; -import org.elasticsearch.test.AbstractStreamableTestCase; +import org.elasticsearch.common.io.stream.Writeable; +import org.elasticsearch.test.AbstractWireSerializingTestCase; import org.elasticsearch.xpack.core.indexlifecycle.action.RetryAction.Response; -public class RetryResponseTests extends AbstractStreamableTestCase { +public class RetryResponseTests extends AbstractWireSerializingTestCase { @Override protected Response createTestInstance() { @@ -17,8 +18,8 @@ protected Response createTestInstance() { } @Override - protected Response createBlankInstance() { - return new Response(); + protected Writeable.Reader instanceReader() { + return Response::new; } @Override diff --git a/x-pack/plugin/data-frame/src/main/java/org/elasticsearch/xpack/dataframe/action/TransportDeleteDataFrameTransformAction.java b/x-pack/plugin/data-frame/src/main/java/org/elasticsearch/xpack/dataframe/action/TransportDeleteDataFrameTransformAction.java index 1e0fcd31fb2d5..122504859bd6a 100644 --- a/x-pack/plugin/data-frame/src/main/java/org/elasticsearch/xpack/dataframe/action/TransportDeleteDataFrameTransformAction.java +++ b/x-pack/plugin/data-frame/src/main/java/org/elasticsearch/xpack/dataframe/action/TransportDeleteDataFrameTransformAction.java @@ -49,14 +49,13 @@ protected String executor() { } @Override - protected AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + protected AcknowledgedResponse read(StreamInput in) throws IOException { + return new AcknowledgedResponse(in); } - protected AcknowledgedResponse read(StreamInput in) throws IOException { - AcknowledgedResponse response = new AcknowledgedResponse(); - response.readFrom(in); - return response; + @Override + protected AcknowledgedResponse newResponse() { + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/x-pack/plugin/data-frame/src/main/java/org/elasticsearch/xpack/dataframe/action/TransportPutDataFrameTransformAction.java b/x-pack/plugin/data-frame/src/main/java/org/elasticsearch/xpack/dataframe/action/TransportPutDataFrameTransformAction.java index 36023c0f7372c..39b9a5fd18f82 100644 --- a/x-pack/plugin/data-frame/src/main/java/org/elasticsearch/xpack/dataframe/action/TransportPutDataFrameTransformAction.java +++ b/x-pack/plugin/data-frame/src/main/java/org/elasticsearch/xpack/dataframe/action/TransportPutDataFrameTransformAction.java @@ -22,6 +22,7 @@ import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -91,9 +92,14 @@ protected String executor() { return ThreadPool.Names.SAME; } + @Override + protected AcknowledgedResponse read(StreamInput in) throws IOException { + return new AcknowledgedResponse(in); + } + @Override protected AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportDeleteLifecycleAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportDeleteLifecycleAction.java index 13232649e0df5..360b14ec4b26b 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportDeleteLifecycleAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportDeleteLifecycleAction.java @@ -20,6 +20,7 @@ import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.indexlifecycle.IndexLifecycleMetadata; @@ -28,6 +29,7 @@ import org.elasticsearch.xpack.core.indexlifecycle.action.DeleteLifecycleAction.Request; import org.elasticsearch.xpack.core.indexlifecycle.action.DeleteLifecycleAction.Response; +import java.io.IOException; import java.util.List; import java.util.SortedMap; import java.util.Spliterator; @@ -53,7 +55,12 @@ protected String executor() { @Override protected Response newResponse() { - return new Response(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + protected Response read(StreamInput in) throws IOException { + return new Response(in); } @Override diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportMoveToStepAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportMoveToStepAction.java index e5cb15f6c3b24..46f776d74faae 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportMoveToStepAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportMoveToStepAction.java @@ -19,6 +19,7 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.indexlifecycle.action.MoveToStepAction; @@ -26,6 +27,8 @@ import org.elasticsearch.xpack.core.indexlifecycle.action.MoveToStepAction.Response; import org.elasticsearch.xpack.indexlifecycle.IndexLifecycleService; +import java.io.IOException; + public class TransportMoveToStepAction extends TransportMasterNodeAction { private static final Logger logger = LogManager.getLogger(TransportMoveToStepAction.class); @@ -46,7 +49,12 @@ protected String executor() { @Override protected Response newResponse() { - return new Response(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + protected Response read(StreamInput in) throws IOException { + return new Response(in); } @Override diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportPutLifecycleAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportPutLifecycleAction.java index d94de3e201a46..1b47ba2348cde 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportPutLifecycleAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportPutLifecycleAction.java @@ -17,6 +17,7 @@ import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.ClientHelper; @@ -27,6 +28,7 @@ import org.elasticsearch.xpack.core.indexlifecycle.action.PutLifecycleAction.Request; import org.elasticsearch.xpack.core.indexlifecycle.action.PutLifecycleAction.Response; +import java.io.IOException; import java.time.Instant; import java.util.Map; import java.util.SortedMap; @@ -53,7 +55,12 @@ protected String executor() { @Override protected Response newResponse() { - return new Response(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + protected Response read(StreamInput in) throws IOException { + return new Response(in); } @Override diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportRetryAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportRetryAction.java index c9fabe8225714..181f2309062c0 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportRetryAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportRetryAction.java @@ -17,6 +17,7 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.indexlifecycle.LifecycleExecutionState; @@ -26,6 +27,8 @@ import org.elasticsearch.xpack.core.indexlifecycle.action.RetryAction.Response; import org.elasticsearch.xpack.indexlifecycle.IndexLifecycleService; +import java.io.IOException; + public class TransportRetryAction extends TransportMasterNodeAction { IndexLifecycleService indexLifecycleService; @@ -46,7 +49,12 @@ protected String executor() { @Override protected Response newResponse() { - return new Response(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); + } + + @Override + protected Response read(StreamInput in) throws IOException { + return new Response(in); } @Override diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportStartILMAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportStartILMAction.java index aab9ef90e03d5..ec5cf4e64a40f 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportStartILMAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportStartILMAction.java @@ -17,6 +17,7 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.indexlifecycle.OperationMode; @@ -24,6 +25,8 @@ import org.elasticsearch.xpack.core.indexlifecycle.action.StartILMAction; import org.elasticsearch.xpack.indexlifecycle.OperationModeUpdateTask; +import java.io.IOException; + public class TransportStartILMAction extends TransportMasterNodeAction { @Inject @@ -38,9 +41,14 @@ protected String executor() { return ThreadPool.Names.SAME; } + @Override + protected AcknowledgedResponse read(StreamInput in) throws IOException { + return new AcknowledgedResponse(in); + } + @Override protected AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportStopILMAction.java b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportStopILMAction.java index f27373353ecda..aa6820e1ed33e 100644 --- a/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportStopILMAction.java +++ b/x-pack/plugin/ilm/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/TransportStopILMAction.java @@ -17,6 +17,7 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.indexlifecycle.OperationMode; @@ -24,6 +25,8 @@ import org.elasticsearch.xpack.core.indexlifecycle.action.StopILMAction; import org.elasticsearch.xpack.indexlifecycle.OperationModeUpdateTask; +import java.io.IOException; + public class TransportStopILMAction extends TransportMasterNodeAction { @Inject @@ -38,9 +41,14 @@ protected String executor() { return ThreadPool.Names.SAME; } + @Override + protected AcknowledgedResponse read(StreamInput in) throws IOException { + return new AcknowledgedResponse(in); + } + @Override protected AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteDatafeedAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteDatafeedAction.java index 97e437ec4caf2..1a6bbfb8f2a3b 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteDatafeedAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteDatafeedAction.java @@ -17,6 +17,7 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.persistent.PersistentTasksCustomMetaData; @@ -32,6 +33,8 @@ import org.elasticsearch.xpack.ml.MlConfigMigrationEligibilityCheck; import org.elasticsearch.xpack.ml.datafeed.persistence.DatafeedConfigProvider; +import java.io.IOException; + import static org.elasticsearch.xpack.core.ClientHelper.ML_ORIGIN; import static org.elasticsearch.xpack.core.ClientHelper.executeAsyncWithOrigin; @@ -63,9 +66,14 @@ protected String executor() { return ThreadPool.Names.SAME; } + @Override + protected AcknowledgedResponse read(StreamInput in) throws IOException { + return new AcknowledgedResponse(in); + } + @Override protected AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteJobAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteJobAction.java index 98275a294d13b..6494b2dbb2bbd 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteJobAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportDeleteJobAction.java @@ -32,6 +32,7 @@ import org.elasticsearch.common.CheckedConsumer; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.index.query.ConstantScoreQueryBuilder; @@ -73,6 +74,7 @@ import org.elasticsearch.xpack.ml.process.MlMemoryTracker; import org.elasticsearch.xpack.ml.utils.MlIndicesUtils; +import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -132,9 +134,14 @@ protected String executor() { return ThreadPool.Names.SAME; } + @Override + protected AcknowledgedResponse read(StreamInput in) throws IOException { + return new AcknowledgedResponse(in); + } + @Override protected AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportFinalizeJobExecutionAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportFinalizeJobExecutionAction.java index 14491d7ca9c61..dd1df011758b3 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportFinalizeJobExecutionAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportFinalizeJobExecutionAction.java @@ -19,6 +19,7 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.ml.action.FinalizeJobExecutionAction; @@ -27,6 +28,7 @@ import org.elasticsearch.xpack.ml.MachineLearning; import org.elasticsearch.xpack.ml.utils.VoidChainTaskExecutor; +import java.io.IOException; import java.util.Collections; import java.util.Date; import java.util.Map; @@ -53,9 +55,14 @@ protected String executor() { return ThreadPool.Names.SAME; } + @Override + protected AcknowledgedResponse read(StreamInput in) throws IOException { + return new AcknowledgedResponse(in); + } + @Override protected AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportOpenJobAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportOpenJobAction.java index 86d6fe3dfe59e..5a454a8a37566 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportOpenJobAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportOpenJobAction.java @@ -26,6 +26,7 @@ import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.license.LicenseUtils; @@ -57,6 +58,7 @@ import org.elasticsearch.xpack.ml.job.process.autodetect.AutodetectProcessManager; import org.elasticsearch.xpack.ml.process.MlMemoryTracker; +import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.LinkedList; @@ -379,9 +381,14 @@ protected String executor() { return ThreadPool.Names.SAME; } + @Override + protected AcknowledgedResponse read(StreamInput in) throws IOException { + return new AcknowledgedResponse(in); + } + @Override protected AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportSetUpgradeModeAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportSetUpgradeModeAction.java index 44fc5f48a5942..743ed883524e0 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportSetUpgradeModeAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportSetUpgradeModeAction.java @@ -24,6 +24,7 @@ import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.persistent.PersistentTasksClusterService; import org.elasticsearch.persistent.PersistentTasksCustomMetaData; import org.elasticsearch.persistent.PersistentTasksCustomMetaData.PersistentTask; @@ -37,6 +38,7 @@ import org.elasticsearch.xpack.core.ml.action.SetUpgradeModeAction; import org.elasticsearch.xpack.ml.utils.TypedChainTaskExecutor; +import java.io.IOException; import java.util.Comparator; import java.util.List; import java.util.Set; @@ -77,9 +79,14 @@ protected String executor() { return ThreadPool.Names.SAME; } + @Override + protected AcknowledgedResponse read(StreamInput in) throws IOException { + return new AcknowledgedResponse(in); + } + @Override protected AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportStartDatafeedAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportStartDatafeedAction.java index 1a0d1b84c87d5..2da7b3291c7e1 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportStartDatafeedAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/action/TransportStartDatafeedAction.java @@ -21,6 +21,7 @@ import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Strings; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.NamedXContentRegistry; @@ -54,6 +55,7 @@ import org.elasticsearch.xpack.ml.job.persistence.JobConfigProvider; import org.elasticsearch.xpack.ml.notifications.Auditor; +import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -133,9 +135,14 @@ protected String executor() { return ThreadPool.Names.SAME; } + @Override + protected AcknowledgedResponse read(StreamInput in) throws IOException { + return new AcknowledgedResponse(in); + } + @Override protected AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportPutRollupJobAction.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportPutRollupJobAction.java index db6c1c5ddeaa7..6a0eae1685691 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportPutRollupJobAction.java +++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportPutRollupJobAction.java @@ -33,6 +33,7 @@ import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.CheckedConsumer; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.time.DateUtils; import org.elasticsearch.common.unit.TimeValue; @@ -52,6 +53,7 @@ import org.elasticsearch.xpack.core.rollup.job.RollupJobConfig; import org.elasticsearch.xpack.rollup.Rollup; +import java.io.IOException; import java.util.Map; import java.util.Objects; import java.util.stream.Collectors; @@ -80,9 +82,14 @@ protected String executor() { return ThreadPool.Names.SAME; } + @Override + protected AcknowledgedResponse read(StreamInput in) throws IOException { + return new AcknowledgedResponse(in); + } + @Override protected AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/service/TransportWatcherServiceAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/service/TransportWatcherServiceAction.java index 047e43acf35ac..9e71f958675be 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/service/TransportWatcherServiceAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/service/TransportWatcherServiceAction.java @@ -20,6 +20,7 @@ import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; @@ -28,6 +29,8 @@ import org.elasticsearch.xpack.core.watcher.transport.actions.service.WatcherServiceAction; import org.elasticsearch.xpack.core.watcher.transport.actions.service.WatcherServiceRequest; +import java.io.IOException; + public class TransportWatcherServiceAction extends TransportMasterNodeAction { private AckedRequest ackedRequest = new AckedRequest() { @@ -55,9 +58,14 @@ protected String executor() { return ThreadPool.Names.MANAGEMENT; } + @Override + protected AcknowledgedResponse read(StreamInput in) throws IOException { + return new AcknowledgedResponse(in); + } + @Override protected AcknowledgedResponse newResponse() { - return new AcknowledgedResponse(); + throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable"); } @Override diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryTests.java index 58a649de48c02..d128b907a73e6 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherIndexTemplateRegistryTests.java @@ -321,9 +321,5 @@ private static class TestPutIndexTemplateResponse extends AcknowledgedResponse { TestPutIndexTemplateResponse(boolean acknowledged) { super(acknowledged); } - - TestPutIndexTemplateResponse() { - super(); - } } }