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 void
close()
void
notify(long count)
Notify the tracker upon new arrivals.double
reportRate()
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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
-