com.netflix.stats.distribution
Class DataPublisher

java.lang.Object
  extended by com.netflix.stats.distribution.DataPublisher

public class DataPublisher
extends java.lang.Object

An object that periodically updates a DataAccumulator, swapping between the buffers.


Constructor Summary
DataPublisher(DataAccumulator accumulator, long delayMillis)
          Creates a new DataPublisher.
 
Method Summary
 DataAccumulator getDataAccumulator()
          Gets the DataAccumulator that is managed by this publisher.
protected  java.util.concurrent.ScheduledExecutorService getExecutor()
          Gets the ScheduledExecutorService to use to run the task to periodically update the DataAccumulator.
protected  void handleException(java.lang.Exception e)
          Called if an attempt to publish data throws an exception.
 boolean isRunning()
          Is the DataPublisher scheduled to run?
 void start()
          Starts the DataPublisher.
 void stop()
          Stops publishing new data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataPublisher

public DataPublisher(DataAccumulator accumulator,
                     long delayMillis)
Creates a new DataPublisher. When created it is not running; it is up to the caller to call start().

Parameters:
accumulator - the DataAccumulator to periodically publish
delayMillis - the number of milliseconds between publish events
Method Detail

getDataAccumulator

public DataAccumulator getDataAccumulator()
Gets the DataAccumulator that is managed by this publisher.


isRunning

public boolean isRunning()
Is the DataPublisher scheduled to run?


start

public void start()
Starts the DataPublisher. The method DataAccumulator.publish() will be called approximately every delayMillis milliseconds. If the publisher has already been started, does nothing.

See Also:
stop()

getExecutor

protected java.util.concurrent.ScheduledExecutorService getExecutor()
Gets the ScheduledExecutorService to use to run the task to periodically update the DataAccumulator. The default uses a global executor pool for all DataPublishers. Subclasses are free to override this if desired, for example to use a per-publisher executor pool.


stop

public void stop()
Stops publishing new data.

See Also:
start()

handleException

protected void handleException(java.lang.Exception e)
Called if an attempt to publish data throws an exception. The default does nothing. Subclasses are free to override this.