com.grandcentral.appstats.impl
Class SynchronizedStatImpl

java.lang.Object
  |
  +--com.grandcentral.appstats.impl.StatImpl
        |
        +--com.grandcentral.appstats.impl.SynchronizedStatImpl
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable, Stat
Direct Known Subclasses:
SynchronizedCounterImpl, SynchronizedTimerImpl

public class SynchronizedStatImpl
extends StatImpl

Synchronized Stat implementation

Copyright: Copyright (c) 2002

Company: Grand Central Communications

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

Fields inherited from class com.grandcentral.appstats.impl.StatImpl
m_aDouble, m_aggr, m_aLong, m_name, m_obj, m_type
 
Fields inherited from interface com.grandcentral.appstats.Stat
AGGREGATE_AVG, AGGREGATE_EXPAVG, AGGREGATE_MAX, AGGREGATE_MIN, AGGREGATE_REPLACE, AGGREGATE_SUM, DELIM_STATNAME, DELIM_STATPREFIX, DELIM_TASKPARENT, DONT_AGGREGATE, TYPE_DOUBLE, TYPE_HEIRARCH, TYPE_HIDDEN, TYPE_LONG, TYPE_OBJECT, TYPE_UNDEFINED
 
Constructor Summary
SynchronizedStatImpl()
           
 
Method Summary
 void addType(int type)
          add a type to this stat
 java.lang.Object clone()
           
 boolean containsType(int type)
          returns true if this Stat is configured with param type
 void fromStringAbbr(java.lang.String s)
          parses what it can from abbreviated form.
 int getAggregationMethod()
          Returns the aggregation method for this stat.
 double getDouble()
           
 java.lang.String getFullName()
          A Stat's full name is composed of two distinct parts: a task hierarchy and a statName.
 long getLong()
           
 java.lang.Object getObject()
           
 java.lang.String getStatName()
          A statName can be further broken down into a prefix and a suffix, as:
 java.lang.String getStatPrefix()
           
 java.lang.String getStatSuffix()
           
 java.lang.String getTaskHierarchy()
          returns the task hierarchy from the full name of this stat
 int getType()
          Returns the type for this stat.
 void prependTaskName(java.lang.String taskname)
          prepends taskname + StatSource.DELIM_PARENT to the fullname of this stat
 void removeType(int type)
          remove a type from this stat.
 void setAggregationMethod(int am)
          sets the aggregationMethod for this Stat.
 void setDouble(double num)
           
 void setFullName(java.lang.String name)
          sets the full name of this Stat.
 void setLong(long num)
           
 void setObject(java.lang.Object o)
           
 void setStatName(java.lang.String name)
          sets the stat name.
 void setStatPrefix(java.lang.String name)
          set the statName's prefix.
 void setStatSuffix(java.lang.String suffix)
           
 void setTaskHierarchy(java.lang.String taskHierarchy)
          sets the task hierarchy from the full name of this stat
 void setType(int type)
          sets the type for this stat.
 java.lang.String toStringAbbr()
          returns statName and values in String representation.
 
Methods inherited from class com.grandcentral.appstats.impl.StatImpl
addAggregationMethod, containsAggregationMethod, createFullName, createFullName, createStatName, getStatName, getStatPrefix, getStatSuffix, getTaskHierarchy, isValidPrefix, isValidStatName, isValidSuffix, isValidTaskName, prependTaskName, removeAggregationMethod, toString, toStringAbbr
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SynchronizedStatImpl

public SynchronizedStatImpl()
Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Overrides:
clone in class StatImpl

getFullName

