LANG-1370 Fix EventCountCircuitBreaker increment batch
Fixes #incrementAndCheckState(Integer increment) by passing the increment downstream.
This commit is contained in:
parent
6049e77fdc
commit
7d061e33e5
|
@ -271,7 +271,7 @@ public class EventCountCircuitBreaker extends AbstractCircuitBreaker<Integer> {
|
||||||
@Override
|
@Override
|
||||||
public boolean incrementAndCheckState(final Integer increment)
|
public boolean incrementAndCheckState(final Integer increment)
|
||||||
throws CircuitBreakingException {
|
throws CircuitBreakingException {
|
||||||
return performStateCheck(1);
|
return performStateCheck(increment);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -154,6 +154,21 @@ public class EventCountCircuitBreakerTest {
|
||||||
assertFalse("Closed", breaker.isClosed());
|
assertFalse("Closed", breaker.isClosed());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests that the circuit breaker opens if all conditions are met when using
|
||||||
|
* {@link EventCountCircuitBreaker#incrementAndCheckState(Integer increment)}.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testOpeningWhenThresholdReachedThroughBatch() {
|
||||||
|
final long timeIncrement = NANO_FACTOR / OPENING_THRESHOLD - 1;
|
||||||
|
final EventCountCircuitBreakerTestImpl breaker = new EventCountCircuitBreakerTestImpl(OPENING_THRESHOLD, 1,
|
||||||
|
TimeUnit.SECONDS, CLOSING_THRESHOLD, 1, TimeUnit.SECONDS);
|
||||||
|
long startTime = timeIncrement * (OPENING_THRESHOLD + 1);
|
||||||
|
boolean open = !breaker.at(startTime).incrementAndCheckState(OPENING_THRESHOLD + 1);
|
||||||
|
assertTrue("Not open", open);
|
||||||
|
assertFalse("Closed", breaker.isClosed());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests that an open circuit breaker does not close itself when the number of events
|
* Tests that an open circuit breaker does not close itself when the number of events
|
||||||
* received is over the threshold.
|
* received is over the threshold.
|
||||||
|
|
Loading…
Reference in New Issue