Class CircuitBreakerState
- java.lang.Object
-
- fish.payara.microprofile.faulttolerance.state.CircuitBreakerState
-
public class CircuitBreakerState extends Object
Class that represents the state of a CircuitBreaker.- Author:
- Andrew Pielage, Jan Bernitt (2.0)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CircuitBreakerState.CircuitState
-
Constructor Summary
Constructors Constructor Description CircuitBreakerState(int requestVolumeThreshold, double failureRatio)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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
isClosedOutcomeSuccessOnly()
boolean
isOverFailureThreshold()
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.
-
-
-
Method Detail
-
getCircuitState
public CircuitBreakerState.CircuitState getCircuitState()
Gets the current circuit state.- Returns:
- The current circuit state
-
setCircuitState
public void setCircuitState(CircuitBreakerState.CircuitState circuitState)
Sets the CircuitBreaker state to the provided enum value.- Parameters:
circuitState
- The state to set the CircuitBreaker to.
-
recordClosedOutcome
public void recordClosedOutcome(boolean success)
Records a success or failure result to the CircuitBreaker.- Parameters:
success
- True for a success, false for a failure
-
isClosedOutcomeSuccessOnly
public boolean isClosedOutcomeSuccessOnly()
-
resetResults
public void resetResults()
Clears the results queue.
-
incrementHalfOpenSuccessfulResultCounter
public void incrementHalfOpenSuccessfulResultCounter()
Increments the successful results counter for the half open state.
-
resetHalfOpenSuccessfulResultCounter
public void resetHalfOpenSuccessfulResultCounter()
Resets the successful results counter for the half open state.
-
getHalfOpenSuccessfulResultCounter
public int getHalfOpenSuccessfulResultCounter()
Gets the successful results counter for the half open state.- Returns:
- The number of consecutive successful results.
-
isOverFailureThreshold
public boolean isOverFailureThreshold()
Checks to see if the CircuitBreaker is over the given failure threshold.
-
updateAndGet
public long updateAndGet(CircuitBreakerState.CircuitState circuitState)
Updates if the current state equals the provided and returns the amount of nanos.- Returns:
- The amount of nanos.
-
nanosOpen
public long nanosOpen()
-
nanosHalfOpen
public long nanosHalfOpen()
-
nanosClosed
public long nanosClosed()
-
close
public void close()
-
open
public void open()
-
halfOpen
public void halfOpen()
-
halfOpenSuccessfulClosedCircuit
public boolean halfOpenSuccessfulClosedCircuit(int successThreshold)
-
-