Skip to content

Commit

Permalink
Removing cluster setting as part of ThreadPool and just registering a…
Browse files Browse the repository at this point in the history
… listener on it

Signed-off-by: Gaurav Bafna <gbbafna@amazon.com>
  • Loading branch information
gbbafna committed Oct 11, 2024
1 parent a3db411 commit cc11f7e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
2 changes: 1 addition & 1 deletion server/src/main/java/org/opensearch/node/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,6 @@ public static ThreadPoolType fromType(String type) {

private final ScheduledThreadPoolExecutor scheduler;

private ClusterSettings clusterSettings = null;

public Collection<ExecutorBuilder> builders() {
return Collections.unmodifiableCollection(builders.values());
}
Expand Down Expand Up @@ -418,9 +416,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);
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,7 @@ public void testThreadPoolResizeFail() {
TestThreadPool threadPool = new TestThreadPool("test");
try {
Settings commonSettings = Settings.builder().put("snapshot.max", "50").put("snapshot.core", "100").build();
threadPool.setThreadPool(commonSettings);
ExecutorService executorService = threadPool.executor("snapshot");
OpenSearchThreadPoolExecutor executor = (OpenSearchThreadPoolExecutor) executorService;
assertNotEquals(50, executor.getMaximumPoolSize());
assertNotEquals(100, executor.getCorePoolSize());
assertThrows(IllegalArgumentException.class, () -> threadPool.setThreadPool(commonSettings));
} finally {
terminate(threadPool);
}
Expand Down

0 comments on commit cc11f7e

Please sign in to comment.