FileContext (Hadoop 0.20.2+737 API)
Date: 2010-10-11

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.hadoop.metrics.file
Class FileContext

    java.lang.Object
      org.apache.hadoop.metrics.spi.AbstractMetricsContext
          org.apache.hadoop.metrics.file.FileContext

All Implemented Interfaces:
  MetricsContext

    public class FileContext

extends AbstractMetricsContext

Metrics context for writing metrics to a file.

This class is configured by setting ContextFactory attributes which in turn are usually configured through a properties file. All the attributes are prefixed by the contextName. For example, the properties file might contain:

     myContextName.fileName=/tmp/metrics.log
     myContextName.period=5

Nested Class Summary

Nested classes/interfaces inherited from class org.apache.hadoop.metrics.spi.AbstractMetricsContext
`AbstractMetricsContext.MetricMap, AbstractMetricsContext.TagMap`

Field Summary
`protected static String` | `FILE_NAME_PROPERTY`
`protected static String` | `PERIOD_PROPERTY`

Fields inherited from interface org.apache.hadoop.metrics.MetricsContext
`DEFAULT_PERIOD`

Constructor Summary
`FileContext()` Creates a new instance of FileContext

Method Summary
`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.

Methods inherited from class org.apache.hadoop.metrics.spi.AbstractMetricsContext
`close, createRecord, getAllRecords, getAttribute, getAttributeTable, getContextFactory, getContextName, getPeriod, isMonitoring, newRecord, parseAndSetPeriod, registerUpdater, remove, setPeriod, unregisterUpdater, update`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### FILE_NAME_PROPERTY

    protected static final String FILE_NAME_PROPERTY

See Also:
  Constant Field Values

### PERIOD_PROPERTY

    protected static final String PERIOD_PROPERTY

See Also:
  Constant Field Values

Constructor Detail

### FileContext

    public FileContext()

  Creates a new instance of FileContext

Method Detail

### init

    public void init(String contextName,
                     ContextFactory factory)

  Description copied from class: `AbstractMetricsContext`
  Initializes the context.

  Specified by:
    `init` in interface `MetricsContext`
  Overrides:
    `init` in class `AbstractMetricsContext`
  Parameters:
    `contextName` - The given name for this context
    `factory` - The creator of this context

### getFileName

    public String getFileName()

  Returns the configured file name, or null.

### startMonitoring

    public void startMonitoring()
                         throws IOException

  Starts or restarts monitoring, by opening in append-mode, the file specified by the `fileName` attribute, if specified. Otherwise the data will be written to standard output.

  Specified by:
    `startMonitoring` in interface `MetricsContext`
  Overrides:
    `startMonitoring` in class `AbstractMetricsContext`
  Throws:
    `IOException`

### stopMonitoring

    public void stopMonitoring()

  Stops monitoring, closing the file.

  Specified by:
    `stopMonitoring` in interface `MetricsContext`
  Overrides:
    `stopMonitoring` in class `AbstractMetricsContext`
  See Also:
    `AbstractMetricsContext.close()`

### emitRecord

    public void emitRecord(String contextName,
                           String recordName,
                           OutputRecord outRec)

  Emits a metrics record to a file.

  Specified by:
    `emitRecord` in class `AbstractMetricsContext`

### flush

    public void flush()

  Flushes the output writer, forcing updates to disk.

  Overrides:
    `flush` in class `AbstractMetricsContext`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2009 The Apache Software Foundation