AbstractCircuitBreaker
- public abstract class org.apache.commons.lang3.concurrent.AbstractCircuitBreaker<T> implements CircuitBreaker<T>[source]
Base class for circuit breakers.
- Parameters:
<T> – The type of the value monitored by this circuit breaker
- Since:
3.5
Constructors
Creates an |
- public AbstractCircuitBreaker()[source]
Creates an
AbstractCircuitBreaker. It also creates an internalPropertyChangeSupport.
Fields and constants
The name of the open property as it is passed to registered change listeners. |
|
The current state of this circuit breaker. |
- public static final String PROPERTY_NAME = "open"[source]
The name of the open property as it is passed to registered change listeners.
- protected final AtomicReference<AbstractCircuitBreaker.State> state[source]
The current state of this circuit breaker.
Methods
Adds a change listener to this circuit breaker. |
|
Changes the internal state of this circuit breaker. |
|
Checks the state of this circuit breaker and changes it if necessary. |
|
Closes this circuit breaker. |
|
Increments the monitored value and performs a check of the current state of this circuit breaker. |
|
Tests the current closed state of this circuit breaker. |
|
Tests the current open state of this circuit breaker. |
|
Tests whether the given state represents an open circuit breaker. |
|
Opens this circuit breaker. |
|
Removes the specified change listener from this circuit breaker. |
- public void addChangeListener(PropertyChangeListener listener)[source]
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
- protected void changeState(AbstractCircuitBreaker.State newState)[source]
Changes the internal state of this circuit breaker. If there is actually a change of the state value, all registered change listeners are notified.
- Parameters:
newState – The new state to be set
- @Override public abstract boolean checkState()[source]
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.
- Returns:
true if the circuit breaker is now closed; false otherwise.
- @Override public void close()[source]
Closes this circuit breaker. Its state is changed to closed. If this circuit breaker is already closed, this method has no effect.
- @Override public abstract boolean incrementAndCheckState(T increment)[source]
Increments the monitored value and performs a check of the current state of this circuit breaker. This method works like
#checkState(), but the monitored value is incremented before the state check is performed.- Parameters:
increment – value to increment in the monitored value of the circuit breaker
- Returns:
true if the circuit breaker is now closed; false otherwise
- @Override public boolean isClosed()[source]
Tests 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 subsystem.
- Returns:
The current closed state of this circuit breaker.
- @Override public boolean isOpen()[source]
Tests 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 subsystem.
- Returns:
The current open state of this circuit breaker.
- protected static boolean isOpen(AbstractCircuitBreaker.State state)[source]
Tests whether the given state represents an open circuit breaker.
- Parameters:
state – The state to be converted
- Returns:
The boolean open flag
- @Override public void open()[source]
Opens this circuit breaker. Its state is changed to open. Depending on a concrete implementation, it may close itself again if the monitored subsystem becomes available. If this circuit breaker is already open, this method has no effect.
- public void removeChangeListener(PropertyChangeListener listener)[source]
Removes the specified change listener from this circuit breaker.
- Parameters:
listener – The listener to be removed