public class RateTracker extends Object implements Closeable
This class is a utility to track the rate of something.
Constructor and Description |
---|
RateTracker(int validTimeWindowInMils,
int numBuckets) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
notify(long count)
Notify the tracker upon new arrivals
|
double |
reportRate() |
public RateTracker(int validTimeWindowInMils, int numBuckets)
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.public void notify(long count)
Notify the tracker upon new arrivals
count
- number of arrivalspublic double reportRate()
public void close()
close
in interface Closeable
close
in interface AutoCloseable
Copyright © 2019 The Apache Software Foundation. All rights reserved.