Package dev.failsafe.internal
Class CountingCircuitStats
java.lang.Object
dev.failsafe.internal.CountingCircuitStats
- All Implemented Interfaces:
CircuitStats
A CircuitStats implementation that counts execution results using a BitSet.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final BitSet
(package private) int
Index to write next entry toprivate int
private int
private final int
private int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) void
copyStats
(CircuitStats oldStats) Copies the most recent stats from theoldStats
into this in order from oldest to newest.int
int
int
int
int
private int
indexAfter
(int index) Returns the index after theindex
.void
void
void
reset()
(package private) int
setNext
(boolean value) Sets the value of the next bit in the bitset, returning the previous value, else -1 if no previous value was set for the bit.toString()
Returns an array representation of the BitSet entries.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface dev.failsafe.internal.CircuitStats
copyExecutions
-
Field Details
-
bitSet
-
size
private final int size -
currentIndex
volatile int currentIndexIndex to write next entry to -
occupiedBits
private volatile int occupiedBits -
successes
private volatile int successes -
failures
private volatile int failures
-
-
Constructor Details
-
CountingCircuitStats
-
-
Method Details
-
copyStats
Copies the most recent stats from theoldStats
into this in order from oldest to newest. -
recordSuccess
public void recordSuccess()- Specified by:
recordSuccess
in interfaceCircuitStats
-
recordFailure
public void recordFailure()- Specified by:
recordFailure
in interfaceCircuitStats
-
getExecutionCount
public int getExecutionCount()- Specified by:
getExecutionCount
in interfaceCircuitStats
-
getFailureCount
public int getFailureCount()- Specified by:
getFailureCount
in interfaceCircuitStats
-
getFailureRate
public int getFailureRate()- Specified by:
getFailureRate
in interfaceCircuitStats
-
getSuccessCount
public int getSuccessCount()- Specified by:
getSuccessCount
in interfaceCircuitStats
-
getSuccessRate
public int getSuccessRate()- Specified by:
getSuccessRate
in interfaceCircuitStats
-
reset
public void reset()- Specified by:
reset
in interfaceCircuitStats
-
setNext
int setNext(boolean value) Sets the value of the next bit in the bitset, returning the previous value, else -1 if no previous value was set for the bit.- Parameters:
value
- true if positive/success, false if negative/failure
-
toString
Returns an array representation of the BitSet entries. -
indexAfter
private int indexAfter(int index) Returns the index after theindex
.
-