net.i2p.stat
Class RateStat

java.lang.Object
  extended by net.i2p.stat.RateStat

public class RateStat
extends java.lang.Object

coordinate a moving rate over various periods


Constructor Summary
RateStat(java.lang.String name, java.lang.String description, java.lang.String group, long[] periods)
           
 
Method Summary
 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 equals(java.lang.Object obj)
           
 java.lang.String getDescription()
           
 java.lang.String getGroupName()
           
 double getLifetimeAverageValue()
           
 long getLifetimeEventCount()
           
 java.lang.String getName()
           
 long[] getPeriods()
           
 Rate getRate(long period)
           
 int hashCode()
           
 void load(java.util.Properties props, java.lang.String prefix, boolean treatAsCurrent)
          Load this rate stat from the properties, populating all of the rates contained underneath it.
 void setStatLog(StatLog sl)
           
 void store(java.io.OutputStream out, java.lang.String prefix)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RateStat

public RateStat(java.lang.String name,
                java.lang.String description,
                java.lang.String group,
                long[] periods)
Method Detail

setStatLog

public void setStatLog(StatLog sl)

addData

public void addData(long value,
                    long eventDuration)
update all of the rates for the various periods with the given value.


coalesceStats

public void coalesceStats()
coalesce all the stats


getName

public java.lang.String getName()

getGroupName

public java.lang.String getGroupName()

getDescription

public java.lang.String getDescription()

getPeriods

public long[] getPeriods()

getLifetimeAverageValue

public double getLifetimeAverageValue()

getLifetimeEventCount

public long getLifetimeEventCount()

getRate

public Rate getRate(long period)

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

store

public void store(java.io.OutputStream out,
                  java.lang.String prefix)
           throws java.io.IOException
Throws:
java.io.IOException

load

public void load(java.util.Properties props,
                 java.lang.String prefix,
                 boolean treatAsCurrent)
          throws java.lang.IllegalArgumentException
Load 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:
java.lang.IllegalArgumentException - if the data was formatted incorrectly