Class UniformTimeReservoir
- java.lang.Object
-
- org.glassfish.jersey.server.internal.monitoring.core.UniformTimeReservoir
-
- All Implemented Interfaces:
TimeReservoir<Long>
public class UniformTimeReservoir extends Object implements TimeReservoir<Long>
A random sampling reservoir of a stream oflongs. Uses Vitter's Algorithm R to produce a statistically representative sample.- Author:
- Stepan Vavra, Dropwizard Team
- See Also:
- Random Sampling with a Reservoir, https://github.com/dropwizard/metrics
-
-
Constructor Summary
Constructors Constructor Description UniformTimeReservoir(int size, long startTime, TimeUnit startTimeUnit)Creates a newUniformTimeReservoirinstance.UniformTimeReservoir(long startTime, TimeUnit startTimeUnit)Creates a newUniformTimeReservoirinstance of 1024 elements, which offers a 99.9% confidence level with a 5% margin of error assuming a normal distribution.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description UniformTimeSnapshotgetSnapshot(long time, TimeUnit timeUnit)Returns a snapshot of the reservoir's values at given time or newer.longinterval(TimeUnit timeUnit)The time interval this reservoir stores data of.intsize(long time, TimeUnit timeUnit)Returns the number of values recorded at given time or newer.voidupdate(Long value, long time, TimeUnit timeUnit)Adds a new recorded value to the reservoir bound to a given time.
-
-
-
Constructor Detail
-
UniformTimeReservoir
public UniformTimeReservoir(long startTime, TimeUnit startTimeUnit)Creates a newUniformTimeReservoirinstance of 1024 elements, which offers a 99.9% confidence level with a 5% margin of error assuming a normal distribution.- Parameters:
startTime- The start timestartTimeUnit- The start time unit
-
UniformTimeReservoir
public UniformTimeReservoir(int size, long startTime, TimeUnit startTimeUnit)Creates a newUniformTimeReservoirinstance.- Parameters:
size- the number of samples to keep in the sampling reservoirstartTime- The start timestartTimeUnit- The start time unit
-
-
Method Detail
-
size
public int size(long time, TimeUnit timeUnit)Description copied from interface:TimeReservoirReturns the number of values recorded at given time or newer. It may not be supported to return a size in past due to performance optimizations.- Specified by:
sizein interfaceTimeReservoir<Long>- Parameters:
time- The time to get the size fortimeUnit- Time unit of the provided time- Returns:
- the number of values recorded for given time or newer
-
update
public void update(Long value, long time, TimeUnit timeUnit)
Description copied from interface:TimeReservoirAdds a new recorded value to the reservoir bound to a given time.- Specified by:
updatein interfaceTimeReservoir<Long>- Parameters:
value- a new recorded valuetime- The time the recorded value occurred attimeUnit- Time unit of the provided time
-
getSnapshot
public UniformTimeSnapshot getSnapshot(long time, TimeUnit timeUnit)
Description copied from interface:TimeReservoirReturns a snapshot of the reservoir's values at given time or newer. It may not be supported to return a snapshot in past due to performance optimizations.- Specified by:
getSnapshotin interfaceTimeReservoir<Long>- Parameters:
time- The time for which to get the snapshottimeUnit- Time unit of the provided time- Returns:
- a snapshot of the reservoir's values for given time or newer
-
interval
public long interval(TimeUnit timeUnit)
Description copied from interface:TimeReservoirThe time interval this reservoir stores data of.- Specified by:
intervalin interfaceTimeReservoir<Long>- Parameters:
timeUnit- The time unit in which to get the interval- Returns:
- The time interval of this time reservoir
-
-