com.grandcentral.appstats
Class StatCalculator

java.lang.Object
  |
  +--com.grandcentral.appstats.StatCalculator
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
HistogramCalculator, RingBuffer

public abstract class StatCalculator
extends java.lang.Object
implements java.io.Serializable

A StatCalculator, as the name implies, calculates Stats. A StatCalculator will maintain state information to calculate Stats from the Stats it receives in its calculate method. The Stats calculated by a StatCalculator are placed into the destination task also passed into its calculate method.

Consider the simple example of an average calculator. To get the average Stat of a set of Stats, the StatCalculator needs to maintain internally a total Stat value, and a count of the number of Stats received. With each call to calculate, it will update a Stat in the destination task with the current average.

StatCalculators can be configured in a LinkedList fashion by adding a parent StatCalculator to an instance. The calculate method will check to ensure that the parent's calculate method is called before the child's to insure order of the stat creation. The internally managed LinkedList datastructure was chosen over an external Collection implementation to allow for resource sharing amongst StatCalculators, most specifically in the case where StatCalculators need to maintain large buffer spaces for analyses.

When the configuration of a StatCalculator changes, it may alter the number or names of Stats that it calculates and inserts into destination Tasks. Though configuration change is not expected to happen after initialization, there should be a way for the destination Task to clean up the Stats left behind by previous calls to calculate(). This is left as a @todo!

Copyright: Copyright (c) 2002

Company: Grand Central Communications

Version:
1.0
Author:
Taras Shkvarchuk, Adrian Dorsman
See Also:
Serialized Form

Field Summary
protected  StatCalculator m_parent
           
 
Constructor Summary
StatCalculator()
           
 
Method Summary
abstract  void calculate(Task destination, Stat newSample, java.lang.String prependName)
           
abstract  void clear()
          Causes to clear any state accumulated from processing stats.
 StatCalculator getParent()
           
abstract  java.util.List getSuffices()
           
 StatCalculator getTopMostParent()
          returns a StatCalculator whose parent is null
 void setParent(StatCalculator parent)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_parent

protected StatCalculator m_parent
Constructor Detail

StatCalculator

public StatCalculator()
Method Detail

getParent

public StatCalculator getParent()

setParent

public void setParent(StatCalculator parent)

getTopMostParent

public StatCalculator getTopMostParent()
returns a StatCalculator whose parent is null

getSuffices

public abstract java.util.List getSuffices()

calculate

public abstract void calculate(Task destination,
                               Stat newSample,
                               java.lang.String prependName)
                        throws DatatypeMismatchException

clear

public abstract void clear()
Causes to clear any state accumulated from processing stats. All/Any configuration data remains intact.