Skip to content

Commit

Permalink
convert more admin requests to writeable
Browse files Browse the repository at this point in the history
  • Loading branch information
talevy committed Sep 10, 2017
1 parent d00d18a commit c4b5733
Show file tree
Hide file tree
Showing 37 changed files with 288 additions and 209 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ public GetRepositoriesRequest(String[] repositories) {
this.repositories = repositories;
}

public GetRepositoriesRequest(StreamInput in) throws IOException {
super(in);
repositories = in.readStringArray();
}

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeStringArray(repositories);
}

@Override
public ActionRequestValidationException validate() {
ActionRequestValidationException validationException = null;
Expand Down Expand Up @@ -85,13 +96,6 @@ public GetRepositoriesRequest repositories(String[] repositories) {

@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
repositories = in.readStringArray();
}

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeStringArray(repositories);
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class TransportGetRepositoriesAction extends TransportMasterNodeReadActio
@Inject
public TransportGetRepositoriesAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
super(settings, GetRepositoriesAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, GetRepositoriesRequest::new);
super(settings, GetRepositoriesAction.NAME, transportService, clusterService, threadPool, actionFilters, GetRepositoriesRequest::new, indexNameExpressionResolver);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,42 @@ public ClusterSearchShardsRequest(String... indices) {
indices(indices);
}

public ClusterSearchShardsRequest(StreamInput in) throws IOException {
super(in);
indices = new String[in.readVInt()];
for (int i = 0; i < indices.length; i++) {
indices[i] = in.readString();
}

routing = in.readOptionalString();
preference = in.readOptionalString();

if (in.getVersion().onOrBefore(Version.V_5_1_1)) {
//types
in.readStringArray();
}
indicesOptions = IndicesOptions.readIndicesOptions(in);
}

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);

out.writeVInt(indices.length);
for (String index : indices) {
out.writeString(index);
}

out.writeOptionalString(routing);
out.writeOptionalString(preference);

if (out.getVersion().onOrBefore(Version.V_5_1_1)) {
//types
out.writeStringArray(Strings.EMPTY_ARRAY);
}
indicesOptions.writeIndicesOptions(out);
}

@Override
public ActionRequestValidationException validate() {
return null;
Expand Down Expand Up @@ -124,40 +160,6 @@ public String preference() {

@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);

indices = new String[in.readVInt()];
for (int i = 0; i < indices.length; i++) {
indices[i] = in.readString();
}

routing = in.readOptionalString();
preference = in.readOptionalString();

if (in.getVersion().onOrBefore(Version.V_5_1_1)) {
//types
in.readStringArray();
}
indicesOptions = IndicesOptions.readIndicesOptions(in);
}

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);

out.writeVInt(indices.length);
for (String index : indices) {
out.writeString(index);
}

out.writeOptionalString(routing);
out.writeOptionalString(preference);

if (out.getVersion().onOrBefore(Version.V_5_1_1)) {
//types
out.writeStringArray(Strings.EMPTY_ARRAY);
}
indicesOptions.writeIndicesOptions(out);
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public TransportClusterSearchShardsAction(Settings settings, TransportService tr
IndicesService indicesService, ThreadPool threadPool, ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver) {
super(settings, ClusterSearchShardsAction.NAME, transportService, clusterService, threadPool, actionFilters,
indexNameExpressionResolver, ClusterSearchShardsRequest::new);
ClusterSearchShardsRequest::new, indexNameExpressionResolver);
this.indicesService = indicesService;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,29 @@ public class ClusterStateRequest extends MasterNodeReadRequest<ClusterStateReque
public ClusterStateRequest() {
}

public ClusterStateRequest(StreamInput in) throws IOException {
super(in);
routingTable = in.readBoolean();
nodes = in.readBoolean();
metaData = in.readBoolean();
blocks = in.readBoolean();
customs = in.readBoolean();
indices = in.readStringArray();
indicesOptions = IndicesOptions.readIndicesOptions(in);
}

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeBoolean(routingTable);
out.writeBoolean(nodes);
out.writeBoolean(metaData);
out.writeBoolean(blocks);
out.writeBoolean(customs);
out.writeStringArray(indices);
indicesOptions.writeIndicesOptions(out);
}

