From b161100665288527cee3a565d0c5e5327a14286d Mon Sep 17 00:00:00 2001 From: Gaurav Bafna Date: Fri, 11 Oct 2024 18:34:53 +0530 Subject: [PATCH] Removing cluster setting as part of ThreadPool and just registering a listener on it Signed-off-by: Gaurav Bafna --- server/src/main/java/org/opensearch/node/Node.java | 2 +- .../main/java/org/opensearch/threadpool/ThreadPool.java | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/server/src/main/java/org/opensearch/node/Node.java b/server/src/main/java/org/opensearch/node/Node.java index 994a8bf2d57aa..eea021b6b0f80 100644 --- a/server/src/main/java/org/opensearch/node/Node.java +++ b/server/src/main/java/org/opensearch/node/Node.java @@ -624,7 +624,7 @@ protected Node( additionalSettingsFilter, settingsUpgraders ); - threadPool.setClusterSettings(settingsModule.getClusterSettings()); + threadPool.registerClusterSettingsListeners(settingsModule.getClusterSettings()); scriptModule.registerClusterSettingsListeners(scriptService, settingsModule.getClusterSettings()); final NetworkService networkService = new NetworkService( getCustomNameResolvers(pluginsService.filterPlugins(DiscoveryPlugin.class)) diff --git a/server/src/main/java/org/opensearch/threadpool/ThreadPool.java b/server/src/main/java/org/opensearch/threadpool/ThreadPool.java index 3a80a6844fcae..aa9aacfee291a 100644 --- a/server/src/main/java/org/opensearch/threadpool/ThreadPool.java +++ b/server/src/main/java/org/opensearch/threadpool/ThreadPool.java @@ -218,8 +218,6 @@ public static ThreadPoolType fromType(String type) { private final ScheduledThreadPoolExecutor scheduler; - private ClusterSettings clusterSettings = null; - public Collection builders() { return Collections.unmodifiableCollection(builders.values()); } @@ -423,9 +421,8 @@ public Info info(String name) { return holder.info; } - public void setClusterSettings(ClusterSettings clusterSettings) { - this.clusterSettings = clusterSettings; - this.clusterSettings.addSettingsUpdateConsumer(CLUSTER_THREAD_POOL_SIZE_SETTING, this::setThreadPool, this::validateSetting); + public void registerClusterSettingsListeners(ClusterSettings clusterSettings) { + clusterSettings.addSettingsUpdateConsumer(CLUSTER_THREAD_POOL_SIZE_SETTING, this::setThreadPool, this::validateSetting); } /*