[CCR] Change response classes to not use from Streamable. (#35085)
Only the response classes of get auto follow pattern, the follow and stats APIs were moved away from Streamable. The other APIs use `AcknowledgedResponse` or `BaseTasksResponse` as response class and moving that class away from Streamable is a bigger change.
This commit is contained in:
parent
598b0a0eb4
commit
19d6cf1b9e
|
@ -17,6 +17,7 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
|||
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.settings.Settings;
|
||||
import org.elasticsearch.license.LicenseUtils;
|
||||
import org.elasticsearch.tasks.Task;
|
||||
|
@ -28,6 +29,7 @@ import org.elasticsearch.xpack.core.ccr.AutoFollowStats;
|
|||
import org.elasticsearch.xpack.core.ccr.action.FollowStatsAction;
|
||||
import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
public class TransportCcrStatsAction extends TransportMasterNodeAction<CcrStatsAction.Request, CcrStatsAction.Response> {
|
||||
|
@ -70,7 +72,12 @@ public class TransportCcrStatsAction extends TransportMasterNodeAction<CcrStatsA
|
|||
|
||||
@Override
|
||||
protected CcrStatsAction.Response newResponse() {
|
||||
return new CcrStatsAction.Response();
|
||||
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CcrStatsAction.Response read(StreamInput in) throws IOException {
|
||||
return new CcrStatsAction.Response(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
|||
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.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
|
@ -24,6 +25,7 @@ import org.elasticsearch.xpack.core.ccr.AutoFollowMetadata;
|
|||
import org.elasticsearch.xpack.core.ccr.AutoFollowMetadata.AutoFollowPattern;
|
||||
import org.elasticsearch.xpack.core.ccr.action.GetAutoFollowPatternAction;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -48,7 +50,12 @@ public class TransportGetAutoFollowPatternAction
|
|||
|
||||
@Override
|
||||
protected GetAutoFollowPatternAction.Response newResponse() {
|
||||
return new GetAutoFollowPatternAction.Response();
|
||||
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected GetAutoFollowPatternAction.Response read(StreamInput in) throws IOException {
|
||||
return new GetAutoFollowPatternAction.Response(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.elasticsearch.cluster.routing.allocation.AllocationService;
|
|||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.UUIDs;
|
||||
import org.elasticsearch.common.inject.Inject;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.IndexSettings;
|
||||
import org.elasticsearch.license.LicenseUtils;
|
||||
|
@ -38,6 +39,7 @@ import org.elasticsearch.xpack.ccr.CcrSettings;
|
|||
import org.elasticsearch.xpack.core.ccr.action.PutFollowAction;
|
||||
import org.elasticsearch.xpack.core.ccr.action.ResumeFollowAction;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
@ -83,7 +85,12 @@ public final class TransportPutFollowAction
|
|||
|
||||
@Override
|
||||
protected PutFollowAction.Response newResponse() {
|
||||
return new PutFollowAction.Response();
|
||||
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PutFollowAction.Response read(StreamInput in) throws IOException {
|
||||
return new PutFollowAction.Response(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
*/
|
||||
package org.elasticsearch.xpack.ccr.action;
|
||||
|
||||
import org.elasticsearch.test.AbstractStreamableTestCase;
|
||||
import org.elasticsearch.common.io.stream.Writeable;
|
||||
import org.elasticsearch.test.AbstractWireSerializingTestCase;
|
||||
import org.elasticsearch.xpack.core.ccr.AutoFollowStats;
|
||||
import org.elasticsearch.xpack.core.ccr.action.FollowStatsAction;
|
||||
import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction;
|
||||
|
@ -13,11 +14,11 @@ import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction;
|
|||
import static org.elasticsearch.xpack.ccr.action.AutoFollowStatsTests.randomReadExceptions;
|
||||
import static org.elasticsearch.xpack.ccr.action.StatsResponsesTests.createStatsResponse;
|
||||
|
||||
public class AutoFollowStatsResponseTests extends AbstractStreamableTestCase<CcrStatsAction.Response> {
|
||||
public class AutoFollowStatsResponseTests extends AbstractWireSerializingTestCase<CcrStatsAction.Response> {
|
||||
|
||||
@Override
|
||||
protected CcrStatsAction.Response createBlankInstance() {
|
||||
return new CcrStatsAction.Response();
|
||||
protected Writeable.Reader<CcrStatsAction.Response> instanceReader() {
|
||||
return CcrStatsAction.Response::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,10 +5,11 @@
|
|||
*/
|
||||
package org.elasticsearch.xpack.ccr.action;
|
||||
|
||||
import org.elasticsearch.common.io.stream.Writeable;
|
||||
import org.elasticsearch.common.unit.ByteSizeUnit;
|
||||
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.test.AbstractStreamableTestCase;
|
||||
import org.elasticsearch.test.AbstractWireSerializingTestCase;
|
||||
import org.elasticsearch.xpack.core.ccr.AutoFollowMetadata.AutoFollowPattern;
|
||||
import org.elasticsearch.xpack.core.ccr.action.GetAutoFollowPatternAction;
|
||||
|
||||
|
@ -16,11 +17,11 @@ import java.util.Collections;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class GetAutoFollowPatternResponseTests extends AbstractStreamableTestCase<GetAutoFollowPatternAction.Response> {
|
||||
public class GetAutoFollowPatternResponseTests extends AbstractWireSerializingTestCase<GetAutoFollowPatternAction.Response> {
|
||||
|
||||
@Override
|
||||
protected GetAutoFollowPatternAction.Response createBlankInstance() {
|
||||
return new GetAutoFollowPatternAction.Response();
|
||||
protected Writeable.Reader<GetAutoFollowPatternAction.Response> instanceReader() {
|
||||
return GetAutoFollowPatternAction.Response::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,14 +5,15 @@
|
|||
*/
|
||||
package org.elasticsearch.xpack.ccr.action;
|
||||
|
||||
import org.elasticsearch.test.AbstractStreamableTestCase;
|
||||
import org.elasticsearch.common.io.stream.Writeable;
|
||||
import org.elasticsearch.test.AbstractWireSerializingTestCase;
|
||||
import org.elasticsearch.xpack.core.ccr.action.PutFollowAction;
|
||||
|
||||
public class PutFollowActionResponseTests extends AbstractStreamableTestCase<PutFollowAction.Response> {
|
||||
public class PutFollowActionResponseTests extends AbstractWireSerializingTestCase<PutFollowAction.Response> {
|
||||
|
||||
@Override
|
||||
protected PutFollowAction.Response createBlankInstance() {
|
||||
return new PutFollowAction.Response();
|
||||
protected Writeable.Reader<PutFollowAction.Response> instanceReader() {
|
||||
return PutFollowAction.Response::new;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.elasticsearch.action.support.master.MasterNodeRequest;
|
|||
import org.elasticsearch.action.Action;
|
||||
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.xpack.core.ccr.AutoFollowStats;
|
||||
|
@ -30,7 +31,12 @@ public class CcrStatsAction extends Action<CcrStatsAction.Response> {
|
|||
|
||||
@Override
|
||||
public Response newResponse() {
|
||||
return new Response();
|
||||
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Writeable.Reader<Response> getResponseReader() {
|
||||
return Response::new;
|
||||
}
|
||||
|
||||
public static class Request extends MasterNodeRequest<Request> {
|
||||
|
@ -55,15 +61,19 @@ public class CcrStatsAction extends Action<CcrStatsAction.Response> {
|
|||
|
||||
public static class Response extends ActionResponse implements ToXContentObject {
|
||||
|
||||
private AutoFollowStats autoFollowStats;
|
||||
private FollowStatsAction.StatsResponses followStats;
|
||||
private final AutoFollowStats autoFollowStats;
|
||||
private final FollowStatsAction.StatsResponses followStats;
|
||||
|
||||
public Response(AutoFollowStats autoFollowStats, FollowStatsAction.StatsResponses followStats) {
|
||||
this.autoFollowStats = Objects.requireNonNull(autoFollowStats);
|
||||
this.followStats = Objects.requireNonNull(followStats);
|
||||
}
|
||||
|
||||
public Response() {
|
||||
public Response(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
autoFollowStats = new AutoFollowStats(in);
|
||||
followStats = new FollowStatsAction.StatsResponses();
|
||||
followStats.readFrom(in);
|
||||
}
|
||||
|
||||
public AutoFollowStats getAutoFollowStats() {
|
||||
|
@ -74,14 +84,6 @@ public class CcrStatsAction extends Action<CcrStatsAction.Response> {
|
|||
return followStats;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
autoFollowStats = new AutoFollowStats(in);
|
||||
followStats = new FollowStatsAction.StatsResponses();
|
||||
followStats.readFrom(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.elasticsearch.action.ActionResponse;
|
|||
import org.elasticsearch.action.support.master.MasterNodeReadRequest;
|
||||
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.xpack.core.ccr.AutoFollowMetadata.AutoFollowPattern;
|
||||
|
@ -31,7 +32,12 @@ public class GetAutoFollowPatternAction extends Action<GetAutoFollowPatternActio
|
|||
|
||||
@Override
|
||||
public Response newResponse() {
|
||||
return new Response();
|
||||
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Writeable.Reader<Response> getResponseReader() {
|
||||
return Response::new;
|
||||
}
|
||||
|
||||
public static class Request extends MasterNodeReadRequest<Request> {
|
||||
|
@ -81,21 +87,17 @@ public class GetAutoFollowPatternAction extends Action<GetAutoFollowPatternActio
|
|||
|
||||
public static class Response extends ActionResponse implements ToXContentObject {
|
||||
|
||||
private Map<String, AutoFollowPattern> autoFollowPatterns;
|
||||
private final Map<String, AutoFollowPattern> autoFollowPatterns;
|
||||
|
||||
public Response(Map<String, AutoFollowPattern> autoFollowPatterns) {
|
||||
this.autoFollowPatterns = autoFollowPatterns;
|
||||
}
|
||||
|
||||
public Response() {
|
||||
}
|
||||
|
||||
public Map<String, AutoFollowPattern> getAutoFollowPatterns() {
|
||||
return autoFollowPatterns;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
public Response(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
autoFollowPatterns = in.readMap(StreamInput::readString, AutoFollowPattern::new);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.elasticsearch.action.support.master.AcknowledgedRequest;
|
|||
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.unit.ByteSizeValue;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.ObjectParser;
|
||||
|
@ -49,7 +50,12 @@ public final class PutFollowAction extends Action<PutFollowAction.Response> {
|
|||
|
||||
@Override
|
||||
public Response newResponse() {
|
||||
return new Response();
|
||||
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Writeable.Reader<Response> getResponseReader() {
|
||||
return Response::new;
|
||||
}
|
||||
|
||||
public static class Request extends AcknowledgedRequest<Request> implements IndicesRequest, ToXContentObject {
|
||||
|
@ -211,13 +217,9 @@ public final class PutFollowAction extends Action<PutFollowAction.Response> {
|
|||
|
||||
public static class Response extends ActionResponse implements ToXContentObject {
|
||||
|
||||
private boolean followIndexCreated;
|
||||
private boolean followIndexShardsAcked;
|
||||
private boolean indexFollowingStarted;
|
||||
|
||||
public Response() {
|
||||
|
||||
}
|
||||
private final boolean followIndexCreated;
|
||||
private final boolean followIndexShardsAcked;
|
||||
private final boolean indexFollowingStarted;
|
||||
|
||||
public Response(boolean followIndexCreated, boolean followIndexShardsAcked, boolean indexFollowingStarted) {
|
||||
this.followIndexCreated = followIndexCreated;
|
||||
|
@ -237,9 +239,8 @@ public final class PutFollowAction extends Action<PutFollowAction.Response> {
|
|||
return indexFollowingStarted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
public Response(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
followIndexCreated = in.readBoolean();
|
||||
followIndexShardsAcked = in.readBoolean();
|
||||
indexFollowingStarted = in.readBoolean();
|
||||
|
|
Loading…
Reference in New Issue