Class AbstractCircuitBreaker<T>

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String PROPERTY_NAME
      The name of the open property as it is passed to registered change listeners.
    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractCircuitBreaker()
      Creates an AbstractCircuitBreaker.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void addChangeListener​(java.beans.PropertyChangeListener listener)
      Adds a change listener to this circuit breaker.
      abstract boolean checkState()
      Checks the state of this circuit breaker and changes it if necessary.
      void close()
      Closes this circuit breaker.
      abstract boolean incrementAndCheckState​(T increment)
      Increments the monitored value and performs a check of the current state of this circuit breaker.
      boolean isClosed()
      Returns the current closed state of this circuit breaker.
      boolean isOpen()
      Returns the current open state of this circuit breaker.
      void open()
      Opens this circuit breaker.
      void removeChangeListener​(java.beans.PropertyChangeListener listener)
      Removes the specified change listener from this circuit breaker.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • PROPERTY_NAME

        public static final java.lang.String PROPERTY_NAME
        The name of the open property as it is passed to registered change listeners.
        See Also:
        Constant Field Values
    • Constructor Detail

      • AbstractCircuitBreaker

        public AbstractCircuitBreaker()
        Creates an AbstractCircuitBreaker. It also creates an internal PropertyChangeSupport.
    • Method Detail

      • isOpen

        public boolean isOpen()
        Returns the current open state of this circuit breaker. A return value of true means that the circuit breaker is currently open indicating a problem in the monitored sub system.
        Specified by:
        isOpen in interface CircuitBreaker<T>
        Returns:
        the current open state of this circuit breaker
      • isClosed

        public boolean isClosed()
        Returns the current closed state of this circuit breaker. A return value of true means that the circuit breaker is currently closed. This means that everything is okay with the monitored sub system.
        Specified by:
        isClosed in interface CircuitBreaker<T>
        Returns:
        the current closed state of this circuit breaker
      • checkState

        public abstract boolean checkState()
        Checks the state of this circuit breaker and changes it if necessary. The return value indicates whether the circuit breaker is now in state CLOSED; a value of true typically means that the current operation can continue.
        Specified by:
        checkState in interface CircuitBreaker<T>
        Returns:
        true if the circuit breaker is now closed; false otherwise
      • incrementAndCheckState

        public abstract boolean incrementAndCheckState​(T increment)
        Increments the monitored value and performs a check of the current state of this circuit breaker. This method works like CircuitBreaker.checkState(), but the monitored value is incremented before the state check is performed.
        Specified by:
        incrementAndCheckState in interface CircuitBreaker<T>
        Parameters:
        increment - value to increment in the monitored value of the circuit breaker
        Returns:
        true if the circuit breaker is now closed; false otherwise
      • close

        public void close()
        Closes this circuit breaker. Its state is changed to closed. If this circuit breaker is already closed, this method has no effect.
        Specified by:
        close in interface CircuitBreaker<T>
      • open

        public void open()
        Opens this circuit breaker. Its state is changed to open. Depending on a concrete implementation, it may close itself again if the monitored sub system becomes available. If this circuit breaker is already open, this method has no effect.
        Specified by:
        open in interface CircuitBreaker<T>
      • addChangeListener

        public void addChangeListener​(java.beans.PropertyChangeListener listener)
        Adds a change listener to this circuit breaker. This listener is notified whenever the state of this circuit breaker changes. If the listener is null, it is silently ignored.
        Parameters:
        listener - the listener to be added
      • removeChangeListener

        public void removeChangeListener​(java.beans.PropertyChangeListener listener)
        Removes the specified change listener from this circuit breaker.
        Parameters:
        listener - the listener to be removed