public class CircuitBreakerState extends Object
Modifier and Type | Class and Description |
---|---|
static class |
CircuitBreakerState.CircuitState |
Constructor and Description |
---|
CircuitBreakerState(int requestVolumeThreshold) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
CircuitBreakerState.CircuitState |
getCircuitState()
Gets the current circuit state.
|
int |
getHalfOpenSuccessFulResultCounter()
Gets the successful results counter for the half open state.
|
void |
halfOpen() |
boolean |
halfOpenSuccessfulClosedCircuit(int successThreshold) |
void |
incrementHalfOpenSuccessfulResultCounter()
Increments the successful results counter for the half open state.
|
boolean |
isOverFailureThreshold(int requestVolumeThreshold,
double failureRatio)
Checks to see if the CircuitBreaker is over the given failure threshold.
|
long |
nanosClosed() |
long |
nanosHalfOpen() |
long |
nanosOpen() |
void |
open() |
void |
recordClosedOutcome(boolean success)
Records a success or failure result to the CircuitBreaker.
|
void |
resetHalfOpenSuccessfulResultCounter()
Resets the successful results counter for the half open state.
|
void |
resetResults()
Clears the results queue.
|
void |
setCircuitState(CircuitBreakerState.CircuitState circuitState)
Sets the CircuitBreaker state to the provided enum value.
|
long |
updateAndGet(CircuitBreakerState.CircuitState circuitState)
Updates if the current state equals the provided and returns the amount of nanos.
|
public CircuitBreakerState.CircuitState getCircuitState()
public void setCircuitState(CircuitBreakerState.CircuitState circuitState)
circuitState
- The state to set the CircuitBreaker to.public void recordClosedOutcome(boolean success)
success
- True for a success, false for a failurepublic void resetResults()
public void incrementHalfOpenSuccessfulResultCounter()
public void resetHalfOpenSuccessfulResultCounter()
public int getHalfOpenSuccessFulResultCounter()
public boolean isOverFailureThreshold(int requestVolumeThreshold, double failureRatio)
failureThreshold
- The number of failures before the circuit breaker should openpublic long updateAndGet(CircuitBreakerState.CircuitState circuitState)
public long nanosOpen()
public long nanosHalfOpen()
public long nanosClosed()
public void close()
public void open()
public void halfOpen()
public boolean halfOpenSuccessfulClosedCircuit(int successThreshold)
Copyright © 2019. All rights reserved.