Browse Source

convert more admin requests to writeable (#26566)

Tal Levy 8 years ago
parent
commit
cc726cb3b6
37 changed files with 288 additions and 209 deletions
  1. 12 8
      core/src/main/java/org/elasticsearch/action/admin/cluster/repositories/get/GetRepositoriesRequest.java
  2. 1 1
      core/src/main/java/org/elasticsearch/action/admin/cluster/repositories/get/TransportGetRepositoriesAction.java
  3. 37 35
      core/src/main/java/org/elasticsearch/action/admin/cluster/shards/ClusterSearchShardsRequest.java
  4. 1 1
      core/src/main/java/org/elasticsearch/action/admin/cluster/shards/TransportClusterSearchShardsAction.java
  5. 24 20
      core/src/main/java/org/elasticsearch/action/admin/cluster/state/ClusterStateRequest.java
  6. 1 1
      core/src/main/java/org/elasticsearch/action/admin/cluster/state/TransportClusterStateAction.java
  7. 21 18
      core/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/GetStoredScriptRequest.java
  8. 1 1
      core/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/TransportGetStoredScriptAction.java
  9. 10 0
      core/src/main/java/org/elasticsearch/action/admin/cluster/tasks/PendingClusterTasksRequest.java
  10. 1 1
      core/src/main/java/org/elasticsearch/action/admin/cluster/tasks/TransportPendingClusterTasksAction.java
  11. 1 1
      core/src/main/java/org/elasticsearch/action/admin/indices/alias/exists/TransportAliasesExistAction.java
  12. 16 12
      core/src/main/java/org/elasticsearch/action/admin/indices/alias/get/GetAliasesRequest.java
  13. 1 1
      core/src/main/java/org/elasticsearch/action/admin/indices/alias/get/TransportGetAliasesAction.java
  14. 14 10
      core/src/main/java/org/elasticsearch/action/admin/indices/exists/indices/IndicesExistsRequest.java
  15. 1 1
      core/src/main/java/org/elasticsearch/action/admin/indices/exists/indices/TransportIndicesExistsAction.java
  16. 1 1
      core/src/main/java/org/elasticsearch/action/admin/indices/exists/types/TransportTypesExistsAction.java
  17. 16 12
      core/src/main/java/org/elasticsearch/action/admin/indices/exists/types/TypesExistsRequest.java
  18. 15 7
      core/src/main/java/org/elasticsearch/action/admin/indices/get/GetIndexRequest.java
  19. 1 1
      core/src/main/java/org/elasticsearch/action/admin/indices/get/TransportGetIndexAction.java
  20. 10 0
      core/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetMappingsRequest.java
  21. 1 1
      core/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/TransportGetMappingsAction.java
  22. 21 14
      core/src/main/java/org/elasticsearch/action/admin/indices/settings/get/GetSettingsRequest.java
  23. 1 1
      core/src/main/java/org/elasticsearch/action/admin/indices/settings/get/TransportGetSettingsAction.java
  24. 23 19
      core/src/main/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoresRequest.java
  25. 1 1
      core/src/main/java/org/elasticsearch/action/admin/indices/shards/TransportIndicesShardStoresAction.java
  26. 12 8
      core/src/main/java/org/elasticsearch/action/admin/indices/template/get/GetIndexTemplatesRequest.java
  27. 1 1
      core/src/main/java/org/elasticsearch/action/admin/indices/template/get/TransportGetIndexTemplatesAction.java
  28. 12 8
      core/src/main/java/org/elasticsearch/action/ingest/GetPipelineRequest.java
  29. 1 1
      core/src/main/java/org/elasticsearch/action/ingest/GetPipelineTransportAction.java
  30. 1 4
      core/src/main/java/org/elasticsearch/action/support/master/MasterNodeReadRequest.java
  31. 20 8
      core/src/main/java/org/elasticsearch/action/support/master/info/ClusterInfoRequest.java
  32. 3 2
      core/src/main/java/org/elasticsearch/action/support/master/info/TransportClusterInfoAction.java
  33. 1 2
      core/src/test/java/org/elasticsearch/action/admin/cluster/shards/ClusterSearchShardsRequestTests.java
  34. 1 2
      core/src/test/java/org/elasticsearch/action/admin/cluster/state/ClusterStateRequestTests.java
  35. 1 2
      core/src/test/java/org/elasticsearch/action/admin/cluster/storedscripts/GetStoredScriptRequestTests.java
  36. 1 1
      core/src/test/java/org/elasticsearch/client/transport/TransportClientNodesServiceTests.java
  37. 2 2
      core/src/test/java/org/elasticsearch/transport/RemoteClusterConnectionTests.java

+ 12 - 8
core/src/main/java/org/elasticsearch/action/admin/cluster/repositories/get/GetRepositoriesRequest.java

@@ -51,6 +51,17 @@ public class GetRepositoriesRequest extends MasterNodeReadRequest<GetRepositorie
         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;
@@ -85,13 +96,6 @@ public class GetRepositoriesRequest extends MasterNodeReadRequest<GetRepositorie
 
     @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");
     }
 }

