Skip to content

Commit 5505fab

Browse files
send requests only to data nodes; and fix merge conflict with name change
1 parent 5f3d76e commit 5505fab

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

server/src/internalClusterTest/java/org/elasticsearch/cluster/ClusterInfoServiceIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ public void testClusterInfoIncludesNodeUsageStatsForThreadPools() {
388388

389389
final Map<String, NodeUsageStatsForThreadPools> usageStatsForThreadPools = clusterInfo.getNodeUsageStatsForThreadPools();
390390
logger.info("---> Thread pool usage stats reported by data nodes to the master: " + usageStatsForThreadPools);
391-
assertThat(usageStatsForThreadPools.size(), equalTo(2)); // master and data node
391+
assertThat(usageStatsForThreadPools.size(), equalTo(1)); // only stats from data nodes should be collectedg
392392
var dataNodeId = getNodeId(dataNodeName);
393393
var nodeUsageStatsForThreadPool = usageStatsForThreadPools.get(dataNodeId);
394394
assertNotNull(nodeUsageStatsForThreadPool);

server/src/main/java/org/elasticsearch/action/admin/cluster/node/usage/NodeUsageStatsForThreadPoolsAction.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@ public class NodeUsageStatsForThreadPoolsAction {
3333
* The sender request type that will be resolved to send individual {@link NodeRequest} requests to every node in the cluster.
3434
*/
3535
public static class Request extends BaseNodesRequest {
36-
public Request() {
37-
// Send all nodes a request by specifying null.
38-
super((String[]) null);
36+
/**
37+
* @param nodeIds The list of nodes to which to send individual requests and collect responses from. If the list is null, all nodes
38+
* in the cluster will be sent a request.
39+
*/
40+
public Request(String[] nodeIds) {
41+
super(nodeIds);
3942
}
4043
}
4144

server/src/main/java/org/elasticsearch/cluster/NodeUsageStatsForThreadPoolsCollector.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ public void collectUsageStats(
4343
ClusterState clusterState,
4444
ActionListener<Map<String, NodeUsageStatsForThreadPools>> listener
4545
) {
46+
var dataNodeIds = clusterState.nodes().getDataNodes().values().stream().map(node -> node.getId()).toArray(String[]::new);
4647
if (clusterState.getMinTransportVersion().onOrAfter(TransportVersions.TRANSPORT_NODE_USAGE_STATS_FOR_THREAD_POOLS_ACTION)) {
4748
client.execute(
4849
TransportNodeUsageStatsForThreadPoolsAction.TYPE,
49-
new NodeUsageStatsForThreadPoolsAction.Request(),
50+
new NodeUsageStatsForThreadPoolsAction.Request(dataNodeIds),
5051
listener.map(response -> response.getAllNodeUsageStatsForThreadPools())
5152
);
5253
} else {

server/src/main/java/org/elasticsearch/cluster/routing/ShardMovementWriteLoadSimulator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ private static NodeUsageStatsForThreadPools.ThreadPoolUsageStats replaceWritePoo
9292
(writeThreadPoolStats.averageThreadPoolUtilization() + (writeLoadDelta / writeThreadPoolStats.totalThreadPoolThreads())),
9393
0.0
9494
),
95-
writeThreadPoolStats.averageThreadPoolQueueLatencyMillis()
95+
writeThreadPoolStats.maxThreadPoolQueueLatencyMillis()
9696
);
9797
}
9898
}

0 commit comments

Comments
 (0)