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

public Class EventCountCircuitBreaker

extends AbstractCircuitBreaker<Integer>
Class Inheritance
Imports
java.beans.PropertyChangeListener, java.util.EnumMap, .Map, java.util.concurrent.TimeUnit, java.util.concurrent.atomic.AtomicReference

A simple implementation of the Circuit Breaker pattern that counts specific events.

A circuit breaker can be used to protect an application against unreliable services or unexpected load. A newly created EventCountCircuitBreaker object is initially in state closed meaning that no problem has been detected. When the application encounters specific events (like errors or service timeouts), it tells the circuit breaker to increment an internal counter. If the number of events reported in a specific time interval exceeds a configurable threshold, the circuit breaker changes into state open. This means that there is a problem with the associated sub system; the application should no longer call it, but give it some time to settle down. The circuit breaker can be configured to switch back to closed state after a certain time frame if the number of events received goes below a threshold.

When a EventCountCircuitBreaker object is constructed the following parameters can be provided:

This class supports the following typical use cases:

Protecting against load peaks

Imagine you have a server which can handle a certain number of requests per minute. Suddenly, the number of requests increases significantly - maybe because a connected partner system is going mad or due to a denial of service attack. A EventCountCircuitBreaker can be configured to stop the application from processing requests when a sudden peak load is detected and to start request processing again when things calm down. The following code fragment shows a typical example of such a scenario. Here the EventCountCircuitBreaker allows up to 1000 requests per minute before it interferes. When the load goes down again to 800 requests per second it switches back to state closed:

EventCountCircuitBreaker breaker = new EventCountCircuitBreaker(1000, 1, TimeUnit.MINUTE, 800);
...
public void handleRequest(Request request) {
    if (breaker.incrementAndCheckState()) {
        // actually handle this request
    } else {
        // do something else, e.g. send an error code
    }
}

Deal with an unreliable service

In this scenario, an application uses an external service which may fail from time to time. If there are too many errors, the service is considered down and should not be called for a while. This can be achieved using the following pattern - in this concrete example we accept up to 5 errors in 2 minutes; if this limit is reached, the service is given a rest time of 10 minutes:

EventCountCircuitBreaker breaker = new EventCountCircuitBreaker(5, 2, TimeUnit.MINUTE, 5, 10, TimeUnit.MINUTE);
...
public void handleRequest(Request request) {
    if (breaker.checkState()) {
        try {
            service.doSomething();
        } catch (ServiceException ex) {
            breaker.incrementAndCheckState();
        }
    } else {
        // return an error code, use an alternative service, etc.
    }
}

In addition to automatic state transitions, the state of a circuit breaker can be changed manually using the methods open() and close(). It is also possible to register PropertyChangeListener objects that get notified whenever a state transition occurs. This is useful, for instance to directly react on a freshly detected error condition.

Implementation notes:

Since
3.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
private abstract static class
EventCountCircuitBreaker.AbstractStateStrategy

Internally used class for executing check logic based on the current state of the circuit breaker.

private static class
EventCountCircuitBreaker.CheckIntervalData

An internally used data class holding information about the checks performed by this class.

private static class
EventCountCircuitBreaker.StateStrategyClosed

A specialized AbstractStateStrategy implementation for the state closed.

private static class
EventCountCircuitBreaker.StateStrategyOpen

A specialized AbstractStateStrategy implementation for the state open.

Field Summary

Modifier and TypeField and Description
private final AtomicReference<EventCountCircuitBreaker.CheckIntervalData>
checkIntervalData

Stores information about the current check interval.

private final long
closingInterval

The time interval for closing the circuit breaker.

private final int
closingThreshold

The threshold for closing the circuit breaker.

private final long
openingInterval

The time interval for opening the circuit breaker.

private final int
openingThreshold

The threshold for opening the circuit breaker.

private static final Map<AbstractCircuitBreaker.State, EventCountCircuitBreaker.AbstractStateStrategy>
STRATEGY_MAP

A map for accessing the strategy objects for the different states.

Inherited from org.apache.commons.lang3.concurrent.AbstractCircuitBreaker:
PROPERTY_NAMEstate

Constructor Summary

AccessConstructor and Description
public
EventCountCircuitBreaker(final int
the threshold for changing the status of the circuit breaker; if the number of events received in a check interval is greater than this value, the circuit breaker is opened; if it is lower than this value, it is closed again
threshold
,
final long
the check interval for opening or closing the circuit breaker
checkInterval
,
final TimeUnit
the TimeUnit defining the check interval
checkUnit
)

