Skip to content

Commit 5783217

Browse files
rename collector
1 parent a93d678 commit 5783217

File tree

7 files changed

+33
-27
lines changed

7 files changed

+33
-27
lines changed

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

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
import org.elasticsearch.cluster.EstimatedHeapUsage;
2525
import org.elasticsearch.cluster.EstimatedHeapUsageCollector;
2626
import org.elasticsearch.cluster.InternalClusterInfoService;
27-
import org.elasticsearch.cluster.NodeUsageLoadCollector;
2827
import org.elasticsearch.cluster.NodeUsageStatsForThreadPools;
28+
import org.elasticsearch.cluster.NodeUsageStatsForThreadPoolsCollector;
2929
import org.elasticsearch.cluster.metadata.IndexMetadata;
3030
import org.elasticsearch.cluster.node.DiscoveryNode;
3131
import org.elasticsearch.cluster.node.DiscoveryNodeUtils;
@@ -133,7 +133,11 @@ public class IndexShardIT extends ESSingleNodeTestCase {
133133

134134
@Override
135135
protected Collection<Class<? extends Plugin>> getPlugins() {
136-
return pluginList(InternalSettingsPlugin.class, BogusEstimatedHeapUsagePlugin.class, BogusNodeUsageLoadCollectorPlugin.class);
136+
return pluginList(
137+
InternalSettingsPlugin.class,
138+
BogusEstimatedHeapUsagePlugin.class,
139+
BogusNodeUsageStatsForThreadPoolsCollectorPlugin.class
140+
);
137141
}
138142

139143
public void testLockTryingToDelete() throws Exception {
@@ -328,7 +332,7 @@ public void testNodeWriteLoadsArePresent() {
328332
ClusterInfoServiceUtils.refresh(clusterInfoService);
329333
nodeThreadPoolStats = clusterInfoService.getClusterInfo().getNodeUsageStatsForThreadPools();
330334

331-
/** Verify that each node has a write load reported. The test {@link BogusNodeUsageLoadCollector} generates random load values */
335+
/** Verify that each node has a write load reported. The test {@link BogusNodeUsageStatsForThreadPoolsCollector} generates random load values */
332336
ClusterState state = getInstanceFromNode(ClusterService.class).state();
333337
assertEquals(state.nodes().size(), nodeThreadPoolStats.size());
334338
for (DiscoveryNode node : state.nodes()) {
@@ -932,17 +936,17 @@ public ClusterService getClusterService() {
932936
}
933937

934938
/**
935-
* A simple {@link NodeUsageLoadCollector} implementation that creates and returns random {@link NodeUsageStatsForThreadPools} for each node in the
939+
* A simple {@link NodeUsageStatsForThreadPoolsCollector} implementation that creates and returns random {@link NodeUsageStatsForThreadPools} for each node in the
936940
* cluster.
937941
* <p>
938942
* Note: there's an 'org.elasticsearch.cluster.WriteLoadCollector' file that declares this implementation so that the plugin system can
939943
* pick it up and use it for the test set-up.
940944
*/
941-
public static class BogusNodeUsageLoadCollector implements NodeUsageLoadCollector {
945+
public static class BogusNodeUsageStatsForThreadPoolsCollector implements NodeUsageStatsForThreadPoolsCollector {
942946

943-
private final BogusNodeUsageLoadCollectorPlugin plugin;
947+
private final BogusNodeUsageStatsForThreadPoolsCollectorPlugin plugin;
944948

945-
public BogusNodeUsageLoadCollector(BogusNodeUsageLoadCollectorPlugin plugin) {
949+
public BogusNodeUsageStatsForThreadPoolsCollector(BogusNodeUsageStatsForThreadPoolsCollectorPlugin plugin) {
946950
this.plugin = plugin;
947951
}
948952

@@ -973,7 +977,7 @@ private NodeUsageStatsForThreadPools makeRandomNodeLoad(String nodeId) {
973977
/**
974978
* Make a plugin to gain access to the {@link ClusterService} instance.
975979
*/
976-
public static class BogusNodeUsageLoadCollectorPlugin extends Plugin implements ClusterPlugin {
980+
public static class BogusNodeUsageStatsForThreadPoolsCollectorPlugin extends Plugin implements ClusterPlugin {
977981

978982
private final SetOnce<ClusterService> clusterService = new SetOnce<>();
979983

server/src/internalClusterTest/resources/META-INF/services/org.elasticsearch.cluster.NodeUsageLoadCollector renamed to server/src/internalClusterTest/resources/META-INF/services/org.elasticsearch.cluster.NodeUsageStatsForThreadPoolsCollector

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
# License v3.0 only", or the "Server Side Public License, v 1".
88
#
99

10-
org.elasticsearch.index.shard.IndexShardIT$BogusNodeUsageLoadCollector
10+
org.elasticsearch.index.shard.IndexShardIT$BogusNodeUsageStatsForThreadPoolsCollector

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public class InternalClusterInfoService implements ClusterInfoService, ClusterSt
112112
private final Object mutex = new Object();
113113
private final List<ActionListener<ClusterInfo>> nextRefreshListeners = new ArrayList<>();
114114
private final EstimatedHeapUsageCollector estimatedHeapUsageCollector;
115-
private final NodeUsageLoadCollector nodeUsageLoadCollector;
115+
private final NodeUsageStatsForThreadPoolsCollector nodeUsageStatsForThreadPoolsCollector;
116116

117117
private AsyncRefresh currentRefresh;
118118
private RefreshScheduler refreshScheduler;
@@ -124,7 +124,7 @@ public InternalClusterInfoService(
124124
ThreadPool threadPool,
125125
Client client,
126126
EstimatedHeapUsageCollector estimatedHeapUsageCollector,
127-
NodeUsageLoadCollector nodeUsageLoadCollector
127+
NodeUsageStatsForThreadPoolsCollector nodeUsageStatsForThreadPoolsCollector
128128
) {
129129
this.leastAvailableSpaceUsages = Map.of();
130130
this.mostAvailableSpaceUsages = Map.of();
@@ -135,7 +135,7 @@ public InternalClusterInfoService(
135135
this.threadPool = threadPool;
136136
this.client = client;
137137
this.estimatedHeapUsageCollector = estimatedHeapUsageCollector;
138-
this.nodeUsageLoadCollector = nodeUsageLoadCollector;
138+
this.nodeUsageStatsForThreadPoolsCollector = nodeUsageStatsForThreadPoolsCollector;
139139
this.updateFrequency = INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL_SETTING.get(settings);
140140
this.fetchTimeout = INTERNAL_CLUSTER_INFO_TIMEOUT_SETTING.get(settings);
141141
this.diskThresholdEnabled = DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.get(settings);
@@ -269,7 +269,7 @@ private void maybeFetchNodesThreadPoolUsageStats(WriteLoadDeciderStatus writeLoa
269269
}
270270

271271
private void fetchNodesThreadPoolUsageStats() {
272-
nodeUsageLoadCollector.collectUsageStats(ActionListener.releaseAfter(new ActionListener<>() {
272+
nodeUsageStatsForThreadPoolsCollector.collectUsageStats(ActionListener.releaseAfter(new ActionListener<>() {
273273
@Override
274274
public void onResponse(Map<String, NodeUsageStatsForThreadPools> writeLoads) {
275275
nodeThreadPoolUsageStatsPerNode = writeLoads;

server/src/main/java/org/elasticsearch/cluster/NodeUsageLoadCollector.java renamed to server/src/main/java/org/elasticsearch/cluster/NodeUsageStatsForThreadPoolsCollector.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
* <p>
1919
* Results are returned as a map of node ID to node usage stats.
2020
*/
21-
public interface NodeUsageLoadCollector {
21+
public interface NodeUsageStatsForThreadPoolsCollector {
2222
/**
2323
* This will be used when there is no NodeUsageLoadCollector available.
2424
*/
25-
NodeUsageLoadCollector EMPTY = listener -> listener.onResponse(Map.of());
25+
NodeUsageStatsForThreadPoolsCollector EMPTY = listener -> listener.onResponse(Map.of());
2626

2727
/**
2828
* Collects the write load estimates from the cluster.

server/src/main/java/org/elasticsearch/node/NodeServiceProvider.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import org.elasticsearch.cluster.ClusterInfoService;
1515
import org.elasticsearch.cluster.EstimatedHeapUsageCollector;
1616
import org.elasticsearch.cluster.InternalClusterInfoService;
17-
import org.elasticsearch.cluster.NodeUsageLoadCollector;
17+
import org.elasticsearch.cluster.NodeUsageStatsForThreadPoolsCollector;
1818
import org.elasticsearch.cluster.node.DiscoveryNode;
1919
import org.elasticsearch.cluster.service.ClusterService;
2020
import org.elasticsearch.common.breaker.CircuitBreaker;
@@ -80,17 +80,17 @@ ClusterInfoService newClusterInfoService(
8080
EstimatedHeapUsageCollector.class,
8181
() -> EstimatedHeapUsageCollector.EMPTY
8282
);
83-
final NodeUsageLoadCollector nodeUsageLoadCollector = pluginsService.loadSingletonServiceProvider(
84-
NodeUsageLoadCollector.class,
85-
() -> NodeUsageLoadCollector.EMPTY
83+
final NodeUsageStatsForThreadPoolsCollector nodeUsageStatsForThreadPoolsCollector = pluginsService.loadSingletonServiceProvider(
84+
NodeUsageStatsForThreadPoolsCollector.class,
85+
() -> NodeUsageStatsForThreadPoolsCollector.EMPTY
8686
);
8787
final InternalClusterInfoService service = new InternalClusterInfoService(
8888
settings,
8989
clusterService,
9090
threadPool,
9191
client,
9292
estimatedHeapUsageCollector,
93-
nodeUsageLoadCollector
93+
nodeUsageStatsForThreadPoolsCollector
9494
);
9595
if (DiscoveryNode.isMasterNode(settings)) {
9696
// listen for state changes (this node starts/stops being the elected master, or new nodes are added)

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,16 @@ protected PrioritizedEsThreadPoolExecutor createThreadPoolExecutor() {
8484

8585
final FakeClusterInfoServiceClient client = new FakeClusterInfoServiceClient(threadPool);
8686
final EstimatedHeapUsageCollector mockEstimatedHeapUsageCollector = spy(new StubEstimatedEstimatedHeapUsageCollector());
87-
final NodeUsageLoadCollector mockNodeUsageLoadCollector = spy(new StubNodeUsageLoadCollector());
87+
final NodeUsageStatsForThreadPoolsCollector mockNodeUsageStatsForThreadPoolsCollector = spy(
88+
new StubNodeUsageStatsForThreadPoolsCollector()
89+
);
8890
final InternalClusterInfoService clusterInfoService = new InternalClusterInfoService(
8991
settings,
9092
clusterService,
9193
threadPool,
9294
client,
9395
mockEstimatedHeapUsageCollector,
94-
mockNodeUsageLoadCollector
96+
mockNodeUsageStatsForThreadPoolsCollector
9597
);
9698
clusterService.addListener(clusterInfoService);
9799
clusterInfoService.addListener(ignored -> {});
@@ -129,14 +131,14 @@ protected PrioritizedEsThreadPoolExecutor createThreadPoolExecutor() {
129131

130132
for (int i = 0; i < 3; i++) {
131133
Mockito.clearInvocations(mockEstimatedHeapUsageCollector);
132-
Mockito.clearInvocations(mockNodeUsageLoadCollector);
134+
Mockito.clearInvocations(mockNodeUsageStatsForThreadPoolsCollector);
133135
final int initialRequestCount = client.requestCount;
134136
final long duration = INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL_SETTING.get(settings).millis();
135137
runFor(deterministicTaskQueue, duration);
136138
deterministicTaskQueue.runAllRunnableTasks();
137139
assertThat(client.requestCount, equalTo(initialRequestCount + 2)); // should have run two client requests per interval
138140
verify(mockEstimatedHeapUsageCollector).collectClusterHeapUsage(any()); // Should poll for heap usage once per interval
139-
verify(mockNodeUsageLoadCollector).collectUsageStats(any());
141+
verify(mockNodeUsageStatsForThreadPoolsCollector).collectUsageStats(any());
140142
}
141143

142144
final AtomicBoolean failMaster2 = new AtomicBoolean();
@@ -162,9 +164,9 @@ public void collectClusterHeapUsage(ActionListener<Map<String, Long>> listener)
162164
}
163165

164166
/**
165-
* Simple for test {@link NodeUsageLoadCollector} 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 {@link NodeUsageStatsForThreadPools}.
166168
*/
167-
private static class StubNodeUsageLoadCollector implements NodeUsageLoadCollector {
169+
private static class StubNodeUsageStatsForThreadPoolsCollector implements NodeUsageStatsForThreadPoolsCollector {
168170
@Override
169171
public void collectUsageStats(ActionListener<Map<String, NodeUsageStatsForThreadPools>> listener) {
170172
listener.onResponse(Map.of());

test/framework/src/main/java/org/elasticsearch/cluster/MockInternalClusterInfoService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static class TestPlugin extends Plugin {}
4343
private volatile BiFunction<DiscoveryNode, FsInfo.Path, FsInfo.Path> diskUsageFunction;
4444

4545
public MockInternalClusterInfoService(Settings settings, ClusterService clusterService, ThreadPool threadPool, NodeClient client) {
46-
super(settings, clusterService, threadPool, client, EstimatedHeapUsageCollector.EMPTY, NodeUsageLoadCollector.EMPTY);
46+
super(settings, clusterService, threadPool, client, EstimatedHeapUsageCollector.EMPTY, NodeUsageStatsForThreadPoolsCollector.EMPTY);
4747
}
4848

4949
public void setDiskUsageFunctionAndRefresh(BiFunction<DiscoveryNode, FsInfo.Path, FsInfo.Path> diskUsageFn) {

0 commit comments

Comments
 (0)