public class FileContext extends AbstractMetricsContext
myContextName.fileName=/tmp/metrics.log myContextName.period=5
Modifier and Type | Field and Description |
---|---|
protected static String |
FILE_NAME_PROPERTY |
protected static String |
PERIOD_PROPERTY |
DEFAULT_PERIOD
Constructor and Description |
---|
FileContext()
Creates a new instance of FileContext
|
Modifier and Type | Method and Description |
---|---|
void |
emitRecord(String contextName,
String recordName,
OutputRecord outRec)
Emits a metrics record to a file.
|
void |
flush()
Flushes the output writer, forcing updates to disk.
|
String |
getFileName()
Returns the configured file name, or null.
|
void |
init(String contextName,
ContextFactory factory)
Initializes the context.
|
void |
startMonitoring()
Starts or restarts monitoring, by opening in append-mode, the
file specified by the
fileName attribute,
if specified. |
void |
stopMonitoring()
Stops monitoring, closing the file.
|
close, createRecord, getAttribute, getAttributeTable, getContextFactory, getContextName, getPeriod, isMonitoring, newRecord, registerUpdater, remove, setPeriod, unregisterUpdater, update
protected static final String FILE_NAME_PROPERTY
protected static final String PERIOD_PROPERTY
public void init(String contextName, ContextFactory factory)
AbstractMetricsContext
init
in interface MetricsContext
init
in class AbstractMetricsContext
contextName
- The given name for this contextfactory
- The creator of this contextpublic String getFileName()
public void startMonitoring() throws IOException
fileName
attribute,
if specified. Otherwise the data will be written to standard
output.startMonitoring
in interface MetricsContext
startMonitoring
in class AbstractMetricsContext
IOException
public void stopMonitoring()
stopMonitoring
in interface MetricsContext
stopMonitoring
in class AbstractMetricsContext
AbstractMetricsContext.close()
public void emitRecord(String contextName, String recordName, OutputRecord outRec)
emitRecord
in class AbstractMetricsContext
public void flush()
flush
in class AbstractMetricsContext
Copyright © 2010 The Apache Software Foundation