Top Description Fields Constructors Methods
org.terracotta.statistics.derived.latency

public Class MaximumLatencyHistory

extends Object
implements ChainedEventObserver, SampledStatistic<Long>
Class Inheritance
All Implemented Interfaces
org.terracotta.statistics.SampledStatistic, org.terracotta.statistics.ValueStatistic, org.terracotta.statistics.observer.ChainedEventObserver, org.terracotta.statistics.observer.ChainedObserver
Imports
org.terracotta.statistics.Sample, .SampledStatistic, .StatisticType, .Time, org.terracotta.statistics.observer.ChainedEventObserver, java.util.List, .Queue, java.util.concurrent.ArrayBlockingQueue, .TimeUnit, java.util.concurrent.atomic.AtomicReference, java.util.function.Consumer, .LongSupplier, java.util.stream.Collectors

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.

Author
Mathieu Carbou

Field Summary

Modifier and TypeField and Description
private final Queue<LatencyPeriodAccumulator>
private volatile long
private final AtomicReference<LatencyPeriodAccumulator>
private final Consumer<LatencyPeriodAccumulator>
private final LongSupplier
private final long

Constructor Summary

AccessConstructor and Description
public
MaximumLatencyHistory(int historySize, long windowSize, TimeUnit windowSizeUnit, LongSupplier timeSupplier)

public
MaximumLatencyHistory(int
The number of samples to keep
historySize
,
long
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.
windowSize
,
TimeUnit
Window size unit
windowSizeUnit
,
LongSupplier timeSupplier, Consumer<LatencyPeriodAccumulator>
The sink used to collect the old values that are discarded from the history.
sink
)

Method Summary

Modifier and TypeMethod and Description
public void
event(long
the clock at event completion in ns
timeNs
,
long
the event latency in ns
latencyNs
)

Implements org.terracotta.statistics.observer.ChainedEventObserver.event.

Called to indicate an event happened.
public List<Sample<Long>>
public List<Sample<Long>>
history(long
starting point of history in ms
sinceMillis
)

Implements org.terracotta.statistics.SampledStatistic.history.

The history of values, since a given time in ms
private void
public StatisticType
public Long
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

archiveback to summary
private final Queue<LatencyPeriodAccumulator> archive
driftback to summary
private volatile long drift
latestAccumulatorback to summary
private final AtomicReference<LatencyPeriodAccumulator> latestAccumulator
sinkback to summary
private final Consumer<LatencyPeriodAccumulator> sink
timeSupplierback to summary
private final LongSupplier timeSupplier
windowSizeNsback to summary
private final long windowSizeNs

Constructor Detail

MaximumLatencyHistoryback to summary
public MaximumLatencyHistory(int historySize, long windowSize, TimeUnit windowSizeUnit, LongSupplier timeSupplier)
MaximumLatencyHistoryback to summary
public MaximumLatencyHistory(int historySize, long windowSize, TimeUnit windowSizeUnit, LongSupplier timeSupplier, Consumer<LatencyPeriodAccumulator> sink)
Parameters
historySize:int

The number of samples to keep

windowSize:long

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:TimeUnit

Window size unit

sink:Consumer<LatencyPeriodAccumulator>

The sink used to collect the old values that are discarded from the history.

Method Detail

eventback to summary
public void event(long timeNs, long latencyNs)

Implements org.terracotta.statistics.observer.ChainedEventObserver.event.

Doc from org.terracotta.statistics.observer.ChainedEventObserver.event.

Called to indicate an event happened.

Parameters
timeNs:long

the clock at event completion in ns

latencyNs:long

the event latency in ns

Annotations
@Override
historyback to summary
public List<Sample<Long>> history()

Implements org.terracotta.statistics.SampledStatistic.history.

Doc from org.terracotta.statistics.SampledStatistic.history.

The history of values

Returns:List<Sample<Long>>

the list

Annotations
@Override
historyback to summary
public List<Sample<Long>> history(long sinceMillis)

Implements org.terracotta.statistics.SampledStatistic.history.

Doc from org.terracotta.statistics.SampledStatistic.history.

The history of values, since a given time in ms

Parameters
sinceMillis:long

starting point of history in ms

Returns:List<Sample<Long>>

the list

Annotations
@Override
insertback to summary
private void insert(LatencyPeriodAccumulator newAccumulator)
typeback to summary
public StatisticType type()

Implements org.terracotta.statistics.ValueStatistic.type.

Returns:StatisticType

Doc from org.terracotta.statistics.ValueStatistic.type.

The statistic type

Annotations
@Override
valueback to summary
public Long value()

Implements org.terracotta.statistics.ValueStatistic.value.

Returns:Long

Doc from org.terracotta.statistics.ValueStatistic.value.

The current statistic value

Annotations
@Override