Class AbstractCircuitBreaker<T>
java.lang.Object
org.apache.commons.lang3.concurrent.AbstractCircuitBreaker<T>
- Type Parameters:
- T- the type of the value monitored by this circuit breaker
- All Implemented Interfaces:
- CircuitBreaker<T>
- Direct Known Subclasses:
- EventCountCircuitBreaker,- ThresholdCircuitBreaker
Base class for circuit breakers.
- Since:
- 3.5
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected static enumAn internal enumeration representing the different states of a circuit breaker.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringThe name of the open property as it is passed to registered change listeners.protected final AtomicReference<AbstractCircuitBreaker.State>The current state of this circuit breaker.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddChangeListener(PropertyChangeListener listener) Adds a change listener to this circuit breaker.protected voidchangeState(AbstractCircuitBreaker.State newState) Changes the internal state of this circuit breaker.abstract booleanChecks the state of this circuit breaker and changes it if necessary.voidclose()Closes this circuit breaker.abstract booleanincrementAndCheckState(T increment) Increments the monitored value and performs a check of the current state of this circuit breaker.booleanisClosed()Tests the current closed state of this circuit breaker.booleanisOpen()Tests the current open state of this circuit breaker.protected static booleanConverts the given state value to a boolean open property.voidopen()Opens this circuit breaker.voidremoveChangeListener(PropertyChangeListener listener) Removes the specified change listener from this circuit breaker.
- 
Field Details- 
PROPERTY_NAMEThe name of the open property as it is passed to registered change listeners.- See Also:
 
- 
stateThe current state of this circuit breaker.
 
- 
- 
Constructor Details- 
AbstractCircuitBreakerpublic AbstractCircuitBreaker()Creates anAbstractCircuitBreaker. It also creates an internalPropertyChangeSupport.
 
- 
- 
Method Details- 
isOpenConverts the given state value to a boolean open property.- Parameters:
- state- the state to be converted
- Returns:
- the boolean open flag
 
- 
addChangeListenerAdds 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
 
- 
changeStateChanges 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
 
- 
checkStateChecks 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:
- checkStatein interface- CircuitBreaker<T>
- Returns:
- true if the circuit breaker is now closed; false otherwise.
 
- 
closeCloses this circuit breaker. Its state is changed to closed. If this circuit breaker is already closed, this method has no effect.- Specified by:
- closein interface- CircuitBreaker<T>
 
- 
incrementAndCheckStateIncrements the monitored value and performs a check of the current state of this circuit breaker. This method works likeCircuitBreaker.checkState(), but the monitored value is incremented before the state check is performed.- Specified by:
- incrementAndCheckStatein 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
 
- 
isClosedTests 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.- Specified by:
- isClosedin interface- CircuitBreaker<T>
- Returns:
- the current closed state of this circuit breaker.
 
- 
isOpenTests 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.- Specified by:
- isOpenin interface- CircuitBreaker<T>
- Returns:
- the current open state of this circuit breaker.
 
- 
openOpens 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.- Specified by:
- openin interface- CircuitBreaker<T>
 
- 
removeChangeListenerRemoves the specified change listener from this circuit breaker.- Parameters:
- listener- the listener to be removed
 
 
-