Creates a new instance of EventCountCircuitBreaker which uses the same parameters for opening and closing checks.

public
EventCountCircuitBreaker(final int
the threshold for opening the circuit breaker; if this number of events is received in the time span determined by the check interval, the circuit breaker is opened
openingThreshold
,
final long
the check interval for opening or closing the circuit breaker
checkInterval
,
final TimeUnit
the TimeUnit defining the check interval
checkUnit
,
final int
the threshold for closing the circuit breaker; if the number of events received in the time span determined by the check interval goes below this threshold, the circuit breaker is closed again
closingThreshold
)

Creates a new instance of EventCountCircuitBreaker with the same interval for opening and closing checks.

public
EventCountCircuitBreaker(final int
the threshold for opening the circuit breaker; if this number of events is received in the time span determined by the opening interval, the circuit breaker is opened
openingThreshold
,
final long
the interval for opening the circuit breaker
openingInterval
,
final TimeUnit
the TimeUnit defining the opening interval
openingUnit
,
final int
the threshold for closing the circuit breaker; if the number of events received in the time span determined by the closing interval goes below this threshold, the circuit breaker is closed again
closingThreshold
,
final long
the interval for closing the circuit breaker
closingInterval
,
final TimeUnit
the TimeUnit defining the closing interval
closingUnit
)

Creates a new instance of EventCountCircuitBreaker and initializes all properties for opening and closing it based on threshold values for events occurring in specific intervals.

Method Summary

Modifier and TypeMethod and Description
private void
changeStateAndStartNewCheckInterval(final AbstractCircuitBreaker.State
the new state to be set
newState
)

Changes the state of this circuit breaker and also initializes a new CheckIntervalData object.

public boolean
checkState()

Implements abstract org.apache.commons.lang3.concurrent.AbstractCircuitBreaker.checkState.

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

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

public void
private static Map<AbstractCircuitBreaker.State, EventCountCircuitBreaker.AbstractStateStrategy>

Returns:

the strategy map
createStrategyMap
()

Creates the map with strategy objects.

public long

Returns:

the opening check interval
getClosingInterval
()

Gets the interval (in nanoseconds) for checking for the closing threshold.

public int

Returns:

the closing threshold
getClosingThreshold
()

Gets the threshold value for closing the circuit breaker.

public long

Returns:

the opening check interval
getOpeningInterval
()

Gets the interval (in nanoseconds) for checking for the opening threshold.

public int

Returns:

the opening threshold
getOpeningThreshold
()

Gets the threshold value for opening the circuit breaker.

public boolean

Returns:

true if the circuit breaker is now closed; false otherwise
incrementAndCheckState
()

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

public boolean
incrementAndCheckState(final Integer increment)

Implements abstract org.apache.commons.lang3.concurrent.AbstractCircuitBreaker.incrementAndCheckState.

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

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

pack-priv long

Returns:

the current time in nanoseconds
nanoTime
()

Returns the current time in nanoseconds.

private EventCountCircuitBreaker.CheckIntervalData

Returns:

the updated CheckIntervalData object
nextCheckIntervalData
(final int
the increment for the internal counter
increment
,
final EventCountCircuitBreaker.CheckIntervalData
the current check data object
currentData
,
final AbstractCircuitBreaker.State
the current state of the circuit breaker
currentState
,
final long
the current time
time
)

Calculates the next CheckIntervalData object based on the current data and the current state.

public void
private boolean

Returns:

a flag whether the circuit breaker is now closed
performStateCheck
(final int
the increment for the internal counter
increment
)

Actually checks the state of this circuit breaker and executes a state transition if necessary.

private static EventCountCircuitBreaker.AbstractStateStrategy

Returns:

the corresponding AbstractStateStrategy
stateStrategy
(final AbstractCircuitBreaker.State
the state
state
)

Returns the AbstractStateStrategy object responsible for the given state.

private boolean

Returns:

a flag whether the update was successful
updateCheckIntervalData
(final EventCountCircuitBreaker.CheckIntervalData
the current check data object
currentData
,
final EventCountCircuitBreaker.CheckIntervalData
the replacing check data object
nextData
)

Updates the CheckIntervalData object.

Inherited from org.apache.commons.lang3.concurrent.AbstractCircuitBreaker:
addChangeListenerchangeStateisClosedisOpenisOpenremoveChangeListener

Field Detail

checkIntervalDataback to summary
private final AtomicReference<EventCountCircuitBreaker.CheckIntervalData> checkIntervalData

