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.

- - ### Constructor Summary

    Constructors
    Constructor and 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 and 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.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 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()

Copyright © 2018 The Apache Software Foundation