Package org.apache.storm.metric.internal

# Class RateTracker

java.lang.Object
org.apache.storm.metric.internal.RateTracker

All Implemented Interfaces:
  `Closeable`, `AutoCloseable`

public class RateTracker extends Object implements Closeable
This class is a utility to track the rate of something.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `RateTracker(int validTimeWindowInMils, int numBuckets)`
  Constructor.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  `void`
  `notify(long count)`
  Notify the tracker upon new arrivals.
  `double`
  `reportRate()`
  Get report rate.

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

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

- ## Constructor Details

  - ### RateTracker

    public RateTracker(int validTimeWindowInMils, int numBuckets)
    Constructor.
    Parameters:
      `validTimeWindowInMils` - events that happened before validTimeWindowInMils are not considered when reporting the rate.
      `numBuckets` - the number of time sildes to divide validTimeWindows. The more buckets, the smother the reported results will be.

- ## Method Details

  - ### notify

    public void notify(long count)
    Notify the tracker upon new arrivals.
    Parameters:
      `count` - number of arrivals

  - ### reportRate

    public double reportRate()
    Get report rate.
    Returns:
      the approximate average rate per second.

  - ### close

    public void close()
    Specified by:
      `close` in interface `AutoCloseable`
    Specified by:
      `close` in interface `Closeable`