Package com.codahale.metrics
Class SlidingTimeWindowReservoir
- java.lang.Object
-
- com.codahale.metrics.SlidingTimeWindowReservoir
-
-
Field Summary
Fields Modifier and Type Field Description private Clock
clock
private static int
COLLISION_BUFFER
private java.util.concurrent.atomic.AtomicLong
count
private java.util.concurrent.atomic.AtomicLong
lastTick
private java.util.concurrent.ConcurrentSkipListMap<java.lang.Long,java.lang.Long>
measurements
private static int
TRIM_THRESHOLD
private long
window
-
Constructor Summary
Constructors Constructor Description SlidingTimeWindowReservoir(long window, java.util.concurrent.TimeUnit windowUnit)
Creates a newSlidingTimeWindowReservoir
with the given window of time.SlidingTimeWindowReservoir(long window, java.util.concurrent.TimeUnit windowUnit, Clock clock)
Creates a newSlidingTimeWindowReservoir
with the given clock and window of time.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Snapshot
getSnapshot()
Returns a snapshot of the reservoir's values.private long
getTick()
int
size()
Returns the number of values recorded.private void
trim()
void
update(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 newSlidingTimeWindowReservoir
with 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 newSlidingTimeWindowReservoir
with the given clock and window of time.- Parameters:
window
- the window of timewindowUnit
- the unit ofwindow
clock
- theClock
to use
-
-
Method Detail
-
size
public int size()
Description copied from interface:Reservoir
Returns the number of values recorded.
-
update
public void update(long value)
Description copied from interface:Reservoir
Adds a new recorded value to the reservoir.
-
getSnapshot
public Snapshot getSnapshot()
Description copied from interface:Reservoir
Returns a snapshot of the reservoir's values.- Specified by:
getSnapshot
in interfaceReservoir
- Returns:
- a snapshot of the reservoir's values
-
getTick
private long getTick()
-
trim
private void trim()
-
-