@Override
public ActionRequestValidationException validate() {
return null;
Expand Down Expand Up @@ -135,25 +158,6 @@ public boolean customs() {

@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
routingTable = in.readBoolean();
nodes = in.readBoolean();
metaData = in.readBoolean();
blocks = in.readBoolean();
customs = in.readBoolean();
indices = in.readStringArray();
indicesOptions = IndicesOptions.readIndicesOptions(in);
}

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeBoolean(routingTable);
out.writeBoolean(nodes);
out.writeBoolean(metaData);
out.writeBoolean(blocks);
out.writeBoolean(customs);
out.writeStringArray(indices);
indicesOptions.writeIndicesOptions(out);
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class TransportClusterStateAction extends TransportMasterNodeReadAction<C
@Inject
public TransportClusterStateAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool,
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
super(settings, ClusterStateAction.NAME, false, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, ClusterStateRequest::new);
super(settings, ClusterStateAction.NAME, false, transportService, clusterService, threadPool, actionFilters, ClusterStateRequest::new, indexNameExpressionResolver);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,26 @@ public GetStoredScriptRequest(String id) {
this.id = id;
}

public GetStoredScriptRequest(StreamInput in) throws IOException {
super(in);
if (in.getVersion().before(Version.V_6_0_0_alpha2)) {
in.readString(); // read lang from previous versions
}

id = in.readString();
}

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);

if (out.getVersion().before(Version.V_6_0_0_alpha2)) {
out.writeString(""); // write an empty lang to previous versions
}

out.writeString(id);
}

@Override
public ActionRequestValidationException validate() {
ActionRequestValidationException validationException = null;
Expand All @@ -68,24 +88,7 @@ public GetStoredScriptRequest id(String id) {

@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);

if (in.getVersion().before(Version.V_6_0_0_alpha2)) {
in.readString(); // read lang from previous versions
}

id = in.readString();
}

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);

if (out.getVersion().before(Version.V_6_0_0_alpha2)) {
out.writeString(""); // write an empty lang to previous versions
}

out.writeString(id);
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public TransportGetStoredScriptAction(Settings settings, TransportService transp
ThreadPool threadPool, ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver, ScriptService scriptService) {
super(settings, GetStoredScriptAction.NAME, transportService, clusterService, threadPool, actionFilters,
indexNameExpressionResolver, GetStoredScriptRequest::new);
GetStoredScriptRequest::new, indexNameExpressionResolver);
this.scriptService = scriptService;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,19 @@

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 PendingClusterTasksRequest extends MasterNodeReadRequest<PendingClusterTasksRequest> {

public PendingClusterTasksRequest() {
}

public PendingClusterTasksRequest(StreamInput in) throws IOException {
super(in);
}

@Override
public ActionRequestValidationException validate() {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class TransportPendingClusterTasksAction extends TransportMasterNodeReadA
@Inject
public TransportPendingClusterTasksAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
super(settings, PendingClusterTasksAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, PendingClusterTasksRequest::new);
super(settings, PendingClusterTasksAction.NAME, transportService, clusterService, threadPool, actionFilters, PendingClusterTasksRequest::new, indexNameExpressionResolver);
this.clusterService = clusterService;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class TransportAliasesExistAction extends TransportMasterNodeReadAction<G
@Inject
public TransportAliasesExistAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
super(settings, AliasesExistAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, GetAliasesRequest::new);
super(settings, AliasesExistAction.NAME, transportService, clusterService, threadPool, actionFilters, GetAliasesRequest::new, indexNameExpressionResolver);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,21 @@ public GetAliasesRequest(String alias) {
public GetAliasesRequest() {
}

public GetAliasesRequest(StreamInput in) throws IOException {
super(in);
indices = in.readStringArray();
aliases = in.readStringArray();
indicesOptions = IndicesOptions.readIndicesOptions(in);
}

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeStringArray(indices);
out.writeStringArray(aliases);
indicesOptions.writeIndicesOptions(out);
}

@Override
public GetAliasesRequest indices(String... indices) {
this.indices = indices;
Expand Down Expand Up @@ -90,17 +105,6 @@ public ActionRequestValidationException validate() {

@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
indices = in.readStringArray();
aliases = in.readStringArray();
indicesOptions = IndicesOptions.readIndicesOptions(in);
}

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeStringArray(indices);
out.writeStringArray(aliases);
indicesOptions.writeIndicesOptions(out);
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class TransportGetAliasesAction extends TransportMasterNodeReadAction<Get
@Inject
public TransportGetAliasesAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
super(settings, GetAliasesAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, GetAliasesRequest::new);
super(settings, GetAliasesAction.NAME, transportService, clusterService, threadPool, actionFilters, GetAliasesRequest::new, indexNameExpressionResolver);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ public IndicesExistsRequest(String... indices) {
this.indices = indices;
}

public IndicesExistsRequest(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;
Expand Down Expand Up @@ -84,15 +97,6 @@ public ActionRequestValidationException validate() {

@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");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class TransportIndicesExistsAction extends TransportMasterNodeReadAction<
@Inject
public TransportIndicesExistsAction(Settings settings, TransportService transportService, ClusterService clusterService,
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
super(settings, IndicesExistsAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, IndicesExistsRequest::new);
super(settings, IndicesExistsAction.NAME, transportService, clusterService, threadPool, actionFilters, IndicesExistsRequest::new, indexNameExpressionResolver);
}

@Override
Expand Down
Loading

0 comments on commit c4b5733

Please sign in to comment.