Package com.codahale.metrics
Class SlidingTimeWindowReservoir
java.lang.Object
com.codahale.metrics.SlidingTimeWindowReservoir
- All Implemented Interfaces:
Reservoir
A
Reservoir implementation backed by a sliding window that stores only the measurements made
in the last N seconds (or other time unit).-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Clockprivate static final intprivate final AtomicLongprivate final AtomicLongprivate final ConcurrentSkipListMap<Long, Long> private static final intprivate final long -
Constructor Summary
ConstructorsConstructorDescriptionSlidingTimeWindowReservoir(long window, TimeUnit windowUnit) Creates a newSlidingTimeWindowReservoirwith the given window of time.SlidingTimeWindowReservoir(long window, TimeUnit windowUnit, Clock clock) Creates a newSlidingTimeWindowReservoirwith the given clock and window of time. -
Method Summary
-
Field Details
-
COLLISION_BUFFER
private static final int COLLISION_BUFFER- See Also:
-
TRIM_THRESHOLD
private static final int TRIM_THRESHOLD- See Also:
-
clock
-
measurements
-
window
private final long window -
lastTick
-
count
-
-
Constructor Details
-
SlidingTimeWindowReservoir
Creates a newSlidingTimeWindowReservoirwith the given window of time.- Parameters:
window- the window of timewindowUnit- the unit ofwindow
-
SlidingTimeWindowReservoir
Creates a newSlidingTimeWindowReservoirwith the given clock and window of time.- Parameters:
window- the window of timewindowUnit- the unit ofwindowclock- theClockto use
-
-
Method Details
-
size
public int size()Description copied from interface:ReservoirReturns the number of values recorded. -
update
public void update(long value) Description copied from interface:ReservoirAdds a new recorded value to the reservoir. -
getSnapshot
Description copied from interface:ReservoirReturns a snapshot of the reservoir's values.- Specified by:
getSnapshotin interfaceReservoir- Returns:
- a snapshot of the reservoir's values
-
getTick
private long getTick() -
trim
private void trim()
-