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

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Rate[]` | `_rates` actual rate objects for this statistic

  - ### Constructor Summary

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

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    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` | `addRate(long period)` Deprecated.
    `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)`
    `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 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)`
    `void` | `removeRate(long period)` Deprecated.
    `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()`

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

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

- - ### Field Detail

    - #### _rates

          protected final Rate[] _rates

      actual rate objects for this statistic

  - ### Constructor Detail

    - #### RateStat

          public RateStat(String name,
                          String description,
                          String group,
                          long[] periods)

  - ### Method Detail

    - #### addData

          public void addData(long value)

      Update all of the rates for the various periods with the given value. Zero duration.

    - #### addData

          public void addData(long value,
                              long eventDuration)

      update all of the rates for the various periods with the given value.

    - #### addRate

          @Deprecated
          public void addRate(long period)

      Deprecated.
      Adds a new rate with the requested period, provided that a rate with that period does not already exist.
      Parameters:
        `period` - ms

    - #### coalesceStats

          public void coalesceStats()

      coalesce all the stats

    - #### 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

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `Object`

    - #### getDescription

          public String getDescription()

    - #### getGroupName

          public String getGroupName()

    - #### getLifetimeAverageValue

          public double getLifetimeAverageValue()

    - #### getLifetimeEventCount

          public long getLifetimeEventCount()

    - #### getName

          public String getName()

    - #### getPeriods

          public long[] getPeriods()

    - #### getRate

          public Rate getRate(long period)

      Returns rate with requested period if it exists, otherwise null
      Parameters:
        `period` - ms
      Returns:
        the Rate

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### 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

    - #### nameGroupDescEquals

          boolean nameGroupDescEquals(RateStat rs)

    - #### removeRate

          @Deprecated
          public void removeRate(long period)

      Deprecated.
      If a rate with the provided period exists, remove it.
      Parameters:
        `period` - ms

    - #### store

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

      Includes comment lines
      Throws:
        `IOException`

    - #### store

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

      Stores the rate statistics to an output stream.
      Parameters:
        `addComments` - add comment lines to the output
      Throws:
        `IOException`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`