xsmeral.pipe.stats
Class Stats

java.lang.Object
  extended by xsmeral.pipe.stats.Stats

public class Stats
extends Object

Provides means of monitoring statistics of object processors.
The monitoring points are created using the newFunction method and results are stored in a processing context.
Values can be accessed directly (by methods of ProcessingContext) or by StatsReader designed specifically for this purpose.
The names of context parameters that hold the values have specific format:

    stats.[group].[name]
where [group] is either a class name of the processor or name of other logical grouping and [name] is name of one monitored value.

See Also:
ProcessingContext

Nested Class Summary
static class Stats.Reader
          The main implementation of StatsReader.
 
Field Summary
static String DEF_GROUP
           
static String PARAM_STATS
           
 
Constructor Summary
Stats(ObjectProcessor processor)
          Convenience constructor, creates the stat with group equal to the processor's simple class name and its associated context.
Stats(String group, ProcessingContext ctx)
          Creates a Stats instance for the specified group and context.
 
Method Summary
 ProcessingContext getContext()
          Returns the associated context, where values are stored.
 String getGroup()
          Returns group name, which is either processor's simple class name or any other arbitrary name.
static Stats.Reader getReader(ProcessingContext ctx)
          Convenience method.
<T extends Number>
StatFunction<T>
newFunction(String name, Class<? extends StatFunction<T>> function)
          Returns StatFunction instance associated with this instance's context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARAM_STATS

public static final String PARAM_STATS
See Also:
Constant Field Values

DEF_GROUP

public static final String DEF_GROUP
See Also:
Constant Field Values
Constructor Detail

Stats

public Stats(ObjectProcessor processor)
Convenience constructor, creates the stat with group equal to the processor's simple class name and its associated context.


Stats

public Stats(String group,
             ProcessingContext ctx)
Creates a Stats instance for the specified group and context. If the group is null or empty, default group name is used.

Method Detail

getGroup

public String getGroup()
Returns group name, which is either processor's simple class name or any other arbitrary name.


getContext

public ProcessingContext getContext()
Returns the associated context, where values are stored.


getReader

public static Stats.Reader getReader(ProcessingContext ctx)
Convenience method. Same as calling
  new Stats.Reader(ctx)


newFunction

public <T extends Number> StatFunction<T> newFunction(String name,
                                                      Class<? extends StatFunction<T>> function)
Returns StatFunction instance associated with this instance's context.
Runtime type of the instance returned is NOT the same as the second parameter, it is rather a custom implementation that forwards all calls to the supplied Function but at the same time writes them to the context.

Parameters:
name - Name of the stat
function - The StatFunction implementation to use