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 Details

    • _rates

      protected final Rate[] _rates
      actual rate objects for this statistic
  • Constructor Details

  • Method Details

    • setStatLog

      public void setStatLog​(StatLog sl)
      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

      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)
      Returns rate with requested period if it exists, otherwise null
      Parameters:
      period - ms
      Returns:
      the Rate
    • 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
      Since:
      0.8.8
    • removeRate

      @Deprecated public void removeRate​(long period)
      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()
      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
    • nameGroupDescEquals

      boolean nameGroupDescEquals​(RateStat rs)
    • 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
      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 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