+ 1 - 1
core/src/main/java/org/elasticsearch/action/admin/cluster/repositories/get/TransportGetRepositoriesAction.java

@@ -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

+ 37 - 35
core/src/main/java/org/elasticsearch/action/admin/cluster/shards/ClusterSearchShardsRequest.java

@@ -49,6 +49,42 @@ public class ClusterSearchShardsRequest extends MasterNodeReadRequest<ClusterSea
         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;
@@ -124,40 +160,6 @@ public class ClusterSearchShardsRequest extends MasterNodeReadRequest<ClusterSea
 
     @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");
     }
-
 }

+ 1 - 1
core/src/main/java/org/elasticsearch/action/admin/cluster/shards/TransportClusterSearchShardsAction.java

@@ -54,7 +54,7 @@ public class TransportClusterSearchShardsAction extends
                                               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;
     }
 

+ 24 - 20
core/src/main/java/org/elasticsearch/action/admin/cluster/state/ClusterStateRequest.java

@@ -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;
@@ -135,25 +158,6 @@ public class ClusterStateRequest extends MasterNodeReadRequest<ClusterStateReque
 
     @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");
     }
 }

+ 1 - 1
core/src/main/java/org/elasticsearch/action/admin/cluster/state/TransportClusterStateAction.java

@@ -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

+ 21 - 18
core/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/GetStoredScriptRequest.java

@@ -43,6 +43,26 @@ public class GetStoredScriptRequest extends MasterNodeReadRequest<GetStoredScrip
         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;
@@ -68,24 +88,7 @@ public class GetStoredScriptRequest extends MasterNodeReadRequest<GetStoredScrip
 
     @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

+ 1 - 1
core/src/main/java/org/elasticsearch/action/admin/cluster/storedscripts/TransportGetStoredScriptAction.java

@@ -43,7 +43,7 @@ public class TransportGetStoredScriptAction extends TransportMasterNodeReadActio
                                           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;
     }
 

+ 10 - 0
core/src/main/java/org/elasticsearch/action/admin/cluster/tasks/PendingClusterTasksRequest.java

@@ -21,9 +21,19 @@ package org.elasticsearch.action.admin.cluster.tasks;
 
 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;

+ 1 - 1
core/src/main/java/org/elasticsearch/action/admin/cluster/tasks/TransportPendingClusterTasksAction.java

@@ -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;
     }
 

+ 1 - 1
core/src/main/java/org/elasticsearch/action/admin/indices/alias/exists/TransportAliasesExistAction.java

@@ -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

+ 16 - 12
core/src/main/java/org/elasticsearch/action/admin/indices/alias/get/GetAliasesRequest.java

@@ -46,6 +46,21 @@ public class GetAliasesRequest extends MasterNodeReadRequest<GetAliasesRequest>
     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;
