com.limegroup.gnutella
Class Statistics

java.lang.Object
  extended bycom.limegroup.gnutella.Statistics

public class Statistics
extends java.lang.Object

Maintains various session statistics, like uptime. Implements the Singleton pattern. Statistics are initialized the when the class is loaded; call Statistics.instance() to guarantee initialization.


Constructor Summary
protected Statistics()
          "PROTECTED" FOR TESTING PURPOSES ONLY!
 
Method Summary
 int calculateDailyUptime()
          Calculates the average number of seconds this host runs per day, i.e., calculateFractionRunning*24*60*60.
 float calculateFractionalUptime()
          Calculates the fraction of time this is running, a unitless quantity between zero and 1.
 long getUptime()
          Returns the amount of time this has been running.
static Statistics instance()
          Returns the single Statistics instance.
protected  long now()
          The current system time, in milliseconds.
 void shutdown()
          Notifies this that LimeWire is shutting down, updating permanent statistics in limewire.props if necessary.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Statistics

protected Statistics()
"PROTECTED" FOR TESTING PURPOSES ONLY!

Method Detail

instance

public static Statistics instance()
Returns the single Statistics instance.


getUptime

public long getUptime()
Returns the amount of time this has been running.

Returns:
the session uptime in milliseconds

calculateDailyUptime

public int calculateDailyUptime()
Calculates the average number of seconds this host runs per day, i.e., calculateFractionRunning*24*60*60.

Returns:
uptime in seconds/day.
See Also:
calculateFractionalUptime

calculateFractionalUptime

public float calculateFractionalUptime()
Calculates the fraction of time this is running, a unitless quantity between zero and 1. Implemented using an exponential moving average (EMA) that discounts the past. Does not update the FRACTION_RUNNING property; that should only be done once, on shutdown

See Also:
calculateDailyUptime

shutdown

public void shutdown()
Notifies this that LimeWire is shutting down, updating permanent statistics in limewire.props if necessary.


now

protected long now()
The current system time, in milliseconds. Exists as a hook for testing purposes only.