Convert remaining Action Response/Request to writeable.reader (#44528) (#44607)

This commit converts readFrom to ctor with StreamInput on the remaining
ActionResponse and ActionRequest classes.

relates #34389
This commit is contained in:
Ryan Ernst 2019-07-19 13:33:38 -07:00 committed by GitHub
parent a63f60b776
commit f193d14764
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
289 changed files with 504 additions and 1946 deletions

View File

@ -93,11 +93,6 @@ public class GrokProcessorGetAction extends ActionType<GrokProcessorGetAction.Re
return builder;
}
@Override
public void readFrom(StreamInput in) {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeMap(grokPatterns, StreamOutput::writeString, StreamOutput::writeString);

View File

@ -42,8 +42,7 @@ public class GrokProcessorGetActionTests extends ESTestCase {
BytesStreamOutput out = new BytesStreamOutput();
request.writeTo(out);
StreamInput streamInput = out.bytes().streamInput();
GrokProcessorGetAction.Request otherRequest = new GrokProcessorGetAction.Request();
otherRequest.readFrom(streamInput);
GrokProcessorGetAction.Request otherRequest = new GrokProcessorGetAction.Request(streamInput);
assertThat(otherRequest.validate(), nullValue());
}

View File

@ -123,11 +123,6 @@ public class MultiSearchTemplateRequest extends ActionRequest implements Composi
return this;
}
@Override
public void readFrom(StreamInput in) {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);

View File

@ -146,11 +146,6 @@ public class MultiSearchTemplateResponse extends ActionResponse implements Itera
return new TimeValue(tookInMillis);
}
@Override
public void readFrom(StreamInput in) throws IOException {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(items.length);

View File

@ -56,10 +56,6 @@ public class SearchTemplateRequest extends ActionRequest implements CompositeInd
public SearchTemplateRequest() {}
public SearchTemplateRequest(SearchRequest searchRequest) {
this.request = searchRequest;
}
public SearchTemplateRequest(StreamInput in) throws IOException {
super(in);
request = in.readOptionalWriteable(SearchRequest::new);
@ -73,6 +69,10 @@ public class SearchTemplateRequest extends ActionRequest implements CompositeInd
}
}
public SearchTemplateRequest(SearchRequest searchRequest) {
this.request = searchRequest;
}
public void setRequest(SearchRequest request) {
this.request = request;
}
@ -229,11 +229,6 @@ public class SearchTemplateRequest extends ActionRequest implements CompositeInd
.endObject();
}
@Override
public void readFrom(StreamInput in) {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);

View File

