net.i2p.stat
Class StatManager

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

public class StatManager
extends java.lang.Object

Coordinate the management of various frequencies and rates within I2P components, both allowing central update and retrieval, as well as distributed creation and use. This does not provide any persistence, but the data structures exposed can be read and updated to manage the complete state.


Field Summary
static java.lang.String DEFAULT_STAT_FILE
           
static java.lang.String DEFAULT_STAT_REQUIRED
          These are all the stats published in netDb, plus those required for the operation of the router (many in RouterThrottleImpl), plus those that are on graphs.jsp by default, plus those used on the summary bar (SummaryHelper.java).
static java.lang.String PROP_STAT_FILE
           
static java.lang.String PROP_STAT_FILTER
          Comma-separated stats or * for all.
static java.lang.String PROP_STAT_FULL
          default true
static java.lang.String PROP_STAT_REQUIRED
           
 
Constructor Summary
StatManager(I2PAppContext context)
          The stat manager should only be constructed and accessed through the application context.
 
Method Summary
 void addRateData(java.lang.String name, long data, long eventDuration)
          update the given rate statistic, taking note that the given data point was received (and recalculating all rates)
 void coalesceStats()
           
 void createFrequencyStat(java.lang.String name, java.lang.String description, java.lang.String group, long[] periods)
          Create a new statistic to monitor the frequency of some event.
 void createRateStat(java.lang.String name, java.lang.String description, java.lang.String group, long[] periods)
          Create a new statistic to monitor the average value and confidence of some action.
 FrequencyStat getFrequency(java.lang.String name)
           
 java.util.Set<java.lang.String> getFrequencyNames()
           
 RateStat getRate(java.lang.String name)
           
 java.util.Set<java.lang.String> getRateNames()
           
 java.lang.String getStatFile()
           
 java.lang.String getStatFilter()
           
 StatLog getStatLog()
          may be null
 java.util.Map getStatsByGroup()
          Group name (String) to a Set of stat names, ordered alphabetically
 boolean ignoreStat(java.lang.String statName)
          Save memory by not creating stats unless they are required for router operation
 boolean isFrequency(java.lang.String statName)
          is the given stat a monitored frequency?
 boolean isRate(java.lang.String statName)
          is the given stat a monitored rate?
 void removeRateStat(java.lang.String name)
           
 void setStatLog(StatLog log)
           
 void updateFrequency(java.lang.String name)
          update the given frequency statistic, taking note that an event occurred (and recalculating all frequencies)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_STAT_FILTER

public static final java.lang.String PROP_STAT_FILTER
Comma-separated stats or * for all. This property must be set at startup, or logging is disabled.

See Also:
Constant Field Values

PROP_STAT_FILE

public static final java.lang.String PROP_STAT_FILE
See Also:
Constant Field Values

DEFAULT_STAT_FILE

public static final java.lang.String DEFAULT_STAT_FILE
See Also:
Constant Field Values

PROP_STAT_FULL

public static final java.lang.String PROP_STAT_FULL
default true

See Also:
Constant Field Values

PROP_STAT_REQUIRED

public static final java.lang.String PROP_STAT_REQUIRED
See Also:
Constant Field Values

DEFAULT_STAT_REQUIRED

public static final java.lang.String DEFAULT_STAT_REQUIRED
These are all the stats published in netDb, plus those required for the operation of the router (many in RouterThrottleImpl), plus those that are on graphs.jsp by default, plus those used on the summary bar (SummaryHelper.java). Wildcard ('*') allowed at end of stat only. Ignore all the rest of the stats unless stat.full=true.

See Also:
Constant Field Values
Constructor Detail

StatManager

public StatManager(I2PAppContext context)
The stat manager should only be constructed and accessed through the application context. This constructor should only be used by the appropriate application context itself.

Method Detail

getStatLog

public StatLog getStatLog()
may be null


setStatLog

public void setStatLog(StatLog log)

createFrequencyStat

public void createFrequencyStat(java.lang.String name,
                                java.lang.String description,
                                java.lang.String group,
                                long[] periods)
Create a new statistic to monitor the frequency of some event.

Parameters:
name - unique name of the statistic
description - simple description of the statistic
group - used to group statistics together
periods - array of period lengths (in milliseconds)

createRateStat

public void createRateStat(java.lang.String name,
                           java.lang.String description,
                           java.lang.String group,
                           long[] periods)
Create a new statistic to monitor the average value and confidence of some action.

Parameters:
name - unique name of the statistic
description - simple description of the statistic
group - used to group statistics together
periods - array of period lengths (in milliseconds)

removeRateStat

public void removeRateStat(java.lang.String name)

updateFrequency

public void updateFrequency(java.lang.String name)
update the given frequency statistic, taking note that an event occurred (and recalculating all frequencies)


addRateData

public void addRateData(java.lang.String name,
                        long data,
                        long eventDuration)
update the given rate statistic, taking note that the given data point was received (and recalculating all rates)


coalesceStats

public void coalesceStats()

getFrequency

public FrequencyStat getFrequency(java.lang.String name)

getRate

public RateStat getRate(java.lang.String name)

getFrequencyNames

public java.util.Set<java.lang.String> getFrequencyNames()

getRateNames

public java.util.Set<java.lang.String> getRateNames()

isRate

public boolean isRate(java.lang.String statName)
is the given stat a monitored rate?


isFrequency

public boolean isFrequency(java.lang.String statName)
is the given stat a monitored frequency?


getStatsByGroup

public java.util.Map getStatsByGroup()
Group name (String) to a Set of stat names, ordered alphabetically


getStatFilter

public java.lang.String getStatFilter()

getStatFile

public java.lang.String getStatFile()

ignoreStat

public boolean ignoreStat(java.lang.String statName)
Save memory by not creating stats unless they are required for router operation

Returns:
true if the stat should be ignored.