T
- the type of the value monitored by this circuit breakerpublic abstract class AbstractCircuitBreaker<T> extends Object implements CircuitBreaker<T>
Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractCircuitBreaker.State
An internal enumeration representing the different states of a circuit
breaker.
|
Modifier and Type | Field and Description |
---|---|
static String |
PROPERTY_NAME
The name of the open property as it is passed to registered
change listeners.
|
protected AtomicReference<AbstractCircuitBreaker.State> |
state
The current state of this circuit breaker.
|
Constructor and Description |
---|
AbstractCircuitBreaker()
Creates an
AbstractCircuitBreaker . |
Modifier and Type | Method and Description |
---|---|
void |
addChangeListener(PropertyChangeListener listener)
Adds a change listener to this circuit breaker.
|
protected void |
changeState(AbstractCircuitBreaker.State newState)
Changes the internal state of 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.
|
protected static boolean |
isOpen(AbstractCircuitBreaker.State state)
Converts the given state value to a boolean open property.
|
void |
open()
Opens this circuit breaker.
|
void |
removeChangeListener(PropertyChangeListener listener)
Removes the specified change listener from this circuit breaker.
|
public static final String PROPERTY_NAME
protected final AtomicReference<AbstractCircuitBreaker.State> state
public AbstractCircuitBreaker()
AbstractCircuitBreaker
. It also creates an internal PropertyChangeSupport
.public boolean isOpen()
isOpen
in interface CircuitBreaker<T>
public boolean isClosed()
isClosed
in interface CircuitBreaker<T>
public abstract boolean checkState()
CLOSED
; a value
of true typically means that the current operation can continue.checkState
in interface CircuitBreaker<T>
public abstract boolean incrementAndCheckState(T increment)
CircuitBreaker.checkState()
, but the monitored
value is incremented before the state check is performed.incrementAndCheckState
in interface CircuitBreaker<T>
increment
- value to increment in the monitored value of the circuit breakerpublic void close()
close
in interface CircuitBreaker<T>
public void open()
open
in interface CircuitBreaker<T>
protected static boolean isOpen(AbstractCircuitBreaker.State state)
state
- the state to be convertedprotected void changeState(AbstractCircuitBreaker.State newState)
newState
- the new state to be setpublic void addChangeListener(PropertyChangeListener listener)
listener
- the listener to be addedpublic void removeChangeListener(PropertyChangeListener listener)
listener
- the listener to be removedCopyright © 2001–2018 The Apache Software Foundation. All rights reserved.