@@ -90,17 +105,6 @@ public class GetAliasesRequest extends MasterNodeReadRequest<GetAliasesRequest>
 
     @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");
     }
 }

+ 1 - 1
core/src/main/java/org/elasticsearch/action/admin/indices/alias/get/TransportGetAliasesAction.java

@@ -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

+ 14 - 10
core/src/main/java/org/elasticsearch/action/admin/indices/exists/indices/IndicesExistsRequest.java

@@ -45,6 +45,19 @@ public class IndicesExistsRequest extends MasterNodeReadRequest<IndicesExistsReq
         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;
@@ -84,15 +97,6 @@ public class IndicesExistsRequest extends MasterNodeReadRequest<IndicesExistsReq
 
     @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");
     }
 }

+ 1 - 1
core/src/main/java/org/elasticsearch/action/admin/indices/exists/indices/TransportIndicesExistsAction.java

@@ -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

+ 1 - 1
core/src/main/java/org/elasticsearch/action/admin/indices/exists/types/TransportTypesExistsAction.java

@@ -41,7 +41,7 @@ public class TransportTypesExistsAction extends TransportMasterNodeReadAction<Ty
     @Inject
     public TransportTypesExistsAction(Settings settings, TransportService transportService, ClusterService clusterService,
                                       ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
-        super(settings, TypesExistsAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, TypesExistsRequest::new);
+        super(settings, TypesExistsAction.NAME, transportService, clusterService, threadPool, actionFilters, TypesExistsRequest::new, indexNameExpressionResolver);
     }
 
     @Override

+ 16 - 12
core/src/main/java/org/elasticsearch/action/admin/indices/exists/types/TypesExistsRequest.java

@@ -44,6 +44,21 @@ public class TypesExistsRequest extends MasterNodeReadRequest<TypesExistsRequest
         this.types = types;
     }
 
+    public TypesExistsRequest(StreamInput in) throws IOException {
+        super(in);
+        indices = in.readStringArray();
+        types = in.readStringArray();
+        indicesOptions = IndicesOptions.readIndicesOptions(in);
+    }
+
+    @Override
+    public void writeTo(StreamOutput out) throws IOException {
+        super.writeTo(out);
+        out.writeStringArray(indices);
+        out.writeStringArray(types);
+        indicesOptions.writeIndicesOptions(out);
+    }
+
     @Override
     public String[] indices() {
         return indices;
@@ -86,19 +101,8 @@ public class TypesExistsRequest extends MasterNodeReadRequest<TypesExistsRequest
         return validationException;
     }
 
-    @Override
-    public void writeTo(StreamOutput out) throws IOException {
-        super.writeTo(out);
-        out.writeStringArray(indices);
-        out.writeStringArray(types);
-        indicesOptions.writeIndicesOptions(out);
-    }
-
     @Override
     public void readFrom(StreamInput in) throws IOException {
-        super.readFrom(in);
-        indices = in.readStringArray();
-        types = in.readStringArray();
-        indicesOptions = IndicesOptions.readIndicesOptions(in);
+        throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
     }
 }

+ 15 - 7
core/src/main/java/org/elasticsearch/action/admin/indices/get/GetIndexRequest.java

