Interface MetricsContext
- All Known Implementing Classes:
AbstractMetricsContext,GangliaContext,GangliaContext31,NullContext
@Private
@Evolving
public interface MetricsContext
The main interface to the metrics package.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault period in seconds at which data is sent to the metrics system. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Stops monitoring and also frees any buffered data, returning this object to its initial state.createRecord(String recordName) Creates a new MetricsRecord instance with the givenrecordName.Retrieves all the records managed by this MetricsContext.Returns the context name.intReturns the timer period.voidinit(String contextName, ContextFactory factory) Initialize this context.booleanReturns true if monitoring is currently in progress.voidregisterUpdater(Updater updater) Registers a callback to be called at regular time intervals, as determined by the implementation-class specific configuration.voidStarts or restarts monitoring, the emitting of metrics records as they are updated.voidStops monitoring.voidunregisterUpdater(Updater updater) Removes a callback, if it exists.
-
Field Details
-
DEFAULT_PERIOD
static final int DEFAULT_PERIODDefault period in seconds at which data is sent to the metrics system.- See Also:
-
-
Method Details
-
init
Initialize this context.- Parameters:
contextName- The given name for this contextfactory- The creator of this context
-
getContextName
String getContextName()Returns the context name.- Returns:
- the context name
-
startMonitoring
Starts or restarts monitoring, the emitting of metrics records as they are updated.- Throws:
IOException
-
stopMonitoring
void stopMonitoring()Stops monitoring. This does not free any data that the implementation may have buffered for sending at the next timer event. It is OK to callstartMonitoring()again after calling this.- See Also:
-
isMonitoring
boolean isMonitoring()Returns true if monitoring is currently in progress. -
close
void close()Stops monitoring and also frees any buffered data, returning this object to its initial state. -
createRecord
Creates a new MetricsRecord instance with the givenrecordName. Throws an exception if the metrics implementation is configured with a fixed set of record names andrecordNameis not in that set.- Parameters:
recordName- the name of the record- Throws:
MetricsException- if recordName conflicts with configuration data
-
registerUpdater
Registers a callback to be called at regular time intervals, as determined by the implementation-class specific configuration.- Parameters:
updater- object to be run periodically; it should updated some metrics records and then return
-
unregisterUpdater
Removes a callback, if it exists.- Parameters:
updater- object to be removed from the callback list
-
getPeriod
int getPeriod()Returns the timer period. -
getAllRecords
Map<String,Collection<OutputRecord>> getAllRecords()Retrieves all the records managed by this MetricsContext. Useful for monitoring systems that are polling-based.- Returns:
- A non-null map from all record names to the records managed.
-