net.i2p.stat

## Class RateStat

- java.lang.Object
- - net.i2p.stat.RateStat

-     public class RateStat
      extends Object

  coordinate a moving rate over various periods

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `RateStat(String name, String description, String group, long[] periods)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `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(Object obj)`
    `String` | `getDescription()`
    `String` | `getGroupName()`
    `double` | `getLifetimeAverageValue()`
    `long` | `getLifetimeEventCount()`
    `String` | `getName()`
    `long[]` | `getPeriods()`
    `Rate` | `getRate(long period)`
    `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.
    `void` | `setStatLog(StatLog sl)`
    `void` | `store(OutputStream out, String prefix)`
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### RateStat

          public RateStat(String name,
                  String description,
                  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 String getName()

    - #### getGroupName

          public String getGroupName()

    - #### getDescription

          public 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 `Object`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `Object`

    - #### store

          public void store(OutputStream out,
                   String prefix)
                     throws IOException

      Throws:
        `IOException`

    - #### load

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