com.grandcentral.appstats.impl
Class StatAggregatorImpl

java.lang.Object
  |
  +--com.grandcentral.appstats.impl.StatAggregatorImpl
All Implemented Interfaces:
java.io.Serializable, StatAggregator

public class StatAggregatorImpl
extends java.lang.Object
implements StatAggregator

Base StatAggregator implementation. Handles all of the aggregationMethods in Stat interface.

Copyright: Copyright (c) 2002

Company: Grand Central Communications

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

Field Summary
static long DEFAULT_EXPAVGSAMPLESIZE
          == 200, the default sample size for exponential average calculation
protected  boolean m_generateHierarchy
          If enabled, then root level stats(not of type Stat.TYPE_HEIRARCH) will be duplicated with heirarchy information.
 
Fields inherited from interface com.grandcentral.appstats.StatAggregator
SUFFIX_AVG, SUFFIX_AVGCOUNT, SUFFIX_AVGSUM, SUFFIX_EXPAVG, SUFFIX_EXPAVGEXPONENT, SUFFIX_MAX, SUFFIX_MIN, SUFFIX_SUM
 
Method Summary
 void aggregate(Task dest, Stat newStat, java.lang.String sourceTaskName)
          aggregates a Stat based on its statName and aggregation method.
 void calculate(Task dest, Stat newStat, java.lang.String targetNamePrefix, boolean hierarchy)
           
 void calculateAvg(Task dest, Stat newStat, java.lang.String targetNamePrefix, boolean hierarchy)
          calculation logic for Stat.AGGREGATE_AVG aggregation method.
 void calculateExpAvg(Task dest, Stat newStat, java.lang.String targetNamePrefix, boolean hierarchy)
          calculation logic for Stat.AGGREGATE_EXPAVG aggregation method.
 void calculateMax(Task dest, Stat newStat, java.lang.String targetNamePrefix, boolean hierarchy)
           
 void calculateMin(Task dest, Stat newStat, java.lang.String targetNamePrefix, boolean hierarchy)
          calculation logic for Stat.AGGREGATE_MIN aggregation method.
 void calculateSum(Task dest, Stat newStat, java.lang.String targetNamePrefix, boolean hierarchy)
          calculation logic for Stat.AGGREGATE_SUM aggregation method.
static StatAggregator getInstance()
           
 boolean isGenerateHierarchy()
           
 void processError(Task dest, java.lang.Throwable error, java.lang.String sourceTaskName)
          Processes a captured Exception and adds it to the list of exceptions.
 void setGenerateHierarchy(boolean generate)
          If enabled, new stats that are not part of a hierarchy will be duplicated.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_EXPAVGSAMPLESIZE

public static final long DEFAULT_EXPAVGSAMPLESIZE
== 200, the default sample size for exponential average calculation

m_generateHierarchy

protected boolean m_generateHierarchy
If enabled, then root level stats(not of type Stat.TYPE_HEIRARCH) will be duplicated with heirarchy information.
Method Detail

aggregate

public void aggregate(Task dest,
                      Stat newStat,
                      java.lang.String sourceTaskName)
Description copied from interface: StatAggregator
aggregates a Stat based on its statName and aggregation method. Any Stats produced by aggregation methods (e.g. min,max,avg) retain the same prefix as newStat with new suffices depending on the aggregation method (e.g. "min","max","avg"). So, in a nutshell, if you have a Stat w/ statName=="latency" and aggregationMethod==AGGREGATE_AVG|AGGREGATE_MIN|AGGREGATE_MAX this method will create in the destination task 3 stats: "latency.avg," "latency.min," and "latency.max"
Specified by:
aggregate in interface StatAggregator
Parameters:
sourceTaskName - is the name of the task from where the stat was generated used only if newStat.containsType(Stat.TYPE_HIERARCH)||generateHierarchy==true

processError

public void processError(Task dest,
                         java.lang.Throwable error,
                         java.lang.String sourceTaskName)
Processes a captured Exception and adds it to the list of exceptions. Special Aggregatiors may provide special handling.
Specified by:
processError in interface StatAggregator
Parameters:
dest - destination Task
error - Exception that should be handled
sourceTaskName - name of the new stat's source

calculate

public void calculate(Task dest,
                      Stat newStat,
                      java.lang.String targetNamePrefix,
                      boolean hierarchy)

calculateMin

public void calculateMin(Task dest,
                         Stat newStat,
                         java.lang.String targetNamePrefix,
                         boolean hierarchy)
calculation logic for Stat.AGGREGATE_MIN aggregation method. If newStat's long value is less than a Stat with the same statName in dest, then a clone of newStat will replace the current Stat in dest. If neither are configured for TYPE_LONG, then compares the double values. If neither are configured for TYPE_DOUBLE, then compares the Object values if they implement Comparable.

calculateMax

public void calculateMax(Task dest,
                         Stat newStat,
                         java.lang.String targetNamePrefix,
                         boolean hierarchy)

calculateSum

public void calculateSum(Task dest,
                         Stat newStat,
                         java.lang.String targetNamePrefix,
                         boolean hierarchy)
calculation logic for Stat.AGGREGATE_SUM aggregation method. Adds both long and double values if they are set. Ignores any Object values.

calculateAvg

public void calculateAvg(Task dest,
                         Stat newStat,
                         java.lang.String targetNamePrefix,
                         boolean hierarchy)
calculation logic for Stat.AGGREGATE_AVG aggregation method. if newStat is of type long, calculates average long value as a double. else if newStat is of type double, calculates average double value as double.

calculateExpAvg

public void calculateExpAvg(Task dest,
                            Stat newStat,
                            java.lang.String targetNamePrefix,
                            boolean hierarchy)
calculation logic for Stat.AGGREGATE_EXPAVG aggregation method. if newStat is of type long, calculates average long value as a double. else if newStat is of type double, calculates average double value as double.

isGenerateHierarchy

public boolean isGenerateHierarchy()

setGenerateHierarchy

public void setGenerateHierarchy(boolean generate)
If enabled, new stats that are not part of a hierarchy will be duplicated. Once with hierarchy prefix, and once without. Default = true
Parameters:
generate - true/false

getInstance

public static StatAggregator getInstance()