Skip to content

Rename NodeUsageStatsForThreadPoolsCollector to ThreadPoolUsageCollector #131727

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.elasticsearch.cluster.EstimatedHeapUsageCollector;
import org.elasticsearch.cluster.InternalClusterInfoService;
import org.elasticsearch.cluster.NodeUsageStatsForThreadPools;
import org.elasticsearch.cluster.NodeUsageStatsForThreadPoolsCollector;
import org.elasticsearch.cluster.ThreadPoolUsageCollector;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.cluster.metadata.ProjectId;
import org.elasticsearch.cluster.node.DiscoveryNode;
Expand Down Expand Up @@ -334,7 +334,7 @@ public void testNodeWriteLoadsArePresent() {
ClusterInfoServiceUtils.refresh(clusterInfoService);
nodeThreadPoolStats = clusterInfoService.getClusterInfo().getNodeUsageStatsForThreadPools();

/** Verify that each node has usage stats reported. The test {@link BogusNodeUsageStatsForThreadPoolsCollector} implementation
/** Verify that each node has usage stats reported. The test {@link BogusThreadPoolUsageCollector} implementation
* generates random usage values */
ClusterState state = getInstanceFromNode(ClusterService.class).state();
assertEquals(state.nodes().size(), nodeThreadPoolStats.size());
Expand Down Expand Up @@ -995,17 +995,17 @@ public ClusterService getClusterService() {
}

/**
* A simple {@link NodeUsageStatsForThreadPoolsCollector} implementation that creates and returns random
* A simple {@link ThreadPoolUsageCollector} implementation that creates and returns random
* {@link NodeUsageStatsForThreadPools} for each node in the cluster.
* <p>
* Note: there's an 'org.elasticsearch.cluster.NodeUsageStatsForThreadPoolsCollector' file that declares this implementation so that the
* plugin system can pick it up and use it for the test set-up.
*/
public static class BogusNodeUsageStatsForThreadPoolsCollector implements NodeUsageStatsForThreadPoolsCollector {
public static class BogusThreadPoolUsageCollector implements ThreadPoolUsageCollector {

private final BogusNodeUsageStatsForThreadPoolsCollectorPlugin plugin;

public BogusNodeUsageStatsForThreadPoolsCollector(BogusNodeUsageStatsForThreadPoolsCollectorPlugin plugin) {
public BogusThreadPoolUsageCollector(BogusNodeUsageStatsForThreadPoolsCollectorPlugin plugin) {
this.plugin = plugin;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
# License v3.0 only", or the "Server Side Public License, v 1".
#

org.elasticsearch.index.shard.IndexShardIT$BogusNodeUsageStatsForThreadPoolsCollector
org.elasticsearch.index.shard.IndexShardIT$BogusThreadPoolUsageCollector
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public class InternalClusterInfoService implements ClusterInfoService, ClusterSt
private final Object mutex = new Object();
private final List<ActionListener<ClusterInfo>> nextRefreshListeners = new ArrayList<>();
private final EstimatedHeapUsageCollector estimatedHeapUsageCollector;
private final NodeUsageStatsForThreadPoolsCollector nodeUsageStatsForThreadPoolsCollector;
private final ThreadPoolUsageCollector threadPoolUsageCollector;

private AsyncRefresh currentRefresh;
private RefreshScheduler refreshScheduler;
Expand All @@ -125,7 +125,7 @@ public InternalClusterInfoService(
ThreadPool threadPool,
Client client,
EstimatedHeapUsageCollector estimatedHeapUsageCollector,
NodeUsageStatsForThreadPoolsCollector nodeUsageStatsForThreadPoolsCollector
ThreadPoolUsageCollector nodeUsageStatsForThreadPoolsCollector
) {
this.leastAvailableSpaceUsages = Map.of();
this.mostAvailableSpaceUsages = Map.of();
Expand All @@ -136,7 +136,7 @@ public InternalClusterInfoService(
this.threadPool = threadPool;
this.client = client;
this.estimatedHeapUsageCollector = estimatedHeapUsageCollector;
this.nodeUsageStatsForThreadPoolsCollector = nodeUsageStatsForThreadPoolsCollector;
this.threadPoolUsageCollector = nodeUsageStatsForThreadPoolsCollector;
this.updateFrequency = INTERNAL_CLUSTER_INFO_UPDATE_INTERVAL_SETTING.get(settings);
this.fetchTimeout = INTERNAL_CLUSTER_INFO_TIMEOUT_SETTING.get(settings);
this.diskThresholdEnabled = DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.get(settings);
Expand Down Expand Up @@ -270,7 +270,7 @@ private void maybeFetchNodesUsageStatsForThreadPools(WriteLoadDeciderStatus writ
}

private void fetchNodesUsageStatsForThreadPools() {
nodeUsageStatsForThreadPoolsCollector.collectUsageStats(ActionListener.releaseAfter(new ActionListener<>() {
threadPoolUsageCollector.collectUsageStats(ActionListener.releaseAfter(new ActionListener<>() {
@Override
public void onResponse(Map<String, NodeUsageStatsForThreadPools> writeLoads) {
nodeThreadPoolUsageStatsPerNode = writeLoads;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
* <p>
* Results are returned as a map of node ID to node usage stats.
*/
public interface NodeUsageStatsForThreadPoolsCollector {
public interface ThreadPoolUsageCollector {
/**
* This will be used when there is no NodeUsageLoadCollector available.
*/
NodeUsageStatsForThreadPoolsCollector EMPTY = listener -> listener.onResponse(Map.of());
ThreadPoolUsageCollector EMPTY = listener -> listener.onResponse(Map.of());

/**
* Collects the write load estimates from the cluster.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.elasticsearch.cluster.ClusterInfoService;
import org.elasticsearch.cluster.EstimatedHeapUsageCollector;
import org.elasticsearch.cluster.InternalClusterInfoService;
import org.elasticsearch.cluster.NodeUsageStatsForThreadPoolsCollector;
import org.elasticsearch.cluster.ThreadPoolUsageCollector;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.breaker.CircuitBreaker;
Expand Down Expand Up @@ -80,9 +80,9 @@ ClusterInfoService newClusterInfoService(
EstimatedHeapUsageCollector.class,
() -> EstimatedHeapUsageCollector.EMPTY
);
final NodeUsageStatsForThreadPoolsCollector nodeUsageStatsForThreadPoolsCollector = pluginsService.loadSingletonServiceProvider(
NodeUsageStatsForThreadPoolsCollector.class,
() -> NodeUsageStatsForThreadPoolsCollector.EMPTY
final ThreadPoolUsageCollector nodeUsageStatsForThreadPoolsCollector = pluginsService.loadSingletonServiceProvider(
ThreadPoolUsageCollector.class,
() -> ThreadPoolUsageCollector.EMPTY
);
final InternalClusterInfoService service = new InternalClusterInfoService(
settings,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ protected PrioritizedEsThreadPoolExecutor createThreadPoolExecutor() {

final FakeClusterInfoServiceClient client = new FakeClusterInfoServiceClient(threadPool);
final EstimatedHeapUsageCollector mockEstimatedHeapUsageCollector = spy(new StubEstimatedEstimatedHeapUsageCollector());
final NodeUsageStatsForThreadPoolsCollector mockNodeUsageStatsForThreadPoolsCollector = spy(
new StubNodeUsageStatsForThreadPoolsCollector()
);
final ThreadPoolUsageCollector mockNodeUsageStatsForThreadPoolsCollector = spy(new StubThreadPoolUsageCollector());
final InternalClusterInfoService clusterInfoService = new InternalClusterInfoService(
settings,
clusterService,
Expand Down Expand Up @@ -164,10 +162,10 @@ public void collectClusterHeapUsage(ActionListener<Map<String, Long>> listener)
}

/**
* Simple for test {@link NodeUsageStatsForThreadPoolsCollector} implementation that returns an empty map of nodeId string to
* Simple for test {@link ThreadPoolUsageCollector} implementation that returns an empty map of nodeId string to
* {@link NodeUsageStatsForThreadPools}.
*/
private static class StubNodeUsageStatsForThreadPoolsCollector implements NodeUsageStatsForThreadPoolsCollector {
private static class StubThreadPoolUsageCollector implements ThreadPoolUsageCollector {
@Override
public void collectUsageStats(ActionListener<Map<String, NodeUsageStatsForThreadPools>> listener) {
listener.onResponse(Map.of());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static class TestPlugin extends Plugin {}
private volatile BiFunction<DiscoveryNode, FsInfo.Path, FsInfo.Path> diskUsageFunction;

public MockInternalClusterInfoService(Settings settings, ClusterService clusterService, ThreadPool threadPool, NodeClient client) {
super(settings, clusterService, threadPool, client, EstimatedHeapUsageCollector.EMPTY, NodeUsageStatsForThreadPoolsCollector.EMPTY);
super(settings, clusterService, threadPool, client, EstimatedHeapUsageCollector.EMPTY, ThreadPoolUsageCollector.EMPTY);
}

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