Stores information about the current check interval.

closingIntervalback to summary
private final long closingInterval

The time interval for closing the circuit breaker.

closingThresholdback to summary
private final int closingThreshold

The threshold for closing the circuit breaker.

openingIntervalback to summary
private final long openingInterval

The time interval for opening the circuit breaker.

openingThresholdback to summary
private final int openingThreshold

The threshold for opening the circuit breaker.

STRATEGY_MAPback to summary
private static final Map<AbstractCircuitBreaker.State, EventCountCircuitBreaker.AbstractStateStrategy> STRATEGY_MAP

A map for accessing the strategy objects for the different states.

Constructor Detail

EventCountCircuitBreakerback to summary
public EventCountCircuitBreaker(final int threshold, final long checkInterval, final TimeUnit checkUnit)

Creates a new instance of EventCountCircuitBreaker which uses the same parameters for opening and closing checks.

Parameters
threshold:int

the threshold for changing the status of the circuit breaker; if the number of events received in a check interval is greater than this value, the circuit breaker is opened; if it is lower than this value, it is closed again

checkInterval:long

the check interval for opening or closing the circuit breaker

checkUnit:TimeUnit

the TimeUnit defining the check interval

EventCountCircuitBreakerback to summary
public EventCountCircuitBreaker(final int openingThreshold, final long checkInterval, final TimeUnit checkUnit, final int closingThreshold)

Creates a new instance of EventCountCircuitBreaker with the same interval for opening and closing checks.

Parameters
openingThreshold:int

the threshold for opening the circuit breaker; if this number of events is received in the time span determined by the check interval, the circuit breaker is opened

checkInterval:long

the check interval for opening or closing the circuit breaker

checkUnit:TimeUnit

the TimeUnit defining the check interval

closingThreshold:int

the threshold for closing the circuit breaker; if the number of events received in the time span determined by the check interval goes below this threshold, the circuit breaker is closed again

EventCountCircuitBreakerback to summary
public EventCountCircuitBreaker(final int openingThreshold, final long openingInterval, final TimeUnit openingUnit, final int closingThreshold, final long closingInterval, final TimeUnit closingUnit)

Creates a new instance of EventCountCircuitBreaker and initializes all properties for opening and closing it based on threshold values for events occurring in specific intervals.

Parameters
openingThreshold:int

the threshold for opening the circuit breaker; if this number of events is received in the time span determined by the opening interval, the circuit breaker is opened

openingInterval:long

the interval for opening the circuit breaker

openingUnit:TimeUnit

the TimeUnit defining the opening interval

closingThreshold:int

the threshold for closing the circuit breaker; if the number of events received in the time span determined by the closing interval goes below this threshold, the circuit breaker is closed again

closingInterval:long

the interval for closing the circuit breaker

closingUnit:TimeUnit

the TimeUnit defining the closing interval

Method Detail

changeStateAndStartNewCheckIntervalback to summary
private void changeStateAndStartNewCheckInterval(final AbstractCircuitBreaker.State newState)

Changes the state of this circuit breaker and also initializes a new CheckIntervalData object.

Parameters
newState:AbstractCircuitBreaker.State

the new state to be set

checkStateback to summary
public boolean checkState()

Implements abstract org.apache.commons.lang3.concurrent.AbstractCircuitBreaker.checkState.

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

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

This implementation checks the internal event counter against the threshold values and the check intervals. This may cause a state change of this circuit breaker.

Annotations
@Override
closeback to summary
public void close()

Overrides org.apache.commons.lang3.concurrent.AbstractCircuitBreaker.close.

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

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

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

A new check interval is started. If too many events are received in this interval, the circuit breaker changes again to state open. If this circuit breaker is already closed, this method has no effect, except that a new check interval is started.

Annotations
@Override
createStrategyMapback to summary
private static Map<AbstractCircuitBreaker.State, EventCountCircuitBreaker.AbstractStateStrategy> createStrategyMap()

Creates the map with strategy objects. It allows access for a strategy for a given state.

Returns:Map<AbstractCircuitBreaker.State, EventCountCircuitBreaker.AbstractStateStrategy>

the strategy map

getClosingIntervalback to summary
public long getClosingInterval()

Gets the interval (in nanoseconds) for checking for the closing threshold.

Returns:long

the opening check interval

getClosingThresholdback to summary
public int getClosingThreshold()

Gets the threshold value for closing the circuit breaker. If the number of events received in the time span determined by the closing interval goes below this threshold, the circuit breaker is closed again.

