V
- The type of values to store in this sliding window reservoirpublic abstract class AbstractSlidingWindowTimeReservoir<V> extends Object implements TimeReservoir<V>
TimeReservoir
implementation backed by a sliding window that stores only the measurements made in the last
N
seconds (or other startTime unit) and allows an update with data that happened in past (which is what makes it
different from Dropwizard's Metrics SlidingTimeWindowReservoir.
The snapshot this reservoir returns has limitations as mentioned in TimeReservoir
.
This reservoir is capable to store up to 2^ReservoirConstants.COLLISION_BUFFER_POWER
, that is 256, in a granularity of
nanoseconds. In other words, up to 256 values that occurred at the same nanosecond can be stored in this reservoir. For
particular nanosecond, if the collision buffer exceeds, newly added values are thrown away.Dropwizard's Metrics SlidingTimeWindowReservoir
Constructor and Description |
---|
AbstractSlidingWindowTimeReservoir(long window,
TimeUnit windowUnit,
long startTime,
TimeUnit startTimeUnit)
Creates a new
SlidingWindowTimeReservoir with the start time and window of startTime. |
AbstractSlidingWindowTimeReservoir(long window,
TimeUnit windowUnit,
long startTime,
TimeUnit startTimeUnit,
SlidingWindowTrimmer<V> trimmer)
Creates a new base sliding time window reservoir with the start time and a specified time window.
|
Modifier and Type | Method and Description |
---|---|
UniformTimeSnapshot |
getSnapshot(long time,
TimeUnit timeUnit)
Returns a snapshot of the reservoir's values at given time or newer.
|
long |
interval(TimeUnit timeUnit)
The time interval this reservoir stores data of.
|
int |
size(long time,
TimeUnit timeUnit)
Returns the number of values recorded at given time or newer.
|
protected abstract UniformTimeSnapshot |
snapshot(Collection<V> values,
long timeInterval,
TimeUnit timeIntervalUnit,
long time,
TimeUnit timeUnit)
Subclasses are required to instantiate
UniformTimeSnapshot on their own. |
void |
update(V value,
long time,
TimeUnit timeUnit)
Adds a new recorded value to the reservoir bound to a given time.
|
public AbstractSlidingWindowTimeReservoir(long window, TimeUnit windowUnit, long startTime, TimeUnit startTimeUnit)
SlidingWindowTimeReservoir
with the start time and window of startTime.window
- The window of startTimewindowUnit
- The unit of window
startTime
- The start time from which this reservoir calculates measurementsstartTimeUnit
- The start time unitpublic AbstractSlidingWindowTimeReservoir(long window, TimeUnit windowUnit, long startTime, TimeUnit startTimeUnit, SlidingWindowTrimmer<V> trimmer)
window
- The window of startTime.windowUnit
- The unit of window
.startTime
- The start time from which this reservoir calculates measurements.startTimeUnit
- The start time unit.trimmer
- The trimmer to use for trimming, if null
, default trimmer is used.public int size(long time, TimeUnit timeUnit)
TimeReservoir
size
in interface TimeReservoir<V>
time
- The time to get the size fortimeUnit
- Time unit of the provided timepublic void update(V value, long time, TimeUnit timeUnit)
TimeReservoir
update
in interface TimeReservoir<V>
value
- a new recorded valuetime
- The time the recorded value occurred attimeUnit
- Time unit of the provided timepublic long interval(TimeUnit timeUnit)
TimeReservoir
interval
in interface TimeReservoir<V>
timeUnit
- The time unit in which to get the intervalprotected abstract UniformTimeSnapshot snapshot(Collection<V> values, long timeInterval, TimeUnit timeIntervalUnit, long time, TimeUnit timeUnit)
UniformTimeSnapshot
on their own.values
- The values to create the snapshot fromtimeInterval
- The time interval this snapshot conforms totimeIntervalUnit
- The interval unit of the time intervaltime
- The time of the request of the snapshottimeUnit
- The unit of the time of the snapshot requestpublic UniformTimeSnapshot getSnapshot(long time, TimeUnit timeUnit)
TimeReservoir
getSnapshot
in interface TimeReservoir<V>
time
- The time for which to get the snapshottimeUnit
- Time unit of the provided timeCopyright © 2007-2024, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.