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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidnotify(long count)Notify the tracker upon new arrivals.doublereportRate()Get report rate.
-
-
-
Constructor Detail
-
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 Detail
-
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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
-