diff --git a/plugin/src/main/java/org/opensearch/ml/breaker/DiskCircuitBreaker.java b/plugin/src/main/java/org/opensearch/ml/breaker/DiskCircuitBreaker.java index 5c8356a6f4..0d87222d1e 100644 --- a/plugin/src/main/java/org/opensearch/ml/breaker/DiskCircuitBreaker.java +++ b/plugin/src/main/java/org/opensearch/ml/breaker/DiskCircuitBreaker.java @@ -5,7 +5,7 @@ package org.opensearch.ml.breaker; -import static org.opensearch.ml.settings.MLCommonsSettings.ML_COMMONS_DISK_FREE_SPACE_MIN_VALUE; +import static org.opensearch.ml.settings.MLCommonsSettings.ML_COMMONS_DISK_FREE_SPACE_THRESHOLD; import java.io.File; import java.security.AccessController; @@ -27,8 +27,8 @@ public class DiskCircuitBreaker extends ThresholdCircuitBreaker { private final File diskDir; public DiskCircuitBreaker(Settings settings, ClusterService clusterService, File diskDir) { - super(Optional.ofNullable(ML_COMMONS_DISK_FREE_SPACE_MIN_VALUE.get(settings)).orElse(DEFAULT_DISK_SHORTAGE_THRESHOLD)); - clusterService.getClusterSettings().addSettingsUpdateConsumer(ML_COMMONS_DISK_FREE_SPACE_MIN_VALUE, super::setThreshold); + super(Optional.ofNullable(ML_COMMONS_DISK_FREE_SPACE_THRESHOLD.get(settings)).orElse(DEFAULT_DISK_SHORTAGE_THRESHOLD)); + clusterService.getClusterSettings().addSettingsUpdateConsumer(ML_COMMONS_DISK_FREE_SPACE_THRESHOLD, super::setThreshold); this.diskDir = diskDir; } diff --git a/plugin/src/main/java/org/opensearch/ml/plugin/MachineLearningPlugin.java b/plugin/src/main/java/org/opensearch/ml/plugin/MachineLearningPlugin.java index de1bb9901b..df9b01b9a9 100644 --- a/plugin/src/main/java/org/opensearch/ml/plugin/MachineLearningPlugin.java +++ b/plugin/src/main/java/org/opensearch/ml/plugin/MachineLearningPlugin.java @@ -911,7 +911,7 @@ public List> getSettings() { MLCommonsSettings.ML_COMMONS_MAX_DEPLOY_MODEL_TASKS_PER_NODE, MLCommonsSettings.ML_COMMONS_TRUSTED_URL_REGEX, MLCommonsSettings.ML_COMMONS_NATIVE_MEM_THRESHOLD, - MLCommonsSettings.ML_COMMONS_DISK_FREE_SPACE_MIN_VALUE, + MLCommonsSettings.ML_COMMONS_DISK_FREE_SPACE_THRESHOLD, MLCommonsSettings.ML_COMMONS_JVM_HEAP_MEM_THRESHOLD, MLCommonsSettings.ML_COMMONS_EXCLUDE_NODE_NAMES, MLCommonsSettings.ML_COMMONS_ALLOW_CUSTOM_DEPLOYMENT_PLAN, diff --git a/plugin/src/main/java/org/opensearch/ml/settings/MLCommonsSettings.java b/plugin/src/main/java/org/opensearch/ml/settings/MLCommonsSettings.java index a1ab5b907c..07ccc196b4 100644 --- a/plugin/src/main/java/org/opensearch/ml/settings/MLCommonsSettings.java +++ b/plugin/src/main/java/org/opensearch/ml/settings/MLCommonsSettings.java @@ -77,9 +77,9 @@ private MLCommonsSettings() {} public static final Setting ML_COMMONS_JVM_HEAP_MEM_THRESHOLD = Setting .intSetting("plugins.ml_commons.jvm_heap_memory_threshold", 85, 0, 100, Setting.Property.NodeScope, Setting.Property.Dynamic); - public static final Setting ML_COMMONS_DISK_FREE_SPACE_MIN_VALUE = Setting + public static final Setting ML_COMMONS_DISK_FREE_SPACE_THRESHOLD = Setting .intSetting( - "plugins.ml_commons.disk_free_space_min_value", + "plugins.ml_commons.disk_free_space_threshold", 5, 0, Integer.MAX_VALUE, diff --git a/plugin/src/test/java/org/opensearch/ml/breaker/DiskCircuitBreakerTests.java b/plugin/src/test/java/org/opensearch/ml/breaker/DiskCircuitBreakerTests.java index 3ac7b1d2c5..84d32db8b0 100644 --- a/plugin/src/test/java/org/opensearch/ml/breaker/DiskCircuitBreakerTests.java +++ b/plugin/src/test/java/org/opensearch/ml/breaker/DiskCircuitBreakerTests.java @@ -8,7 +8,7 @@ package org.opensearch.ml.breaker; import static org.mockito.Mockito.when; -import static org.opensearch.ml.settings.MLCommonsSettings.ML_COMMONS_DISK_FREE_SPACE_MIN_VALUE; +import static org.opensearch.ml.settings.MLCommonsSettings.ML_COMMONS_DISK_FREE_SPACE_THRESHOLD; import java.io.File; import java.util.HashSet; @@ -34,13 +34,13 @@ public class DiskCircuitBreakerTests { public void setup() { MockitoAnnotations.openMocks(this); when(clusterService.getClusterSettings()) - .thenReturn(new ClusterSettings(Settings.EMPTY, new HashSet<>(List.of(ML_COMMONS_DISK_FREE_SPACE_MIN_VALUE)))); + .thenReturn(new ClusterSettings(Settings.EMPTY, new HashSet<>(List.of(ML_COMMONS_DISK_FREE_SPACE_THRESHOLD)))); } @Test public void test_isOpen_whenDiskFreeSpaceIsHigherThanMinValue_breakerIsNotOpen() { CircuitBreaker breaker = new DiskCircuitBreaker( - Settings.builder().put(ML_COMMONS_DISK_FREE_SPACE_MIN_VALUE.getKey(), 5).build(), + Settings.builder().put(ML_COMMONS_DISK_FREE_SPACE_THRESHOLD.getKey(), 5).build(), clusterService, file ); @@ -51,7 +51,7 @@ public void test_isOpen_whenDiskFreeSpaceIsHigherThanMinValue_breakerIsNotOpen() @Test public void test_isOpen_whenDiskFreeSpaceIsLessThanMinValue_breakerIsOpen() { CircuitBreaker breaker = new DiskCircuitBreaker( - Settings.builder().put(ML_COMMONS_DISK_FREE_SPACE_MIN_VALUE.getKey(), 5).build(), + Settings.builder().put(ML_COMMONS_DISK_FREE_SPACE_THRESHOLD.getKey(), 5).build(), clusterService, file ); @@ -62,7 +62,7 @@ public void test_isOpen_whenDiskFreeSpaceIsLessThanMinValue_breakerIsOpen() { @Test public void test_isOpen_whenDiskFreeSpaceConfiguredToZero_breakerIsNotOpen() { CircuitBreaker breaker = new DiskCircuitBreaker( - Settings.builder().put(ML_COMMONS_DISK_FREE_SPACE_MIN_VALUE.getKey(), 5).build(), + Settings.builder().put(ML_COMMONS_DISK_FREE_SPACE_THRESHOLD.getKey(), 5).build(), clusterService, file ); diff --git a/plugin/src/test/java/org/opensearch/ml/breaker/MLCircuitBreakerServiceTests.java b/plugin/src/test/java/org/opensearch/ml/breaker/MLCircuitBreakerServiceTests.java index 9ed06d0b3c..76f371004e 100644 --- a/plugin/src/test/java/org/opensearch/ml/breaker/MLCircuitBreakerServiceTests.java +++ b/plugin/src/test/java/org/opensearch/ml/breaker/MLCircuitBreakerServiceTests.java @@ -6,6 +6,7 @@ package org.opensearch.ml.breaker; import static org.mockito.Mockito.when; +import static org.opensearch.ml.settings.MLCommonsSettings.ML_COMMONS_DISK_FREE_SPACE_THRESHOLD; import static org.opensearch.ml.settings.MLCommonsSettings.ML_COMMONS_JVM_HEAP_MEM_THRESHOLD; import static org.opensearch.ml.settings.MLCommonsSettings.ML_COMMONS_NATIVE_MEM_THRESHOLD; @@ -103,7 +104,9 @@ public void testInit() { .build(); ClusterSettings clusterSettings = new ClusterSettings( settings, - new HashSet<>(Arrays.asList(ML_COMMONS_NATIVE_MEM_THRESHOLD, ML_COMMONS_JVM_HEAP_MEM_THRESHOLD)) + new HashSet<>( + Arrays.asList(ML_COMMONS_NATIVE_MEM_THRESHOLD, ML_COMMONS_JVM_HEAP_MEM_THRESHOLD, ML_COMMONS_DISK_FREE_SPACE_THRESHOLD) + ) ); when(clusterService.getClusterSettings()).thenReturn(clusterSettings); mlCircuitBreakerService = new MLCircuitBreakerService(jvmService, osService, settings, clusterService);