Returns:int

the closing threshold

getOpeningIntervalback to summary
public long getOpeningInterval()

Gets the interval (in nanoseconds) for checking for the opening threshold.

Returns:long

the opening check interval

getOpeningThresholdback to summary
public int getOpeningThreshold()

Gets the threshold value for opening the circuit breaker. If this number of events is received in the time span determined by the opening interval, the circuit breaker is opened.

Returns:int

the opening threshold

incrementAndCheckStateback to summary
public boolean incrementAndCheckState()

Increments the monitored value by 1 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.

Returns:boolean

true if the circuit breaker is now closed; false otherwise

incrementAndCheckStateback to summary
public boolean incrementAndCheckState(final Integer increment)

Implements abstract org.apache.commons.lang3.concurrent.AbstractCircuitBreaker.incrementAndCheckState.

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

Doc from org.apache.commons.lang3.concurrent.AbstractCircuitBreaker.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
nanoTimeback to summary
pack-priv long nanoTime()

Returns the current time in nanoseconds. This method is used to obtain the current time. This is needed to calculate the check intervals correctly.

Returns:long

the current time in nanoseconds

nextCheckIntervalDataback to summary
private EventCountCircuitBreaker.CheckIntervalData nextCheckIntervalData(final int increment, final EventCountCircuitBreaker.CheckIntervalData currentData, final AbstractCircuitBreaker.State currentState, final long time)

Calculates the next CheckIntervalData object based on the current data and the current state. The next data object takes the counter increment and the current time into account.

Parameters
increment:int

the increment for the internal counter

currentData:EventCountCircuitBreaker.CheckIntervalData

the current check data object

currentState:AbstractCircuitBreaker.State

the current state of the circuit breaker

time:long

the current time

Returns:EventCountCircuitBreaker.CheckIntervalData

the updated CheckIntervalData object

openback to summary
public void open()

Overrides org.apache.commons.lang3.concurrent.AbstractCircuitBreaker.open.

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

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

This circuit breaker may close itself again if the number of events received during a check interval goes below the closing threshold. If this circuit breaker is already open, this method has no effect, except that a new check interval is started.

Annotations
@Override
performStateCheckback to summary
private boolean performStateCheck(final int increment)

Actually checks the state of this circuit breaker and executes a state transition if necessary.

Parameters
increment:int

the increment for the internal counter

Returns:boolean

a flag whether the circuit breaker is now closed

stateStrategyback to summary
private static EventCountCircuitBreaker.AbstractStateStrategy stateStrategy(final AbstractCircuitBreaker.State state)

Returns the AbstractStateStrategy object responsible for the given state.

Parameters
state:AbstractCircuitBreaker.State

the state

Returns:EventCountCircuitBreaker.AbstractStateStrategy

the corresponding AbstractStateStrategy

Exceptions
CircuitBreakingException:
if the strategy cannot be resolved
updateCheckIntervalDataback to summary
private boolean updateCheckIntervalData(final EventCountCircuitBreaker.CheckIntervalData currentData, final EventCountCircuitBreaker.CheckIntervalData nextData)

Updates the CheckIntervalData object. The current data object is replaced by the one modified by the last check. The return value indicates whether this was successful. If it is false, another thread interfered, and the whole operation has to be redone.

Parameters
currentData:EventCountCircuitBreaker.CheckIntervalData

the current check data object

nextData:EventCountCircuitBreaker.CheckIntervalData

the replacing check data object

Returns:boolean

a flag whether the update was successful

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

private abstract Class EventCountCircuitBreaker.AbstractStateStrategy

extends Object
Class Inheritance
  • java.lang.Object
  • org.apache.commons.lang3.concurrent.EventCountCircuitBreaker.AbstractStateStrategy
Known Direct Subclasses
org.apache.commons.lang3.concurrent.EventCountCircuitBreaker.StateStrategyClosed, org.apache.commons.lang3.concurrent.EventCountCircuitBreaker.StateStrategyOpen

Internally used class for executing check logic based on the current state of the circuit breaker. Having this logic extracted into special classes avoids complex if-then-else cascades.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
protected abstract long

Returns:

the check interval to be applied
fetchCheckInterval
(EventCountCircuitBreaker breaker)

Obtains the check interval to applied for the represented state from the given CircuitBreaker.

public boolean

Returns:

a flag whether the end of the current check interval is reached
isCheckIntervalFinished
(final EventCountCircuitBreaker breaker, final EventCountCircuitBreaker.CheckIntervalData
the current state object
currentData
,
final long
the current time
now
)

