public class RateStat extends Object
| Modifier and Type | Field and Description |
|---|---|
protected Rate[] | _ratesactual rate objects for this statistic |
| Constructor and Description |
|---|
RateStat(String name,
String description,
String group,
long[] periods)Unique name of the statistic. |
| Modifier and Type | Method and Description |
|---|---|
void | addData(long value)Update all of the rates for the various periods with the given value. |
void | addData(long value,
long eventDuration)Update all of the rates for the various periods with the given value. |
void | coalesceStats()coalesce all the stats |
boolean | containsRate(long period)Tests if a rate with the provided period exists within this RateStat. |
boolean | equals(Object obj)Object to compare. |
String | getDescription()Description of what this rate stat measures. |
String | getGroupName()Grouping name for this rate stat. |
double | getLifetimeAverageValue()Lifetime average from the shortest period. |
long | getLifetimeEventCount()Lifetime event count from the shortest period. |
String | getName()Unique name for this rate stat. |
long[] | getPeriods()Tracked periods for this rate. |
Rate | getRate(long period)Returns rate with requested period if it exists,
otherwise null |
int | hashCode() |
void | load(Properties props,
String prefix,
boolean treatAsCurrent)Load this rate stat from the properties, populating all of the rates contained
underneath it. |
(package private) boolean | nameGroupDescEquals(RateStat rs)Whether the other stat shares name, group, and description. |
void | store(OutputStream out,
String prefix)Includes comment lines |
void | store(OutputStream out,
String prefix,
boolean addComments)Stores the rate statistics to an output stream. |
String | toString() |
protected final Rate[] _rates
public RateStat(String name, String description, String group, long[] periods)
name - unique name of the statisticdescription - simple description of the statisticgroup - used to group statistics togetherperiods - array of period lengths (in milliseconds), must not be emptyIllegalArgumentException - if periods is emptypublic void addData(long value)
value - the valuepublic void addData(long value,
long eventDuration)value - the valueeventDuration - the event durationpublic void coalesceStats()
public boolean containsRate(long period)
period - mspublic boolean equals(Object obj)
public String getDescription()
public String getGroupName()
public double getLifetimeAverageValue()
public long getLifetimeEventCount()
public String getName()
public long[] getPeriods()
public Rate getRate(long period)
period - mspublic void load(Properties props, String prefix, boolean treatAsCurrent) throws IllegalArgumentException
props - the propertiesprefix - prefix to the property entries (should NOT end with a period)treatAsCurrent - if true, we'll treat the loaded data as if no time has
elapsed since it was written out, but if it is false, we'll
treat the data with as much freshness (or staleness) as appropriate.IllegalArgumentException - if the data was formatted incorrectlyboolean nameGroupDescEquals(RateStat rs)
rs - the other RateStatpublic void store(OutputStream out, String prefix) throws IOException
out - the output streamprefix - the property prefixIOException - if an I/O error occurspublic void store(OutputStream out, String prefix, boolean addComments) throws IOException
out - the output streamprefix - the property prefixaddComments - add comment lines to the outputIOException - if an I/O error occurs