Class CircuitBreakerState


  • public class CircuitBreakerState
    extends Object
    Class that represents the state of a CircuitBreaker.
    Author:
    Andrew Pielage, Jan Bernitt (2.0)
    • Constructor Detail

      • CircuitBreakerState

        public CircuitBreakerState​(int requestVolumeThreshold,
                                   double failureRatio)
    • Method Detail

      • 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)