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 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