com.twitter.common.metrics
Class MetricPoller

java.lang.Object
  extended by com.twitter.common.metrics.MetricPoller

public class MetricPoller
extends Object

A fixed-rate poller that triggers a MetricSampler.


Constructor Summary
MetricPoller(com.twitter.common.metrics.MetricSampler sampler, ScheduledExecutorService executor)
          Creates a new metric poller.
 
Method Summary
 void start(Amount<Long,Time> pollInterval)
          Initiates the poller.
 void stop()
          Stops the poller.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetricPoller

public MetricPoller(com.twitter.common.metrics.MetricSampler sampler,
                    ScheduledExecutorService executor)
Creates a new metric poller.

Parameters:
sampler - Sampler to fetch metric values from.
executor - Executor service to run the sampler with.
Method Detail

start

public void start(Amount<Long,Time> pollInterval)
Initiates the poller. The poller may only be started once. If an attempt is made to start a poller when it is already started, IllegalStateException will be thrown.

Parameters:
pollInterval - Fixed poll rate.

stop

public void stop()
Stops the poller. If the poller is already stopped, or is in the process of being stopped, subsequent calls will throw IllegalStateException.