public class OffsetStatsManager<T> extends Object
addOffsetDataPoint
repeatedly over time. Then calcAverageRate
can be called to
retrieve the average offset-unit per second over a given time interval.
For a given object T that is actively adding data points, stats are kept for
up to 20 minutes.
Care should be taken to always call remove()
when old T objects
should no longer be tracked.
Modifier and Type | Class and Description |
---|---|
class |
OffsetStatsManager.OffsetData |
Modifier and Type | Field and Description |
---|---|
protected org.apache.log4j.Logger |
log |
Constructor and Description |
---|
OffsetStatsManager() |
OffsetStatsManager(long statsDataTTL) |
Modifier and Type | Method and Description |
---|---|
void |
addOffsetDataPoint(T key,
long offset,
long timestamp)
Record that at a given point in time an object key had a given offset.
|
double |
calcAverageRate(T key,
long timeIntervalSecs) |
void |
clear()
Remove all objectst that we're tracking stats for.
|
OffsetStatsManager.OffsetData |
mostRecentDataPoint(T key) |
OffsetStatsManager.OffsetData |
oldestDataPoint(T key) |
void |
remove(T key)
Remove key from the set of objects that we're tracking stats for.
|
public OffsetStatsManager()
public OffsetStatsManager(long statsDataTTL)
public void addOffsetDataPoint(T key, long offset, long timestamp)
key
- Object to key this data point tooffset
- How much of an offset to recordtimestamp
- The time the offset occuredpublic double calcAverageRate(T key, long timeIntervalSecs)
public OffsetStatsManager.OffsetData oldestDataPoint(T key)
public OffsetStatsManager.OffsetData mostRecentDataPoint(T key)
public void remove(T key)
key
- key of stats to be removedpublic void clear()
Copyright © 2014 Apache Software Foundation. All Rights Reserved.