Package dev.failsafe.internal
Class TimedCircuitStats
java.lang.Object
dev.failsafe.internal.TimedCircuitStats
- All Implemented Interfaces:
CircuitStats
A CircuitStats implementation that counts execution results within a time period, and buckets results to
minimize overhead.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
(package private) static class
(package private) static class
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final TimedCircuitStats.Bucket[]
private final long
private final TimedCircuitStats.Clock
(package private) int
(package private) static final int
private final TimedCircuitStats.Stat
private final long
-
Constructor Summary
ConstructorsConstructorDescriptionTimedCircuitStats
(int bucketCount, Duration thresholdingPeriod, TimedCircuitStats.Clock clock, CircuitStats oldStats) -
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 and orders buckets from oldest to newest, with uninitialized buckets counting as oldest.(package private) TimedCircuitStats.Bucket
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.int
int
int
int
int
private int
indexAfter
(int index) Returns the index after theindex
.private int
indexBefore
(int index) Returns the index before theindex
.private int
Returns the next index.void
void
void
reset()
toString()
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
-
DEFAULT_BUCKET_COUNT
static final int DEFAULT_BUCKET_COUNT- See Also:
-
clock
-
bucketSizeMillis
private final long bucketSizeMillis -
windowSizeMillis
private final long windowSizeMillis -
buckets
-
summary
-
currentIndex
volatile int currentIndex
-
-
Constructor Details
-
TimedCircuitStats
public TimedCircuitStats(int bucketCount, Duration thresholdingPeriod, TimedCircuitStats.Clock clock, CircuitStats oldStats)
-
-
Method Details
-
copyStats
Copies the most recent stats from theoldStats
into 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:
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
-
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
-