convert more request objects to writeable (elastic/x-pack-elasticsearch#2457)
* convert more to writeable * migrate streamable tests to writeable tests Original commit: elastic/x-pack-elasticsearch@56794e5760
This commit is contained in:
parent
3a9aad5ece
commit
5a090c14c1
|
@ -7,6 +7,9 @@ package org.elasticsearch.license;
|
|||
|
||||
import org.elasticsearch.action.ActionRequestValidationException;
|
||||
import org.elasticsearch.action.support.master.MasterNodeReadRequest;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
public class GetLicenseRequest extends MasterNodeReadRequest<GetLicenseRequest> {
|
||||
|
@ -14,6 +17,10 @@ public class GetLicenseRequest extends MasterNodeReadRequest<GetLicenseRequest>
|
|||
public GetLicenseRequest() {
|
||||
}
|
||||
|
||||
public GetLicenseRequest(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionRequestValidationException validate() {
|
||||
return null;
|
||||
|
|
|
@ -27,8 +27,8 @@ public class TransportGetLicenseAction extends TransportMasterNodeReadAction<Get
|
|||
public TransportGetLicenseAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
LicenseService licenseService, ThreadPool threadPool, ActionFilters actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, GetLicenseAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver,
|
||||
GetLicenseRequest::new);
|
||||
super(settings, GetLicenseAction.NAME, transportService, clusterService, threadPool, actionFilters,
|
||||
GetLicenseRequest::new, indexNameExpressionResolver);
|
||||
this.licenseService = licenseService;
|
||||
}
|
||||
|
||||
|
|
|
@ -210,6 +210,17 @@ public class DeprecationInfoAction extends Action<DeprecationInfoAction.Request,
|
|||
this.indices = indices;
|
||||
}
|
||||
|
||||
public Request(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
indices = in.readStringArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeStringArray(indices);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] indices() {
|
||||
return indices;
|
||||
|
@ -237,14 +248,7 @@ public class DeprecationInfoAction extends Action<DeprecationInfoAction.Request,
|
|||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
indices = in.readStringArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeStringArray(indices);
|
||||
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -286,7 +290,7 @@ public class DeprecationInfoAction extends Action<DeprecationInfoAction.Request,
|
|||
IndexNameExpressionResolver indexNameExpressionResolver,
|
||||
XPackLicenseState licenseState, InternalClient client) {
|
||||
super(settings, DeprecationInfoAction.NAME, transportService, clusterService, threadPool, actionFilters,
|
||||
indexNameExpressionResolver, Request::new);
|
||||
Request::new, indexNameExpressionResolver);
|
||||
this.licenseState = licenseState;
|
||||
this.client = client;
|
||||
this.indexNameExpressionResolver = indexNameExpressionResolver;
|
||||
|
|
|
@ -79,6 +79,23 @@ public class GetDatafeedsAction extends Action<GetDatafeedsAction.Request, GetDa
|
|||
local(true);
|
||||
}
|
||||
|
||||
Request(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
datafeedId = in.readString();
|
||||
if (in.getVersion().onOrAfter(Version.V_6_1_0)) {
|
||||
allowNoDatafeeds = in.readBoolean();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeString(datafeedId);
|
||||
if (out.getVersion().onOrAfter(Version.V_6_1_0)) {
|
||||
out.writeBoolean(allowNoDatafeeds);
|
||||
}
|
||||
}
|
||||
|
||||
public String getDatafeedId() {
|
||||
return datafeedId;
|
||||
}
|
||||
|
@ -98,20 +115,7 @@ public class GetDatafeedsAction extends Action<GetDatafeedsAction.Request, GetDa
|
|||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
datafeedId = in.readString();
|
||||
if (in.getVersion().onOrAfter(Version.V_6_1_0)) {
|
||||
allowNoDatafeeds = in.readBoolean();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeString(datafeedId);
|
||||
if (out.getVersion().onOrAfter(Version.V_6_1_0)) {
|
||||
out.writeBoolean(allowNoDatafeeds);
|
||||
}
|
||||
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -202,7 +206,7 @@ public class GetDatafeedsAction extends Action<GetDatafeedsAction.Request, GetDa
|
|||
public TransportAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, GetDatafeedsAction.NAME, transportService, clusterService, threadPool, actionFilters,
|
||||
indexNameExpressionResolver, Request::new);
|
||||
Request::new, indexNameExpressionResolver);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -85,6 +85,23 @@ public class GetDatafeedsStatsAction extends Action<GetDatafeedsStatsAction.Requ
|
|||
|
||||
Request() {}
|
||||
|
||||
Request(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
datafeedId = in.readString();
|
||||
if (in.getVersion().onOrAfter(Version.V_6_1_0)) {
|
||||
allowNoDatafeeds = in.readBoolean();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeString(datafeedId);
|
||||
if (out.getVersion().onOrAfter(Version.V_6_1_0)) {
|
||||
out.writeBoolean(allowNoDatafeeds);
|
||||
}
|
||||
}
|
||||
|
||||
public String getDatafeedId() {
|
||||
return datafeedId;
|
||||
}
|
||||
|
@ -104,20 +121,7 @@ public class GetDatafeedsStatsAction extends Action<GetDatafeedsStatsAction.Requ
|
|||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
datafeedId = in.readString();
|
||||
if (in.getVersion().onOrAfter(Version.V_6_1_0)) {
|
||||
allowNoDatafeeds = in.readBoolean();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeString(datafeedId);
|
||||
if (out.getVersion().onOrAfter(Version.V_6_1_0)) {
|
||||
out.writeBoolean(allowNoDatafeeds);
|
||||
}
|
||||
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -304,7 +308,7 @@ public class GetDatafeedsStatsAction extends Action<GetDatafeedsStatsAction.Requ
|
|||
ThreadPool threadPool, ActionFilters actionFilters,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, GetDatafeedsStatsAction.NAME, transportService, clusterService, threadPool, actionFilters,
|
||||
indexNameExpressionResolver, Request::new);
|
||||
Request::new, indexNameExpressionResolver);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -73,6 +73,23 @@ public class GetJobsAction extends Action<GetJobsAction.Request, GetJobsAction.R
|
|||
local(true);
|
||||
}
|
||||
|
||||
Request(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
jobId = in.readString();
|
||||
if (in.getVersion().onOrAfter(Version.V_6_1_0)) {
|
||||
allowNoJobs = in.readBoolean();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeString(jobId);
|
||||
if (out.getVersion().onOrAfter(Version.V_6_1_0)) {
|
||||
out.writeBoolean(allowNoJobs);
|
||||
}
|
||||
}
|
||||
|
||||
public void setAllowNoJobs(boolean allowNoJobs) {
|
||||
this.allowNoJobs = allowNoJobs;
|
||||
}
|
||||
|
@ -92,20 +109,7 @@ public class GetJobsAction extends Action<GetJobsAction.Request, GetJobsAction.R
|
|||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
jobId = in.readString();
|
||||
if (in.getVersion().onOrAfter(Version.V_6_1_0)) {
|
||||
allowNoJobs = in.readBoolean();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeString(jobId);
|
||||
if (out.getVersion().onOrAfter(Version.V_6_1_0)) {
|
||||
out.writeBoolean(allowNoJobs);
|
||||
}
|
||||
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -197,10 +201,10 @@ public class GetJobsAction extends Action<GetJobsAction.Request, GetJobsAction.R
|
|||
|
||||
@Inject
|
||||
public TransportAction(Settings settings, TransportService transportService, ClusterService clusterService,
|
||||
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver,
|
||||
JobManager jobManager) {
|
||||
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver,
|
||||
JobManager jobManager) {
|
||||
super(settings, GetJobsAction.NAME, transportService, clusterService, threadPool, actionFilters,
|
||||
indexNameExpressionResolver, Request::new);
|
||||
Request::new, indexNameExpressionResolver);
|
||||
this.jobManager = jobManager;
|
||||
}
|
||||
|
||||
|
|
|
@ -76,6 +76,17 @@ public class IndexUpgradeAction extends Action<IndexUpgradeAction.Request, BulkB
|
|||
this.index = index;
|
||||
}
|
||||
|
||||
public Request(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
index = in.readString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeString(index);
|
||||
}
|
||||
|
||||
public String index() {
|
||||
return index;
|
||||
}
|
||||
|
@ -123,14 +134,7 @@ public class IndexUpgradeAction extends Action<IndexUpgradeAction.Request, BulkB
|
|||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
index = in.readString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeString(index);
|
||||
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -179,7 +183,7 @@ public class IndexUpgradeAction extends Action<IndexUpgradeAction.Request, BulkB
|
|||
IndexUpgradeService indexUpgradeService,
|
||||
IndexNameExpressionResolver indexNameExpressionResolver) {
|
||||
super(settings, IndexUpgradeAction.NAME, transportService, clusterService, threadPool, actionFilters,
|
||||
indexNameExpressionResolver, Request::new);
|
||||
Request::new, indexNameExpressionResolver);
|
||||
this.indexUpgradeService = indexUpgradeService;
|
||||
}
|
||||
|
||||
|
|
|
@ -135,6 +135,19 @@ public class IndexUpgradeInfoAction extends Action<IndexUpgradeInfoAction.Reques
|
|||
this.indices = indices;
|
||||
}
|
||||
|
||||
public Request(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
indices = in.readStringArray();
|
||||
indicesOptions = IndicesOptions.readIndicesOptions(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeStringArray(indices);
|
||||
indicesOptions.writeIndicesOptions(out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] indices() {
|
||||
return indices;
|
||||
|
@ -166,16 +179,7 @@ public class IndexUpgradeInfoAction extends Action<IndexUpgradeInfoAction.Reques
|
|||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
indices = in.readStringArray();
|
||||
indicesOptions = IndicesOptions.readIndicesOptions(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeStringArray(indices);
|
||||
indicesOptions.writeIndicesOptions(out);
|
||||
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -223,7 +227,7 @@ public class IndexUpgradeInfoAction extends Action<IndexUpgradeInfoAction.Reques
|
|||
IndexNameExpressionResolver indexNameExpressionResolver,
|
||||
XPackLicenseState licenseState) {
|
||||
super(settings, IndexUpgradeInfoAction.NAME, transportService, clusterService, threadPool, actionFilters,
|
||||
indexNameExpressionResolver, Request::new);
|
||||
Request::new, indexNameExpressionResolver);
|
||||
this.indexUpgradeService = indexUpgradeService;
|
||||
this.licenseState = licenseState;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.elasticsearch.action.ActionResponse;
|
|||
import org.elasticsearch.action.support.ActionFilters;
|
||||
import org.elasticsearch.action.support.HandledTransportAction;
|
||||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
||||
import org.elasticsearch.common.io.stream.Writeable;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.license.LicenseUtils;
|
||||
import org.elasticsearch.license.XPackLicenseState;
|
||||
|
@ -19,8 +20,6 @@ import org.elasticsearch.threadpool.ThreadPool;
|
|||
import org.elasticsearch.transport.TransportService;
|
||||
import org.elasticsearch.xpack.XPackPlugin;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public abstract class WatcherTransportAction<Request extends ActionRequest, Response extends ActionResponse>
|
||||
extends HandledTransportAction<Request, Response> {
|
||||
|
||||
|
@ -28,8 +27,8 @@ public abstract class WatcherTransportAction<Request extends ActionRequest, Resp
|
|||
|
||||
public WatcherTransportAction(Settings settings, String actionName, TransportService transportService, ThreadPool threadPool,
|
||||
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver,
|
||||
XPackLicenseState licenseState, Supplier<Request> request) {
|
||||
super(settings, actionName, threadPool, transportService, actionFilters, indexNameExpressionResolver, request);
|
||||
XPackLicenseState licenseState, Writeable.Reader<Request> request) {
|
||||
super(settings, actionName, threadPool, transportService, actionFilters, request, indexNameExpressionResolver);
|
||||
this.licenseState = licenseState;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ public class AckWatchRequest extends ActionRequest {
|
|||
private String[] actionIds = Strings.EMPTY_ARRAY;
|
||||
|
||||
public AckWatchRequest() {
|
||||
this(null);
|
||||
this(null, (String[]) null);
|
||||
}
|
||||
|
||||
public AckWatchRequest(String watchId, String... actionIds) {
|
||||
|
@ -33,6 +33,19 @@ public class AckWatchRequest extends ActionRequest {
|
|||
this.actionIds = actionIds;
|
||||
}
|
||||
|
||||
public AckWatchRequest(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
watchId = in.readString();
|
||||
actionIds = in.readStringArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeString(watchId);
|
||||
out.writeStringArray(actionIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The id of the watch to be acked
|
||||
*/
|
||||
|
@ -78,16 +91,7 @@ public class AckWatchRequest extends ActionRequest {
|
|||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
watchId = in.readString();
|
||||
actionIds = in.readStringArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeString(watchId);
|
||||
out.writeStringArray(actionIds);
|
||||
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,6 +31,19 @@ public class ActivateWatchRequest extends ActionRequest {
|
|||
this.activate = activate;
|
||||
}
|
||||
|
||||
public ActivateWatchRequest(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
watchId = in.readString();
|
||||
activate = in.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeString(watchId);
|
||||
out.writeBoolean(activate);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The id of the watch to be acked
|
||||
*/
|
||||
|
@ -59,16 +72,7 @@ public class ActivateWatchRequest extends ActionRequest {
|
|||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
watchId = in.readString();
|
||||
activate = in.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeString(watchId);
|
||||
out.writeBoolean(activate);
|
||||
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -51,6 +51,56 @@ public class ExecuteWatchRequest extends ActionRequest {
|
|||
this.id = id;
|
||||
}
|
||||
|
||||
public ExecuteWatchRequest(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
id = in.readOptionalString();
|
||||
ignoreCondition = in.readBoolean();
|
||||
recordExecution = in.readBoolean();
|
||||
if (in.readBoolean()){
|
||||
alternativeInput = in.readMap();
|
||||
}
|
||||
if (in.readBoolean()) {
|
||||
triggerData = in.readMap();
|
||||
}
|
||||
long actionModesCount = in.readLong();
|
||||
actionModes = new HashMap<>();
|
||||
for (int i = 0; i < actionModesCount; i++) {
|
||||
actionModes.put(in.readString(), ActionExecutionMode.resolve(in.readByte()));
|
||||
}
|
||||
if (in.readBoolean()) {
|
||||
watchSource = in.readBytesReference();
|
||||
xContentType = XContentType.readFrom(in);
|
||||
}
|
||||
debug = in.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeOptionalString(id);
|
||||
out.writeBoolean(ignoreCondition);
|
||||
out.writeBoolean(recordExecution);
|
||||
out.writeBoolean(alternativeInput != null);
|
||||
if (alternativeInput != null) {
|
||||
out.writeMap(alternativeInput);
|
||||
}
|
||||
out.writeBoolean(triggerData != null);
|
||||
if (triggerData != null) {
|
||||
out.writeMap(triggerData);
|
||||
}
|
||||
out.writeLong(actionModes.size());
|
||||
for (Map.Entry<String, ActionExecutionMode> entry : actionModes.entrySet()) {
|
||||
out.writeString(entry.getKey());
|
||||
out.writeByte(entry.getValue().id());
|
||||
}
|
||||
out.writeBoolean(watchSource != null);
|
||||
if (watchSource != null) {
|
||||
out.writeBytesReference(watchSource);
|
||||
xContentType.writeTo(out);
|
||||
}
|
||||
out.writeBoolean(debug);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The id of the watch to be executed
|
||||
*/
|
||||
|
@ -221,54 +271,7 @@ public class ExecuteWatchRequest extends ActionRequest {
|
|||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
id = in.readOptionalString();
|
||||
ignoreCondition = in.readBoolean();
|
||||
recordExecution = in.readBoolean();
|
||||
if (in.readBoolean()){
|
||||
alternativeInput = in.readMap();
|
||||
}
|
||||
if (in.readBoolean()) {
|
||||
triggerData = in.readMap();
|
||||
}
|
||||
long actionModesCount = in.readLong();
|
||||
actionModes = new HashMap<>();
|
||||
for (int i = 0; i < actionModesCount; i++) {
|
||||
actionModes.put(in.readString(), ActionExecutionMode.resolve(in.readByte()));
|
||||
}
|
||||
if (in.readBoolean()) {
|
||||
watchSource = in.readBytesReference();
|
||||
xContentType = XContentType.readFrom(in);
|
||||
}
|
||||
debug = in.readBoolean();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeOptionalString(id);
|
||||
out.writeBoolean(ignoreCondition);
|
||||
out.writeBoolean(recordExecution);
|
||||
out.writeBoolean(alternativeInput != null);
|
||||
if (alternativeInput != null) {
|
||||
out.writeMap(alternativeInput);
|
||||
}
|
||||
out.writeBoolean(triggerData != null);
|
||||
if (triggerData != null) {
|
||||
out.writeMap(triggerData);
|
||||
}
|
||||
out.writeLong(actionModes.size());
|
||||
for (Map.Entry<String, ActionExecutionMode> entry : actionModes.entrySet()) {
|
||||
out.writeString(entry.getKey());
|
||||
out.writeByte(entry.getValue().id());
|
||||
}
|
||||
out.writeBoolean(watchSource != null);
|
||||
if (watchSource != null) {
|
||||
out.writeBytesReference(watchSource);
|
||||
xContentType.writeTo(out);
|
||||
}
|
||||
out.writeBoolean(debug);
|
||||
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,6 +31,17 @@ public class GetWatchRequest extends ActionRequest {
|
|||
this.id = id;
|
||||
}
|
||||
|
||||
public GetWatchRequest(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
id = in.readString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeString(id);
|
||||
}
|
||||
|
||||
GetWatchRequest setId(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
|
@ -58,14 +69,7 @@ public class GetWatchRequest extends ActionRequest {
|
|||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
id = in.readString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeString(id);
|
||||
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -42,6 +42,23 @@ public class PutWatchRequest extends ActionRequest {
|
|||
this.xContentType = xContentType;
|
||||
}
|
||||
|
||||
public PutWatchRequest(StreamInput in) throws IOException {
|
||||
super(in);
|
||||
id = in.readString();
|
||||
source = in.readBytesReference();
|
||||
active = in.readBoolean();
|
||||
xContentType = XContentType.readFrom(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeString(id);
|
||||
out.writeBytesReference(source);
|
||||
out.writeBoolean(active);
|
||||
xContentType.writeTo(out);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The name that will be the ID of the indexed document
|
||||
*/
|
||||
|
@ -115,19 +132,6 @@ public class PutWatchRequest extends ActionRequest {
|
|||
|
||||
@Override
|
||||
public void readFrom(StreamInput in) throws IOException {
|
||||
super.readFrom(in);
|
||||
id = in.readString();
|
||||
source = in.readBytesReference();
|
||||
active = in.readBoolean();
|
||||
xContentType = XContentType.readFrom(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(StreamOutput out) throws IOException {
|
||||
super.writeTo(out);
|
||||
out.writeString(id);
|
||||
out.writeBytesReference(source);
|
||||
out.writeBoolean(active);
|
||||
xContentType.writeTo(out);
|
||||
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,9 +5,10 @@
|
|||
*/
|
||||
package org.elasticsearch.xpack.deprecation;
|
||||
|
||||
import org.elasticsearch.test.AbstractStreamableTestCase;
|
||||
import org.elasticsearch.common.io.stream.Writeable;
|
||||
import org.elasticsearch.test.AbstractWireSerializingTestCase;
|
||||
|
||||
public class DeprecationInfoActionRequestTests extends AbstractStreamableTestCase<DeprecationInfoAction.Request> {
|
||||
public class DeprecationInfoActionRequestTests extends AbstractWireSerializingTestCase<DeprecationInfoAction.Request> {
|
||||
|
||||
@Override
|
||||
protected DeprecationInfoAction.Request createTestInstance() {
|
||||
|
@ -15,7 +16,7 @@ public class DeprecationInfoActionRequestTests extends AbstractStreamableTestCas
|
|||
}
|
||||
|
||||
@Override
|
||||
protected DeprecationInfoAction.Request createBlankInstance() {
|
||||
return new DeprecationInfoAction.Request();
|
||||
protected Writeable.Reader<DeprecationInfoAction.Request> instanceReader() {
|
||||
return DeprecationInfoAction.Request::new;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,10 +6,11 @@
|
|||
package org.elasticsearch.xpack.ml.action;
|
||||
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.test.AbstractStreamableTestCase;
|
||||
import org.elasticsearch.common.io.stream.Writeable;
|
||||
import org.elasticsearch.test.AbstractWireSerializingTestCase;
|
||||
import org.elasticsearch.xpack.ml.action.GetDatafeedsStatsAction.Request;
|
||||
|
||||
public class GetDatafeedStatsActionRequestTests extends AbstractStreamableTestCase<Request> {
|
||||
public class GetDatafeedStatsActionRequestTests extends AbstractWireSerializingTestCase<Request> {
|
||||
|
||||
@Override
|
||||
protected Request createTestInstance() {
|
||||
|
@ -19,8 +20,7 @@ public class GetDatafeedStatsActionRequestTests extends AbstractStreamableTestCa
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Request createBlankInstance() {
|
||||
return new Request();
|
||||
protected Writeable.Reader<Request> instanceReader() {
|
||||
return Request::new;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,10 +6,11 @@
|
|||
package org.elasticsearch.xpack.ml.action;
|
||||
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.test.AbstractStreamableTestCase;
|
||||
import org.elasticsearch.common.io.stream.Writeable;
|
||||
import org.elasticsearch.test.AbstractWireSerializingTestCase;
|
||||
import org.elasticsearch.xpack.ml.action.GetDatafeedsAction.Request;
|
||||
|
||||
public class GetDatafeedsActionRequestTests extends AbstractStreamableTestCase<Request> {
|
||||
public class GetDatafeedsActionRequestTests extends AbstractWireSerializingTestCase<Request> {
|
||||
|
||||
@Override
|
||||
protected Request createTestInstance() {
|
||||
|
@ -19,8 +20,7 @@ public class GetDatafeedsActionRequestTests extends AbstractStreamableTestCase<R
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Request createBlankInstance() {
|
||||
return new Request();
|
||||
protected Writeable.Reader<Request> instanceReader() {
|
||||
return Request::new;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,10 +6,11 @@
|
|||
package org.elasticsearch.xpack.ml.action;
|
||||
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.test.AbstractStreamableTestCase;
|
||||
import org.elasticsearch.common.io.stream.Writeable;
|
||||
import org.elasticsearch.test.AbstractWireSerializingTestCase;
|
||||
import org.elasticsearch.xpack.ml.action.GetJobsAction.Request;
|
||||
|
||||
public class GetJobsActionRequestTests extends AbstractStreamableTestCase<GetJobsAction.Request> {
|
||||
public class GetJobsActionRequestTests extends AbstractWireSerializingTestCase<Request> {
|
||||
|
||||
@Override
|
||||
protected Request createTestInstance() {
|
||||
|
@ -19,7 +20,7 @@ public class GetJobsActionRequestTests extends AbstractStreamableTestCase<GetJob
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Request createBlankInstance() {
|
||||
return new Request();
|
||||
protected Writeable.Reader<Request> instanceReader() {
|
||||
return Request::new;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,17 +5,18 @@
|
|||
*/
|
||||
package org.elasticsearch.xpack.upgrade.actions;
|
||||
|
||||
import org.elasticsearch.test.AbstractStreamableTestCase;
|
||||
import org.elasticsearch.common.io.stream.Writeable;
|
||||
import org.elasticsearch.test.AbstractWireSerializingTestCase;
|
||||
import org.elasticsearch.xpack.upgrade.actions.IndexUpgradeAction.Request;
|
||||
|
||||
public class IndexUpgradeActionRequestTests extends AbstractStreamableTestCase<Request> {
|
||||
public class IndexUpgradeActionRequestTests extends AbstractWireSerializingTestCase<Request> {
|
||||
@Override
|
||||
protected Request createTestInstance() {
|
||||
return new Request(randomAlphaOfLength(10));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Request createBlankInstance() {
|
||||
return new Request();
|
||||
protected Writeable.Reader<Request> instanceReader() {
|
||||
return Request::new;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,10 +6,11 @@
|
|||
package org.elasticsearch.xpack.upgrade.actions;
|
||||
|
||||
import org.elasticsearch.action.support.IndicesOptions;
|
||||
import org.elasticsearch.test.AbstractStreamableTestCase;
|
||||
import org.elasticsearch.common.io.stream.Writeable;
|
||||
import org.elasticsearch.test.AbstractWireSerializingTestCase;
|
||||
import org.elasticsearch.xpack.upgrade.actions.IndexUpgradeInfoAction.Request;
|
||||
|
||||
public class IndexUpgradeInfoActionRequestTests extends AbstractStreamableTestCase<Request> {
|
||||
public class IndexUpgradeInfoActionRequestTests extends AbstractWireSerializingTestCase<Request> {
|
||||
@Override
|
||||
protected Request createTestInstance() {
|
||||
int indexCount = randomInt(4);
|
||||
|
@ -25,7 +26,7 @@ public class IndexUpgradeInfoActionRequestTests extends AbstractStreamableTestCa
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Request createBlankInstance() {
|
||||
return new Request();
|
||||
protected Writeable.Reader<Request> instanceReader() {
|
||||
return Request::new;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ public class WatchRequestValidationTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testGetWatchNullId() {
|
||||
ActionRequestValidationException e = new GetWatchRequest(null).validate();
|
||||
ActionRequestValidationException e = new GetWatchRequest((String) null).validate();
|
||||
assertThat(e, is(notNullValue()));
|
||||
assertThat(e.validationErrors(), hasItem("watch id is missing"));
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ public class WatchRequestValidationTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testExecuteWatchMissingWatchIdNoSource() {
|
||||
ActionRequestValidationException e = new ExecuteWatchRequest(null).validate();
|
||||
ActionRequestValidationException e = new ExecuteWatchRequest((String) null).validate();
|
||||
assertThat(e, is(notNullValue()));
|
||||
assertThat(e.validationErrors(),
|
||||
hasItem("a watch execution request must either have a watch id or an inline watch source, but both are missing"));
|
||||
|
|
|
@ -25,8 +25,7 @@ public class ExecuteWatchRequestTests extends ESTestCase {
|
|||
BytesStreamOutput out = new BytesStreamOutput();
|
||||
request.writeTo(out);
|
||||
StreamInput in = StreamInput.wrap(out.bytes().toBytesRef().bytes);
|
||||
ExecuteWatchRequest serialized = new ExecuteWatchRequest();
|
||||
serialized.readFrom(in);
|
||||
ExecuteWatchRequest serialized = new ExecuteWatchRequest(in);
|
||||
assertEquals(XContentType.JSON, serialized.getXContentType());
|
||||
assertEquals("{}", serialized.getWatchSource().utf8ToString());
|
||||
}
|
||||
|
|
|
@ -29,8 +29,7 @@ public class PutWatchSerializationTests extends ESTestCase {
|
|||
BytesStreamOutput streamOutput = new BytesStreamOutput();
|
||||
request.writeTo(streamOutput);
|
||||
|
||||
PutWatchRequest readRequest = new PutWatchRequest();
|
||||
readRequest.readFrom(streamOutput.bytes().streamInput());
|
||||
PutWatchRequest readRequest = new PutWatchRequest(streamOutput.bytes().streamInput());
|
||||
assertThat(readRequest.isActive(), is(request.isActive()));
|
||||
assertThat(readRequest.getId(), is(request.getId()));
|
||||
assertThat(readRequest.getSource(), is(request.getSource()));
|
||||
|
@ -49,9 +48,7 @@ public class PutWatchSerializationTests extends ESTestCase {
|
|||
BytesStreamOutput streamOutput = new BytesStreamOutput();
|
||||
request.writeTo(streamOutput);
|
||||
|
||||
PutWatchRequest readRequest = new PutWatchRequest();
|
||||
StreamInput input = streamOutput.bytes().streamInput();
|
||||
readRequest.readFrom(input);
|
||||
PutWatchRequest readRequest = new PutWatchRequest(streamOutput.bytes().streamInput());
|
||||
assertThat(readRequest.isActive(), is(request.isActive()));
|
||||
assertThat(readRequest.getId(), is(request.getId()));
|
||||
assertThat(readRequest.getSource(), is(request.getSource()));
|
||||
|
|
Loading…
Reference in New Issue