Package org.apache.cassandra.utils
Class SlidingTimeRate
- java.lang.Object
-
- org.apache.cassandra.utils.SlidingTimeRate
-
public class SlidingTimeRate extends java.lang.Object
Concurrent rate computation over a sliding time window. Currently not used in the Cassandra 4.0 code base. If you decide to use it, please check CASSANDRA-16713. There still might be a bug, flaky test to be fixed before using it again.
-
-
Constructor Summary
Constructors Constructor Description SlidingTimeRate(TimeSource timeSource, long size, long precision, java.util.concurrent.TimeUnit unit)
Creates a sliding rate whose time window is of the given size, with the given precision and time unit.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
get(long toAgo, java.util.concurrent.TimeUnit unit)
Gets the current rate in the given time unit from the beginning of the time window to the provided point in time ago.double
get(java.util.concurrent.TimeUnit unit)
Gets the current rate in the given time unit.void
prune()
Prunes the time window of old unused updates.int
size()
void
update(int delta)
Updates the rate.
-
-
-
Constructor Detail
-
SlidingTimeRate
public SlidingTimeRate(TimeSource timeSource, long size, long precision, java.util.concurrent.TimeUnit unit)
Creates a sliding rate whose time window is of the given size, with the given precision and time unit.The precision defines how accurate the rate computation is, as it will be computed over window size +/- precision.
-
-
Method Detail
-
update
public void update(int delta)
Updates the rate.
-
get
public double get(long toAgo, java.util.concurrent.TimeUnit unit)
Gets the current rate in the given time unit from the beginning of the time window to the provided point in time ago.
-
get
public double get(java.util.concurrent.TimeUnit unit)
Gets the current rate in the given time unit.
-
prune
public void prune()
Prunes the time window of old unused updates.
-
size
public int size()
-
-