Tests whether the end of the current check interval is reached.

public abstract boolean

Returns:

a flag whether a state transition should be performed
isStateTransition
(EventCountCircuitBreaker breaker, EventCountCircuitBreaker.CheckIntervalData
the current CheckIntervalData object
currentData
,
EventCountCircuitBreaker.CheckIntervalData
the updated CheckIntervalData object
nextData
)

Tests whether the specified CheckIntervalData objects indicate that a state transition should occur.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

AbstractStateStrategyback to summary
private AbstractStateStrategy()

Method Detail

fetchCheckIntervalback to summary
protected abstract long fetchCheckInterval(EventCountCircuitBreaker breaker)

Obtains the check interval to applied for the represented state from the given CircuitBreaker.

Parameters
breaker:EventCountCircuitBreaker

the CircuitBreaker

Returns:long

the check interval to be applied

isCheckIntervalFinishedback to summary
public boolean isCheckIntervalFinished(final EventCountCircuitBreaker breaker, final EventCountCircuitBreaker.CheckIntervalData currentData, final long now)

Tests whether the end of the current check interval is reached.

Parameters
breaker:EventCountCircuitBreaker

the CircuitBreaker

currentData:EventCountCircuitBreaker.CheckIntervalData

the current state object

now:long

the current time

Returns:boolean

a flag whether the end of the current check interval is reached

isStateTransitionback to summary
public abstract boolean isStateTransition(EventCountCircuitBreaker breaker, EventCountCircuitBreaker.CheckIntervalData currentData, EventCountCircuitBreaker.CheckIntervalData nextData)

Tests whether the specified CheckIntervalData objects indicate that a state transition should occur. Here the logic which checks for thresholds depending on the current state is implemented.

Parameters
breaker:EventCountCircuitBreaker

the CircuitBreaker

currentData:EventCountCircuitBreaker.CheckIntervalData

the current CheckIntervalData object

nextData:EventCountCircuitBreaker.CheckIntervalData

the updated CheckIntervalData object

Returns:boolean

a flag whether a state transition should be performed

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

private final Class EventCountCircuitBreaker.CheckIntervalData

extends Object
Class Inheritance
  • java.lang.Object
  • org.apache.commons.lang3.concurrent.EventCountCircuitBreaker.CheckIntervalData

An internally used data class holding information about the checks performed by this class. Basically, the number of received events and the start time of the current check interval are stored.

Field Summary

Modifier and TypeField and Description
private final long
checkIntervalStart

The start time of the current check interval.

private final int
eventCount

The counter for events.

Constructor Summary

AccessConstructor and Description
pack-priv
CheckIntervalData(final int
the current count value
count
,
final long
the start time of the check interval
intervalStart
)

Creates a new instance of CheckIntervalData.

Method Summary

Modifier and TypeMethod and Description
public long

Returns:

the check interval start time
getCheckIntervalStart
()

Gets the start time of the current check interval.

public int

Returns:

the number of received events
getEventCount
()

Gets the event counter.

public EventCountCircuitBreaker.CheckIntervalData

Returns:

the updated instance
increment
(final int
the delta
delta
)

Returns a new instance of CheckIntervalData with the event counter incremented by the given delta.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

checkIntervalStartback to summary
private final long checkIntervalStart

The start time of the current check interval.

eventCountback to summary
private final int eventCount

The counter for events.

Constructor Detail

CheckIntervalDataback to summary
pack-priv CheckIntervalData(final int count, final long intervalStart)

Creates a new instance of CheckIntervalData.

Parameters
count:int

the current count value

intervalStart:long

the start time of the check interval

Method Detail

getCheckIntervalStartback to summary
public long getCheckIntervalStart()

Gets the start time of the current check interval.

Returns:long

the check interval start time

getEventCountback to summary
public int getEventCount()

Gets the event counter.

Returns:int

the number of received events

incrementback to summary
public EventCountCircuitBreaker.CheckIntervalData increment(final int delta)

Returns a new instance of CheckIntervalData with the event counter incremented by the given delta. If the delta is 0, this object is returned.

Parameters
delta:int

the delta

Returns:EventCountCircuitBreaker.CheckIntervalData

the updated instance

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

private final Class EventCountCircuitBreaker.StateStrategyClosed

extends AbstractStateStrategy
Class Inheritance

A specialized AbstractStateStrategy implementation for the state closed.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
protected long
fetchCheckInterval(final EventCountCircuitBreaker breaker)

