messif.statistics
Class OperationStatistics

java.lang.Object
  extended by messif.statistics.OperationStatistics
All Implemented Interfaces:
java.io.Serializable

public final class OperationStatistics
extends java.lang.Object
implements java.io.Serializable

A local (operation's) list of statistics. This is typically used to retrieve statistics only during a single operation execution - the statistics registered in this collection are not influenced by other running operations (or other methods possibly modyfying statistics).

To retrieve a statistic, use binding. There are several methods to ease the task of biding a OperationStatistics to global statistics, such as registerBoundStat(java.lang.String).

See Also:
Serialized Form

Field Summary
protected  messif.statistics.StatisticsList statistics
          Local operation statistic objects
 
Constructor Summary
protected OperationStatistics()
          Creates a new instance of OperationStatistics
 
Method Summary
protected  void finalize()
          Destructor - unbind all binded objects
 java.util.Iterator<Statistics<?>> getAllStatistics()
          Access all statistics
 java.util.Iterator<Statistics<?>> getAllStatistics(java.lang.String regex)
          Access statistics whose names match the given regular expression
static OperationStatistics getLocalThreadStatistics()
          OperationStatistics creator
static StatisticCounter getOpStatisticCounter(java.lang.String name)
          Returns statistics counter from current thread operation statistics namespace
static StatisticMinMaxCounter getOpStatisticMinMaxCounter(java.lang.String name)
          Returns statistics counter from current thread operation statistics namespace
static StatisticRefCounter getOpStatisticRefCounter(java.lang.String name)
          Returns statistics reference counter from current thread operation statistics namespace
static
<T extends Statistics<T>>
T
getOpStatistics(java.lang.String name, java.lang.Class<? extends T> statisticsClass)
          Returns statistics counter from current thread operation statistics namespace
 StatisticCounter getStatisticCounter(java.lang.String name)
          Returns statistics counter from this operation statistics namespace
 StatisticMinMaxCounter getStatisticMinMaxCounter(java.lang.String name)
          Returns statistics minmaxcounter from this operation statistics namespace
 StatisticRefCounter getStatisticRefCounter(java.lang.String name)
          Returns statistics reference counter from this operation statistics namespace
<T extends Statistics<T>>
T
getStatistics(java.lang.String statisticName, java.lang.Class<? extends T> statisticClass)
          Return a statistics of defined class from this operation statistics namespace
 java.lang.String printStatistics()
          Returns String containing current states of registered statistics
 java.lang.String printStatistics(java.lang.String regex)
          Returns String containing current states of registered statistics with names matching the provided regular expression
 java.lang.String printStatistics(java.lang.String regex, java.lang.String statSeparator)
          Returns String containing current states of registered statistics with names matching the provided regular expression and separated by specified separator
 void registerBoundAllStats(java.lang.String regex)
          In this operation statistics namespace, register and bind statistics which are present in the global namespace and match the given regular expression.
<T extends Statistics<T>>
T
registerBoundStat(java.lang.Class<? extends T> statClass, java.lang.String name, java.lang.String asName)
          Register bound statistic (using asName name) in this operation statistics namespace.
 Statistics<?> registerBoundStat(java.lang.String name)
          Register bound statistic in this operation statistics namespace
protected
<T extends Statistics<T>>
T
registerBoundStat(java.lang.String asName, Statistics<T> bindToStat)
          Register statistic in this operation statistics namespace.
 Statistics<?> registerBoundStat(java.lang.String name, java.lang.String asName)
          Register bound statistic (using asName name) in this operation statistics namespace
 boolean removeStatistic(java.lang.String name)
          Removes given statistic.
static void resetLocalThreadStatistics()
          Reset current thread statistic
 void resetStatistics()
          Resets all statistics within this operation statistic object.
 void resetStatistics(java.lang.String regex)
          Resets statistics within this operation statistic object names of which match the regular expression
 java.lang.String toString()
           
 void unbindAllStats()
          Unbind all stored statistics from their parents.
 void unbindAllStats(java.lang.String regex)
          Unbind statistics matching the regular expression from their parents
 void updateFrom(OperationStatistics sourceStats)
          Update this statistics with other operation statistics values.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

statistics

protected final messif.statistics.StatisticsList statistics
Local operation statistic objects

Constructor Detail

OperationStatistics

protected OperationStatistics()
Creates a new instance of OperationStatistics

Method Detail

finalize

protected void finalize()
                 throws java.lang.Throwable
Destructor - unbind all binded objects

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

getLocalThreadStatistics

public static OperationStatistics getLocalThreadStatistics()
OperationStatistics creator


resetLocalThreadStatistics

public static void resetLocalThreadStatistics()
Reset current thread statistic


getAllStatistics

public java.util.Iterator<Statistics<?>> getAllStatistics()
Access all statistics


getAllStatistics

public java.util.Iterator<Statistics<?>> getAllStatistics(java.lang.String regex)
Access statistics whose names match the given regular expression


printStatistics

public java.lang.String printStatistics(java.lang.String regex,
                                        java.lang.String statSeparator)
Returns String containing current states of registered statistics with names matching the provided regular expression and separated by specified separator


printStatistics

public java.lang.String printStatistics(java.lang.String regex)
Returns String containing current states of registered statistics with names matching the provided regular expression


printStatistics

public java.lang.String printStatistics()
Returns String containing current states of registered statistics


resetStatistics

public void resetStatistics(java.lang.String regex)
Resets statistics within this operation statistic object names of which match the regular expression


resetStatistics

public void resetStatistics()
Resets all statistics within this operation statistic object.


getStatistics

public <T extends Statistics<T>> T getStatistics(java.lang.String statisticName,
                                                 java.lang.Class<? extends T> statisticClass)
                                      throws java.lang.ClassCastException
Return a statistics of defined class from this operation statistics namespace

Throws:
java.lang.ClassCastException

getOpStatistics

public static <T extends Statistics<T>> T getOpStatistics(java.lang.String name,
                                                          java.lang.Class<? extends T> statisticsClass)
                                               throws java.lang.ClassCastException
Returns statistics counter from current thread operation statistics namespace

Throws:
java.lang.ClassCastException

getStatisticCounter

public StatisticCounter getStatisticCounter(java.lang.String name)
                                     throws java.lang.ClassCastException
Returns statistics counter from this operation statistics namespace

Throws:
java.lang.ClassCastException

getOpStatisticCounter

public static StatisticCounter getOpStatisticCounter(java.lang.String name)
                                              throws java.lang.ClassCastException
Returns statistics counter from current thread operation statistics namespace

Throws:
java.lang.ClassCastException

getStatisticMinMaxCounter

public StatisticMinMaxCounter getStatisticMinMaxCounter(java.lang.String name)
                                                 throws java.lang.ClassCastException
Returns statistics minmaxcounter from this operation statistics namespace

Throws:
java.lang.ClassCastException

getOpStatisticMinMaxCounter

public static StatisticMinMaxCounter getOpStatisticMinMaxCounter(java.lang.String name)
                                                          throws java.lang.ClassCastException
Returns statistics counter from current thread operation statistics namespace

Throws:
java.lang.ClassCastException

getStatisticRefCounter

public StatisticRefCounter getStatisticRefCounter(java.lang.String name)
                                           throws java.lang.ClassCastException
Returns statistics reference counter from this operation statistics namespace

Throws:
java.lang.ClassCastException

getOpStatisticRefCounter

public static StatisticRefCounter getOpStatisticRefCounter(java.lang.String name)
                                                    throws java.lang.ClassCastException
Returns statistics reference counter from current thread operation statistics namespace

Throws:
java.lang.ClassCastException

removeStatistic

public boolean removeStatistic(java.lang.String name)
Removes given statistic. @return true if statistic existed and was removed, false otherwise.


registerBoundStat

public <T extends Statistics<T>> T registerBoundStat(java.lang.Class<? extends T> statClass,
                                                     java.lang.String name,
                                                     java.lang.String asName)
                                          throws java.lang.ClassCastException
Register bound statistic (using asName name) in this operation statistics namespace. If there is no global stat of specified name, it is created.

Throws:
java.lang.ClassCastException

registerBoundStat

protected <T extends Statistics<T>> T registerBoundStat(java.lang.String asName,
                                                        Statistics<T> bindToStat)
                                             throws java.lang.ClassCastException
Register statistic in this operation statistics namespace. The name asName will be used and the same class as the bindToStat. If there is a statistics with this name already, the statistic is not created but the old one is used instead.

Parameters:
asName - the name of the statistic in this operation statistics namespace
bindToStat - the statistics to which the new statistics is bound
Returns:
the newly registered statistics
Throws:
java.lang.ClassCastException - if there is a statistics with this name, but has different class than bindToStat

registerBoundStat

public Statistics<?> registerBoundStat(java.lang.String name,
                                       java.lang.String asName)
                                throws java.lang.IllegalArgumentException
Register bound statistic (using asName name) in this operation statistics namespace

Throws:
java.lang.IllegalArgumentException

registerBoundStat

public Statistics<?> registerBoundStat(java.lang.String name)
                                throws java.lang.IllegalArgumentException
Register bound statistic in this operation statistics namespace

Throws:
java.lang.IllegalArgumentException

registerBoundAllStats

public void registerBoundAllStats(java.lang.String regex)
In this operation statistics namespace, register and bind statistics which are present in the global namespace and match the given regular expression.


unbindAllStats

public void unbindAllStats(java.lang.String regex)
Unbind statistics matching the regular expression from their parents


unbindAllStats

public void unbindAllStats()
Unbind all stored statistics from their parents.


updateFrom

public void updateFrom(OperationStatistics sourceStats)
                throws java.lang.IllegalArgumentException
Update this statistics with other operation statistics values.

Parameters:
sourceStats - the operation statistics that are merged with this ones
Throws:
java.lang.IllegalArgumentException - if there was a statistic of the same name in both this and sourceStats but with of different class

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object