diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/TransportClusterStatsAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/TransportClusterStatsAction.java index d54465ff845..3a0d22945b4 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/TransportClusterStatsAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/TransportClusterStatsAction.java @@ -45,6 +45,7 @@ import org.elasticsearch.indices.IndicesService; import org.elasticsearch.node.NodeService; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import org.elasticsearch.transport.Transports; import java.io.IOException; import java.util.ArrayList; @@ -64,8 +65,8 @@ public class TransportClusterStatsAction extends TransportNodesAction responses, List failures) { + assert Transports.assertNotTransportThread("Constructor of ClusterStatsResponse runs expensive computations on mappings found in" + + " the cluster state that are too slow for a transport thread"); ClusterState state = clusterService.state(); return new ClusterStatsResponse( System.currentTimeMillis(), diff --git a/server/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesAction.java b/server/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesAction.java index af7e48b1eeb..e6da86876dd 100644 --- a/server/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesAction.java +++ b/server/src/main/java/org/elasticsearch/action/support/nodes/TransportNodesAction.java @@ -21,6 +21,7 @@ package org.elasticsearch.action.support.nodes; import org.apache.logging.log4j.message.ParameterizedMessage; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionRunnable; import org.elasticsearch.action.FailedNodeException; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.HandledTransportAction; @@ -60,10 +61,24 @@ public abstract class TransportNodesAction nodeResponseClass; protected final String transportNodeAction; + private final String finalExecutor; + + /** + * @param actionName action name + * @param threadPool thread-pool + * @param clusterService cluster service + * @param transportService transport service + * @param actionFilters action filters + * @param request node request writer + * @param nodeRequest node request reader + * @param nodeExecutor executor to execute node action on + * @param finalExecutor executor to execute final collection of all responses on + * @param nodeResponseClass class of the node responses + */ protected TransportNodesAction(String actionName, ThreadPool threadPool, ClusterService clusterService, TransportService transportService, ActionFilters actionFilters, Writeable.Reader request, Writeable.Reader nodeRequest, String nodeExecutor, - Class nodeResponseClass) { + String finalExecutor, Class nodeResponseClass) { super(actionName, transportService, actionFilters, request); this.threadPool = threadPool; this.clusterService = Objects.requireNonNull(clusterService); @@ -71,9 +86,24 @@ public abstract class TransportNodesAction request, Writeable.Reader nodeRequest, String nodeExecutor, + Class nodeResponseClass) { + this(actionName, threadPool, clusterService, transportService, actionFilters, request, nodeRequest, nodeExecutor, + ThreadPool.Names.SAME, nodeResponseClass); } @Override @@ -230,15 +260,7 @@ public abstract class TransportNodesAction newResponse(request, responses))); } }