net.sourceforge.basher.impl
Class AbstractCollector

java.lang.Object
  extended by net.sourceforge.basher.impl.AbstractCollector
All Implemented Interfaces:
EventListener, Collector, BasherEventListener, org.ops4j.gaderian.events.RegistryShutdownListener
Direct Known Subclasses:
AbstractFileCollector, StdOutCollector

public abstract class AbstractCollector
extends Object
implements Collector, BasherEventListener, org.ops4j.gaderian.events.RegistryShutdownListener

Version:
1.0
Author:
Johan Lindquist

Field Summary
protected  org.apache.commons.logging.Log _log
           
protected  TimeSource _timeSource
           
 
Constructor Summary
AbstractCollector()
           
 
Method Summary
 void basherEvent(BasherEvent basherEvent)
           
protected abstract  void closeOpenResources()
           
 void fail(TaskExecutionContext taskExecutionContext, long elapsedTime, long elapsedTimeNanos, Throwable throwable)
          Reports a task's failure to run together with the time time elapsed for the failure.
 List<Average> getAverages()
          Retrieves the list of averages calculated over time.
 long getFailures()
          Retrieves the total number of failures recorded.
 long getNotRun()
          Retrieves the total number of tasks that didn't wish to run
 long getSuccesses()
          Retrieves the total number of successes recorded.
 long getTotal()
          Retrieves the total number of tasks that were recorded (essentially successes+failures).
protected abstract  void initializeCollector(BasherContext basherContext)
           
 boolean isCollecting()
          Checks if the collector is currently collecting statistics.
 Average markAverage()
          Informs the collector that a collection period has finished.
 void notRun(TaskExecutionContext taskExecutionContext, long elapsedTime, long elapsedTimeNanos)
          Reports a task's wish to not run altogether with the time time elapsed for it to determine this.
 void registryDidShutdown()
           
 void setLog(org.apache.commons.logging.Log log)
           
 void setTimeSource(TimeSource timeSource)
           
 void startCollecting()
          Signals to the collector that statistics collection should start.
 void stopCollecting()
          Signals to the collector that collection should stop.
 void success(TaskExecutionContext taskExecutionContext, long elapsedTime, long elapsedTimeNanos)
          Reports a task's successful invocation together with the time elapsed for the task to run.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_timeSource

protected TimeSource _timeSource

_log

protected org.apache.commons.logging.Log _log
Constructor Detail

AbstractCollector

public AbstractCollector()
Method Detail

startCollecting

public void startCollecting()
Description copied from interface: Collector
Signals to the collector that statistics collection should start.

Specified by:
startCollecting in interface Collector

stopCollecting

public void stopCollecting()
Description copied from interface: Collector
Signals to the collector that collection should stop.

Specified by:
stopCollecting in interface Collector

initializeCollector

protected abstract void initializeCollector(BasherContext basherContext)
                                     throws Exception
Throws:
Exception

closeOpenResources

protected abstract void closeOpenResources()

success

public void success(TaskExecutionContext taskExecutionContext,
                    long elapsedTime,
                    long elapsedTimeNanos)
Description copied from interface: Collector
Reports a task's successful invocation together with the time elapsed for the task to run.

Specified by:
success in interface Collector
Parameters:
taskExecutionContext - The task execution context wrapping the Task that was invoked
elapsedTime - The time it took for the task to run

notRun

public void notRun(TaskExecutionContext taskExecutionContext,
                   long elapsedTime,
                   long elapsedTimeNanos)
Description copied from interface: Collector
Reports a task's wish to not run altogether with the time time elapsed for it to determine this.

Specified by:
notRun in interface Collector
Parameters:
taskExecutionContext - The task execution context wrapping the Task that didn't wish to run
elapsedTime - The time it took for the task to run and determine it didn't want to run

fail

public void fail(TaskExecutionContext taskExecutionContext,
                 long elapsedTime,
                 long elapsedTimeNanos,
                 Throwable throwable)
Description copied from interface: Collector
Reports a task's failure to run together with the time time elapsed for the failure. The (possible) cause of the failure is also provided.

Specified by:
fail in interface Collector
Parameters:
taskExecutionContext - The task execution context wrapping the Task that failed
elapsedTime - The time it took for the task to run and fail.
throwable - The cause of the failure. This may be null if the cause of the failure is not an exception.

getFailures

public long getFailures()
Description copied from interface: Collector
Retrieves the total number of failures recorded.

Specified by:
getFailures in interface Collector
Returns:
The number of failures recorded.

getSuccesses

public long getSuccesses()
Description copied from interface: Collector
Retrieves the total number of successes recorded.

Specified by:
getSuccesses in interface Collector
Returns:
The number of successes recorded.

getNotRun

public long getNotRun()
Description copied from interface: Collector
Retrieves the total number of tasks that didn't wish to run

Specified by:
getNotRun in interface Collector
Returns:
The total number of tasks not wishing to run.

getTotal

public long getTotal()
Description copied from interface: Collector
Retrieves the total number of tasks that were recorded (essentially successes+failures).

Specified by:
getTotal in interface Collector
Returns:
The total number of tasks recorded.

getAverages

public List<Average> getAverages()
Description copied from interface: Collector
Retrieves the list of averages calculated over time.

Specified by:
getAverages in interface Collector
Returns:
A list of Average instances.

markAverage

public Average markAverage()
Description copied from interface: Collector
Informs the collector that a collection period has finished.

Specified by:
markAverage in interface Collector

setTimeSource

public void setTimeSource(TimeSource timeSource)

setLog

public void setLog(org.apache.commons.logging.Log log)

isCollecting

public boolean isCollecting()
Description copied from interface: Collector
Checks if the collector is currently collecting statistics.

Specified by:
isCollecting in interface Collector
Returns:
True if the collector is collecting data, otherwise false.

basherEvent

public void basherEvent(BasherEvent basherEvent)
Specified by:
basherEvent in interface BasherEventListener

registryDidShutdown

public void registryDidShutdown()
Specified by:
registryDidShutdown in interface org.ops4j.gaderian.events.RegistryShutdownListener


Copyright © 2006-2010 Basher Team. All Rights Reserved.