Package dev.failsafe.internal
Class CountingCircuitStats
- java.lang.Object
-
- dev.failsafe.internal.CountingCircuitStats
-
- All Implemented Interfaces:
CircuitStats
class CountingCircuitStats extends java.lang.Object implements CircuitStats
A CircuitStats implementation that counts execution results using a BitSet.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.util.BitSetbitSet(package private) intcurrentIndexIndex to write next entry toprivate intfailuresprivate intoccupiedBitsprivate intsizeprivate intsuccesses
-
Constructor Summary
Constructors Constructor Description CountingCircuitStats(int size, CircuitStats oldStats)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidcopyStats(CircuitStats oldStats)Copies the most recent stats from theoldStatsinto this in order from oldest to newest.intgetExecutionCount()intgetFailureCount()intgetFailureRate()intgetSuccessCount()intgetSuccessRate()private intindexAfter(int index)Returns the index after theindex.voidrecordFailure()voidrecordSuccess()voidreset()(package private) intsetNext(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.java.lang.StringtoString()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
-
-
-
-
Constructor Detail
-
CountingCircuitStats
public CountingCircuitStats(int size, CircuitStats oldStats)
-
-
Method Detail
-
copyStats
void copyStats(CircuitStats oldStats)
Copies the most recent stats from theoldStatsinto this in order from oldest to newest.
-
recordSuccess
public void recordSuccess()
- Specified by:
recordSuccessin interfaceCircuitStats
-
recordFailure
public void recordFailure()
- Specified by:
recordFailurein interfaceCircuitStats
-
getExecutionCount
public int getExecutionCount()
- Specified by:
getExecutionCountin interfaceCircuitStats
-
getFailureCount
public int getFailureCount()
- Specified by:
getFailureCountin interfaceCircuitStats
-
getFailureRate
public int getFailureRate()
- Specified by:
getFailureRatein interfaceCircuitStats
-
getSuccessCount
public int getSuccessCount()
- Specified by:
getSuccessCountin interfaceCircuitStats
-
getSuccessRate
public int getSuccessRate()
- Specified by:
getSuccessRatein interfaceCircuitStats
-
reset
public void reset()
- Specified by:
resetin 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
public java.lang.String toString()
Returns an array representation of the BitSet entries.- Overrides:
toStringin classjava.lang.Object
-
indexAfter
private int indexAfter(int index)
Returns the index after theindex.
-
-