|
16 | 16 | import org.elasticsearch.common.component.AbstractLifecycleComponent; |
17 | 17 | import org.elasticsearch.common.settings.ClusterSettings; |
18 | 18 | import org.elasticsearch.common.settings.Setting; |
19 | | -import org.elasticsearch.common.settings.Settings; |
20 | 19 | import org.elasticsearch.core.TimeValue; |
21 | 20 | import org.elasticsearch.monitor.jvm.HotThreads; |
22 | 21 | import org.elasticsearch.tasks.TaskManager; |
@@ -91,22 +90,15 @@ public class SearchTaskWatchdog extends AbstractLifecycleComponent { |
91 | 90 | private volatile long lastLoggedNanos = 0; |
92 | 91 | private final AtomicBoolean scheduled = new AtomicBoolean(false); |
93 | 92 |
|
94 | | - public SearchTaskWatchdog(Settings settings, ClusterSettings clusterSettings, TaskManager taskManager, ThreadPool threadPool) { |
| 93 | + public SearchTaskWatchdog(ClusterSettings clusterSettings, TaskManager taskManager, ThreadPool threadPool) { |
95 | 94 | this.taskManager = taskManager; |
96 | 95 | this.threadPool = threadPool; |
97 | 96 |
|
98 | | - this.enabled = ENABLED.get(settings); |
99 | | - this.coordinatorThresholdNanos = COORDINATOR_THRESHOLD.get(settings).nanos(); |
100 | | - this.dataNodeThresholdNanos = DATA_NODE_THRESHOLD.get(settings).nanos(); |
101 | | - this.minThresholdNanos = computeMinThreshold(coordinatorThresholdNanos, dataNodeThresholdNanos); |
102 | | - this.interval = INTERVAL.get(settings); |
103 | | - this.cooldownPeriodNanos = COOLDOWN_PERIOD.get(settings).nanos(); |
104 | | - |
105 | | - clusterSettings.addSettingsUpdateConsumer(ENABLED, this::setEnabled); |
106 | | - clusterSettings.addSettingsUpdateConsumer(COORDINATOR_THRESHOLD, v -> setCoordinatorThreshold(v.nanos())); |
107 | | - clusterSettings.addSettingsUpdateConsumer(DATA_NODE_THRESHOLD, v -> setDataNodeThreshold(v.nanos())); |
108 | | - clusterSettings.addSettingsUpdateConsumer(INTERVAL, v -> this.interval = v); |
109 | | - clusterSettings.addSettingsUpdateConsumer(COOLDOWN_PERIOD, v -> this.cooldownPeriodNanos = v.nanos()); |
| 97 | + clusterSettings.initializeAndWatch(ENABLED, this::setEnabled); |
| 98 | + clusterSettings.initializeAndWatch(COORDINATOR_THRESHOLD, v -> setCoordinatorThreshold(v.nanos())); |
| 99 | + clusterSettings.initializeAndWatch(DATA_NODE_THRESHOLD, v -> setDataNodeThreshold(v.nanos())); |
| 100 | + clusterSettings.initializeAndWatch(INTERVAL, v -> this.interval = v); |
| 101 | + clusterSettings.initializeAndWatch(COOLDOWN_PERIOD, v -> this.cooldownPeriodNanos = v.nanos()); |
110 | 102 | } |
111 | 103 |
|
112 | 104 | private void setEnabled(boolean enabled) { |
|
0 commit comments