Package dev.failsafe.internal
Class TimedCircuitStats
- java.lang.Object
-
- dev.failsafe.internal.TimedCircuitStats
-
- All Implemented Interfaces:
CircuitStats
class TimedCircuitStats extends java.lang.Object implements CircuitStats
A CircuitStats implementation that counts execution results within a time period, and buckets results to minimize overhead.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classTimedCircuitStats.Bucket(package private) static classTimedCircuitStats.Clock(package private) static classTimedCircuitStats.Stat
-
Field Summary
Fields Modifier and Type Field Description (package private) TimedCircuitStats.Bucket[]bucketsprivate longbucketSizeMillisprivate TimedCircuitStats.Clockclock(package private) intcurrentIndex(package private) static intDEFAULT_BUCKET_COUNTprivate TimedCircuitStats.Statsummaryprivate longwindowSizeMillis
-
Constructor Summary
Constructors Constructor Description TimedCircuitStats(int bucketCount, java.time.Duration thresholdingPeriod, TimedCircuitStats.Clock clock, 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 and orders buckets from oldest to newest, with uninitialized buckets counting as oldest.(package private) TimedCircuitStats.BucketgetCurrentBucket()Returns the current bucket based on the current time, moving the internal storage to the current bucket if necessary, resetting bucket stats along the way.intgetExecutionCount()intgetFailureCount()intgetFailureRate()intgetSuccessCount()intgetSuccessRate()private intindexAfter(int index)Returns the index after theindex.private intindexBefore(int index)Returns the index before theindex.private intnextIndex()Returns the next index.voidrecordFailure()voidrecordSuccess()voidreset()java.lang.StringtoString()-
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 Detail
-
DEFAULT_BUCKET_COUNT
static final int DEFAULT_BUCKET_COUNT
- See Also:
- Constant Field Values
-
clock
private final TimedCircuitStats.Clock clock
-
bucketSizeMillis
private final long bucketSizeMillis
-
windowSizeMillis
private final long windowSizeMillis
-
buckets
final TimedCircuitStats.Bucket[] buckets
-
summary
private final TimedCircuitStats.Stat summary
-
currentIndex
volatile int currentIndex
-
-
Constructor Detail
-
TimedCircuitStats
public TimedCircuitStats(int bucketCount, java.time.Duration thresholdingPeriod, TimedCircuitStats.Clock clock, CircuitStats oldStats)
-
-
Method Detail
-
copyStats
void copyStats(CircuitStats oldStats)
Copies the most recent stats from theoldStatsinto this in order from oldest to newest and orders buckets from oldest to newest, with uninitialized buckets counting as oldest.
-
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
-
getCurrentBucket
TimedCircuitStats.Bucket getCurrentBucket()
Returns the current bucket based on the current time, moving the internal storage to the current bucket if necessary, resetting bucket stats along the way.
-
nextIndex
private int nextIndex()
Returns the next index.
-
indexAfter
private int indexAfter(int index)
Returns the index after theindex.
-
indexBefore
private int indexBefore(int index)
Returns the index before theindex.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-