[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:
Martijn van Groningen 2018-11-02 08:02:17 +01:00 committed by GitHub
parent 598b0a0eb4
commit 19d6cf1b9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 74 additions and 45 deletions

View File

@ -17,6 +17,7 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.CheckedConsumer; import org.elasticsearch.common.CheckedConsumer;
import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.license.LicenseUtils; import org.elasticsearch.license.LicenseUtils;
import org.elasticsearch.tasks.Task; 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.FollowStatsAction;
import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction; import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction;
import java.io.IOException;
import java.util.Objects; import java.util.Objects;
public class TransportCcrStatsAction extends TransportMasterNodeAction<CcrStatsAction.Request, CcrStatsAction.Response> { public class TransportCcrStatsAction extends TransportMasterNodeAction<CcrStatsAction.Request, CcrStatsAction.Response> {
@ -70,7 +72,12 @@ public class TransportCcrStatsAction extends TransportMasterNodeAction<CcrStatsA
@Override @Override
protected CcrStatsAction.Response newResponse() { 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 @Override

View File

@ -17,6 +17,7 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService; 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.AutoFollowMetadata.AutoFollowPattern;
import org.elasticsearch.xpack.core.ccr.action.GetAutoFollowPatternAction; import org.elasticsearch.xpack.core.ccr.action.GetAutoFollowPatternAction;
import java.io.IOException;
import java.util.Collections; import java.util.Collections;
import java.util.Map; import java.util.Map;
@ -48,7 +50,12 @@ public class TransportGetAutoFollowPatternAction
@Override @Override
protected GetAutoFollowPatternAction.Response newResponse() { 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 @Override

View File

@ -27,6 +27,7 @@ import org.elasticsearch.cluster.routing.allocation.AllocationService;
import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.UUIDs; import org.elasticsearch.common.UUIDs;
import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.license.LicenseUtils; 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.PutFollowAction;
import org.elasticsearch.xpack.core.ccr.action.ResumeFollowAction; import org.elasticsearch.xpack.core.ccr.action.ResumeFollowAction;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
@ -83,7 +85,12 @@ public final class TransportPutFollowAction
@Override @Override
protected PutFollowAction.Response newResponse() { 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 @Override

View File

@ -5,7 +5,8 @@
*/ */
package org.elasticsearch.xpack.ccr.action; 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.AutoFollowStats;
import org.elasticsearch.xpack.core.ccr.action.FollowStatsAction; import org.elasticsearch.xpack.core.ccr.action.FollowStatsAction;
import org.elasticsearch.xpack.core.ccr.action.CcrStatsAction; 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.AutoFollowStatsTests.randomReadExceptions;
import static org.elasticsearch.xpack.ccr.action.StatsResponsesTests.createStatsResponse; import static org.elasticsearch.xpack.ccr.action.StatsResponsesTests.createStatsResponse;
public class AutoFollowStatsResponseTests extends AbstractStreamableTestCase<CcrStatsAction.Response> { public class AutoFollowStatsResponseTests extends AbstractWireSerializingTestCase<CcrStatsAction.Response> {
@Override @Override
protected CcrStatsAction.Response createBlankInstance() { protected Writeable.Reader<CcrStatsAction.Response> instanceReader() {
return new CcrStatsAction.Response(); return CcrStatsAction.Response::new;
} }
@Override @Override

View File

@ -5,10 +5,11 @@
*/ */
package org.elasticsearch.xpack.ccr.action; package org.elasticsearch.xpack.ccr.action;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.unit.ByteSizeUnit; import org.elasticsearch.common.unit.ByteSizeUnit;
import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.unit.TimeValue; 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.AutoFollowMetadata.AutoFollowPattern;
import org.elasticsearch.xpack.core.ccr.action.GetAutoFollowPatternAction; import org.elasticsearch.xpack.core.ccr.action.GetAutoFollowPatternAction;
@ -16,11 +17,11 @@ import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class GetAutoFollowPatternResponseTests extends AbstractStreamableTestCase<GetAutoFollowPatternAction.Response> { public class GetAutoFollowPatternResponseTests extends AbstractWireSerializingTestCase<GetAutoFollowPatternAction.Response> {
@Override @Override
protected GetAutoFollowPatternAction.Response createBlankInstance() { protected Writeable.Reader<GetAutoFollowPatternAction.Response> instanceReader() {
return new GetAutoFollowPatternAction.Response(); return GetAutoFollowPatternAction.Response::new;
} }
@Override @Override

View File

@ -5,14 +5,15 @@
*/ */
package org.elasticsearch.xpack.ccr.action; 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; import org.elasticsearch.xpack.core.ccr.action.PutFollowAction;
public class PutFollowActionResponseTests extends AbstractStreamableTestCase<PutFollowAction.Response> { public class PutFollowActionResponseTests extends AbstractWireSerializingTestCase<PutFollowAction.Response> {
@Override @Override
protected PutFollowAction.Response createBlankInstance() { protected Writeable.Reader<PutFollowAction.Response> instanceReader() {
return new PutFollowAction.Response(); return PutFollowAction.Response::new;
} }
@Override @Override

View File

@ -12,6 +12,7 @@ import org.elasticsearch.action.support.master.MasterNodeRequest;
import org.elasticsearch.action.Action; import org.elasticsearch.action.Action;
import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput; 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.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.xpack.core.ccr.AutoFollowStats; import org.elasticsearch.xpack.core.ccr.AutoFollowStats;
@ -30,7 +31,12 @@ public class CcrStatsAction extends Action<CcrStatsAction.Response> {
@Override @Override
public Response newResponse() { 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> { 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 { public static class Response extends ActionResponse implements ToXContentObject {
private AutoFollowStats autoFollowStats; private final AutoFollowStats autoFollowStats;
private FollowStatsAction.StatsResponses followStats; private final FollowStatsAction.StatsResponses followStats;
public Response(AutoFollowStats autoFollowStats, FollowStatsAction.StatsResponses followStats) { public Response(AutoFollowStats autoFollowStats, FollowStatsAction.StatsResponses followStats) {
this.autoFollowStats = Objects.requireNonNull(autoFollowStats); this.autoFollowStats = Objects.requireNonNull(autoFollowStats);
this.followStats = Objects.requireNonNull(followStats); 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() { public AutoFollowStats getAutoFollowStats() {
@ -74,14 +84,6 @@ public class CcrStatsAction extends Action<CcrStatsAction.Response> {
return followStats; 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 @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out); super.writeTo(out);

View File

@ -12,6 +12,7 @@ import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.action.support.master.MasterNodeReadRequest; import org.elasticsearch.action.support.master.MasterNodeReadRequest;
import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput; 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.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.xpack.core.ccr.AutoFollowMetadata.AutoFollowPattern; import org.elasticsearch.xpack.core.ccr.AutoFollowMetadata.AutoFollowPattern;
@ -31,7 +32,12 @@ public class GetAutoFollowPatternAction extends Action<GetAutoFollowPatternActio
@Override @Override
public Response newResponse() { 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> { 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 { 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) { public Response(Map<String, AutoFollowPattern> autoFollowPatterns) {
this.autoFollowPatterns = autoFollowPatterns; this.autoFollowPatterns = autoFollowPatterns;
} }
public Response() {
}
public Map<String, AutoFollowPattern> getAutoFollowPatterns() { public Map<String, AutoFollowPattern> getAutoFollowPatterns() {
return autoFollowPatterns; return autoFollowPatterns;
} }
@Override public Response(StreamInput in) throws IOException {
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in); super.readFrom(in);
autoFollowPatterns = in.readMap(StreamInput::readString, AutoFollowPattern::new); autoFollowPatterns = in.readMap(StreamInput::readString, AutoFollowPattern::new);
} }

View File

@ -15,6 +15,7 @@ import org.elasticsearch.action.support.master.AcknowledgedRequest;
import org.elasticsearch.common.ParseField; import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput; 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.ByteSizeValue;
import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.ObjectParser; import org.elasticsearch.common.xcontent.ObjectParser;
@ -49,7 +50,12 @@ public final class PutFollowAction extends Action<PutFollowAction.Response> {
@Override @Override
public Response newResponse() { 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 { 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 { public static class Response extends ActionResponse implements ToXContentObject {
private boolean followIndexCreated; private final boolean followIndexCreated;
private boolean followIndexShardsAcked; private final boolean followIndexShardsAcked;
private boolean indexFollowingStarted; private final boolean indexFollowingStarted;
public Response() {
}
public Response(boolean followIndexCreated, boolean followIndexShardsAcked, boolean indexFollowingStarted) { public Response(boolean followIndexCreated, boolean followIndexShardsAcked, boolean indexFollowingStarted) {
this.followIndexCreated = followIndexCreated; this.followIndexCreated = followIndexCreated;
@ -237,9 +239,8 @@ public final class PutFollowAction extends Action<PutFollowAction.Response> {
return indexFollowingStarted; return indexFollowingStarted;
} }
@Override public Response(StreamInput in) throws IOException {
public void readFrom(StreamInput in) throws IOException { super(in);
super.readFrom(in);
followIndexCreated = in.readBoolean(); followIndexCreated = in.readBoolean();
followIndexShardsAcked = in.readBoolean(); followIndexShardsAcked = in.readBoolean();
indexFollowingStarted = in.readBoolean(); indexFollowingStarted = in.readBoolean();