org.perf4j.helpers
Class GenericAsyncCoalescingStatisticsAppender

java.lang.Object
  extended by org.perf4j.helpers.GenericAsyncCoalescingStatisticsAppender

public class GenericAsyncCoalescingStatisticsAppender
extends Object

This class provides the implementation for the AsyncCoalescingStatisticsAppenders made available for different logging frameworks. This class itself is generic in that it does not use any logging-framework-sppecific APIs, but is intended to be wrapped by classes that DO use those specific APIs.

See Also:
AsyncCoalescingStatisticsAppender

Nested Class Summary
static interface GenericAsyncCoalescingStatisticsAppender.GroupedTimingStatisticsHandler
          The GroupedTimingStatisticsHandler defines a callback interface so that logging-framework-specific implementations can decide what to do with the coalesced GroupedTimingStatistics.
 
Constructor Summary
GenericAsyncCoalescingStatisticsAppender()
           
 
Method Summary
 void append(String message)
          The append method should be called each time a StopWatch log message is handled by the logging framework.
 String getName()
          The name of this appender.
 int getNumDiscardedMessages()
          Returns the number of StopWatch messages that have been discarded due to the queue being full.
 int getQueueSize()
          The QueueSize option is used to control the size of the internal queue used by this appender to store logged messages before they are sent to downstream appenders.
 String getStopWatchParserClassName()
          The StopWatchParserClassName option is used to determine the class used to parse stop watch messages into StopWatch instances.
 long getTimeSlice()
          The TimeSlice option represents the length of time, in milliseconds, of the window in which appended log events are coalesced to a single GroupedTimingStatistics and sent to the GroupedTimingStatisticsHandler.
 boolean isCreateRollupStatistics()
          The CreateRollupStatistics option is used to determine whether "rollup" statistics should be created.
 void setCreateRollupStatistics(boolean createRollupStatistics)
          Sets the value of the CreateRollupStatistics option.
 void setName(String name)
          Sets the name of this appender.
 void setQueueSize(int queueSize)
          Sets the value of the QueueSize option.
 void setStopWatchParserClassName(String stopWatchParserClassName)
          Sets the value of the StopWatchParserClassName option.
 void setTimeSlice(long timeSlice)
          Sets the value of the TimeSlice option.
 void start(GenericAsyncCoalescingStatisticsAppender.GroupedTimingStatisticsHandler handler)
          The start method should only be called once, before the append method is called, to initialize options.
 void stop()
          This method should be called on shutdown to flush any pending messages in the queue and create a final GroupedTimingStatistics instance if necessary.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericAsyncCoalescingStatisticsAppender

public GenericAsyncCoalescingStatisticsAppender()
Method Detail

getName

public String getName()
The name of this appender.

Returns:
The name of this appender.

setName

public void setName(String name)
Sets the name of this appender.

Parameters:
name - The new appender name.

getTimeSlice

public long getTimeSlice()
The TimeSlice option represents the length of time, in milliseconds, of the window in which appended log events are coalesced to a single GroupedTimingStatistics and sent to the GroupedTimingStatisticsHandler. Defaults to 30,000 milliseconds.

Returns:
the TimeSlice option.

setTimeSlice

public void setTimeSlice(long timeSlice)
Sets the value of the TimeSlice option.

Parameters:
timeSlice - The new TimeSlice option, in milliseconds.

isCreateRollupStatistics

public boolean isCreateRollupStatistics()
The CreateRollupStatistics option is used to determine whether "rollup" statistics should be created. If the tag name of a StopWatch in a log message contains periods, then the GroupedTimingStatistics will be created as if each substring of the tag up to the period was also logged with a separate StopWatch instance. For example, suppose a StopWatch was logged with a tag of "requests.specificReq.PASS". For grouping purposes a StopWatch entry would be logged under each of the following tags: This allows you to view statistics at both an individual and aggregated level. If there were other StopWatch entries with a tag of "requests.specificReq.FAIL", then the data collected at the "requests.specificReq" level would include BOTH PASS and FAIL events.

Returns:
The CreateRollupStatistics option.

setCreateRollupStatistics

public void setCreateRollupStatistics(boolean createRollupStatistics)
Sets the value of the CreateRollupStatistics option.

Parameters:
createRollupStatistics - The new CreateRollupStatistics option.

getQueueSize

public int getQueueSize()
The QueueSize option is used to control the size of the internal queue used by this appender to store logged messages before they are sent to downstream appenders. Defaults to 1024. If set too small and the queue fills up, then logged StopWatches will be discarded. The number of discarded messages can be accessed using the getNumDiscardedMessages() method.

Returns:
The QueueSize option.

setQueueSize

public void setQueueSize(int queueSize)
Sets the value of the QueueSize option.

Parameters:
queueSize - The new QueueSize option.

getStopWatchParserClassName

public String getStopWatchParserClassName()
The StopWatchParserClassName option is used to determine the class used to parse stop watch messages into StopWatch instances. This defaults to the standard "org.perf4j.helpers.StopWatchParser" class.

Returns:
The StopWatchParserClassName option.

setStopWatchParserClassName

public void setStopWatchParserClassName(String stopWatchParserClassName)
Sets the value of the StopWatchParserClassName option.

Parameters:
stopWatchParserClassName - The new StopWatchParserClassName option.

getNumDiscardedMessages

public int getNumDiscardedMessages()
Returns the number of StopWatch messages that have been discarded due to the queue being full.

Returns:
The number of discarded messages.

start

public void start(GenericAsyncCoalescingStatisticsAppender.GroupedTimingStatisticsHandler handler)
The start method should only be called once, before the append method is called, to initialize options.

Parameters:
handler - The GroupedTimingStatisticsHandler used to process GroupedTimingStatistics created by aggregating StopWatch log message.

append

public void append(String message)
The append method should be called each time a StopWatch log message is handled by the logging framework.

Parameters:
message - The log message, may not be null. If this message is not a valid StopWatch log message it will be discarded.

stop

public void stop()
This method should be called on shutdown to flush any pending messages in the queue and create a final GroupedTimingStatistics instance if necessary.



Copyright © 2008-2011 perf4j.org. All Rights Reserved.