kaos.metrics
Class MetricManager

java.lang.Object
  extended by kaos.metrics.MetricManager
All Implemented Interfaces:
TimerCallBack

public class MetricManager
extends java.lang.Object
implements TimerCallBack

This class is a singleton that provides tracking and logging of metrics related to the listener. The metrics are tracked by this class and logged at intervals defined in the properties file. The available metrics are defined in the properties file.

See Also:
com.telemics.listener.Listener

Method Summary
 void add(java.lang.String pMetricId, java.util.Date pMetricValue)
          Adds to a metrics value, accounting for the type of metric.
 void add(java.lang.String pMetricId, java.util.GregorianCalendar pMetricValue)
          Adds to a metrics value, accounting for the type of metric.
 void add(java.lang.String pMetricId, int pMetricValue)
          Adds to a metrics value, accounting for the type of metric.
 void add(java.lang.String pMetricId, long pMetricValue)
          Adds to a metrics value, accounting for the type of metric.
 float getAverage(java.lang.String pMetricId)
          Returns the specified metric's average value.
 long getDataPointCount(java.lang.String pMetricId)
          Returns the specified metric's count of data points.
static MetricManager getInstance()
          Returns the single instance, creating one if it's the first time this method is called.
 java.util.GregorianCalendar getTimeStamp(java.lang.String pMetricId)
          Returns the specified metric's TimeStamp value.
 long getValue(java.lang.String pMetricId)
          Returns the specified metric's value.
 void logMetrics()
          Logs all the metrics to the file.
 void reset()
          Resets all metrics to zero or null after performing a log of the current values.
 void reset(java.lang.String pMetricId)
          Resets a metric to zero or null after performing a log of the metric.
 void shutdown()
          Allows a client to explicity shutdown the metric manager causing all metrics to be logged, the timer thread to be stopped, and the internal reference for the singleton pattern to be cleared.
 void timerExpired()
          Called during each expiration of the timer in order to log current metric totals.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static MetricManager getInstance()
Returns the single instance, creating one if it's the first time this method is called.

Returns:
The single instance of MetricManager.

shutdown

public void shutdown()
Allows a client to explicity shutdown the metric manager causing all metrics to be logged, the timer thread to be stopped, and the internal reference for the singleton pattern to be cleared.


timerExpired

public void timerExpired()
Called during each expiration of the timer in order to log current metric totals.

Specified by:
timerExpired in interface TimerCallBack

add

public void add(java.lang.String pMetricId,
                int pMetricValue)
Adds to a metrics value, accounting for the type of metric.

Parameters:
pMetricId - String id of the metric to add value to.
pMetricValue - Value to be added to this metric.

add

public void add(java.lang.String pMetricId,
                long pMetricValue)
Adds to a metrics value, accounting for the type of metric.

Parameters:
pMetricId - String id of the metric to add value to.
pMetricValue - Value to be added to this metric.

add

public void add(java.lang.String pMetricId,
                java.util.Date pMetricValue)
Adds to a metrics value, accounting for the type of metric.

Parameters:
pMetricId - String id of the metric to add value to.
pMetricValue - Value to be added to this metric.

add

public void add(java.lang.String pMetricId,
                java.util.GregorianCalendar pMetricValue)
Adds to a metrics value, accounting for the type of metric.

Parameters:
pMetricId - String id of the metric to add value to.
pMetricValue - Value to be added to this metric.

getValue

public long getValue(java.lang.String pMetricId)
Returns the specified metric's value.

Parameters:
pMetricId - String id of the metric to add value to.
Returns:
Value of the metric, 0 is returned if the metric is not an indicator or static metric type.

getAverage

public float getAverage(java.lang.String pMetricId)
Returns the specified metric's average value.

Parameters:
pMetricId - String id of the metric to retrieve.
Returns:
Value of the metric, 0 is returned if the metric is not an indicator or static metric type.

getTimeStamp

public java.util.GregorianCalendar getTimeStamp(java.lang.String pMetricId)
Returns the specified metric's TimeStamp value.

Parameters:
pMetricId - String id of the metric to retrieve.
Returns:
The Date of the metric or null.

getDataPointCount

public long getDataPointCount(java.lang.String pMetricId)
Returns the specified metric's count of data points.

Parameters:
pMetricId - String id of the metric to retrieve.
Returns:
Count of datapoints added to this metric.

logMetrics

public void logMetrics()
Logs all the metrics to the file. This routine is called by another thread that is operating on a timer. The thread controls when this method is called.


reset

public void reset()
Resets all metrics to zero or null after performing a log of the current values.


reset

public void reset(java.lang.String pMetricId)
Resets a metric to zero or null after performing a log of the metric.

Parameters:
@pMetricId - Metric id to reset