Package com.codahale.metrics
Class SlidingTimeWindowReservoir
- java.lang.Object
-
- com.codahale.metrics.SlidingTimeWindowReservoir
-
-
Field Summary
Fields Modifier and Type Field Description private Clockclockprivate static intCOLLISION_BUFFERprivate java.util.concurrent.atomic.AtomicLongcountprivate java.util.concurrent.atomic.AtomicLonglastTickprivate java.util.concurrent.ConcurrentSkipListMap<java.lang.Long,java.lang.Long>measurementsprivate static intTRIM_THRESHOLDprivate longwindow
-
Constructor Summary
Constructors Constructor Description SlidingTimeWindowReservoir(long window, java.util.concurrent.TimeUnit windowUnit)Creates a newSlidingTimeWindowReservoirwith the given window of time.SlidingTimeWindowReservoir(long window, java.util.concurrent.TimeUnit windowUnit, Clock clock)Creates a newSlidingTimeWindowReservoirwith the given clock and window of time.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SnapshotgetSnapshot()Returns a snapshot of the reservoir's values.private longgetTick()intsize()Returns the number of values recorded.private voidtrim()voidupdate(long value)Adds a new recorded value to the reservoir.
-
-
-
Field Detail
-
COLLISION_BUFFER
private static final int COLLISION_BUFFER
- See Also:
- Constant Field Values
-
TRIM_THRESHOLD
private static final int TRIM_THRESHOLD
- See Also:
- Constant Field Values
-
clock
private final Clock clock
-
measurements
private final java.util.concurrent.ConcurrentSkipListMap<java.lang.Long,java.lang.Long> measurements
-
window
private final long window
-
lastTick
private final java.util.concurrent.atomic.AtomicLong lastTick
-
count
private final java.util.concurrent.atomic.AtomicLong count
-
-
Constructor Detail
-
SlidingTimeWindowReservoir
public SlidingTimeWindowReservoir(long window, java.util.concurrent.TimeUnit windowUnit)Creates a newSlidingTimeWindowReservoirwith the given window of time.- Parameters:
window- the window of timewindowUnit- the unit ofwindow
-
SlidingTimeWindowReservoir
public SlidingTimeWindowReservoir(long window, java.util.concurrent.TimeUnit windowUnit, Clock clock)Creates a newSlidingTimeWindowReservoirwith the given clock and window of time.- Parameters:
window- the window of timewindowUnit- the unit ofwindowclock- theClockto use
-
-
Method Detail
-
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
public Snapshot 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()
-
-