Package dev.failsafe.internal
Class HalfOpenState<R>
- java.lang.Object
-
- dev.failsafe.internal.CircuitState<R>
-
- dev.failsafe.internal.HalfOpenState<R>
-
class HalfOpenState<R> extends CircuitState<R>
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.concurrent.atomic.AtomicInteger
permittedExecutions
-
Fields inherited from class dev.failsafe.internal.CircuitState
breaker, config, stats
-
-
Constructor Summary
Constructors Constructor Description HalfOpenState(CircuitBreakerImpl<R> breaker)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static int
capacityFor(CircuitBreaker<?> breaker)
Returns the capacity of the breaker in the half-open state.(package private) void
checkThreshold(ExecutionContext<R> context)
Checks to determine if a threshold has been met and the circuit should be opened or closed.CircuitBreaker.State
getState()
void
handleConfigChange()
void
releasePermit()
boolean
tryAcquirePermit()
-
Methods inherited from class dev.failsafe.internal.CircuitState
getRemainingDelay, getStats, recordFailure, recordSuccess
-
-
-
-
Constructor Detail
-
HalfOpenState
public HalfOpenState(CircuitBreakerImpl<R> breaker)
-
-
Method Detail
-
tryAcquirePermit
public boolean tryAcquirePermit()
- Specified by:
tryAcquirePermit
in classCircuitState<R>
-
releasePermit
public void releasePermit()
- Overrides:
releasePermit
in classCircuitState<R>
-
getState
public CircuitBreaker.State getState()
- Specified by:
getState
in classCircuitState<R>
-
handleConfigChange
public void handleConfigChange()
- Overrides:
handleConfigChange
in classCircuitState<R>
-
checkThreshold
void checkThreshold(ExecutionContext<R> context)
Checks to determine if a threshold has been met and the circuit should be opened or closed.If a success threshold is configured, the circuit is opened or closed based on whether the ratio was exceeded.
Else the circuit is opened or closed based on whether the failure threshold was exceeded.
- Overrides:
checkThreshold
in classCircuitState<R>
-
capacityFor
private static int capacityFor(CircuitBreaker<?> breaker)
Returns the capacity of the breaker in the half-open state.
-
-