@@ -100,6 +100,20 @@ public class GetIndexRequest extends ClusterInfoRequest<GetIndexRequest> {
     private Feature[] features = DEFAULT_FEATURES;
     private boolean humanReadable = false;
 
+    public GetIndexRequest() {
+
+    }
+
+    public GetIndexRequest(StreamInput in) throws IOException {
+        super(in);
+        int size = in.readVInt();
+        features = new Feature[size];
+        for (int i = 0; i < size; i++) {
+            features[i] = Feature.fromId(in.readByte());
+        }
+        humanReadable = in.readBoolean();
+    }
+
     public GetIndexRequest features(Feature... features) {
         if (features == null) {
             throw new IllegalArgumentException("features cannot be null");
@@ -137,13 +151,7 @@ public class GetIndexRequest extends ClusterInfoRequest<GetIndexRequest> {
 
     @Override
     public void readFrom(StreamInput in) throws IOException {
-        super.readFrom(in);
-        int size = in.readVInt();
-        features = new Feature[size];
-        for (int i = 0; i < size; i++) {
-            features[i] = Feature.fromId(in.readByte());
-        }
-        humanReadable = in.readBoolean();
+        throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
     }
 
     @Override

+ 1 - 1
core/src/main/java/org/elasticsearch/action/admin/indices/get/TransportGetIndexAction.java

@@ -49,7 +49,7 @@ public class TransportGetIndexAction extends TransportClusterInfoAction<GetIndex
     @Inject
     public TransportGetIndexAction(Settings settings, TransportService transportService, ClusterService clusterService,
                                    ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
-        super(settings, GetIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, GetIndexRequest::new);
+        super(settings, GetIndexAction.NAME, transportService, clusterService, threadPool, actionFilters, GetIndexRequest::new, indexNameExpressionResolver);
     }
 
     @Override

+ 10 - 0
core/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetMappingsRequest.java

@@ -21,9 +21,19 @@ package org.elasticsearch.action.admin.indices.mapping.get;
 
 import org.elasticsearch.action.ActionRequestValidationException;
 import org.elasticsearch.action.support.master.info.ClusterInfoRequest;
+import org.elasticsearch.common.io.stream.StreamInput;
+
+import java.io.IOException;
 
 public class GetMappingsRequest extends ClusterInfoRequest<GetMappingsRequest> {
 
+    public GetMappingsRequest() {
+    }
+
+    public GetMappingsRequest(StreamInput in) throws IOException {
+        super(in);
+    }
+
     @Override
     public ActionRequestValidationException validate() {
         return null;

+ 1 - 1
core/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/TransportGetMappingsAction.java

@@ -39,7 +39,7 @@ public class TransportGetMappingsAction extends TransportClusterInfoAction<GetMa
     @Inject
     public TransportGetMappingsAction(Settings settings, TransportService transportService, ClusterService clusterService,
                                       ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
-        super(settings, GetMappingsAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, GetMappingsRequest::new);
+        super(settings, GetMappingsAction.NAME, transportService, clusterService, threadPool, actionFilters, GetMappingsRequest::new, indexNameExpressionResolver);
     }
 
     @Override

+ 21 - 14
core/src/main/java/org/elasticsearch/action/admin/indices/settings/get/GetSettingsRequest.java

@@ -48,6 +48,26 @@ public class GetSettingsRequest extends MasterNodeReadRequest<GetSettingsRequest
         return this;
     }
 
+    public GetSettingsRequest() {
+    }
+
+    public GetSettingsRequest(StreamInput in) throws IOException {
+        super(in);
+        indices = in.readStringArray();
+        indicesOptions = IndicesOptions.readIndicesOptions(in);
+        names = in.readStringArray();
+        humanReadable = in.readBoolean();
+    }
+
+    @Override
+    public void writeTo(StreamOutput out) throws IOException {
+        super.writeTo(out);
+        out.writeStringArray(indices);
+        indicesOptions.writeIndicesOptions(out);
+        out.writeStringArray(names);
+        out.writeBoolean(humanReadable);
+    }
+
     @Override
     public String[] indices() {
         return indices;
@@ -87,19 +107,6 @@ public class GetSettingsRequest extends MasterNodeReadRequest<GetSettingsRequest
 
     @Override
     public void readFrom(StreamInput in) throws IOException {
-        super.readFrom(in);
-        indices = in.readStringArray();
-        indicesOptions = IndicesOptions.readIndicesOptions(in);
-        names = in.readStringArray();
-        humanReadable = in.readBoolean();
-    }
-
-    @Override
-    public void writeTo(StreamOutput out) throws IOException {
-        super.writeTo(out);
-        out.writeStringArray(indices);
-        indicesOptions.writeIndicesOptions(out);
-        out.writeStringArray(names);
-        out.writeBoolean(humanReadable);
+        throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
     }
 }

+ 1 - 1
core/src/main/java/org/elasticsearch/action/admin/indices/settings/get/TransportGetSettingsAction.java

@@ -48,7 +48,7 @@ public class TransportGetSettingsAction extends TransportMasterNodeReadAction<Ge
     public TransportGetSettingsAction(Settings settings, TransportService transportService, ClusterService clusterService,
                                       ThreadPool threadPool, SettingsFilter settingsFilter, ActionFilters actionFilters,
                                       IndexNameExpressionResolver indexNameExpressionResolver) {
-        super(settings, GetSettingsAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, GetSettingsRequest::new);
+        super(settings, GetSettingsAction.NAME, transportService, clusterService, threadPool, actionFilters, GetSettingsRequest::new, indexNameExpressionResolver);
         this.settingsFilter = settingsFilter;
     }
 

+ 23 - 19
core/src/main/java/org/elasticsearch/action/admin/indices/shards/IndicesShardStoresRequest.java

@@ -49,6 +49,28 @@ public class IndicesShardStoresRequest extends MasterNodeReadRequest<IndicesShar
     public IndicesShardStoresRequest() {
     }
 
+    public IndicesShardStoresRequest(StreamInput in) throws IOException {
+        super(in);
+        indices = in.readStringArray();
+        int nStatus = in.readVInt();
+        statuses = EnumSet.noneOf(ClusterHealthStatus.class);
+        for (int i = 0; i < nStatus; i++) {
+            statuses.add(ClusterHealthStatus.fromValue(in.readByte()));
+        }
+        indicesOptions = IndicesOptions.readIndicesOptions(in);
+    }
+
+    @Override
+    public void writeTo(StreamOutput out) throws IOException {
+        super.writeTo(out);
+        out.writeStringArrayNullable(indices);
+        out.writeVInt(statuses.size());
+        for (ClusterHealthStatus status : statuses) {
+            out.writeByte(status.value());
+        }
+        indicesOptions.writeIndicesOptions(out);
+    }
+
     /**
      * Set statuses to filter shards to get stores info on.
      * see {@link ClusterHealthStatus} for details.
@@ -107,26 +129,8 @@ public class IndicesShardStoresRequest extends MasterNodeReadRequest<IndicesShar
         return null;
     }
 
-    @Override
-    public void writeTo(StreamOutput out) throws IOException {
-        super.writeTo(out);
-        out.writeStringArrayNullable(indices);
-        out.writeVInt(statuses.size());
-        for (ClusterHealthStatus status : statuses) {
-            out.writeByte(status.value());
-        }
-        indicesOptions.writeIndicesOptions(out);
-    }
-
     @Override
     public void readFrom(StreamInput in) throws IOException {
-        super.readFrom(in);
-        indices = in.readStringArray();
-        int nStatus = in.readVInt();
-        statuses = EnumSet.noneOf(ClusterHealthStatus.class);
-        for (int i = 0; i < nStatus; i++) {
-            statuses.add(ClusterHealthStatus.fromValue(in.readByte()));
-        }
-        indicesOptions = IndicesOptions.readIndicesOptions(in);
+        throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
     }
 }

+ 1 - 1
core/src/main/java/org/elasticsearch/action/admin/indices/shards/TransportIndicesShardStoresAction.java

@@ -69,7 +69,7 @@ public class TransportIndicesShardStoresAction extends TransportMasterNodeReadAc
     @Inject
     public TransportIndicesShardStoresAction(Settings settings, TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters,
                                              IndexNameExpressionResolver indexNameExpressionResolver, TransportNodesListGatewayStartedShards listShardStoresInfo) {
-        super(settings, IndicesShardStoresAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, IndicesShardStoresRequest::new);
+        super(settings, IndicesShardStoresAction.NAME, transportService, clusterService, threadPool, actionFilters, IndicesShardStoresRequest::new, indexNameExpressionResolver);
         this.listShardStoresInfo = listShardStoresInfo;
     }
 

+ 12 - 8
core/src/main/java/org/elasticsearch/action/admin/indices/template/get/GetIndexTemplatesRequest.java

@@ -42,6 +42,17 @@ public class GetIndexTemplatesRequest extends MasterNodeReadRequest<GetIndexTemp
         this.names = names;
     }
 
+    public GetIndexTemplatesRequest(StreamInput in) throws IOException {
+        super(in);
+        names = in.readStringArray();
+    }
+
+    @Override
+    public void writeTo(StreamOutput out) throws IOException {
+        super.writeTo(out);
+        out.writeStringArray(names);
+    }
+
     @Override
     public ActionRequestValidationException validate() {
         ActionRequestValidationException validationException = null;
@@ -74,13 +85,6 @@ public class GetIndexTemplatesRequest extends MasterNodeReadRequest<GetIndexTemp
 
     @Override
     public void readFrom(StreamInput in) throws IOException {
-        super.readFrom(in);
-        names = in.readStringArray();
-    }
-
-    @Override
-    public void writeTo(StreamOutput out) throws IOException {
-        super.writeTo(out);
-        out.writeStringArray(names);
+        throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
     }
 }

+ 1 - 1
core/src/main/java/org/elasticsearch/action/admin/indices/template/get/TransportGetIndexTemplatesAction.java

@@ -43,7 +43,7 @@ public class TransportGetIndexTemplatesAction extends TransportMasterNodeReadAct
     @Inject
     public TransportGetIndexTemplatesAction(Settings settings, TransportService transportService, ClusterService clusterService,
                                             ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
-        super(settings, GetIndexTemplatesAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, GetIndexTemplatesRequest::new);
+        super(settings, GetIndexTemplatesAction.NAME, transportService, clusterService, threadPool, actionFilters, GetIndexTemplatesRequest::new, indexNameExpressionResolver);
     }
 
     @Override

+ 12 - 8
core/src/main/java/org/elasticsearch/action/ingest/GetPipelineRequest.java

@@ -42,6 +42,17 @@ public class GetPipelineRequest extends MasterNodeReadRequest<GetPipelineRequest
         this.ids = Strings.EMPTY_ARRAY;
     }
 
+    public GetPipelineRequest(StreamInput in) throws IOException {
+        super(in);
+        ids = in.readStringArray();
+    }
+
+    @Override
+    public void writeTo(StreamOutput out) throws IOException {
+        super.writeTo(out);
+        out.writeStringArray(ids);
+    }
+
     public String[] getIds() {
         return ids;
     }
@@ -53,13 +64,6 @@ public class GetPipelineRequest extends MasterNodeReadRequest<GetPipelineRequest
 
     @Override
     public void readFrom(StreamInput in) throws IOException {
-        super.readFrom(in);
-        ids = in.readStringArray();
-    }
-
-    @Override
-    public void writeTo(StreamOutput out) throws IOException {
-        super.writeTo(out);
-        out.writeStringArray(ids);
+        throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
     }
 }

+ 1 - 1
core/src/main/java/org/elasticsearch/action/ingest/GetPipelineTransportAction.java

@@ -42,7 +42,7 @@ public class GetPipelineTransportAction extends TransportMasterNodeReadAction<Ge
     public GetPipelineTransportAction(Settings settings, ThreadPool threadPool, ClusterService clusterService,
                                       TransportService transportService, ActionFilters actionFilters,
                                       IndexNameExpressionResolver indexNameExpressionResolver, NodeService nodeService) {
-        super(settings, GetPipelineAction.NAME, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, GetPipelineRequest::new);
+        super(settings, GetPipelineAction.NAME, transportService, clusterService, threadPool, actionFilters, GetPipelineRequest::new, indexNameExpressionResolver);
         this.pipelineStore = nodeService.getIngestService().getPipelineStore();
     }
 

+ 1 - 4
core/src/main/java/org/elasticsearch/action/support/master/MasterNodeReadRequest.java

@@ -57,9 +57,6 @@ public abstract class MasterNodeReadRequest<Request extends MasterNodeReadReques
 
     @Override
     public void readFrom(StreamInput in) throws IOException {
-        // TODO(talevy): throw exception once all MasterNodeReadRequest
-        //               subclasses have been migrated to Writeable Readers
-        super.readFrom(in);
-        local = in.readBoolean();
+        throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
     }
 }

+ 20 - 8
core/src/main/java/org/elasticsearch/action/support/master/info/ClusterInfoRequest.java

@@ -35,6 +35,24 @@ public abstract class ClusterInfoRequest<Request extends ClusterInfoRequest<Requ
 
     private IndicesOptions indicesOptions = IndicesOptions.strictExpandOpen();
 
+    public ClusterInfoRequest() {
+    }
+
+    public ClusterInfoRequest(StreamInput in) throws IOException {
+        super(in);
+        indices = in.readStringArray();
+        types = in.readStringArray();
+        indicesOptions = IndicesOptions.readIndicesOptions(in);
+    }
+
+    @Override
+    public void writeTo(StreamOutput out) throws IOException {
+        super.writeTo(out);
+        out.writeStringArray(indices);
+        out.writeStringArray(types);
+        indicesOptions.writeIndicesOptions(out);
+    }
+
     @Override
     @SuppressWarnings("unchecked")
     public Request indices(String... indices) {
@@ -70,17 +88,11 @@ public abstract class ClusterInfoRequest<Request extends ClusterInfoRequest<Requ
 
     @Override
     public void readFrom(StreamInput in) throws IOException {
+        // TODO(talevy): once all ClusterInfoRequest objects are converted, remove this
         super.readFrom(in);
         indices = in.readStringArray();
         types = in.readStringArray();
         indicesOptions = IndicesOptions.readIndicesOptions(in);
-    }
-
-    @Override
-    public void writeTo(StreamOutput out) throws IOException {
-        super.writeTo(out);
-        out.writeStringArray(indices);
-        out.writeStringArray(types);
-        indicesOptions.writeIndicesOptions(out);
+        // throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
     }
 }

+ 3 - 2
core/src/main/java/org/elasticsearch/action/support/master/info/TransportClusterInfoAction.java

@@ -25,6 +25,7 @@ import org.elasticsearch.action.support.master.TransportMasterNodeReadAction;
 import org.elasticsearch.cluster.ClusterState;
 import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
 import org.elasticsearch.cluster.service.ClusterService;
+import org.elasticsearch.common.io.stream.Writeable;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.threadpool.ThreadPool;
 import org.elasticsearch.transport.TransportService;
@@ -36,8 +37,8 @@ public abstract class TransportClusterInfoAction<Request extends ClusterInfoRequ
 
     public TransportClusterInfoAction(Settings settings, String actionName, TransportService transportService,
                                       ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters,
-                                      IndexNameExpressionResolver indexNameExpressionResolver, Supplier<Request> request) {
-        super(settings, actionName, transportService, clusterService, threadPool, actionFilters, indexNameExpressionResolver, request);
+                                      Writeable.Reader<Request> request, IndexNameExpressionResolver indexNameExpressionResolver) {
+        super(settings, actionName, transportService, clusterService, threadPool, actionFilters, request, indexNameExpressionResolver);
     }
 
     @Override

+ 1 - 2
core/src/test/java/org/elasticsearch/action/admin/cluster/shards/ClusterSearchShardsRequestTests.java

@@ -60,8 +60,7 @@ public class ClusterSearchShardsRequestTests extends ESTestCase {
             request.writeTo(out);
             try (StreamInput in = out.bytes().streamInput()) {
                 in.setVersion(version);
-                ClusterSearchShardsRequest deserialized = new ClusterSearchShardsRequest();
-                deserialized.readFrom(in);
+                ClusterSearchShardsRequest deserialized = new ClusterSearchShardsRequest(in);
                 assertArrayEquals(request.indices(), deserialized.indices());
                 assertSame(request.indicesOptions(), deserialized.indicesOptions());
                 assertEquals(request.routing(), deserialized.routing());

+ 1 - 2
core/src/test/java/org/elasticsearch/action/admin/cluster/state/ClusterStateRequestTests.java

@@ -47,8 +47,7 @@ public class ClusterStateRequestTests extends ESTestCase {
 
             StreamInput streamInput = output.bytes().streamInput();
             streamInput.setVersion(testVersion);
-            ClusterStateRequest deserializedCSRequest = new ClusterStateRequest();
-            deserializedCSRequest.readFrom(streamInput);
+            ClusterStateRequest deserializedCSRequest = new ClusterStateRequest(streamInput);
 
             assertThat(deserializedCSRequest.routingTable(), equalTo(clusterStateRequest.routingTable()));
             assertThat(deserializedCSRequest.metaData(), equalTo(clusterStateRequest.metaData()));

+ 1 - 2
core/src/test/java/org/elasticsearch/action/admin/cluster/storedscripts/GetStoredScriptRequestTests.java

@@ -38,8 +38,7 @@ public class GetStoredScriptRequestTests extends ESTestCase {
 
         StreamInput in = out.bytes().streamInput();
         in.setVersion(out.getVersion());
-        GetStoredScriptRequest request2 = new GetStoredScriptRequest();
-        request2.readFrom(in);
+        GetStoredScriptRequest request2 = new GetStoredScriptRequest(in);
 
         assertThat(request2.id(), equalTo(request.id()));
     }

+ 1 - 1
core/src/test/java/org/elasticsearch/client/transport/TransportClientNodesServiceTests.java

@@ -340,7 +340,7 @@ public class TransportClientNodesServiceTests extends ESTestCase {
         Settings remoteSettings = Settings.builder().put(Node.NODE_NAME_SETTING.getKey(), "remote").build();
         try (MockTransportService remoteService = createNewService(remoteSettings, Version.CURRENT, threadPool, null)) {
             final MockHandler handler = new MockHandler(remoteService);
-            remoteService.registerRequestHandler(ClusterStateAction.NAME, ClusterStateRequest::new, ThreadPool.Names.SAME, handler);
+            remoteService.registerRequestHandler(ClusterStateAction.NAME, ThreadPool.Names.SAME, ClusterStateRequest::new,  handler);
             remoteService.start();
             remoteService.acceptIncomingRequests();
 

+ 2 - 2
core/src/test/java/org/elasticsearch/transport/RemoteClusterConnectionTests.java

@@ -110,12 +110,12 @@ public class RemoteClusterConnectionTests extends ESTestCase {
         ClusterName clusterName = ClusterName.CLUSTER_NAME_SETTING.get(s);
         MockTransportService newService = MockTransportService.createNewService(s, version, threadPool, null);
         try {
-            newService.registerRequestHandler(ClusterSearchShardsAction.NAME, ClusterSearchShardsRequest::new, ThreadPool.Names.SAME,
+            newService.registerRequestHandler(ClusterSearchShardsAction.NAME,ThreadPool.Names.SAME, ClusterSearchShardsRequest::new,
                     (request, channel) -> {
                         channel.sendResponse(new ClusterSearchShardsResponse(new ClusterSearchShardsGroup[0],
                                 knownNodes.toArray(new DiscoveryNode[0]), Collections.emptyMap()));
                     });
-            newService.registerRequestHandler(ClusterStateAction.NAME, ClusterStateRequest::new, ThreadPool.Names.SAME,
+            newService.registerRequestHandler(ClusterStateAction.NAME, ThreadPool.Names.SAME, ClusterStateRequest::new,
                     (request, channel) -> {
                         DiscoveryNodes.Builder builder = DiscoveryNodes.builder();
                         for (DiscoveryNode node : knownNodes) {