com.netflix.stats.distribution
Class DataDistribution

java.lang.Object
  extended by com.netflix.stats.distribution.DataAccumulator
      extended by com.netflix.stats.distribution.DataDistribution
All Implemented Interfaces:
DataCollector, DataDistributionMBean, DistributionMBean

public class DataDistribution
extends DataAccumulator
implements DataDistributionMBean

A DataAccumulator that also publishes statistics about the "previous" buffer. This implements DataDistributionMBean and so can be registered as an MBean and accessed via JMX if desired.


Constructor Summary
DataDistribution(int bufferSize, double[] percents)
          Creates a new DataDistribution with no data summarized.
 
Method Summary
 void clear()
          Clears out the distribution, resetting it to its initial state.
 double getMaximum()
          Get the maximum value found in the distribution.
 double getMean()
          Get the average value in the distribtion.
 double getMinimum()
          Get the minimum value found in the distribution.
 long getNumValues()
          Get the number of values in the distribution.
 double[] getPercentiles()
          Gets the array of known percentile values.
 double[] getPercents()
          Gets the array of known percentile percents.
 long getSampleIntervalMillis()
          Gets the length of time over which the data was collected, in milliseconds.
 int getSampleSize()
          Gets the number of values used to compute the percentile values.
 double getStdDev()
          Get the standard deviation of values in the distribution.
 java.lang.String getTimestamp()
          Gets a String representation of the time when this data was produced.
 long getTimestampMillis()
          Gets the time when this data was produced, in milliseconds since the epoch.
 double getVariance()
          Get the variance (the square of the standard deviation) of values in the distribution.
protected  void publish(DataBuffer buf)
          Called to publish recently collected data.
 
Methods inherited from class com.netflix.stats.distribution.DataAccumulator
noteValue, publish
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataDistribution

public DataDistribution(int bufferSize,
                        double[] percents)
Creates a new DataDistribution with no data summarized.

Parameters:
bufferSize - the size of each buffer held by the DataAccumulator
percents - array of percentile values to calculate when buffers are swapped and new data is published. The array values must be in the range [0 .. 100].
Method Detail

publish

protected void publish(DataBuffer buf)
Called to publish recently collected data. When called, the Lock associated with the "previous" buffer is held, so the data will not be changed. Other locks have been released, and so new data can be collected in the "current" buffer. The data in the buffer has also been sorted in increasing order.

Specified by:
publish in class DataAccumulator
Parameters:
buf - the DataBuffer that is now "previous".

clear

public void clear()
Clears out the distribution, resetting it to its initial state.

Specified by:
clear in interface DistributionMBean

getNumValues

public long getNumValues()
Get the number of values in the distribution.

Specified by:
getNumValues in interface DistributionMBean

getMean

public double getMean()
Get the average value in the distribtion.

Specified by:
getMean in interface DistributionMBean

getVariance

public double getVariance()
Get the variance (the square of the standard deviation) of values in the distribution.

Specified by:
getVariance in interface DistributionMBean

getStdDev

public double getStdDev()
Get the standard deviation of values in the distribution.

Specified by:
getStdDev in interface DistributionMBean

getMinimum

public double getMinimum()
Get the minimum value found in the distribution.

Specified by:
getMinimum in interface DistributionMBean

getMaximum

public double getMaximum()
Get the maximum value found in the distribution.

Specified by:
getMaximum in interface DistributionMBean

getTimestamp

public java.lang.String getTimestamp()
Gets a String representation of the time when this data was produced.

Specified by:
getTimestamp in interface DataDistributionMBean

getTimestampMillis

public long getTimestampMillis()
Gets the time when this data was produced, in milliseconds since the epoch.

Specified by:
getTimestampMillis in interface DataDistributionMBean

getSampleIntervalMillis

public long getSampleIntervalMillis()
Gets the length of time over which the data was collected, in milliseconds.

Specified by:
getSampleIntervalMillis in interface DataDistributionMBean

getSampleSize

public int getSampleSize()
Gets the number of values used to compute the percentile values. This value may be smaller than the value of DistributionMBean.getNumValues() depending on how the percentile values were computed.

Specified by:
getSampleSize in interface DataDistributionMBean

getPercents

public double[] getPercents()
Gets the array of known percentile percents.

Specified by:
getPercents in interface DataDistributionMBean

getPercentiles

public double[] getPercentiles()
Gets the array of known percentile values.

Specified by:
getPercentiles in interface DataDistributionMBean