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.BitSet
bitSet
(package private) int
currentIndex
Index to write next entry toprivate int
failures
private int
occupiedBits
private int
size
private int
successes
-
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) void
copyStats(CircuitStats oldStats)
Copies the most recent stats from theoldStats
into this in order from oldest to newest.int
getExecutionCount()
int
getFailureCount()
int
getFailureRate()
int
getSuccessCount()
int
getSuccessRate()
private int
indexAfter(int index)
Returns the index after theindex
.void
recordFailure()
void
recordSuccess()
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.java.lang.String
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
-
-
-
-
Constructor Detail
-
CountingCircuitStats
public CountingCircuitStats(int size, CircuitStats oldStats)
-
-
Method Detail
-
copyStats
void copyStats(CircuitStats oldStats)
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
public java.lang.String toString()
Returns an array representation of the BitSet entries.- Overrides:
toString
in classjava.lang.Object
-
indexAfter
private int indexAfter(int index)
Returns the index after theindex
.
-
-