Skip to content

Commit b064071

Browse files
tidying up rename
1 parent 5783217 commit b064071

File tree

6 files changed

+33
-31
lines changed

6 files changed

+33
-31
lines changed

server/src/internalClusterTest/java/org/elasticsearch/index/shard/IndexShardIT.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -328,11 +328,12 @@ public void testNodeWriteLoadsArePresent() {
328328
.build()
329329
);
330330
try {
331-
// Force a ClusterInfo refresh to run collection of the node write loads.
331+
// Force a ClusterInfo refresh to run collection of the node thread pool usage stats.
332332
ClusterInfoServiceUtils.refresh(clusterInfoService);
333333
nodeThreadPoolStats = clusterInfoService.getClusterInfo().getNodeUsageStatsForThreadPools();
334334

335-
/** Verify that each node has a write load reported. The test {@link BogusNodeUsageStatsForThreadPoolsCollector} generates random load values */
335+
/** Verify that each node has usage stats reported. The test {@link BogusNodeUsageStatsForThreadPoolsCollector} implementation
336+
* generates random usage values */
336337
ClusterState state = getInstanceFromNode(ClusterService.class).state();
337338
assertEquals(state.nodes().size(), nodeThreadPoolStats.size());
338339
for (DiscoveryNode node : state.nodes()) {
@@ -936,11 +937,11 @@ public ClusterService getClusterService() {
936937
}
937938

938939
/**
939-
* A simple {@link NodeUsageStatsForThreadPoolsCollector} implementation that creates and returns random {@link NodeUsageStatsForThreadPools} for each node in the
940-
* cluster.
940+
* A simple {@link NodeUsageStatsForThreadPoolsCollector} implementation that creates and returns random
941+
* {@link NodeUsageStatsForThreadPools} for each node in the cluster.
941942
* <p>
942-
* Note: there's an 'org.elasticsearch.cluster.WriteLoadCollector' file that declares this implementation so that the plugin system can
943-
* pick it up and use it for the test set-up.
943+
* Note: there's an 'org.elasticsearch.cluster.NodeUsageStatsForThreadPoolsCollector' file that declares this implementation so that the
944+
* plugin system can pick it up and use it for the test set-up.
944945
*/
945946
public static class BogusNodeUsageStatsForThreadPoolsCollector implements NodeUsageStatsForThreadPoolsCollector {
946947

@@ -958,11 +959,11 @@ public void collectUsageStats(ActionListener<Map<String, NodeUsageStatsForThread
958959
.state()
959960
.nodes()
960961
.stream()
961-
.collect(Collectors.toUnmodifiableMap(DiscoveryNode::getId, node -> makeRandomNodeLoad(node.getId())))
962+
.collect(Collectors.toUnmodifiableMap(DiscoveryNode::getId, node -> makeRandomNodeUsageStats(node.getId())))
962963
);
963964
}
964965

965-
private NodeUsageStatsForThreadPools makeRandomNodeLoad(String nodeId) {
966+
private NodeUsageStatsForThreadPools makeRandomNodeUsageStats(String nodeId) {
966967
NodeUsageStatsForThreadPools.ThreadPoolUsageStats writeThreadPoolStats = new NodeUsageStatsForThreadPools.ThreadPoolUsageStats(
967968
randomNonNegativeInt(),
968969
randomFloat(),

server/src/main/java/org/elasticsearch/TransportVersions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ static TransportVersion def(int id) {
335335
public static final TransportVersion ESQL_SPLIT_ON_BIG_VALUES = def(9_116_0_00);
336336
public static final TransportVersion ESQL_LOCAL_RELATION_WITH_NEW_BLOCKS = def(9_117_0_00);
337337
public static final TransportVersion ML_INFERENCE_CUSTOM_SERVICE_EMBEDDING_TYPE = def(9_118_0_00);
338-
public static final TransportVersion NODE_WRITE_LOAD_IN_CLUSTER_INFO = def(9_119_0_00);
338+
public static final TransportVersion NODE_USAGE_STATS_FOR_THREAD_POOLS_IN_CLUSTER_INFO = def(9_119_0_00);
339339

340340
/*
341341
* STOP! READ THIS FIRST! No, really,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public ClusterInfo(StreamInput in) throws IOException {
111111
} else {
112112
this.estimatedHeapUsages = Map.of();
113113
}
114-
if (in.getTransportVersion().onOrAfter(TransportVersions.NODE_WRITE_LOAD_IN_CLUSTER_INFO)) {
114+
if (in.getTransportVersion().onOrAfter(TransportVersions.NODE_USAGE_STATS_FOR_THREAD_POOLS_IN_CLUSTER_INFO)) {
115115
this.nodeUsageStatsForThreadPools = in.readImmutableMap(NodeUsageStatsForThreadPools::new);
116116
} else {
117117
this.nodeUsageStatsForThreadPools = Map.of();
@@ -133,7 +133,7 @@ public void writeTo(StreamOutput out) throws IOException {
133133
if (out.getTransportVersion().onOrAfter(TransportVersions.HEAP_USAGE_IN_CLUSTER_INFO)) {
134134
out.writeMap(this.estimatedHeapUsages, StreamOutput::writeWriteable);
135135
}
136-
if (out.getTransportVersion().onOrAfter(TransportVersions.NODE_WRITE_LOAD_IN_CLUSTER_INFO)) {
136+
if (out.getTransportVersion().onOrAfter(TransportVersions.NODE_USAGE_STATS_FOR_THREAD_POOLS_IN_CLUSTER_INFO)) {
137137
out.writeMap(this.nodeUsageStatsForThreadPools, StreamOutput::writeWriteable);
138138
}
139139
}

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

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

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

260-
private void maybeFetchNodesThreadPoolUsageStats(WriteLoadDeciderStatus writeLoadConstraintEnabled) {
260+
private void maybeFetchNodesUsageStatsForThreadPools(WriteLoadDeciderStatus writeLoadConstraintEnabled) {
261261
if (writeLoadConstraintEnabled != WriteLoadDeciderStatus.DISABLED) {
262262
try (var ignored = threadPool.getThreadContext().clearTraceContext()) {
263-
fetchNodesThreadPoolUsageStats();
263+
fetchNodesUsageStatsForThreadPools();
264264
}
265265
} else {
266266
logger.trace("skipping collecting shard/node write load estimates from cluster, feature currently disabled");
267267
nodeThreadPoolUsageStatsPerNode = Map.of();
268268
}
269269
}
270270

271-
private void fetchNodesThreadPoolUsageStats() {
271+
private void fetchNodesUsageStatsForThreadPools() {
272272
nodeUsageStatsForThreadPoolsCollector.collectUsageStats(ActionListener.releaseAfter(new ActionListener<>() {
273273
@Override
274274
public void onResponse(Map<String, NodeUsageStatsForThreadPools> writeLoads) {
@@ -527,8 +527,8 @@ public ClusterInfo getClusterInfo() {
527527
estimatedHeapUsages.put(nodeId, new EstimatedHeapUsage(nodeId, maxHeapSize.getBytes(), estimatedHeapUsage));
528528
}
529529
});
530-
final Map<String, NodeUsageStatsForThreadPools> nodeWriteLoads = new HashMap<>();
531-
nodeThreadPoolUsageStatsPerNode.forEach((nodeId, nodeWriteLoad) -> { nodeWriteLoads.put(nodeId, nodeWriteLoad); });
530+
final Map<String, NodeUsageStatsForThreadPools> nodeThreadPoolUsageStats = new HashMap<>();
531+
nodeThreadPoolUsageStatsPerNode.forEach((nodeId, nodeWriteLoad) -> { nodeThreadPoolUsageStats.put(nodeId, nodeWriteLoad); });
532532
return new ClusterInfo(
533533
leastAvailableSpaceUsages,
534534
mostAvailableSpaceUsages,
@@ -537,7 +537,7 @@ public ClusterInfo getClusterInfo() {
537537
indicesStatsSummary.dataPath,
538538
indicesStatsSummary.reservedSpace,
539539
estimatedHeapUsages,
540-
nodeWriteLoads
540+
nodeThreadPoolUsageStats
541541
);
542542
}
543543

server/src/test/java/org/elasticsearch/cluster/ClusterInfoTests.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static ClusterInfo randomClusterInfo() {
4444
randomRoutingToDataPath(),
4545
randomReservedSpace(),
4646
randomNodeHeapUsage(),
47-
randomNodeWriteLoads()
47+
randomNodeUsageStatsForThreadPools()
4848
);
4949
}
5050

@@ -64,21 +64,21 @@ private static Map<String, EstimatedHeapUsage> randomNodeHeapUsage() {
6464
return nodeHeapUsage;
6565
}
6666

67-
private static Map<String, NodeUsageStatsForThreadPools> randomNodeWriteLoads() {
67+
private static Map<String, NodeUsageStatsForThreadPools> randomNodeUsageStatsForThreadPools() {
6868
int numEntries = randomIntBetween(0, 128);
69-
Map<String, NodeUsageStatsForThreadPools> nodeWriteLoads = new HashMap<>(numEntries);
69+
Map<String, NodeUsageStatsForThreadPools> nodeUsageStatsForThreadPools = new HashMap<>(numEntries);
7070
for (int i = 0; i < numEntries; i++) {
7171
String nodeIdKey = randomAlphaOfLength(32);
72-
NodeUsageStatsForThreadPools.ThreadPoolUsageStats writeThreadPoolStats = new NodeUsageStatsForThreadPools.ThreadPoolUsageStats(
73-
/* totalThreadPoolThreads= */ randomIntBetween(1, 16),
74-
/* averageThreadPoolUtilization= */ randomFloat(),
75-
/* averageThreadPoolQueueLatencyMillis= */ randomLongBetween(0, 50000)
76-
);
77-
Map<String, NodeUsageStatsForThreadPools.ThreadPoolUsageStats> statsForThreadPools = new HashMap<>();
78-
statsForThreadPools.put(ThreadPool.Names.WRITE, writeThreadPoolStats);
79-
nodeWriteLoads.put(ThreadPool.Names.WRITE, new NodeUsageStatsForThreadPools(nodeIdKey, statsForThreadPools));
72+
NodeUsageStatsForThreadPools.ThreadPoolUsageStats writeThreadPoolUsageStats =
73+
new NodeUsageStatsForThreadPools.ThreadPoolUsageStats(/* totalThreadPoolThreads= */ randomIntBetween(1, 16),
74+
/* averageThreadPoolUtilization= */ randomFloat(),
75+
/* averageThreadPoolQueueLatencyMillis= */ randomLongBetween(0, 50000)
76+
);
77+
Map<String, NodeUsageStatsForThreadPools.ThreadPoolUsageStats> usageStatsForThreadPools = new HashMap<>();
78+
usageStatsForThreadPools.put(ThreadPool.Names.WRITE, writeThreadPoolUsageStats);
79+
nodeUsageStatsForThreadPools.put(ThreadPool.Names.WRITE, new NodeUsageStatsForThreadPools(nodeIdKey, usageStatsForThreadPools));
8080
}
81-
return nodeWriteLoads;
81+
return nodeUsageStatsForThreadPools;
8282
}
8383

8484
private static Map<String, DiskUsage> randomDiskUsage() {

server/src/test/java/org/elasticsearch/cluster/InternalClusterInfoServiceSchedulingTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ public void collectClusterHeapUsage(ActionListener<Map<String, Long>> listener)
164164
}
165165

166166
/**
167-
* Simple for test {@link NodeUsageStatsForThreadPoolsCollector} implementation that returns an empty map of nodeId string to {@link NodeUsageStatsForThreadPools}.
167+
* Simple for test {@link NodeUsageStatsForThreadPoolsCollector} implementation that returns an empty map of nodeId string to
168+
* {@link NodeUsageStatsForThreadPools}.
168169
*/
169170
private static class StubNodeUsageStatsForThreadPoolsCollector implements NodeUsageStatsForThreadPoolsCollector {
170171
@Override

0 commit comments

Comments
 (0)