com.netflix.stats.distribution
Class DataAccumulator

java.lang.Object
  extended by com.netflix.stats.distribution.DataAccumulator
All Implemented Interfaces:
DataCollector
Direct Known Subclasses:
DataDistribution

public abstract class DataAccumulator
extends java.lang.Object
implements DataCollector

A double-buffer of DataBuffer objects. One is the "current" buffer, and new data is added to it. The other is the "previous" buffer, and is used as a sorce of computed statistics.

See Also:
DataPublisher

Constructor Summary
DataAccumulator(int bufferSize)
          Creates a new initially empty DataAccumulator.
 
Method Summary
 void noteValue(double val)
          Adds a value to the collected data.
 void publish()
          Swaps the data collection buffers, and computes statistics about the data collected up til now.
protected abstract  void publish(DataBuffer buf)
          Called to publish recently collected data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataAccumulator

public DataAccumulator(int bufferSize)
Creates a new initially empty DataAccumulator.

Parameters:
bufferSize - the size of the buffers to use
Method Detail

noteValue

public void noteValue(double val)
Adds a value to the collected data. This must run very quickly, and so can safely be called in time-critical code.

Specified by:
noteValue in interface DataCollector

publish

public void publish()
Swaps the data collection buffers, and computes statistics about the data collected up til now.


publish

protected abstract 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.

Parameters:
buf - the DataBuffer that is now "previous".