com.twitter.common.stats
Class TimeSeriesRepositoryImpl

java.lang.Object
  extended by com.twitter.common.stats.TimeSeriesRepositoryImpl
All Implemented Interfaces:
TimeSeriesRepository

public class TimeSeriesRepositoryImpl
extends Object
implements TimeSeriesRepository

A simple in-memory repository for exported variables.


Field Summary
static String SAMPLE_PERIOD
          @Named binding key for the sampling period.
static String SAMPLE_RETENTION_PERIOD
          @Named binding key for the maximum number of retained samples.
 
Constructor Summary
TimeSeriesRepositoryImpl(StatRegistry statRegistry, Amount<Long,Time> samplePeriod, Amount<Long,Time> retentionPeriod)
           
 
Method Summary
 TimeSeries get(String name)
          Fetches a time series by name.
 Set<String> getAvailableSeries()
          Fetches the names of all available time series.
 Iterable<Number> getTimestamps()
          Gets an ordered iterable of the timestamps that all timeseries were sampled at.
 void start(ShutdownRegistry shutdownRegistry)
          Starts the variable sampler, which will fetch variables Stats on the given period.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SAMPLE_PERIOD

public static final String SAMPLE_PERIOD
@Named binding key for the sampling period.

See Also:
Constant Field Values

SAMPLE_RETENTION_PERIOD

public static final String SAMPLE_RETENTION_PERIOD
@Named binding key for the maximum number of retained samples.

See Also:
Constant Field Values
Constructor Detail

TimeSeriesRepositoryImpl

@Inject
public TimeSeriesRepositoryImpl(StatRegistry statRegistry,
                                       Amount<Long,Time> samplePeriod,
                                       Amount<Long,Time> retentionPeriod)
Method Detail

start

public void start(ShutdownRegistry shutdownRegistry)
Starts the variable sampler, which will fetch variables Stats on the given period.

Specified by:
start in interface TimeSeriesRepository
Parameters:
shutdownRegistry - An action registry that the repository can use to register a shutdown for the sampler.

getAvailableSeries

public Set<String> getAvailableSeries()
Description copied from interface: TimeSeriesRepository
Fetches the names of all available time series.

Specified by:
getAvailableSeries in interface TimeSeriesRepository
Returns:
Available time series, which can then be obtained by calling TimeSeriesRepository.get(String).

get

public TimeSeries get(String name)
Description copied from interface: TimeSeriesRepository
Fetches a time series by name.

Specified by:
get in interface TimeSeriesRepository
Parameters:
name - The name of the time series to fetch.
Returns:
The time series registered with the given name, or null if no such time series has been registered.

getTimestamps

public Iterable<Number> getTimestamps()
Description copied from interface: TimeSeriesRepository
Gets an ordered iterable of the timestamps that all timeseries were sampled at.

Specified by:
getTimestamps in interface TimeSeriesRepository
Returns:
All current timestamps.