Top Description Inners Fields Constructors Methods
org.apache.commons.lang3.concurrent

public abstract Class AbstractCircuitBreaker<T>

extends Object
implements CircuitBreaker<T>
Class Inheritance
All Implemented Interfaces
org.apache.commons.lang3.concurrent.CircuitBreaker
Known Direct Subclasses
org.apache.commons.lang3.concurrent.EventCountCircuitBreaker, org.apache.commons.lang3.concurrent.ThresholdCircuitBreaker
Type Parameters
<T>
the type of the value monitored by this circuit breaker
Imports
java.beans.PropertyChangeListener, .PropertyChangeSupport, java.util.concurrent.atomic.AtomicReference

Base class for circuit breakers.
Since
3.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static enum
AbstractCircuitBreaker.State

An internal enumeration representing the different states of a circuit breaker.

Field Summary

Modifier and TypeField and Description
private final PropertyChangeSupport
changeSupport

An object for managing change listeners registered at this instance.

public static final String
PROPERTY_NAME

The name of the open property as it is passed to registered change listeners.

protected final AtomicReference<AbstractCircuitBreaker.State>
state

The current state of this circuit breaker.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addChangeListener(final PropertyChangeListener
the listener to be added
listener
)

Adds a change listener to this circuit breaker.

protected void
changeState(final AbstractCircuitBreaker.State
the new state to be set
newState
)

Changes the internal state of this circuit breaker.

public abstract boolean
checkState()

Redeclares org.apache.commons.lang3.concurrent.CircuitBreaker.checkState.

Checks the state of this circuit breaker and changes it if necessary.

public void
close()

Implements org.apache.commons.lang3.concurrent.CircuitBreaker.close.

Closes this circuit breaker.

public abstract boolean
incrementAndCheckState(T increment)

Redeclares org.apache.commons.lang3.concurrent.CircuitBreaker.incrementAndCheckState.

Increments the monitored value and performs a check of the current state of this circuit breaker.

public boolean
isClosed()

Implements org.apache.commons.lang3.concurrent.CircuitBreaker.isClosed.

Tests the current closed state of this circuit breaker.

protected static boolean

Returns:

the boolean open flag
isOpen
(final AbstractCircuitBreaker.State
the state to be converted
state
)

Converts the given state value to a boolean open property.

public boolean
isOpen()

Implements org.apache.commons.lang3.concurrent.CircuitBreaker.isOpen.

Tests the current open state of this circuit breaker.

public void
open()

Implements org.apache.commons.lang3.concurrent.CircuitBreaker.open.

Opens this circuit breaker.

public void
removeChangeListener(final PropertyChangeListener
the listener to be removed
listener
)

Removes the specified change listener from this circuit breaker.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

changeSupportback to summary
private final PropertyChangeSupport changeSupport

An object for managing change listeners registered at this instance.

PROPERTY_NAMEback to summary
public static final String PROPERTY_NAME

The name of the open property as it is passed to registered change listeners.

stateback to summary
protected final AtomicReference<AbstractCircuitBreaker.State> state

The current state of this circuit breaker.

Constructor Detail

AbstractCircuitBreakerback to summary
public AbstractCircuitBreaker()

Creates an AbstractCircuitBreaker. It also creates an internal PropertyChangeSupport.

Method Detail

addChangeListenerback to summary
public void addChangeListener(final 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:PropertyChangeListener

the listener to be added

changeStateback to summary
protected void changeState(final AbstractCircuitBreaker.State newState)

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:AbstractCircuitBreaker.State

the new state to be set

checkStateback to summary
public abstract boolean checkState()

Redeclares org.apache.commons.lang3.concurrent.CircuitBreaker.checkState.

Doc from org.apache.commons.lang3.concurrent.CircuitBreaker.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.

Annotations
@Override
closeback to summary
public void close()

Implements org.apache.commons.lang3.concurrent.CircuitBreaker.close.

Doc from org.apache.commons.lang3.concurrent.CircuitBreaker.close.

Closes this circuit breaker. Its state is changed to closed. If this circuit breaker is already closed, this method has no effect.

Annotations
@Override
incrementAndCheckStateback to summary
public abstract boolean incrementAndCheckState(T increment)

Redeclares org.apache.commons.lang3.concurrent.CircuitBreaker.incrementAndCheckState.

Doc from org.apache.commons.lang3.concurrent.CircuitBreaker.incrementAndCheckState.

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.

Annotations
@Override
isClosedback to summary
public boolean isClosed()

Implements org.apache.commons.lang3.concurrent.CircuitBreaker.isClosed.

Doc from org.apache.commons.lang3.concurrent.CircuitBreaker.isClosed.

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.

Annotations
@Override
isOpenback to summary
protected static boolean isOpen(final AbstractCircuitBreaker.State state)

Converts the given state value to a boolean open property.

Parameters
state:AbstractCircuitBreaker.State

the state to be converted

Returns:boolean

the boolean open flag

isOpenback to summary
public boolean isOpen()

Implements org.apache.commons.lang3.concurrent.CircuitBreaker.isOpen.

Doc from org.apache.commons.lang3.concurrent.CircuitBreaker.isOpen.

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.

Annotations
@Override
openback to summary
public void open()

Implements org.apache.commons.lang3.concurrent.CircuitBreaker.open.

Doc from org.apache.commons.lang3.concurrent.CircuitBreaker.open.

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.

Annotations
@Override
removeChangeListenerback to summary
public void removeChangeListener(final PropertyChangeListener listener)

Removes the specified change listener from this circuit breaker.

Parameters
listener:PropertyChangeListener

the listener to be removed

org.apache.commons.lang3.concurrent back to summary

protected sealed Enum AbstractCircuitBreaker.State

extends Enum<AbstractCircuitBreaker.State>
Class Inheritance

An internal enumeration representing the different states of a circuit breaker. This class also contains some logic for performing state transitions. This is done to avoid complex if-conditions in the code of CircuitBreaker.

Field Summary

Modifier and TypeField and Description
public static final AbstractCircuitBreaker.State
CLOSED

The closed state.

public static final AbstractCircuitBreaker.State
OPEN

The open state.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public abstract AbstractCircuitBreaker.State

Returns:

the opposite state
oppositeState
()

Returns the opposite state to the represented state.

public static AbstractCircuitBreaker.State
public static AbstractCircuitBreaker.State[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CLOSEDback to summary
public static final AbstractCircuitBreaker.State CLOSED

The closed state.

OPENback to summary
public static final AbstractCircuitBreaker.State OPEN

The open state.

Constructor Detail

Stateback to summary
private State()

Method Detail

oppositeStateback to summary
public abstract AbstractCircuitBreaker.State oppositeState()

Returns the opposite state to the represented state. This is useful for flipping the current state.

Returns:AbstractCircuitBreaker.State

the opposite state

valueOfback to summary
public static AbstractCircuitBreaker.State valueOf(String name)
valuesback to summary
public static AbstractCircuitBreaker.State[] values()