use of com.tencent.polaris.api.plugin.stat.DefaultCircuitBreakResult in project polaris-java by polarismesh.
the class InMemoryRegistry method convertToCircuitBreakGauge.
private CircuitBreakGauge convertToCircuitBreakGauge(Entry<StatusDimension, CircuitBreakerStatus> dimensionEntry, Instance instance) {
DefaultCircuitBreakResult result = new DefaultCircuitBreakResult();
result.setMethod(dimensionEntry.getKey().getMethod());
result.setCallerService(dimensionEntry.getKey().getCallerService());
result.setCircuitBreakStatus(dimensionEntry.getValue());
result.setHost(instance.getHost());
result.setPort(instance.getPort());
result.setInstanceId(instance.getId());
result.setService(instance.getService());
result.setNamespace(instance.getNamespace());
return result;
}
use of com.tencent.polaris.api.plugin.stat.DefaultCircuitBreakResult in project polaris-java by polarismesh.
the class PrometheusPushHandlerTest method testCircuitBreakerRepeatOpenToHalfOpen.
@Test
public void testCircuitBreakerRepeatOpenToHalfOpen() throws InterruptedException {
changeCircuitBreakerStatus(mockFixedCircuitResult(CircuitBreakerStatus.Status.OPEN));
changeCircuitBreakerStatus(mockFixedCircuitResult(CircuitBreakerStatus.Status.HALF_OPEN));
changeCircuitBreakerStatus(mockFixedCircuitResult(CircuitBreakerStatus.Status.OPEN));
changeCircuitBreakerStatus(mockFixedCircuitResult(CircuitBreakerStatus.Status.HALF_OPEN));
changeCircuitBreakerStatus(mockFixedCircuitResult(CircuitBreakerStatus.Status.OPEN));
Thread.sleep(pushInterval + 1000);
handler.stopHandle();
DefaultCircuitBreakResult example = mockFixedCircuitResult(CircuitBreakerStatus.Status.OPEN);
Assert.assertEquals(new Double(1), getOpenResult(example));
Assert.assertEquals(new Double(0), getHalfOpenResult(example));
}
Aggregations