org.javasimon.callback.timeline
Class TimelineCallback

java.lang.Object
  extended by org.javasimon.callback.CallbackSkeleton
      extended by org.javasimon.callback.timeline.TimelineCallback
All Implemented Interfaces:
Callback

public class TimelineCallback
extends CallbackSkeleton

Timeline callback aims at keeping simon data for the last N minutes. A "timeline" object is stored in each Simon, it's fixed size ring buffer of "time ranges". A "time range" aggregates Simon data for a fixed duration.

Example: a timeline containing 6 time ranges of 10 minutes each can be used to see evolution for an hour.

Author:
gerald

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.javasimon.callback.Callback
Callback.Event
 
Field Summary
static String TIMELINE_ATTRIBUTE_NAME
          Default attribute name for storing timelines
private  String timelineAttributeName
          Attribute name for storing timeline in Simons
private  int timelineCapacity
          Number of time ranges to keep in the timeline
private  long timeRangeWidth
          Width in milliseconds of the time ranges
 
Constructor Summary
TimelineCallback()
          Constructor using default attribute name, default timeline capacity of 6 and default timeline width of 10 minutes.
TimelineCallback(int timelineCapacity, long timeRangeWidth)
          Constructor using default attribute name
TimelineCallback(String timelineAttributeName, int timelineCapacity, long timeRangeWidth)
          Main constructor
 
Method Summary
private  StopwatchTimeline getStopwatchTimeline(Stopwatch stopwatch)
          Get timeline for given Stopwatch
private  Timeline getTimeline(Simon simon)
          Get timeline for given Simon
 void onSimonCreated(Simon simon)
          On simon creation a timeline attribute is added
 void onStopwatchAdd(Stopwatch stopwatch, Split split, StopwatchSample sample)
          Stopwatch add split event.
 void onStopwatchStop(Split split, StopwatchSample sample)
          Stopwatch stop event.
 
Methods inherited from class org.javasimon.callback.CallbackSkeleton
cleanup, initialize, onCounterDecrease, onCounterIncrease, onCounterSet, onManagerClear, onManagerMessage, onManagerWarning, onSimonDestroyed, onSimonReset, onStopwatchAdd, onStopwatchStart
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TIMELINE_ATTRIBUTE_NAME

public static final String TIMELINE_ATTRIBUTE_NAME
Default attribute name for storing timelines

See Also:
Constant Field Values

timelineAttributeName

private final String timelineAttributeName
Attribute name for storing timeline in Simons


timelineCapacity

private final int timelineCapacity
Number of time ranges to keep in the timeline


timeRangeWidth

private final long timeRangeWidth
Width in milliseconds of the time ranges

Constructor Detail

TimelineCallback

public TimelineCallback(String timelineAttributeName,
                        int timelineCapacity,
                        long timeRangeWidth)
Main constructor

Parameters:
timelineAttributeName - Simon attribute name used for storing Timeline
timelineCapacity - Timeline capacity (number of time ranges)
timeRangeWidth - Time range width (in milliseconds)

TimelineCallback

public TimelineCallback(int timelineCapacity,
                        long timeRangeWidth)
Constructor using default attribute name

Parameters:
timelineCapacity - Timeline capacity (number of time ranges)
timeRangeWidth - Time range width (in milliseconds)

TimelineCallback

public TimelineCallback()
Constructor using default attribute name, default timeline capacity of 6 and default timeline width of 10 minutes. Timeline stores an hour of data.

Method Detail

getTimeline

private Timeline getTimeline(Simon simon)
Get timeline for given Simon

Parameters:
simon -
Returns:
Timeline

getStopwatchTimeline

private StopwatchTimeline getStopwatchTimeline(Stopwatch stopwatch)
Get timeline for given Stopwatch

Parameters:
stopwatch - Stopwatch
Returns:
Stopwatch timeline

onSimonCreated

public void onSimonCreated(Simon simon)
On simon creation a timeline attribute is added

Specified by:
onSimonCreated in interface Callback
Overrides:
onSimonCreated in class CallbackSkeleton
Parameters:
simon - Create simon

onStopwatchAdd

public void onStopwatchAdd(Stopwatch stopwatch,
                           Split split,
                           StopwatchSample sample)
Description copied from interface: Callback
Stopwatch add split event. StopwatchSample valid for the moment after the add is provided because the callback is executed out of synchronized block.

Specified by:
onStopwatchAdd in interface Callback
Overrides:
onStopwatchAdd in class CallbackSkeleton
Parameters:
stopwatch - modified Stopwatch
split - added split object
sample - stopwatch sampled after the add

onStopwatchStop

public void onStopwatchStop(Split split,
                            StopwatchSample sample)
Description copied from interface: Callback
Stopwatch stop event. This action is executed after the split time is calculated and does not affect the measuring. StopwatchSample valid for the moment after the stop is provided because the callback is executed out of synchronized block.

Specified by:
onStopwatchStop in interface Callback
Overrides:
onStopwatchStop in class CallbackSkeleton
Parameters:
split - stopped Split
sample - stopwatch sampled after the stop


Copyright © 2013. All Rights Reserved.