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 classCircuitBreakerState.CircuitState
-
Constructor Summary
Constructors Constructor Description CircuitBreakerState(int requestVolumeThreshold, double failureRatio)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()CircuitBreakerState.CircuitStategetCircuitState()Gets the current circuit state.intgetHalfOpenSuccessfulResultCounter()Gets the successful results counter for the half open state.voidhalfOpen()booleanhalfOpenSuccessfulClosedCircuit(int successThreshold)voidincrementHalfOpenSuccessfulResultCounter()Increments the successful results counter for the half open state.booleanisClosedOutcomeSuccessOnly()booleanisOverFailureThreshold()Checks to see if the CircuitBreaker is over the given failure threshold.longnanosClosed()longnanosHalfOpen()longnanosOpen()voidopen()voidrecordClosedOutcome(boolean success)Records a success or failure result to the CircuitBreaker.voidresetHalfOpenSuccessfulResultCounter()Resets the successful results counter for the half open state.voidresetResults()Clears the results queue.voidsetCircuitState(CircuitBreakerState.CircuitState circuitState)Sets the CircuitBreaker state to the provided enum value.longupdateAndGet(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)
-
-