@ -85,11 +85,6 @@ public class SearchTemplateResponse extends ActionResponse implements StatusToXC
out.writeOptionalStreamable(response);
}
@Override
public void readFrom(StreamInput in) {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
public static SearchTemplateResponse fromXContent(XContentParser parser) throws IOException {
SearchTemplateResponse searchTemplateResponse = new SearchTemplateResponse();
Map<String, Object> contentAsMap = parser.map();

View File

@ -101,11 +101,6 @@ public class PainlessContextAction extends ActionType<PainlessContextAction.Resp
return null;
}
@Override
public void readFrom(StreamInput in) {
throw new UnsupportedOperationException();
}
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
@ -134,11 +129,6 @@ public class PainlessContextAction extends ActionType<PainlessContextAction.Resp
painlessContextInfo = in.readOptionalWriteable(PainlessContextInfo::new);
}
@Override
public void readFrom(StreamInput in) {
throw new UnsupportedOperationException();
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeStringCollection(scriptContextNames);

View File

@ -394,11 +394,6 @@ public class PainlessExecuteAction extends ActionType<PainlessExecuteAction.Resp
return result;
}
@Override
public void readFrom(StreamInput in) throws IOException {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeGenericValue(result);

View File

@ -49,7 +49,7 @@ public class RankEvalRequest extends ActionRequest implements IndicesRequest.Rep
}
RankEvalRequest(StreamInput in) throws IOException {
super.readFrom(in);
super(in);
rankingEvaluationSpec = new RankEvalSpec(in);
if (in.getVersion().onOrAfter(Version.V_6_3_0)) {
indices = in.readStringArray();
@ -122,11 +122,6 @@ public class RankEvalRequest extends ActionRequest implements IndicesRequest.Rep
this.indicesOptions = Objects.requireNonNull(indicesOptions, "indicesOptions must not be null");
}
@Override
public void readFrom(StreamInput in) throws IOException {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);

View File

@ -111,11 +111,6 @@ public class RankEvalResponse extends ActionResponse implements ToXContentObject
}
}
@Override
public void readFrom(StreamInput in) throws IOException {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();

View File

@ -48,8 +48,8 @@ public abstract class ActionRequest extends TransportRequest {
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
public final void readFrom(StreamInput in) throws IOException {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable " + getClass().getName());
}
@Override

View File

@ -37,7 +37,7 @@ public abstract class ActionResponse extends TransportResponse {
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
public final void readFrom(StreamInput in) throws IOException {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
}

View File

@ -1,51 +0,0 @@
/*
* 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;
import org.elasticsearch.common.io.stream.Writeable;
/**
* An action for with the response type implements {@link org.elasticsearch.common.io.stream.Streamable}.
* @deprecated Use {@link ActionType} directly and provide a {@link Writeable.Reader}
*/
@Deprecated
public abstract class StreamableResponseActionType<Response extends ActionResponse> extends ActionType<Response> {
protected StreamableResponseActionType(String name) {
super(name, null);
}
/**
* Creates a new response instance.
* @deprecated Implement {@link #getResponseReader()} instead and make this method throw an
* {@link UnsupportedOperationException}
*/
@Deprecated
public abstract Response newResponse();
@Override
public final Writeable.Reader<Response> getResponseReader() {
return in -> {
Response response = newResponse();
response.readFrom(in);
return response;
};
}
}

View File

@ -19,22 +19,17 @@
package org.elasticsearch.action.admin.cluster.allocation;
import org.elasticsearch.action.StreamableResponseActionType;
import org.elasticsearch.action.ActionType;
/**
* ActionType for explaining shard allocation for a shard in the cluster
*/
public class ClusterAllocationExplainAction extends StreamableResponseActionType<ClusterAllocationExplainResponse> {
public class ClusterAllocationExplainAction extends ActionType<ClusterAllocationExplainResponse> {
public static final ClusterAllocationExplainAction INSTANCE = new ClusterAllocationExplainAction();
public static final String NAME = "cluster:monitor/allocation/explain";
private ClusterAllocationExplainAction() {
super(NAME);
}
@Override
public ClusterAllocationExplainResponse newResponse() {
return new ClusterAllocationExplainResponse();
super(NAME, ClusterAllocationExplainResponse::new);
}
}

View File

@ -32,7 +32,9 @@ public class ClusterAllocationExplainResponse extends ActionResponse {
private ClusterAllocationExplanation cae;
public ClusterAllocationExplainResponse() {
public ClusterAllocationExplainResponse(StreamInput in) throws IOException {
super(in);
this.cae = new ClusterAllocationExplanation(in);
}
public ClusterAllocationExplainResponse(ClusterAllocationExplanation cae) {
@ -46,12 +48,6 @@ public class ClusterAllocationExplainResponse extends ActionResponse {
return this.cae;
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
this.cae = new ClusterAllocationExplanation(in);
}
@Override
public void writeTo(StreamOutput out) throws IOException {
cae.writeTo(out);

View File

@ -21,7 +21,7 @@ package org.elasticsearch.action.admin.cluster.allocation;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.StreamableTransportMasterNodeAction;
import org.elasticsearch.action.support.master.TransportMasterNodeAction;
import org.elasticsearch.cluster.ClusterInfo;
import org.elasticsearch.cluster.ClusterInfoService;
import org.elasticsearch.cluster.ClusterState;
@ -40,10 +40,12 @@ import org.elasticsearch.cluster.routing.allocation.allocator.ShardsAllocator;
import org.elasticsearch.cluster.routing.allocation.decider.AllocationDeciders;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.gateway.GatewayAllocator;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import java.io.IOException;
import java.util.List;
/**
@ -51,7 +53,7 @@ import java.util.List;
* master node in the cluster.
*/
public class TransportClusterAllocationExplainAction
extends StreamableTransportMasterNodeAction<ClusterAllocationExplainRequest, ClusterAllocationExplainResponse> {
extends TransportMasterNodeAction<ClusterAllocationExplainRequest, ClusterAllocationExplainResponse> {
private final ClusterInfoService clusterInfoService;
private final AllocationDeciders allocationDeciders;
@ -78,13 +80,13 @@ public class TransportClusterAllocationExplainAction
}
@Override
protected ClusterBlockException checkBlock(ClusterAllocationExplainRequest request, ClusterState state) {
return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_READ);
protected ClusterAllocationExplainResponse read(StreamInput in) throws IOException {
return new ClusterAllocationExplainResponse(in);
}
@Override
protected ClusterAllocationExplainResponse newResponse() {
return new ClusterAllocationExplainResponse();
protected ClusterBlockException checkBlock(ClusterAllocationExplainRequest request, ClusterState state) {
return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_READ);
}
@Override

View File

@ -39,11 +39,6 @@ public class AddVotingConfigExclusionsResponse extends ActionResponse implements
super(in);
}
@Override
public void readFrom(StreamInput in) throws IOException {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
@Override
public void writeTo(StreamOutput out) throws IOException {}

View File

@ -38,11 +38,6 @@ public class ClearVotingConfigExclusionsResponse extends ActionResponse implemen
super(in);
}
@Override
public void readFrom(StreamInput in) throws IOException {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
@Override
public void writeTo(StreamOutput out) throws IOException {}

View File

@ -19,19 +19,14 @@
package org.elasticsearch.action.admin.cluster.health;
import org.elasticsearch.action.StreamableResponseActionType;
import org.elasticsearch.action.ActionType;
public class ClusterHealthAction extends StreamableResponseActionType<ClusterHealthResponse> {
public class ClusterHealthAction extends ActionType<ClusterHealthResponse> {
public static final ClusterHealthAction INSTANCE = new ClusterHealthAction();
public static final String NAME = "cluster:monitor/health";
private ClusterHealthAction() {
super(NAME);
}
@Override
public ClusterHealthResponse newResponse() {
return new ClusterHealthResponse();
super(NAME, ClusterHealthResponse::new);
}
}

View File

@ -142,7 +142,18 @@ public class ClusterHealthResponse extends ActionResponse implements StatusToXCo
private ClusterStateHealth clusterStateHealth;
private ClusterHealthStatus clusterHealthStatus;
ClusterHealthResponse() {
public ClusterHealthResponse() {}
public ClusterHealthResponse(StreamInput in) throws IOException {
super(in);
clusterName = in.readString();
clusterHealthStatus = ClusterHealthStatus.fromValue(in.readByte());
clusterStateHealth = new ClusterStateHealth(in);
numberOfPendingTasks = in.readInt();
timedOut = in.readBoolean();
numberOfInFlightFetch = in.readInt();
delayedUnassignedShards= in.readInt();
taskMaxWaitingTime = in.readTimeValue();
}
/** needed for plugins BWC */
@ -277,22 +288,7 @@ public class ClusterHealthResponse extends ActionResponse implements StatusToXCo
}
public static ClusterHealthResponse readResponseFrom(StreamInput in) throws IOException {
ClusterHealthResponse response = new ClusterHealthResponse();
response.readFrom(in);
return response;
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
clusterName = in.readString();
clusterHealthStatus = ClusterHealthStatus.fromValue(in.readByte());
clusterStateHealth = new ClusterStateHealth(in);
numberOfPendingTasks = in.readInt();
timedOut = in.readBoolean();
numberOfInFlightFetch = in.readInt();
delayedUnassignedShards= in.readInt();
taskMaxWaitingTime = in.readTimeValue();
return new ClusterHealthResponse(in);
}
@Override

View File

@ -26,7 +26,7 @@ import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.ActiveShardCount;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.action.support.master.StreamableTransportMasterNodeReadAction;
import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.ClusterStateObserver;
import org.elasticsearch.cluster.ClusterStateUpdateTask;
@ -39,6 +39,7 @@ import org.elasticsearch.cluster.routing.UnassignedInfo;
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.unit.TimeValue;
import org.elasticsearch.gateway.GatewayAllocator;
import org.elasticsearch.index.IndexNotFoundException;
@ -46,10 +47,11 @@ import org.elasticsearch.tasks.Task;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import java.io.IOException;
import java.util.function.Consumer;
import java.util.function.Predicate;
public class TransportClusterHealthAction extends StreamableTransportMasterNodeReadAction<ClusterHealthRequest, ClusterHealthResponse> {
public class TransportClusterHealthAction extends TransportMasterNodeReadAction<ClusterHealthRequest, ClusterHealthResponse> {
private static final Logger logger = LogManager.getLogger(TransportClusterHealthAction.class);
@ -71,14 +73,14 @@ public class TransportClusterHealthAction extends StreamableTransportMasterNodeR
}
@Override
protected ClusterBlockException checkBlock(ClusterHealthRequest request, ClusterState state) {
// we want users to be able to call this even when there are global blocks, just to check the health (are there blocks?)
return null;
protected ClusterHealthResponse read(StreamInput in) throws IOException {
return new ClusterHealthResponse(in);
}
@Override
protected ClusterHealthResponse newResponse() {
return new ClusterHealthResponse();
protected ClusterBlockException checkBlock(ClusterHealthRequest request, ClusterState state) {
// we want users to be able to call this even when there are global blocks, just to check the health (are there blocks?)
return null;
}
@Override

View File

@ -20,12 +20,21 @@ package org.elasticsearch.action.admin.cluster.node.liveness;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestValidationException;
import org.elasticsearch.common.io.stream.StreamInput;
import java.io.IOException;
/**
* Transport level private response for the transport handler registered under
* {@value org.elasticsearch.action.admin.cluster.node.liveness.TransportLivenessAction#NAME}
*/
public final class LivenessRequest extends ActionRequest {
public LivenessRequest() {}
public LivenessRequest(StreamInput in) throws IOException {
super(in);
}
@Override
public ActionRequestValidationException validate() {
return null;

View File

@ -36,7 +36,12 @@ public final class LivenessResponse extends ActionResponse {
private DiscoveryNode node;
private ClusterName clusterName;
public LivenessResponse() {
public LivenessResponse() {}
public LivenessResponse(StreamInput in) throws IOException {
super(in);
clusterName = new ClusterName(in);
node = in.readOptionalWriteable(DiscoveryNode::new);
}
public LivenessResponse(ClusterName clusterName, DiscoveryNode node) {
@ -44,13 +49,6 @@ public final class LivenessResponse extends ActionResponse {
this.clusterName = clusterName;
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
clusterName = new ClusterName(in);
node = in.readOptionalWriteable(DiscoveryNode::new);
}
@Override
public void writeTo(StreamOutput out) throws IOException {
clusterName.writeTo(out);

View File

@ -35,8 +35,8 @@ public final class TransportLivenessAction implements TransportRequestHandler<Li
@Inject
public TransportLivenessAction(ClusterService clusterService, TransportService transportService) {
this.clusterService = clusterService;
transportService.registerRequestHandler(NAME, LivenessRequest::new, ThreadPool.Names.SAME,
false, false /*can not trip circuit breaker*/, this);
transportService.registerRequestHandler(NAME, ThreadPool.Names.SAME,
false, false /*can not trip circuit breaker*/, LivenessRequest::new, this);
}
@Override

View File

@ -38,6 +38,9 @@ public class GetTaskRequest extends ActionRequest {
private boolean waitForCompletion = false;
private TimeValue timeout = null;
/**
* Get the TaskId to look up.
*/
public GetTaskRequest() {}
public GetTaskRequest(StreamInput in) throws IOException {
@ -47,9 +50,6 @@ public class GetTaskRequest extends ActionRequest {
waitForCompletion = in.readBoolean();
}
/**
* Get the TaskId to look up.
*/
public TaskId getTaskId() {
return taskId;
}
@ -110,11 +110,6 @@ public class GetTaskRequest extends ActionRequest {
return validationException;
}
@Override
public void readFrom(StreamInput in) throws IOException {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);

View File

@ -35,6 +35,7 @@ import static java.util.Objects.requireNonNull;
* Returns the list of tasks currently running on the nodes
*/
public class GetTaskResponse extends ActionResponse implements ToXContentObject {
private final TaskResult task;
public GetTaskResponse(TaskResult task) {
@ -46,11 +47,6 @@ public class GetTaskResponse extends ActionResponse implements ToXContentObject
task = in.readOptionalWriteable(TaskResult::new);
}
@Override
public void readFrom(StreamInput in) throws IOException {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalWriteable(task);

View File

@ -54,11 +54,6 @@ public final class RemoteInfoResponse extends ActionResponse implements ToXConte
out.writeList(infos);
}
@Override
public void readFrom(StreamInput in) throws IOException {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();

View File

@ -58,11 +58,6 @@ public class GetRepositoriesResponse extends ActionResponse implements ToXConten
}
@Override
public void readFrom(StreamInput in) throws IOException {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
@Override
public void writeTo(StreamOutput out) throws IOException {
repositories.writeTo(out);

View File

@ -21,7 +21,7 @@ package org.elasticsearch.action.admin.cluster.repositories.verify;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.StreamableTransportMasterNodeAction;
import org.elasticsearch.action.support.master.TransportMasterNodeAction;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.cluster.block.ClusterBlockLevel;
@ -29,15 +29,18 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.node.DiscoveryNode;
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 verifying repository operation
*/
public class TransportVerifyRepositoryAction extends
StreamableTransportMasterNodeAction<VerifyRepositoryRequest, VerifyRepositoryResponse> {
TransportMasterNodeAction<VerifyRepositoryRequest, VerifyRepositoryResponse> {
private final RepositoriesService repositoriesService;
@ -57,8 +60,8 @@ public class TransportVerifyRepositoryAction extends
}
@Override
protected VerifyRepositoryResponse newResponse() {
return new VerifyRepositoryResponse();
protected VerifyRepositoryResponse read(StreamInput in) throws IOException {
return new VerifyRepositoryResponse(in);
}
@Override

View File

@ -19,23 +19,18 @@
package org.elasticsearch.action.admin.cluster.repositories.verify;
import org.elasticsearch.action.StreamableResponseActionType;
import org.elasticsearch.action.ActionType;
/**
* Unregister repository action
*/
public class VerifyRepositoryAction extends StreamableResponseActionType<VerifyRepositoryResponse> {
public class VerifyRepositoryAction extends ActionType<VerifyRepositoryResponse> {
public static final VerifyRepositoryAction INSTANCE = new VerifyRepositoryAction();
public static final String NAME = "cluster:admin/repository/verify";
private VerifyRepositoryAction() {
super(NAME);
}
@Override
public VerifyRepositoryResponse newResponse() {
return new VerifyRepositoryResponse();
super(NAME, VerifyRepositoryResponse::new);
}
}

View File

@ -115,7 +115,11 @@ public class VerifyRepositoryResponse extends ActionResponse implements ToXConte
PARSER.declareNamedObjects(VerifyRepositoryResponse::setNodes, NodeView.PARSER, new ParseField("nodes"));
}
VerifyRepositoryResponse() {
public VerifyRepositoryResponse() {}
public VerifyRepositoryResponse(StreamInput in) throws IOException {
super(in);
this.nodes = in.readList(NodeView::new);
}
public VerifyRepositoryResponse(DiscoveryNode[] nodes) {
@ -126,12 +130,6 @@ public class VerifyRepositoryResponse extends ActionResponse implements ToXConte
this.nodes = nodes;
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
this.nodes = in.readList(NodeView::new);
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeList(nodes);

View File

@ -57,11 +57,6 @@ public class ClusterSearchShardsResponse extends ActionResponse implements ToXCo
}
}
@Override
public void readFrom(StreamInput in) throws IOException {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(groups.length);

View File

@ -19,23 +19,18 @@
package org.elasticsearch.action.admin.cluster.snapshots.create;
import org.elasticsearch.action.StreamableResponseActionType;
import org.elasticsearch.action.ActionType;
/**
* Create snapshot action
*/
public class CreateSnapshotAction extends StreamableResponseActionType<CreateSnapshotResponse> {
public class CreateSnapshotAction extends ActionType<CreateSnapshotResponse> {
public static final CreateSnapshotAction INSTANCE = new CreateSnapshotAction();
public static final String NAME = "cluster:admin/snapshot/create";
private CreateSnapshotAction() {
super(NAME);
}
@Override
public CreateSnapshotResponse newResponse() {
return new CreateSnapshotResponse();
super(NAME, CreateSnapshotResponse::new);
}
}

View File

@ -51,11 +51,15 @@ public class CreateSnapshotResponse extends ActionResponse implements ToXContent
@Nullable
private SnapshotInfo snapshotInfo;
CreateSnapshotResponse() {}
CreateSnapshotResponse(@Nullable SnapshotInfo snapshotInfo) {
this.snapshotInfo = snapshotInfo;
}
CreateSnapshotResponse() {
public CreateSnapshotResponse(StreamInput in) throws IOException {
super(in);
snapshotInfo = in.readOptionalWriteable(SnapshotInfo::new);
}
private void setSnapshotInfoFromBuilder(SnapshotInfoBuilder snapshotInfoBuilder) {
@ -71,12 +75,6 @@ public class CreateSnapshotResponse extends ActionResponse implements ToXContent
return snapshotInfo;
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
snapshotInfo = in.readOptionalWriteable(SnapshotInfo::new);
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalWriteable(snapshotInfo);

View File

@ -21,21 +21,24 @@ package org.elasticsearch.action.admin.cluster.snapshots.create;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.StreamableTransportMasterNodeAction;
import org.elasticsearch.action.support.master.TransportMasterNodeAction;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.cluster.block.ClusterBlockLevel;
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 create snapshot operation
*/
public class TransportCreateSnapshotAction extends StreamableTransportMasterNodeAction<CreateSnapshotRequest, CreateSnapshotResponse> {
public class TransportCreateSnapshotAction extends TransportMasterNodeAction<CreateSnapshotRequest, CreateSnapshotResponse> {
private final SnapshotsService snapshotsService;
@Inject
@ -55,8 +58,8 @@ public class TransportCreateSnapshotAction extends StreamableTransportMasterNode
}
@Override
protected CreateSnapshotResponse newResponse() {
return new CreateSnapshotResponse();
protected CreateSnapshotResponse read(StreamInput in) throws IOException {
return new CreateSnapshotResponse(in);
}
@Override

View File

@ -80,11 +80,6 @@ public class GetSnapshotsResponse extends ActionResponse implements ToXContentOb
return snapshots;
}
@Override
public void readFrom(StreamInput in) throws IOException {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(snapshots.size());

View File

@ -58,7 +58,7 @@ public class RestoreClusterStateListener implements ClusterStateListener {
// on the current master and as such it might miss some intermediary cluster states due to batching.
// Clean up listener in that case and acknowledge completion of restore operation to client.
clusterService.removeListener(this);
listener.onResponse(new RestoreSnapshotResponse(null));
listener.onResponse(new RestoreSnapshotResponse((RestoreInfo) null));
} else if (newEntry == null) {
clusterService.removeListener(this);
ImmutableOpenMap<ShardId, RestoreInProgress.ShardRestoreStatus> shards = prevEntry.shards();

View File

@ -19,23 +19,18 @@
package org.elasticsearch.action.admin.cluster.snapshots.restore;
import org.elasticsearch.action.StreamableResponseActionType;
import org.elasticsearch.action.ActionType;
/**
* Restore snapshot action
*/
public class RestoreSnapshotAction extends StreamableResponseActionType<RestoreSnapshotResponse> {
public class RestoreSnapshotAction extends ActionType<RestoreSnapshotResponse> {
public static final RestoreSnapshotAction INSTANCE = new RestoreSnapshotAction();
public static final String NAME = "cluster:admin/snapshot/restore";
private RestoreSnapshotAction() {
super(NAME);
}
@Override
public RestoreSnapshotResponse newResponse() {
return new RestoreSnapshotResponse();
super(NAME, RestoreSnapshotResponse::new);
}
}

View File

@ -49,7 +49,9 @@ public class RestoreSnapshotResponse extends ActionResponse implements ToXConten
this.restoreInfo = restoreInfo;
}
RestoreSnapshotResponse() {
public RestoreSnapshotResponse(StreamInput in) throws IOException {
super(in);
restoreInfo = RestoreInfo.readOptionalRestoreInfo(in);
}
/**
@ -61,12 +63,6 @@ public class RestoreSnapshotResponse extends ActionResponse implements ToXConten
return restoreInfo;
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
restoreInfo = RestoreInfo.readOptionalRestoreInfo(in);
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeOptionalWriteable(restoreInfo);

View File

@ -21,21 +21,24 @@ package org.elasticsearch.action.admin.cluster.snapshots.restore;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.StreamableTransportMasterNodeAction;
import org.elasticsearch.action.support.master.TransportMasterNodeAction;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.cluster.block.ClusterBlockLevel;
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.RestoreService;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import java.io.IOException;
/**
* Transport action for restore snapshot operation
*/
public class TransportRestoreSnapshotAction extends StreamableTransportMasterNodeAction<RestoreSnapshotRequest, RestoreSnapshotResponse> {
public class TransportRestoreSnapshotAction extends TransportMasterNodeAction<RestoreSnapshotRequest, RestoreSnapshotResponse> {
private final RestoreService restoreService;
@Inject
@ -55,8 +58,8 @@ public class TransportRestoreSnapshotAction extends StreamableTransportMasterNod
}
@Override
protected RestoreSnapshotResponse newResponse() {
return new RestoreSnapshotResponse();
protected RestoreSnapshotResponse read(StreamInput in) throws IOException {
return new RestoreSnapshotResponse(in);
}
@Override

View File

@ -19,23 +19,18 @@
package org.elasticsearch.action.admin.cluster.snapshots.status;
import org.elasticsearch.action.StreamableResponseActionType;
import org.elasticsearch.action.ActionType;
/**
* Snapshots status action
*/
public class SnapshotsStatusAction extends StreamableResponseActionType<SnapshotsStatusResponse> {
public class SnapshotsStatusAction extends ActionType<SnapshotsStatusResponse> {
public static final SnapshotsStatusAction INSTANCE = new SnapshotsStatusAction();
public static final String NAME = "cluster:admin/snapshot/status";
private SnapshotsStatusAction() {
super(NAME);
}
@Override
public SnapshotsStatusResponse newResponse() {
return new SnapshotsStatusResponse();
super(NAME, SnapshotsStatusResponse::new);
}
}

View File

@ -42,7 +42,14 @@ public class SnapshotsStatusResponse extends ActionResponse implements ToXConten
private List<SnapshotStatus> snapshots = Collections.emptyList();
SnapshotsStatusResponse() {
public SnapshotsStatusResponse(StreamInput in) throws IOException {
super(in);
int size = in.readVInt();
List<SnapshotStatus> builder = new ArrayList<>();
for (int i = 0; i < size; i++) {
builder.add(SnapshotStatus.readSnapshotStatus(in));
}
snapshots = Collections.unmodifiableList(builder);
}
SnapshotsStatusResponse(List<SnapshotStatus> snapshots) {
@ -58,17 +65,6 @@ public class SnapshotsStatusResponse extends ActionResponse implements ToXConten
return snapshots;
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
int size = in.readVInt();
List<SnapshotStatus> builder = new ArrayList<>();
for (int i = 0; i < size; i++) {
builder.add(SnapshotStatus.readSnapshotStatus(in));
}
snapshots = Collections.unmodifiableList(builder);
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(snapshots.size());

View File

@ -23,7 +23,7 @@ import com.carrotsearch.hppc.cursors.ObjectCursor;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.StreamableTransportMasterNodeAction;
import org.elasticsearch.action.support.master.TransportMasterNodeAction;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.SnapshotsInProgress;
import org.elasticsearch.cluster.block.ClusterBlockException;
@ -32,6 +32,7 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
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.util.set.Sets;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.index.snapshots.IndexShardSnapshotStatus;
@ -56,7 +57,7 @@ import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
public class TransportSnapshotsStatusAction extends StreamableTransportMasterNodeAction<SnapshotsStatusRequest, SnapshotsStatusResponse> {
public class TransportSnapshotsStatusAction extends TransportMasterNodeAction<SnapshotsStatusRequest, SnapshotsStatusResponse> {
private final SnapshotsService snapshotsService;
@ -84,8 +85,8 @@ public class TransportSnapshotsStatusAction extends StreamableTransportMasterNod
}
@Override
protected SnapshotsStatusResponse newResponse() {
return new SnapshotsStatusResponse();
protected SnapshotsStatusResponse read(StreamInput in) throws IOException {
return new SnapshotsStatusResponse(in);
}
@Override

View File

@ -19,19 +19,14 @@
package org.elasticsearch.action.admin.cluster.state;
import org.elasticsearch.action.StreamableResponseActionType;
import org.elasticsearch.action.ActionType;
public class ClusterStateAction extends StreamableResponseActionType<ClusterStateResponse> {
public class ClusterStateAction extends ActionType<ClusterStateResponse> {
public static final ClusterStateAction INSTANCE = new ClusterStateAction();
public static final String NAME = "cluster:monitor/state";
private ClusterStateAction() {
super(NAME);
}
@Override
public ClusterStateResponse newResponse() {
return new ClusterStateResponse();
super(NAME, ClusterStateResponse::new);
}
}

View File

@ -41,7 +41,20 @@ public class ClusterStateResponse extends ActionResponse {
private ClusterState clusterState;
private boolean waitForTimedOut = false;
public ClusterStateResponse() {
public ClusterStateResponse(StreamInput in) throws IOException {
super(in);
clusterName = new ClusterName(in);
if (in.getVersion().onOrAfter(Version.V_6_6_0)) {
clusterState = in.readOptionalWriteable(innerIn -> ClusterState.readFrom(innerIn, null));
} else {
clusterState = ClusterState.readFrom(in, null);
}
if (in.getVersion().before(Version.V_7_0_0)) {
new ByteSizeValue(in);
}
if (in.getVersion().onOrAfter(Version.V_6_6_0)) {
waitForTimedOut = in.readBoolean();
}
}
public ClusterStateResponse(ClusterName clusterName, ClusterState clusterState, boolean waitForTimedOut) {
@ -73,23 +86,6 @@ public class ClusterStateResponse extends ActionResponse {
return waitForTimedOut;
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
clusterName = new ClusterName(in);
if (in.getVersion().onOrAfter(Version.V_6_6_0)) {
clusterState = in.readOptionalWriteable(innerIn -> ClusterState.readFrom(innerIn, null));
} else {
clusterState = ClusterState.readFrom(in, null);
}
if (in.getVersion().before(Version.V_7_0_0)) {
new ByteSizeValue(in);
}
if (in.getVersion().onOrAfter(Version.V_6_6_0)) {
waitForTimedOut = in.readBoolean();
}
}
@Override
public void writeTo(StreamOutput out) throws IOException {
clusterName.writeTo(out);

View File

@ -24,7 +24,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.StreamableTransportMasterNodeReadAction;
import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.ClusterStateObserver;
import org.elasticsearch.cluster.NotMasterException;
@ -36,6 +36,7 @@ import org.elasticsearch.cluster.metadata.MetaData.Custom;
import org.elasticsearch.cluster.routing.RoutingTable;
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.node.NodeClosedException;
import org.elasticsearch.threadpool.ThreadPool;
@ -44,7 +45,7 @@ import org.elasticsearch.transport.TransportService;
import java.io.IOException;
import java.util.function.Predicate;
public class TransportClusterStateAction extends StreamableTransportMasterNodeReadAction<ClusterStateRequest, ClusterStateResponse> {
public class TransportClusterStateAction extends TransportMasterNodeReadAction<ClusterStateRequest, ClusterStateResponse> {
private final Logger logger = LogManager.getLogger(getClass());
@ -69,6 +70,11 @@ public class TransportClusterStateAction extends StreamableTransportMasterNodeRe
return ThreadPool.Names.SAME;
}
@Override
protected ClusterStateResponse read(StreamInput in) throws IOException {
return new ClusterStateResponse(in);
}
@Override
protected ClusterBlockException checkBlock(ClusterStateRequest request, ClusterState state) {
// cluster state calls are done also on a fully blocked cluster to figure out what is going
@ -78,11 +84,6 @@ public class TransportClusterStateAction extends StreamableTransportMasterNodeRe
return null;
}
@Override
protected ClusterStateResponse newResponse() {
return new ClusterStateResponse();
}
@Override
protected void masterOperation(final ClusterStateRequest request, final ClusterState state,
final ActionListener<ClusterStateResponse> listener) throws IOException {

View File

@ -19,19 +19,14 @@
package org.elasticsearch.action.admin.cluster.storedscripts;
import org.elasticsearch.action.StreamableResponseActionType;
import org.elasticsearch.action.ActionType;
public class GetStoredScriptAction extends StreamableResponseActionType<GetStoredScriptResponse> {
public class GetStoredScriptAction extends ActionType<GetStoredScriptResponse> {
public static final GetStoredScriptAction INSTANCE = new GetStoredScriptAction();
public static final String NAME = "cluster:admin/script/get";
private GetStoredScriptAction() {
super(NAME);
}
@Override
public GetStoredScriptResponse newResponse() {
return new GetStoredScriptResponse();
super(NAME, GetStoredScriptResponse::new);
}
}

View File

@ -66,7 +66,18 @@ public class GetStoredScriptResponse extends ActionResponse implements StatusToX
private String id;
private StoredScriptSource source;
GetStoredScriptResponse() {
public GetStoredScriptResponse(StreamInput in) throws IOException {
super(in);
if (in.readBoolean()) {
source = new StoredScriptSource(in);
} else {
source = null;
}
if (in.getVersion().onOrAfter(Version.V_6_4_0)) {
id = in.readString();
}
}
GetStoredScriptResponse(String id, StoredScriptSource source) {
@ -109,21 +120,6 @@ public class GetStoredScriptResponse extends ActionResponse implements StatusToX
return PARSER.parse(parser, null);
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
if (in.readBoolean()) {
source = new StoredScriptSource(in);
} else {
source = null;
}
if (in.getVersion().onOrAfter(Version.V_6_4_0)) {
id = in.readString();
}
}
@Override
public void writeTo(StreamOutput out) throws IOException {
if (source == null) {

View File

@ -21,18 +21,21 @@ package org.elasticsearch.action.admin.cluster.storedscripts;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.StreamableTransportMasterNodeReadAction;
import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.cluster.block.ClusterBlockLevel;
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;
public class TransportGetStoredScriptAction extends StreamableTransportMasterNodeReadAction<GetStoredScriptRequest,
import java.io.IOException;
public class TransportGetStoredScriptAction extends TransportMasterNodeReadAction<GetStoredScriptRequest,
GetStoredScriptResponse> {
private final ScriptService scriptService;
@ -52,8 +55,8 @@ public class TransportGetStoredScriptAction extends StreamableTransportMasterNod
}
@Override
protected GetStoredScriptResponse newResponse() {
return new GetStoredScriptResponse();
protected GetStoredScriptResponse read(StreamInput in) throws IOException {
return new GetStoredScriptResponse(in);
}
@Override

View File

@ -19,19 +19,14 @@
package org.elasticsearch.action.admin.cluster.tasks;
import org.elasticsearch.action.StreamableResponseActionType;
import org.elasticsearch.action.ActionType;
public class PendingClusterTasksAction extends StreamableResponseActionType<PendingClusterTasksResponse> {
public class PendingClusterTasksAction extends ActionType<PendingClusterTasksResponse> {
public static final PendingClusterTasksAction INSTANCE = new PendingClusterTasksAction();
public static final String NAME = "cluster:monitor/task";
private PendingClusterTasksAction() {
super(NAME);
}
@Override
public PendingClusterTasksResponse newResponse() {
return new PendingClusterTasksResponse();
super(NAME, PendingClusterTasksResponse::new);
}
}

View File

@ -35,7 +35,13 @@ public class PendingClusterTasksResponse extends ActionResponse implements Itera
private List<PendingClusterTask> pendingTasks;
PendingClusterTasksResponse() {
public PendingClusterTasksResponse(StreamInput in) throws IOException {
super(in);
int size = in.readVInt();
pendingTasks = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
pendingTasks.add(new PendingClusterTask(in));
}
}
PendingClusterTasksResponse(List<PendingClusterTask> pendingTasks) {
@ -100,16 +106,6 @@ public class PendingClusterTasksResponse extends ActionResponse implements Itera
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
int size = in.readVInt();
pendingTasks = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
pendingTasks.add(new PendingClusterTask(in));
}
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(pendingTasks.size());

View File

@ -21,7 +21,7 @@ package org.elasticsearch.action.admin.cluster.tasks;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.StreamableTransportMasterNodeReadAction;
import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.cluster.block.ClusterBlockLevel;
@ -29,13 +29,15 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.cluster.service.PendingClusterTask;
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.List;
public class TransportPendingClusterTasksAction
extends StreamableTransportMasterNodeReadAction<PendingClusterTasksRequest, PendingClusterTasksResponse> {
extends TransportMasterNodeReadAction<PendingClusterTasksRequest, PendingClusterTasksResponse> {
private final ClusterService clusterService;
@ -44,7 +46,7 @@ public class TransportPendingClusterTasksAction
ThreadPool threadPool, ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver) {
super(PendingClusterTasksAction.NAME, transportService, clusterService, threadPool, actionFilters,
PendingClusterTasksRequest::new, indexNameExpressionResolver);
PendingClusterTasksRequest::new, indexNameExpressionResolver);
this.clusterService = clusterService;
}
@ -55,13 +57,13 @@ public class TransportPendingClusterTasksAction
}
@Override
protected ClusterBlockException checkBlock(PendingClusterTasksRequest request, ClusterState state) {
return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_READ);
protected PendingClusterTasksResponse read(StreamInput in) throws IOException {
return new PendingClusterTasksResponse(in);
}
@Override
protected PendingClusterTasksResponse newResponse() {
return new PendingClusterTasksResponse();
protected ClusterBlockException checkBlock(PendingClusterTasksRequest request, ClusterState state) {
return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_READ);
}
@Override

View File

@ -19,19 +19,14 @@
package org.elasticsearch.action.admin.indices.alias.exists;
import org.elasticsearch.action.StreamableResponseActionType;
import org.elasticsearch.action.ActionType;
public class AliasesExistAction extends StreamableResponseActionType<AliasesExistResponse> {
public class AliasesExistAction extends ActionType<AliasesExistResponse> {
public static final AliasesExistAction INSTANCE = new AliasesExistAction();
public static final String NAME = "indices:admin/aliases/exists";
private AliasesExistAction() {
super(NAME);
}
@Override
public AliasesExistResponse newResponse() {
return new AliasesExistResponse();
super(NAME, AliasesExistResponse::new);
}
}

View File

@ -33,7 +33,9 @@ public class AliasesExistResponse extends ActionResponse {
this.exists = exists;
}
AliasesExistResponse() {
AliasesExistResponse(StreamInput in) throws IOException {
super(in);
exists = in.readBoolean();
}
public boolean exists() {
@ -44,12 +46,6 @@ public class AliasesExistResponse extends ActionResponse {
return exists();
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
exists = in.readBoolean();
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeBoolean(exists);

View File

@ -21,17 +21,20 @@ package org.elasticsearch.action.admin.indices.alias.exists;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.StreamableTransportMasterNodeReadAction;
import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.cluster.block.ClusterBlockLevel;
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;
public class TransportAliasesExistAction extends StreamableTransportMasterNodeReadAction<GetAliasesRequest, AliasesExistResponse> {
import java.io.IOException;
public class TransportAliasesExistAction extends TransportMasterNodeReadAction<GetAliasesRequest, AliasesExistResponse> {
@Inject
public TransportAliasesExistAction(TransportService transportService, ClusterService clusterService,
@ -48,14 +51,14 @@ public class TransportAliasesExistAction extends StreamableTransportMasterNodeRe
}
@Override
protected ClusterBlockException checkBlock(GetAliasesRequest request, ClusterState state) {
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ,
indexNameExpressionResolver.concreteIndexNames(state, request));
protected AliasesExistResponse read(StreamInput in) throws IOException {
return new AliasesExistResponse(in);
}
@Override
protected AliasesExistResponse newResponse() {
return new AliasesExistResponse();
protected ClusterBlockException checkBlock(GetAliasesRequest request, ClusterState state) {
return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ,
indexNameExpressionResolver.concreteIndexNames(state, request));
}
@Override

View File

@ -19,19 +19,14 @@
package org.elasticsearch.action.admin.indices.alias.get;
import org.elasticsearch.action.StreamableResponseActionType;
import org.elasticsearch.action.ActionType;
public class GetAliasesAction extends StreamableResponseActionType<GetAliasesResponse> {
public class GetAliasesAction extends ActionType<GetAliasesResponse> {
public static final GetAliasesAction INSTANCE = new GetAliasesAction();
public static final String NAME = "indices:admin/aliases/get";
private GetAliasesAction() {
super(NAME);
}
@Override
public GetAliasesResponse newResponse() {
return new GetAliasesResponse();
super(NAME, GetAliasesResponse::new);
}
}

View File

@ -40,16 +40,8 @@ public class GetAliasesResponse extends ActionResponse {
this.aliases = aliases;
}
GetAliasesResponse() {
}
public ImmutableOpenMap<String, List<AliasMetaData>> getAliases() {
return aliases;
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
public GetAliasesResponse(StreamInput in) throws IOException {
super(in);
int size = in.readVInt();
ImmutableOpenMap.Builder<String, List<AliasMetaData>> aliasesBuilder = ImmutableOpenMap.builder();
for (int i = 0; i < size; i++) {
@ -64,6 +56,10 @@ public class GetAliasesResponse extends ActionResponse {
aliases = aliasesBuilder.build();
}
public ImmutableOpenMap<String, List<AliasMetaData>> getAliases() {
return aliases;
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(aliases.size());

View File

@ -20,7 +20,7 @@ package org.elasticsearch.action.admin.indices.alias.get;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.StreamableTransportMasterNodeReadAction;
import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.cluster.block.ClusterBlockLevel;
@ -29,13 +29,15 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
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.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
public class TransportGetAliasesAction extends StreamableTransportMasterNodeReadAction<GetAliasesRequest, GetAliasesResponse> {
public class TransportGetAliasesAction extends TransportMasterNodeReadAction<GetAliasesRequest, GetAliasesResponse> {
@Inject
public TransportGetAliasesAction(TransportService transportService, ClusterService clusterService,
@ -58,8 +60,8 @@ public class TransportGetAliasesAction extends StreamableTransportMasterNodeRead
}
@Override
protected GetAliasesResponse newResponse() {
return new GetAliasesResponse();
protected GetAliasesResponse read(StreamInput in) throws IOException {
return new GetAliasesResponse(in);
}
@Override

View File

@ -313,11 +313,6 @@ public class AnalyzeAction extends ActionType<AnalyzeAction.Response> {
detail = in.readOptionalWriteable(DetailAnalyzeResponse::new);
}
@Override
public void readFrom(StreamInput in) throws IOException {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
public List<AnalyzeToken> getTokens() {
return this.tokens;
}

View File

@ -19,19 +19,14 @@
package org.elasticsearch.action.admin.indices.exists.indices;
import org.elasticsearch.action.StreamableResponseActionType;
import org.elasticsearch.action.ActionType;
public class IndicesExistsAction extends StreamableResponseActionType<IndicesExistsResponse> {
public class IndicesExistsAction extends ActionType<IndicesExistsResponse> {
public static final IndicesExistsAction INSTANCE = new IndicesExistsAction();
public static final String NAME = "indices:admin/exists";
private IndicesExistsAction() {
super(NAME);
}
@Override
public IndicesExistsResponse newResponse() {
return new IndicesExistsResponse();
super(NAME, IndicesExistsResponse::new);
}
}

View File

@ -29,7 +29,9 @@ public class IndicesExistsResponse extends ActionResponse {
private boolean exists;
IndicesExistsResponse() {
IndicesExistsResponse(StreamInput in) throws IOException {
super(in);
exists = in.readBoolean();
}
public IndicesExistsResponse(boolean exists) {
@ -40,12 +42,6 @@ public class IndicesExistsResponse extends ActionResponse {
return this.exists;
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
exists = in.readBoolean();
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeBoolean(exists);

View File

@ -22,21 +22,24 @@ package org.elasticsearch.action.admin.indices.exists.indices;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.action.support.master.StreamableTransportMasterNodeReadAction;
import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.cluster.block.ClusterBlockLevel;
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.index.IndexNotFoundException;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import java.io.IOException;
/**
* Indices exists action.
*/
public class TransportIndicesExistsAction extends StreamableTransportMasterNodeReadAction<IndicesExistsRequest, IndicesExistsResponse> {
public class TransportIndicesExistsAction extends TransportMasterNodeReadAction<IndicesExistsRequest, IndicesExistsResponse> {
@Inject
public TransportIndicesExistsAction(TransportService transportService, ClusterService clusterService,
@ -53,8 +56,8 @@ public class TransportIndicesExistsAction extends StreamableTransportMasterNodeR
}
@Override
protected IndicesExistsResponse newResponse() {
return new IndicesExistsResponse();
protected IndicesExistsResponse read(StreamInput in) throws IOException {
return new IndicesExistsResponse(in);
}
@Override

View File

@ -20,7 +20,7 @@ package org.elasticsearch.action.admin.indices.exists.types;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.StreamableTransportMasterNodeReadAction;
import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.cluster.block.ClusterBlockLevel;
@ -28,13 +28,16 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.metadata.MappingMetaData;
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;
/**
* Types exists transport action.
*/
public class TransportTypesExistsAction extends StreamableTransportMasterNodeReadAction<TypesExistsRequest, TypesExistsResponse> {
public class TransportTypesExistsAction extends TransportMasterNodeReadAction<TypesExistsRequest, TypesExistsResponse> {
@Inject
public TransportTypesExistsAction(TransportService transportService, ClusterService clusterService,
@ -51,8 +54,8 @@ public class TransportTypesExistsAction extends StreamableTransportMasterNodeRea
}
@Override
protected TypesExistsResponse newResponse() {
return new TypesExistsResponse();
protected TypesExistsResponse read(StreamInput in) throws IOException {
return new TypesExistsResponse(in);
}
@Override

View File

@ -18,19 +18,14 @@
*/
package org.elasticsearch.action.admin.indices.exists.types;
import org.elasticsearch.action.StreamableResponseActionType;
import org.elasticsearch.action.ActionType;
public class TypesExistsAction extends StreamableResponseActionType<TypesExistsResponse> {
public class TypesExistsAction extends ActionType<TypesExistsResponse> {
public static final TypesExistsAction INSTANCE = new TypesExistsAction();
public static final String NAME = "indices:admin/types/exists";
private TypesExistsAction() {
super(NAME);
}
@Override
public TypesExistsResponse newResponse() {
return new TypesExistsResponse();
super(NAME, TypesExistsResponse::new);
}
}

View File

@ -31,7 +31,9 @@ public class TypesExistsResponse extends ActionResponse {
private boolean exists;
TypesExistsResponse() {
TypesExistsResponse(StreamInput in) throws IOException {
super(in);
exists = in.readBoolean();
}
public TypesExistsResponse(boolean exists) {
@ -42,12 +44,6 @@ public class TypesExistsResponse extends ActionResponse {
return this.exists;
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
exists = in.readBoolean();
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeBoolean(exists);

View File

@ -198,11 +198,6 @@ public class SyncedFlushResponse extends ActionResponse implements ToXContentFra
static final String REASON = "reason";
}
@Override
public void readFrom(StreamInput in) throws IOException {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
@Override
public void writeTo(StreamOutput out) throws IOException {
shardCounts.writeTo(out);

View File

@ -198,11 +198,6 @@ public class GetIndexResponse extends ActionResponse implements ToXContentObject
}
}
@Override
public void readFrom(StreamInput in) throws IOException {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeStringArray(indices);

View File

@ -48,9 +48,7 @@ public class GetFieldMappingsRequest extends ActionRequest implements IndicesReq
private IndicesOptions indicesOptions = IndicesOptions.strictExpandOpen();
public GetFieldMappingsRequest() {
}
public GetFieldMappingsRequest() {}
public GetFieldMappingsRequest(StreamInput in) throws IOException {
super(in);
@ -140,9 +138,4 @@ public class GetFieldMappingsRequest extends ActionRequest implements IndicesReq
out.writeStringArray(fields);
out.writeBoolean(includeDefaults);
}
@Override
public void readFrom(StreamInput in) throws IOException {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
}

View File

@ -286,11 +286,6 @@ public class GetFieldMappingsResponse extends ActionResponse implements ToXConte
}
}
@Override
public void readFrom(StreamInput in) throws IOException {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(mappings.size());

View File

@ -71,11 +71,6 @@ public class GetMappingsResponse extends ActionResponse implements ToXContentFra
return mappings();
}
@Override
public void readFrom(StreamInput in) throws IOException {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(mappings.size());

View File

@ -19,19 +19,14 @@
package org.elasticsearch.action.admin.indices.settings.get;
import org.elasticsearch.action.StreamableResponseActionType;
import org.elasticsearch.action.ActionType;
public class GetSettingsAction extends StreamableResponseActionType<GetSettingsResponse> {
public class GetSettingsAction extends ActionType<GetSettingsResponse> {
public static final GetSettingsAction INSTANCE = new GetSettingsAction();
public static final String NAME = "indices:monitor/settings/get";
public GetSettingsAction() {
super(NAME);
}
@Override
public GetSettingsResponse newResponse() {
return new GetSettingsResponse();
super(NAME, GetSettingsResponse::new);
}
}

View File

@ -50,7 +50,24 @@ public class GetSettingsResponse extends ActionResponse implements ToXContentObj
this.indexToDefaultSettings = indexToDefaultSettings;
}
GetSettingsResponse() {
public GetSettingsResponse(StreamInput in) throws IOException {
super(in);
int settingsSize = in.readVInt();
ImmutableOpenMap.Builder<String, Settings> settingsBuilder = ImmutableOpenMap.builder();
for (int i = 0; i < settingsSize; i++) {
settingsBuilder.put(in.readString(), Settings.readSettingsFromStream(in));
}
ImmutableOpenMap.Builder<String, Settings> defaultSettingsBuilder = ImmutableOpenMap.builder();
if (in.getVersion().onOrAfter(org.elasticsearch.Version.V_6_4_0)) {
int defaultSettingsSize = in.readVInt();
for (int i = 0; i < defaultSettingsSize ; i++) {
defaultSettingsBuilder.put(in.readString(), Settings.readSettingsFromStream(in));
}
}
indexToSettings = settingsBuilder.build();
indexToDefaultSettings = defaultSettingsBuilder.build();
}
/**
@ -99,27 +116,6 @@ public class GetSettingsResponse extends ActionResponse implements ToXContentObj
}
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
int settingsSize = in.readVInt();
ImmutableOpenMap.Builder<String, Settings> settingsBuilder = ImmutableOpenMap.builder();
for (int i = 0; i < settingsSize; i++) {
settingsBuilder.put(in.readString(), Settings.readSettingsFromStream(in));
}
ImmutableOpenMap.Builder<String, Settings> defaultSettingsBuilder = ImmutableOpenMap.builder();
if (in.getVersion().onOrAfter(org.elasticsearch.Version.V_6_4_0)) {
int defaultSettingsSize = in.readVInt();
for (int i = 0; i < defaultSettingsSize ; i++) {
defaultSettingsBuilder.put(in.readString(), Settings.readSettingsFromStream(in));
}
}
indexToSettings = settingsBuilder.build();
indexToDefaultSettings = defaultSettingsBuilder.build();
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(indexToSettings.size());

View File

@ -21,7 +21,7 @@ package org.elasticsearch.action.admin.indices.settings.get;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.StreamableTransportMasterNodeReadAction;
import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.cluster.block.ClusterBlockLevel;
@ -30,6 +30,7 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
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.common.regex.Regex;
import org.elasticsearch.common.settings.IndexScopedSettings;
import org.elasticsearch.common.settings.Settings;
@ -39,8 +40,10 @@ import org.elasticsearch.index.Index;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import java.io.IOException;
public class TransportGetSettingsAction extends StreamableTransportMasterNodeReadAction<GetSettingsRequest, GetSettingsResponse> {
public class TransportGetSettingsAction extends TransportMasterNodeReadAction<GetSettingsRequest, GetSettingsResponse> {
private final SettingsFilter settingsFilter;
private final IndexScopedSettings indexScopedSettings;
@ -70,8 +73,8 @@ public class TransportGetSettingsAction extends StreamableTransportMasterNodeRea
@Override
protected GetSettingsResponse newResponse() {
return new GetSettingsResponse();
protected GetSettingsResponse read(StreamInput in) throws IOException {
return new GetSettingsResponse(in);
}
private static boolean isFilteredRequest(GetSettingsRequest request) {

View File

@ -19,7 +19,7 @@
package org.elasticsearch.action.admin.indices.shards;
import org.elasticsearch.action.StreamableResponseActionType;
import org.elasticsearch.action.ActionType;
/**
* ActionType for {@link TransportIndicesShardStoresAction}
@ -28,17 +28,12 @@ import org.elasticsearch.action.StreamableResponseActionType;
* Shard store information reports which nodes hold shard copies, how recent they are
* and any exceptions on opening the shard index or from previous engine failures
*/
public class IndicesShardStoresAction extends StreamableResponseActionType<IndicesShardStoresResponse> {
public class IndicesShardStoresAction extends ActionType<IndicesShardStoresResponse> {
public static final IndicesShardStoresAction INSTANCE = new IndicesShardStoresAction();
public static final String NAME = "indices:monitor/shard_stores";
private IndicesShardStoresAction() {
super(NAME);
}
@Override
public IndicesShardStoresResponse newResponse() {
return new IndicesShardStoresResponse();
super(NAME, IndicesShardStoresResponse::new);
}
}

View File

@ -291,28 +291,7 @@ public class IndicesShardStoresResponse extends ActionResponse implements ToXCon
}
public IndicesShardStoresResponse(StreamInput in) throws IOException {
readFrom(in);
}
/**
* Returns {@link StoreStatus}s
* grouped by their index names and shard ids.
*/
public ImmutableOpenMap<String, ImmutableOpenIntMap<List<StoreStatus>>> getStoreStatuses() {
return storeStatuses;
}
/**
* Returns node {@link Failure}s encountered
* while executing the request
*/
public List<Failure> getFailures() {
return failures;
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
super(in);
int numResponse = in.readVInt();
ImmutableOpenMap.Builder<String, ImmutableOpenIntMap<List<StoreStatus>>> storeStatusesBuilder = ImmutableOpenMap.builder();
for (int i = 0; i < numResponse; i++) {
@ -339,6 +318,22 @@ public class IndicesShardStoresResponse extends ActionResponse implements ToXCon
failures = Collections.unmodifiableList(failureBuilder);
}
/**
* Returns {@link StoreStatus}s
* grouped by their index names and shard ids.
*/
public ImmutableOpenMap<String, ImmutableOpenIntMap<List<StoreStatus>>> getStoreStatuses() {
return storeStatuses;
}
/**
* Returns node {@link Failure}s encountered
* while executing the request
*/
public List<Failure> getFailures() {
return failures;
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(storeStatuses.size());

View File

@ -23,7 +23,7 @@ import org.apache.lucene.util.CollectionUtil;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.FailedNodeException;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.StreamableTransportMasterNodeReadAction;
import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.cluster.block.ClusterBlockLevel;
@ -41,6 +41,7 @@ import org.elasticsearch.cluster.service.ClusterService;
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.common.util.concurrent.CountDown;
import org.elasticsearch.gateway.AsyncShardFetch;
import org.elasticsearch.gateway.TransportNodesListGatewayStartedShards;
@ -49,6 +50,7 @@ import org.elasticsearch.index.shard.ShardId;
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;
@ -62,7 +64,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
* indices and fetches store information from all the nodes using {@link TransportNodesListGatewayStartedShards}
*/
public class TransportIndicesShardStoresAction
extends StreamableTransportMasterNodeReadAction<IndicesShardStoresRequest, IndicesShardStoresResponse> {
extends TransportMasterNodeReadAction<IndicesShardStoresRequest, IndicesShardStoresResponse> {
private final TransportNodesListGatewayStartedShards listShardStoresInfo;
@ -82,8 +84,8 @@ public class TransportIndicesShardStoresAction
}
@Override
protected IndicesShardStoresResponse newResponse() {
return new IndicesShardStoresResponse();
protected IndicesShardStoresResponse read(StreamInput in) throws IOException {
return new IndicesShardStoresResponse(in);
}
@Override

View File

@ -18,19 +18,14 @@
*/
package org.elasticsearch.action.admin.indices.template.get;
import org.elasticsearch.action.StreamableResponseActionType;
import org.elasticsearch.action.ActionType;
public class GetIndexTemplatesAction extends StreamableResponseActionType<GetIndexTemplatesResponse> {
public class GetIndexTemplatesAction extends ActionType<GetIndexTemplatesResponse> {
public static final GetIndexTemplatesAction INSTANCE = new GetIndexTemplatesAction();
public static final String NAME = "indices:admin/template/get";
protected GetIndexTemplatesAction() {
super(NAME);
}
@Override
public GetIndexTemplatesResponse newResponse() {
return new GetIndexTemplatesResponse();
super(NAME, GetIndexTemplatesResponse::new);
}
}

View File

@ -39,8 +39,13 @@ public class GetIndexTemplatesResponse extends ActionResponse implements ToXCont
private final List<IndexTemplateMetaData> indexTemplates;
GetIndexTemplatesResponse() {
public GetIndexTemplatesResponse(StreamInput in) throws IOException {
super(in);
int size = in.readVInt();
indexTemplates = new ArrayList<>();
for (int i = 0 ; i < size ; i++) {
indexTemplates.add(0, IndexTemplateMetaData.readFrom(in));
}
}
public GetIndexTemplatesResponse(List<IndexTemplateMetaData> indexTemplates) {
@ -51,16 +56,6 @@ public class GetIndexTemplatesResponse extends ActionResponse implements ToXCont
return indexTemplates;
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
int size = in.readVInt();
indexTemplates.clear();
for (int i = 0 ; i < size ; i++) {
indexTemplates.add(0, IndexTemplateMetaData.readFrom(in));
}
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(indexTemplates.size());

View File

@ -21,7 +21,7 @@ package org.elasticsearch.action.admin.indices.template.get;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.StreamableTransportMasterNodeReadAction;
import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.cluster.block.ClusterBlockLevel;
@ -29,16 +29,18 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.metadata.IndexTemplateMetaData;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.regex.Regex;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class TransportGetIndexTemplatesAction extends
StreamableTransportMasterNodeReadAction<GetIndexTemplatesRequest, GetIndexTemplatesResponse> {
TransportMasterNodeReadAction<GetIndexTemplatesRequest, GetIndexTemplatesResponse> {
@Inject
public TransportGetIndexTemplatesAction(TransportService transportService, ClusterService clusterService,
@ -54,13 +56,13 @@ public class TransportGetIndexTemplatesAction extends
}
@Override
protected ClusterBlockException checkBlock(GetIndexTemplatesRequest request, ClusterState state) {
return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_READ);
protected GetIndexTemplatesResponse read(StreamInput in) throws IOException {
return new GetIndexTemplatesResponse(in);
}
@Override
protected GetIndexTemplatesResponse newResponse() {
return new GetIndexTemplatesResponse();
protected ClusterBlockException checkBlock(GetIndexTemplatesRequest request, ClusterState state) {
return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_READ);
}
@Override

View File

@ -93,11 +93,6 @@ public class ShardValidateQueryRequest extends BroadcastShardRequest {
return this.nowInMillis;
}
@Override
public void readFrom(StreamInput in) throws IOException {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);

View File

@ -399,11 +399,6 @@ public class BulkRequest extends ActionRequest implements CompositeIndicesReques
return validationException;
}
@Override
public void readFrom(StreamInput in) throws IOException {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);

View File

@ -138,11 +138,6 @@ public class BulkResponse extends ActionResponse implements Iterable<BulkItemRes
return Arrays.stream(responses).iterator();
}
@Override
public void readFrom(StreamInput in) throws IOException {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(responses.length);

View File

@ -136,11 +136,6 @@ public class ExplainResponse extends ActionResponse implements StatusToXContentO
return exists ? RestStatus.OK : RestStatus.NOT_FOUND;
}
@Override
public void readFrom(StreamInput in) throws IOException {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeString(index);

View File

@ -40,11 +40,11 @@ public class FieldCapabilitiesIndexResponse extends ActionResponse implements Wr
this.responseMap = responseMap;
}
FieldCapabilitiesIndexResponse() {
}
FieldCapabilitiesIndexResponse(StreamInput input) throws IOException {
this.readFrom(input);
FieldCapabilitiesIndexResponse(StreamInput in) throws IOException {
super(in);
this.indexName = in.readString();
this.responseMap =
in.readMap(StreamInput::readString, FieldCapabilities::new);
}
@ -70,14 +70,6 @@ public class FieldCapabilitiesIndexResponse extends ActionResponse implements Wr
return responseMap.get(field);
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
this.indexName = in.readString();
this.responseMap =
in.readMap(StreamInput::readString, FieldCapabilities::new);
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeString(indexName);

View File

@ -90,11 +90,6 @@ public final class FieldCapabilitiesRequest extends ActionRequest implements Ind
this.mergeResults = mergeResults;
}
@Override
public void readFrom(StreamInput in) {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);

View File

@ -116,11 +116,6 @@ public class FieldCapabilitiesResponse extends ActionResponse implements ToXCont
return responseMap.get(field);
}
@Override
public void readFrom(StreamInput in) {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
private static Map<String, FieldCapabilities> readField(StreamInput in) throws IOException {
return in.readMap(StreamInput::readString, FieldCapabilities::new);
}

View File

@ -203,11 +203,6 @@ public class GetResponse extends ActionResponse implements Iterable<DocumentFiel
return new GetResponse(getResult);
}
@Override
public void readFrom(StreamInput in) throws IOException {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
@Override
public void writeTo(StreamOutput out) throws IOException {
getResult.writeTo(out);

View File

@ -545,11 +545,6 @@ public class MultiGetRequest extends ActionRequest
return Collections.unmodifiableCollection(items).iterator();
}
@Override
public void readFrom(StreamInput in) throws IOException {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);

View File

@ -238,11 +238,6 @@ public class MultiGetResponse extends ActionResponse implements Iterable<MultiGe
}
}
@Override
public void readFrom(StreamInput in) throws IOException {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(responses.length);

View File

@ -73,11 +73,6 @@ public class MultiGetShardResponse extends ActionResponse {
failures.add(failure);
}
@Override
public void readFrom(StreamInput in) throws IOException {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(locations.size());

View File

@ -19,19 +19,14 @@
package org.elasticsearch.action.ingest;
import org.elasticsearch.action.StreamableResponseActionType;
import org.elasticsearch.action.ActionType;
public class GetPipelineAction extends StreamableResponseActionType<GetPipelineResponse> {
public class GetPipelineAction extends ActionType<GetPipelineResponse> {
public static final GetPipelineAction INSTANCE = new GetPipelineAction();
public static final String NAME = "cluster:admin/ingest/pipeline/get";
public GetPipelineAction() {
super(NAME);
}
@Override
public GetPipelineResponse newResponse() {
return new GetPipelineResponse();
super(NAME, GetPipelineResponse::new);
}
}

View File

@ -44,7 +44,13 @@ public class GetPipelineResponse extends ActionResponse implements StatusToXCont
private List<PipelineConfiguration> pipelines;
public GetPipelineResponse() {
public GetPipelineResponse(StreamInput in) throws IOException {
super(in);
int size = in.readVInt();
pipelines = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
pipelines.add(PipelineConfiguration.readFrom(in));
}
}
public GetPipelineResponse(List<PipelineConfiguration> pipelines) {
@ -60,16 +66,6 @@ public class GetPipelineResponse extends ActionResponse implements StatusToXCont
return Collections.unmodifiableList(pipelines);
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
int size = in.readVInt();
pipelines = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
pipelines.add(PipelineConfiguration.readFrom(in));
}
}
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeVInt(pipelines.size());

View File

@ -21,18 +21,21 @@ package org.elasticsearch.action.ingest;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.master.StreamableTransportMasterNodeReadAction;
import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.cluster.block.ClusterBlockLevel;
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.ingest.IngestService;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService;
public class GetPipelineTransportAction extends StreamableTransportMasterNodeReadAction<GetPipelineRequest, GetPipelineResponse> {
import java.io.IOException;
public class GetPipelineTransportAction extends TransportMasterNodeReadAction<GetPipelineRequest, GetPipelineResponse> {
@Inject
public GetPipelineTransportAction(ThreadPool threadPool, ClusterService clusterService,
@ -48,8 +51,8 @@ public class GetPipelineTransportAction extends StreamableTransportMasterNodeRea
}
@Override
protected GetPipelineResponse newResponse() {
return new GetPipelineResponse();
protected GetPipelineResponse read(StreamInput in) throws IOException {
return new GetPipelineResponse(in);
}
@Override

View File

@ -19,19 +19,14 @@
package org.elasticsearch.action.ingest;
import org.elasticsearch.action.StreamableResponseActionType;
import org.elasticsearch.action.ActionType;
public class SimulatePipelineAction extends StreamableResponseActionType<SimulatePipelineResponse> {
public class SimulatePipelineAction extends ActionType<SimulatePipelineResponse> {
public static final SimulatePipelineAction INSTANCE = new SimulatePipelineAction();
public static final String NAME = "cluster:admin/ingest/pipeline/simulate";
public SimulatePipelineAction() {
super(NAME);
}
@Override
public SimulatePipelineResponse newResponse() {
return new SimulatePipelineResponse();
super(NAME, SimulatePipelineResponse::new);
}
}

View File

@ -102,11 +102,6 @@ public class SimulatePipelineRequest extends ActionRequest implements ToXContent
return xContentType;
}
@Override
public void readFrom(StreamInput in) throws IOException {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);

View File

@ -103,8 +103,21 @@ public class SimulatePipelineResponse extends ActionResponse implements ToXConte
new ParseField(Fields.DOCUMENTS));
}
public SimulatePipelineResponse() {
public SimulatePipelineResponse(StreamInput in) throws IOException {
super(in);
this.pipelineId = in.readOptionalString();
boolean verbose = in.readBoolean();
int responsesLength = in.readVInt();
results = new ArrayList<>();
for (int i = 0; i < responsesLength; i++) {
SimulateDocumentResult simulateDocumentResult;
if (verbose) {
simulateDocumentResult = new SimulateDocumentVerboseResult(in);
} else {
simulateDocumentResult = new SimulateDocumentBaseResult(in);
}
results.add(simulateDocumentResult);
}
}
public SimulatePipelineResponse(String pipelineId, boolean verbose, List<SimulateDocumentResult> responses) {
@ -135,24 +148,6 @@ public class SimulatePipelineResponse extends ActionResponse implements ToXConte
}
}
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
this.pipelineId = in.readOptionalString();
boolean verbose = in.readBoolean();
int responsesLength = in.readVInt();
results = new ArrayList<>();
for (int i = 0; i < responsesLength; i++) {
SimulateDocumentResult simulateDocumentResult;
if (verbose) {
simulateDocumentResult = new SimulateDocumentVerboseResult(in);
} else {
simulateDocumentResult = new SimulateDocumentBaseResult(in);
}
results.add(simulateDocumentResult);
}
}
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();

View File

@ -29,5 +29,4 @@ public class MainAction extends ActionType<MainResponse> {
public MainAction() {
super(NAME, MainResponse::new);
}
}

View File

@ -37,9 +37,4 @@ public class MainRequest extends ActionRequest {
public ActionRequestValidationException validate() {
return null;
}
@Override
public void readFrom(StreamInput in) throws IOException {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
}

View File

@ -97,11 +97,6 @@ public class MainResponse extends ActionResponse implements ToXContentObject {
}
}
@Override
public void readFrom(StreamInput in) throws IOException {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();

View File

@ -77,11 +77,6 @@ public class ClearScrollRequest extends ActionRequest implements ToXContentObjec
return validationException;
}
@Override
public void readFrom(StreamInput in) {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);

Some files were not shown because too many files have changed in this diff Show More