org.javasimon.callback.quantiles
Class AutoQuantilesCallback

java.lang.Object
  extended by org.javasimon.callback.CallbackSkeleton
      extended by org.javasimon.callback.quantiles.QuantilesCallback
          extended by org.javasimon.callback.quantiles.AutoQuantilesCallback
All Implemented Interfaces:
Callback

public class AutoQuantilesCallback
extends QuantilesCallback

Callback which stores data in buckets to compute quantiles. Quantiles can only be obtained after warmup period, after which buckets are initialized. For each Simon the following lifecycle occurs:

  1. Warm up:
  2. Trigger: splits count >= warmup count threshold
  3. Normal:

Since:
3.2
Author:
gquintana
See Also:
Buckets

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.javasimon.callback.Callback
Callback.Event
 
Field Summary
static String ATTR_NAME_BUCKETS_VALUES
          Simon attribute name of the list of split values stored in Simons before warmup time.
private  int bucketNb
          Number of buckets of data for each Simon.
private  long warmupCounter
          Number of splits before buckets are initialized.
 
Fields inherited from class org.javasimon.callback.quantiles.QuantilesCallback
ATTR_NAME_BUCKETS
 
Constructor Summary
AutoQuantilesCallback()
          Default constructor.
AutoQuantilesCallback(BucketsType bucketsType, long warmupCounter, int bucketNb)
          Constructor with all configuration
AutoQuantilesCallback(long warmupCounter, int bucketNb)
          Constructor with warmup counter and number of linear buckets for each Simon.
 
Method Summary
protected  Buckets createBuckets(Stopwatch stopwatch)
          When warmup ends, buckets are create and retained splits are sorted in the buckets.
protected  Buckets createBucketsAfterWarmup(Stopwatch stopwatch)
          Create the buckets after warmup time.
private  List<Long> getBucketsValues(Stopwatch stopwatch)
          Get the bucket values attribute.
private  List<Long> getOrCreateBucketsValues(Stopwatch stopwatch)
          Get the bucket values attribute or create it if it does not exist.
 void onSimonCreated(Simon simon)
          When simon is created, the list containing Split values is added to stopwatch attributes.
 void onSimonReset(Simon simon)
          When the Stopwatch is reset, so are the buckets.
protected  void onStopwatchSplit(Stopwatch stopwatch, long value)
          Called when there is a new split on a Stopwatch, either QuantilesCallback.onStopwatchStop(org.javasimon.Split, org.javasimon.StopwatchSample) or QuantilesCallback.onStopwatchAdd(org.javasimon.Stopwatch, org.javasimon.Split, org.javasimon.StopwatchSample).
protected  void onStopwatchSplit(Stopwatch stopwatch, Split split)
          Called when there is a new split on a Stopwatch, either QuantilesCallback.onStopwatchStop(org.javasimon.Split, org.javasimon.StopwatchSample) or QuantilesCallback.onStopwatchAdd(org.javasimon.Stopwatch, org.javasimon.Split, org.javasimon.StopwatchSample).
private  void removeBucketsValues(Stopwatch stopwatch)
          Remove the bucket values attribute (after warmup).
 
Methods inherited from class org.javasimon.callback.quantiles.QuantilesCallback
createBuckets, createLogTemplate, getBuckets, getBucketsType, getOrCreateBuckets, isLogEnabled, onStopwatchAdd, onStopwatchAdd, onStopwatchStop, sampleBuckets, setLogEnabled
 
Methods inherited from class org.javasimon.callback.CallbackSkeleton
cleanup, initialize, onCounterDecrease, onCounterIncrease, onCounterSet, onManagerClear, onManagerMessage, onManagerWarning, onSimonDestroyed, onStopwatchStart
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ATTR_NAME_BUCKETS_VALUES

public static final String ATTR_NAME_BUCKETS_VALUES
Simon attribute name of the list of split values stored in Simons before warmup time.

See Also:
Constant Field Values

warmupCounter

private final long warmupCounter
Number of splits before buckets are initialized. Default 10


bucketNb

private final int bucketNb
Number of buckets of data for each Simon.

Constructor Detail

AutoQuantilesCallback

public AutoQuantilesCallback()
Default constructor.


AutoQuantilesCallback

public AutoQuantilesCallback(long warmupCounter,
                             int bucketNb)
Constructor with warmup counter and number of linear buckets for each Simon.


AutoQuantilesCallback

public AutoQuantilesCallback(BucketsType bucketsType,
                             long warmupCounter,
                             int bucketNb)
Constructor with all configuration

Parameters:
bucketsType - Linear or exponential
warmupCounter - Number of splits before init
bucketNb - Bucket number
Method Detail

getOrCreateBucketsValues

private List<Long> getOrCreateBucketsValues(Stopwatch stopwatch)
Get the bucket values attribute or create it if it does not exist.


getBucketsValues

private List<Long> getBucketsValues(Stopwatch stopwatch)
Get the bucket values attribute.


removeBucketsValues

private void removeBucketsValues(Stopwatch stopwatch)
Remove the bucket values attribute (after warmup).


createBucketsAfterWarmup

protected Buckets createBucketsAfterWarmup(Stopwatch stopwatch)
Create the buckets after warmup time. Can be overridden to customize buckets configuration. By default buckets are create with:

createBuckets

protected final Buckets createBuckets(Stopwatch stopwatch)
When warmup ends, buckets are create and retained splits are sorted in the buckets.

Specified by:
createBuckets in class QuantilesCallback
Parameters:
stopwatch - Stopwatch
Returns:
Buckets

onSimonCreated

public void onSimonCreated(Simon simon)
When simon is created, the list containing Split values is added to stopwatch attributes.

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

onStopwatchSplit

protected void onStopwatchSplit(Stopwatch stopwatch,
                                Split split)
Called when there is a new split on a Stopwatch, either QuantilesCallback.onStopwatchStop(org.javasimon.Split, org.javasimon.StopwatchSample) or QuantilesCallback.onStopwatchAdd(org.javasimon.Stopwatch, org.javasimon.Split, org.javasimon.StopwatchSample). If buckets have been initialized, the value is added to appropriate bucket. Else if stopwatch is warming up value is added to value list.

Overrides:
onStopwatchSplit in class QuantilesCallback

onStopwatchSplit

protected void onStopwatchSplit(Stopwatch stopwatch,
                                long value)
Called when there is a new split on a Stopwatch, either QuantilesCallback.onStopwatchStop(org.javasimon.Split, org.javasimon.StopwatchSample) or QuantilesCallback.onStopwatchAdd(org.javasimon.Stopwatch, org.javasimon.Split, org.javasimon.StopwatchSample). If buckets have been initialized, the value is added to appropriate bucket. Else if stopwatch is warming up value is added to value list.

Overrides:
onStopwatchSplit in class QuantilesCallback

onSimonReset

public void onSimonReset(Simon simon)
When the Stopwatch is reset, so are the buckets.

Specified by:
onSimonReset in interface Callback
Overrides:
onSimonReset in class QuantilesCallback
Parameters:
simon - reset Simon


Copyright © 2013. All Rights Reserved.