public java.lang.String getFullName()
Description copied from interface: Stat
A Stat's full name is composed of two distinct parts: a task hierarchy and a statName. It is one of two forms:
  • task hierarchy + Stat.DELIM_STATNAME + statName
  • statName, or Stat.DELIM_STATNAME + statName
  • Overrides:
    getFullName in class StatImpl
    Following copied from interface: com.grandcentral.appstats.Stat
    See Also:
    Stat.getStatName(), Task.getName()

    setFullName

    public void setFullName(java.lang.String name)
    Description copied from interface: Stat
    sets the full name of this Stat.
    Overrides:
    setFullName in class StatImpl
    Following copied from class: com.grandcentral.appstats.impl.StatImpl
    Throws:
    NullPointerException - if name is null

    getStatName

    public java.lang.String getStatName()
    Description copied from interface: Stat
    A statName can be further broken down into a prefix and a suffix, as:

  • prefix + Stat.DELIM_STATPREFIX + suffix
  • Examples:

  • httpTransactionLatency.min
  • httpTransactionLatency.max
  • httpTransactionLatency.avg
  • In the above, "httpTransactionLatency" is the prefix, and "min," "max," and "avg" are the suffixes.
    Overrides:
    getStatName in class StatImpl
    Following copied from interface: com.grandcentral.appstats.Stat
    Returns:
    the StatSource name or "" if the statName does not contain a StatSource (i.e., it's missing a DELIM_STATPREFIX character)
    See Also:
    Stat.getFullName()

    setStatName

    public void setStatName(java.lang.String name)
    Description copied from interface: Stat
    sets the stat name.
    Overrides:
    setStatName in class StatImpl
    Following copied from class: com.grandcentral.appstats.impl.StatImpl
    Throws:
    java.lang.IllegalArgumentException - if name is not valid
    NullPointerException - if name is null

    getTaskHierarchy

    public java.lang.String getTaskHierarchy()
    Description copied from interface: Stat
    returns the task hierarchy from the full name of this stat
    Overrides:
    getTaskHierarchy in class StatImpl
    Following copied from interface: com.grandcentral.appstats.Stat
    Returns:
    "" if no task hierarchy can be found
    See Also:
    Stat.getFullName()

    setTaskHierarchy

    public void setTaskHierarchy(java.lang.String taskHierarchy)
    Description copied from interface: Stat
    sets the task hierarchy from the full name of this stat
    Overrides:
    setTaskHierarchy in class StatImpl
    Following copied from interface: com.grandcentral.appstats.Stat
    Parameters:
    name - contains the task hierarchy, or can be null to clear this Stat's taskHierarchy
    See Also:
    Stat.getFullName()

    prependTaskName

    public void prependTaskName(java.lang.String taskname)
    Description copied from interface: Stat
    prepends taskname + StatSource.DELIM_PARENT to the fullname of this stat
    Overrides:
    prependTaskName in class StatImpl
    Following copied from interface: com.grandcentral.appstats.Stat
    Throws:
    java.lang.IllegalArgumentException - if taskname contains StatSource.DELIM_PARENT character
    NullPointerException - if taskname is null

    getStatPrefix

    public java.lang.String getStatPrefix()
    Overrides:
    getStatPrefix in class StatImpl
    Following copied from interface: com.grandcentral.appstats.Stat
    See Also:
    Stat.getStatName()

    setStatPrefix

    public void setStatPrefix(java.lang.String name)
    Description copied from interface: Stat
    set the statName's prefix. This name cannot contain the DELIM_STATPREFIX character, nor the DELIM_STATNAME character.
    Overrides:
    setStatPrefix in class StatImpl
    Following copied from interface: com.grandcentral.appstats.Stat
    Throws:
    NullPointerException - if you try to set the name to a null value
    java.lang.IllegalArgumentException - if the name is invalid
    See Also:
    Stat.getStatName()

    getStatSuffix

    public java.lang.String getStatSuffix()
    Overrides:
    getStatSuffix in class StatImpl
    Following copied from interface: com.grandcentral.appstats.Stat
    Returns:
    the statname's suffix or "" if one can't be found (i.e. the statName's missing a DELIM_STATPREFIX character)
    See Also:
    Stat.getStatName(), Stat.getStatPrefix()

    setStatSuffix

    public void setStatSuffix(java.lang.String suffix)
    Overrides:
    setStatSuffix in class StatImpl

    setType

    public void setType(int type)
    Description copied from interface: Stat
    sets the type for this stat. Doesn't clear any previously stored values associated with the old type
    Overrides:
    setType in class StatImpl

    getType

    public int getType()
    Description copied from interface: Stat
    Returns the type for this stat. A stat's type is implemented as a bitfield. Thus, a stat implemented with getType()==(TYPE_LONG|TYPE_STRING) will fail the test if(getType()==(TYPE_LONG)). For comparison, it is better to use the containsType() method.

    Using multiple types in a stat allows for numerical comparison of string values, for instance, consider the case of a status Stat where you want the highest priority status of any task to filter down to the root task. You can set a numerical value along with a status String in each status Stat where numerically greater values correspond to more critical statae. Then call Stat.setAggregationMethod(AGGREGATE_MAX) and the status' stat will get filtered down in a task hierarchy so that if any child task has a high priority status the whole application will have that high priority status.

    Overrides:
    getType in class StatImpl
    Following copied from interface: com.grandcentral.appstats.Stat
    See Also:
    see also the TYPE_{type} constants

    addType

    public void addType(int type)
    Description copied from interface: Stat
    add a type to this stat
    Overrides:
    addType in class StatImpl

    removeType

    public void removeType(int type)
    Description copied from interface: Stat
    remove a type from this stat. Doesn't clear any previously stored values associated with the old type
    Overrides:
    removeType in class StatImpl

    containsType

    public boolean containsType(int type)
    Description copied from interface: Stat
    returns true if this Stat is configured with param type
    Overrides:
    containsType in class StatImpl
    Following copied from interface: com.grandcentral.appstats.Stat
    Returns:
    getType()&type

    setAggregationMethod

    public void setAggregationMethod(int am)
    Description copied from interface: Stat
    sets the aggregationMethod for this Stat. Usually this is done immediately after the Stat is created. However, if you are modifying this after a Stat has been aggregated into a destination task, you should go an remove any Stats that the prior aggregation method might have created in the destination task (otherwise, they'll sit around forever)
    Overrides:
    setAggregationMethod in class StatImpl

    getAggregationMethod

    public int getAggregationMethod()
    Description copied from interface: Stat
    Returns the aggregation method for this stat. The aggregation method is implemented as a bitfield. Thus, a stat implemented with getAggregationMethod()==(AGGREGATE_MIN|AGGREGATE_MAX) will fail the test if(getAggregationMethod()==(AGGREGATE_MIN)). For comparison, it is better to use the containsAggregationMethod() method.

    AggregationMethods are used by StatAggregators when a Task aggregates Stats from another Task. Using a bitfield allows for multiple calculations to occur when a Stat is aggregated. For instance, when a timer statistic is aggregated, the aggregator will calculate minimum, maximum, and an exponential average value and place it into the destination task, because all Timers by default have aggregation methods of (AGGREGATE_MIN|AGGREGATE_MAX|AGGREGATE_EXPAVG)

    AppStat's standard aggregation methods are stored in this class as AGGREGATE_* public static final ints. These values map to logic inside of the StatAggregatorImpl class. If a user wants to implement their own custom aggregation methods, they may use their own values and their own StatAggregator implementation. The standard aggregation methods are meant to cover 80-90% of the use cases, and that's why they are hardcoded into this class.

    Alternatively, a user may also provide a StatCalculator to calculate further statistics on aggregation. (@see Task#registerStatCalculator)

    Overrides:
    getAggregationMethod in class StatImpl
    Following copied from interface: com.grandcentral.appstats.Stat
    See Also:
    see also the AGGREGATE_{method} constants

    setLong

    public void setLong(long num)
    Overrides:
    setLong in class StatImpl

    getLong

    public long getLong()
    Overrides:
    getLong in class StatImpl

    setDouble

    public void setDouble(double num)
    Overrides:
    setDouble in class StatImpl

    getDouble

    public double getDouble()
    Overrides:
    getDouble in class StatImpl

    setObject

    public void setObject(java.lang.Object o)
    Overrides:
    setObject in class StatImpl

    getObject

    public java.lang.Object getObject()
    Overrides:
    getObject in class StatImpl

    toStringAbbr

    public java.lang.String toStringAbbr()
    Description copied from class: StatImpl
    returns statName and values in String representation. Does not serialize aggregationMethod or dataType or taskHierarchy information
    Overrides:
    toStringAbbr in class StatImpl

    fromStringAbbr

    public void fromStringAbbr(java.lang.String s)
    Description copied from class: StatImpl
    parses what it can from abbreviated form. if it fails to parse numerical value, stores value as an Object of type String
    Overrides:
    fromStringAbbr in class StatImpl