Skip to content

Commit 57d1d26

Browse files
Always fetch node usage stats for write load decider
The NodeUsageStats Action will not be unconditionally called every 30 seconds, regardless of the write load decider being enabled. It is a lightweight action that fetches stats that are collected on the node regardless. This supports better seeing what happens when the write load decider is enabled, providing a before- (not just after) enablement picture. ES-12631
1 parent f32d7b6 commit 57d1d26

File tree

1 file changed

+18
-27
lines changed

1 file changed

+18
-27
lines changed

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

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ void execute() {
218218
maybeFetchIndicesStats(diskThresholdEnabled || writeLoadConstraintEnabled.atLeastLowThresholdEnabled());
219219
maybeFetchNodeStats(diskThresholdEnabled || estimatedHeapThresholdEnabled);
220220
maybeFetchNodesEstimatedHeapUsage(estimatedHeapThresholdEnabled);
221-
maybeFetchNodesUsageStatsForThreadPools(writeLoadConstraintEnabled);
221+
fetchNodesUsageStatsForThreadPools();
222222
}
223223
}
224224

@@ -257,34 +257,25 @@ private void maybeFetchNodesEstimatedHeapUsage(boolean shouldFetch) {
257257
}
258258
}
259259

260-
private void maybeFetchNodesUsageStatsForThreadPools(WriteLoadDeciderStatus writeLoadConstraintEnabled) {
261-
if (writeLoadConstraintEnabled.atLeastLowThresholdEnabled()) {
262-
try (var ignored = threadPool.getThreadContext().clearTraceContext()) {
263-
fetchNodesUsageStatsForThreadPools();
264-
}
265-
} else {
266-
logger.trace("skipping collecting shard/node write load estimates from cluster, feature currently disabled");
267-
nodeThreadPoolUsageStatsPerNode = Map.of();
268-
}
269-
}
270-
271260
private void fetchNodesUsageStatsForThreadPools() {
272-
nodeUsageStatsForThreadPoolsCollector.collectUsageStats(
273-
client,
274-
clusterStateSupplier.get(),
275-
ActionListener.releaseAfter(new ActionListener<>() {
276-
@Override
277-
public void onResponse(Map<String, NodeUsageStatsForThreadPools> threadPoolStats) {
278-
nodeThreadPoolUsageStatsPerNode = threadPoolStats;
279-
}
261+
try (var ignored = threadPool.getThreadContext().clearTraceContext()) {
262+
nodeUsageStatsForThreadPoolsCollector.collectUsageStats(
263+
client,
264+
clusterStateSupplier.get(),
265+
ActionListener.releaseAfter(new ActionListener<>() {
266+
@Override
267+
public void onResponse(Map<String, NodeUsageStatsForThreadPools> threadPoolStats) {
268+
nodeThreadPoolUsageStatsPerNode = threadPoolStats;
269+
}
280270

281-
@Override
282-
public void onFailure(Exception e) {
283-
logger.warn("failed to fetch thread pool usage estimates for nodes", e);
284-
nodeThreadPoolUsageStatsPerNode = Map.of();
285-
}
286-
}, fetchRefs.acquire())
287-
);
271+
@Override
272+
public void onFailure(Exception e) {
273+
logger.warn("failed to fetch thread pool usage estimates for nodes", e);
274+
nodeThreadPoolUsageStatsPerNode = Map.of();
275+
}
276+
}, fetchRefs.acquire())
277+
);
278+
}
288279
}
289280

290281
private void fetchNodesEstimatedHeapUsage() {

0 commit comments

Comments
 (0)