Class EventCountCircuitBreaker.AbstractStateStrategy
- java.lang.Object
-
- org.apache.commons.lang3.concurrent.EventCountCircuitBreaker.AbstractStateStrategy
-
- Direct Known Subclasses:
EventCountCircuitBreaker.StateStrategyClosed,EventCountCircuitBreaker.StateStrategyOpen
- Enclosing class:
- EventCountCircuitBreaker
private abstract static class EventCountCircuitBreaker.AbstractStateStrategy extends java.lang.ObjectInternally used class for executing check logic based on the current state of the circuit breaker. Having this logic extracted into special classes avoids complex if-then-else cascades.
-
-
Constructor Summary
Constructors Modifier Constructor Description privateAbstractStateStrategy()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract longfetchCheckInterval(EventCountCircuitBreaker breaker)Obtains the check interval to applied for the represented state from the givenCircuitBreaker.booleanisCheckIntervalFinished(EventCountCircuitBreaker breaker, EventCountCircuitBreaker.CheckIntervalData currentData, long now)Tests whether the end of the current check interval is reached.abstract booleanisStateTransition(EventCountCircuitBreaker breaker, EventCountCircuitBreaker.CheckIntervalData currentData, EventCountCircuitBreaker.CheckIntervalData nextData)Tests whether the specifiedEventCountCircuitBreaker.CheckIntervalDataobjects indicate that a state transition should occur.
-
-
-
Method Detail
-
fetchCheckInterval
protected abstract long fetchCheckInterval(EventCountCircuitBreaker breaker)
Obtains the check interval to applied for the represented state from the givenCircuitBreaker.- Parameters:
breaker- theCircuitBreaker- Returns:
- the check interval to be applied
-
isCheckIntervalFinished
public boolean isCheckIntervalFinished(EventCountCircuitBreaker breaker, EventCountCircuitBreaker.CheckIntervalData currentData, long now)
Tests whether the end of the current check interval is reached.- Parameters:
breaker- theCircuitBreakercurrentData- the current state objectnow- the current time- Returns:
- a flag whether the end of the current check interval is reached
-
isStateTransition
public abstract boolean isStateTransition(EventCountCircuitBreaker breaker, EventCountCircuitBreaker.CheckIntervalData currentData, EventCountCircuitBreaker.CheckIntervalData nextData)
Tests whether the specifiedEventCountCircuitBreaker.CheckIntervalDataobjects indicate that a state transition should occur. Here the logic which checks for thresholds depending on the current state is implemented.- Parameters:
breaker- theCircuitBreakercurrentData- the currentEventCountCircuitBreaker.CheckIntervalDataobjectnextData- the updatedEventCountCircuitBreaker.CheckIntervalDataobject- Returns:
- a flag whether a state transition should be performed
-
-