Class MaximumLatencyHistory
- java.lang.Object
-
- org.terracotta.statistics.derived.latency.MaximumLatencyHistory
-
- All Implemented Interfaces:
ChainedEventObserver,ChainedObserver,SampledStatistic<java.lang.Long>,ValueStatistic<java.lang.Long>
public class MaximumLatencyHistory extends java.lang.Object implements ChainedEventObserver, SampledStatistic<java.lang.Long>
Keeps a history of the maximum operation latencies over a specific window. The window needs to be as small as possible to get the most detailed history.This is important to note that the history is based on a sample count and not a time frame. If you set a history to 100 samples and a window of 500ms, you won't have a complete time-frame of 10 seconds. You can have a sample at t0, then another one at t0 + 1 sec depending on when the operations occur.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Queue<LatencyPeriodAccumulator>archiveprivate longdriftprivate java.util.concurrent.atomic.AtomicReference<LatencyPeriodAccumulator>latestAccumulatorprivate java.util.function.Consumer<LatencyPeriodAccumulator>sinkprivate java.util.function.LongSuppliertimeSupplierprivate longwindowSizeNs
-
Constructor Summary
Constructors Constructor Description MaximumLatencyHistory(int historySize, long windowSize, java.util.concurrent.TimeUnit windowSizeUnit, java.util.function.LongSupplier timeSupplier)MaximumLatencyHistory(int historySize, long windowSize, java.util.concurrent.TimeUnit windowSizeUnit, java.util.function.LongSupplier timeSupplier, java.util.function.Consumer<LatencyPeriodAccumulator> sink)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidevent(long timeNs, long latencyNs)Called to indicate an event happened.java.util.List<Sample<java.lang.Long>>history()The history of valuesjava.util.List<Sample<java.lang.Long>>history(long sinceMillis)The history of values, since a given time in msprivate voidinsert(LatencyPeriodAccumulator newAccumulator)StatisticTypetype()java.lang.Longvalue()
-
-
-
Field Detail
-
latestAccumulator
private final java.util.concurrent.atomic.AtomicReference<LatencyPeriodAccumulator> latestAccumulator
-
archive
private final java.util.Queue<LatencyPeriodAccumulator> archive
-
windowSizeNs
private final long windowSizeNs
-
sink
private final java.util.function.Consumer<LatencyPeriodAccumulator> sink
-
timeSupplier
private final java.util.function.LongSupplier timeSupplier
-
drift
private volatile long drift
-
-
Constructor Detail
-
MaximumLatencyHistory
public MaximumLatencyHistory(int historySize, long windowSize, java.util.concurrent.TimeUnit windowSizeUnit, java.util.function.LongSupplier timeSupplier)
-
MaximumLatencyHistory
public MaximumLatencyHistory(int historySize, long windowSize, java.util.concurrent.TimeUnit windowSizeUnit, java.util.function.LongSupplier timeSupplier, java.util.function.Consumer<LatencyPeriodAccumulator> sink)- Parameters:
historySize- The number of samples to keepwindowSize- The size of the window over which the reduction is applied. A small value is better for more details, but history might discard values faster.windowSizeUnit- Window size unitsink- The sink used to collect the old values that are discarded from the history.
-
-
Method Detail
-
event
public void event(long timeNs, long latencyNs)Description copied from interface:ChainedEventObserverCalled to indicate an event happened.- Specified by:
eventin interfaceChainedEventObserver- Parameters:
timeNs- the clock at event completion in nslatencyNs- the event latency in ns
-
value
public java.lang.Long value()
- Specified by:
valuein interfaceValueStatistic<java.lang.Long>- Returns:
- The current statistic value
-
type
public StatisticType type()
- Specified by:
typein interfaceValueStatistic<java.lang.Long>- Returns:
- The statistic type
-
history
public java.util.List<Sample<java.lang.Long>> history()
Description copied from interface:SampledStatisticThe history of values- Specified by:
historyin interfaceSampledStatistic<java.lang.Long>- Returns:
- the list
-
history
public java.util.List<Sample<java.lang.Long>> history(long sinceMillis)
Description copied from interface:SampledStatisticThe history of values, since a given time in ms- Specified by:
historyin interfaceSampledStatistic<java.lang.Long>- Parameters:
sinceMillis- starting point of history in ms- Returns:
- the list
-
insert
private void insert(LatencyPeriodAccumulator newAccumulator)
-
-