Package net.i2p.stat
Class RateStat
java.lang.Object
net.i2p.stat.RateStat
public class RateStat extends Object
coordinate a moving rate over various periods
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and Type Method 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
addRate(long period)
Deprecated.void
coalesceStats()
coalesce all the statsboolean
containsRate(long period)
Tests if a rate with the provided period exists within this RateStat.boolean
equals(Object obj)
String
getDescription()
String
getGroupName()
double
getLifetimeAverageValue()
long
getLifetimeEventCount()
String
getName()
long[]
getPeriods()
Rate
getRate(long period)
Returns rate with requested period if it exists, otherwise nullint
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)
void
removeRate(long period)
Deprecated.void
setStatLog(StatLog sl)
Sets the default stat log for this RateStat.void
store(OutputStream out, String prefix)
Includes comment linesvoid
store(OutputStream out, String prefix, boolean addComments)
String
toString()
-
Field Details
-
_rates
actual rate objects for this statistic
-
-
Constructor Details
-
Method Details
-
setStatLog
Sets the default stat log for this RateStat. Deprecated, unused, to be disabled in a future release. -
addData
public void addData(long value, long eventDuration)update all of the rates for the various periods with the given value. -
addData
public void addData(long value)Update all of the rates for the various periods with the given value. Zero duration.- Since:
- 0.8.10
-
coalesceStats
public void coalesceStats()coalesce all the stats -
getName
-
getGroupName
-
getDescription
-
getPeriods
public long[] getPeriods() -
getLifetimeAverageValue
public double getLifetimeAverageValue() -
getLifetimeEventCount
public long getLifetimeEventCount() -
getRate
Returns rate with requested period if it exists, otherwise null- Parameters:
period
- ms- Returns:
- the Rate
-
addRate
Deprecated.Adds a new rate with the requested period, provided that a rate with that period does not already exist.- Parameters:
period
- ms- Since:
- 0.8.8
-
removeRate
Deprecated.If a rate with the provided period exists, remove it.- Parameters:
period
- ms- Since:
- 0.8.8
-
containsRate
public boolean containsRate(long period)Tests if a rate with the provided period exists within this RateStat.- Parameters:
period
- ms- Returns:
- true if exists
- Since:
- 0.8.8
-
hashCode
public int hashCode() -
toString
-
equals
-
nameGroupDescEquals
-
store
Includes comment lines- Throws:
IOException
-
store
- Parameters:
addComments
- add comment lines to the output- Throws:
IOException
- Since:
- 0.9.41
-
load
public void load(Properties props, String prefix, boolean treatAsCurrent) throws IllegalArgumentExceptionLoad this rate stat from the properties, populating all of the rates contained underneath it. The comes from the given prefix (e.g. if we are given the prefix "profile.dbIntroduction", a series of rates may be found underneath "profile.dbIntroduction.60s", "profile.dbIntroduction.60m", and "profile.dbIntroduction.24h"). This RateStat must already be created, with the specified rate entries constructued - this merely loads them with data.- Parameters:
prefix
- 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.- Throws:
IllegalArgumentException
- if the data was formatted incorrectly
-