Implements abstract org.apache.commons.lang3.concurrent.EventCountCircuitBreaker.AbstractStateStrategy.fetchCheckInterval.

Obtains the check interval to applied for the represented state from the given CircuitBreaker.

public boolean
isStateTransition(final EventCountCircuitBreaker breaker, final EventCountCircuitBreaker.CheckIntervalData currentData, final EventCountCircuitBreaker.CheckIntervalData nextData)

Implements abstract org.apache.commons.lang3.concurrent.EventCountCircuitBreaker.AbstractStateStrategy.isStateTransition.

Tests whether the specified CheckIntervalData objects indicate that a state transition should occur.

Inherited from org.apache.commons.lang3.concurrent.EventCountCircuitBreaker.AbstractStateStrategy:
isCheckIntervalFinished

Constructor Detail

StateStrategyClosedback to summary
private StateStrategyClosed()

Method Detail

fetchCheckIntervalback to summary
protected long fetchCheckInterval(final EventCountCircuitBreaker breaker)

Implements abstract org.apache.commons.lang3.concurrent.EventCountCircuitBreaker.AbstractStateStrategy.fetchCheckInterval.

Doc from org.apache.commons.lang3.concurrent.EventCountCircuitBreaker.AbstractStateStrategy.fetchCheckInterval.

Obtains the check interval to applied for the represented state from the given CircuitBreaker.

Annotations
@Override
isStateTransitionback to summary
public boolean isStateTransition(final EventCountCircuitBreaker breaker, final EventCountCircuitBreaker.CheckIntervalData currentData, final EventCountCircuitBreaker.CheckIntervalData nextData)

Implements abstract org.apache.commons.lang3.concurrent.EventCountCircuitBreaker.AbstractStateStrategy.isStateTransition.

Doc from org.apache.commons.lang3.concurrent.EventCountCircuitBreaker.AbstractStateStrategy.isStateTransition.

Tests whether the specified CheckIntervalData objects indicate that a state transition should occur. Here the logic which checks for thresholds depending on the current state is implemented.

Annotations
@Override
org.apache.commons.lang3.concurrent back to summary

private final Class EventCountCircuitBreaker.StateStrategyOpen

extends AbstractStateStrategy
Class Inheritance

A specialized AbstractStateStrategy implementation for the state open.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
protected long
fetchCheckInterval(final EventCountCircuitBreaker breaker)

Implements abstract org.apache.commons.lang3.concurrent.EventCountCircuitBreaker.AbstractStateStrategy.fetchCheckInterval.

Obtains the check interval to applied for the represented state from the given CircuitBreaker.

public boolean
isStateTransition(final EventCountCircuitBreaker breaker, final EventCountCircuitBreaker.CheckIntervalData currentData, final EventCountCircuitBreaker.CheckIntervalData nextData)

Implements abstract org.apache.commons.lang3.concurrent.EventCountCircuitBreaker.AbstractStateStrategy.isStateTransition.

Tests whether the specified CheckIntervalData objects indicate that a state transition should occur.

Inherited from org.apache.commons.lang3.concurrent.EventCountCircuitBreaker.AbstractStateStrategy:
isCheckIntervalFinished

Constructor Detail

StateStrategyOpenback to summary
private StateStrategyOpen()

Method Detail

fetchCheckIntervalback to summary
protected long fetchCheckInterval(final EventCountCircuitBreaker breaker)

Implements abstract org.apache.commons.lang3.concurrent.EventCountCircuitBreaker.AbstractStateStrategy.fetchCheckInterval.

Doc from org.apache.commons.lang3.concurrent.EventCountCircuitBreaker.AbstractStateStrategy.fetchCheckInterval.

Obtains the check interval to applied for the represented state from the given CircuitBreaker.

Annotations
@Override
isStateTransitionback to summary
public boolean isStateTransition(final EventCountCircuitBreaker breaker, final EventCountCircuitBreaker.CheckIntervalData currentData, final EventCountCircuitBreaker.CheckIntervalData nextData)

Implements abstract org.apache.commons.lang3.concurrent.EventCountCircuitBreaker.AbstractStateStrategy.isStateTransition.

Doc from org.apache.commons.lang3.concurrent.EventCountCircuitBreaker.AbstractStateStrategy.isStateTransition.

Tests whether the specified CheckIntervalData objects indicate that a state transition should occur. Here the logic which checks for thresholds depending on the current state is implemented.

Annotations
@Override