Skip to content

Commit de627b7

Browse files
committed
fix issues after backport in 2.11
Signed-off-by: Xun Zhang <xunzh@amazon.com>
1 parent e2be583 commit de627b7

File tree

4 files changed

+7
-88
lines changed

4 files changed

+7
-88
lines changed

ml-algorithms/src/test/java/org/opensearch/ml/engine/httpclient/MLHttpClientFactoryTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public void test_validateIp_validIp_noException() throws UnknownHostException {
3434
@Test
3535
public void test_validateIp_invalidIp_throwException() throws UnknownHostException {
3636
expectedException.expect(UnknownHostException.class);
37-
MLHttpClientFactory.validateIp("www.zaniu.com");
37+
MLHttpClientFactory.validateIp("www.zanniu.com");
3838
}
3939

4040
@Test

plugin/src/main/java/org/opensearch/ml/breaker/MemoryCircuitBreaker.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ public class MemoryCircuitBreaker extends ThresholdCircuitBreaker<Short> {
2020
public static final short DEFAULT_JVM_HEAP_USAGE_THRESHOLD = 85;
2121
public static final short JVM_HEAP_MAX_THRESHOLD = 100; // when threshold is 100, this CB check is ignored
2222
private final JvmService jvmService;
23-
private volatile Integer jvmHeapMemThreshold = 85;
2423

2524
public MemoryCircuitBreaker(JvmService jvmService) {
2625
super(DEFAULT_JVM_HEAP_USAGE_THRESHOLD);
@@ -35,8 +34,9 @@ public MemoryCircuitBreaker(short threshold, JvmService jvmService) {
3534
public MemoryCircuitBreaker(Settings settings, ClusterService clusterService, JvmService jvmService) {
3635
super(DEFAULT_JVM_HEAP_USAGE_THRESHOLD);
3736
this.jvmService = jvmService;
38-
this.jvmHeapMemThreshold = ML_COMMONS_JVM_HEAP_MEM_THRESHOLD.get(settings);
39-
clusterService.getClusterSettings().addSettingsUpdateConsumer(ML_COMMONS_JVM_HEAP_MEM_THRESHOLD, it -> jvmHeapMemThreshold = it);
37+
clusterService
38+
.getClusterSettings()
39+
.addSettingsUpdateConsumer(ML_COMMONS_JVM_HEAP_MEM_THRESHOLD, it -> super.setThreshold(it.shortValue()));
4040
}
4141

4242
@Override

plugin/src/main/java/org/opensearch/ml/breaker/ThresholdCircuitBreaker.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55

66
package org.opensearch.ml.breaker;
77

8+
import lombok.Data;
9+
810
/**
911
* An abstract class for all breakers with threshold.
1012
* @param <T> data type of threshold
1113
*/
14+
@Data
1215
public abstract class ThresholdCircuitBreaker<T> implements CircuitBreaker {
1316

1417
private T threshold;
@@ -17,10 +20,6 @@ public ThresholdCircuitBreaker(T threshold) {
1720
this.threshold = threshold;
1821
}
1922

20-
public T getThreshold() {
21-
return threshold;
22-
}
23-
2423
@Override
2524
public abstract boolean isOpen();
2625
}

plugin/src/test/java/org/opensearch/ml/rest/RestMLMemoryCircuitBreakerIT.java

-80
This file was deleted.

0 commit comments

Comments
 (0)