## 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

Deprecated. use `FileSink` instead.

    @InterfaceAudience.Public
    @InterfaceStability.Evolving
    @Deprecated
    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` Deprecated.
`protected static String` `PERIOD_PROPERTY` Deprecated.

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

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

Method Summary
`void` `emitRecord(String contextName, String recordName, OutputRecord outRec)` Deprecated. Emits a metrics record to a file.
`void` `flush()` Deprecated. Flushes the output writer, forcing updates to disk.
`String` `getFileName()` Deprecated. Returns the configured file name, or null.
`void` `init(String contextName, ContextFactory factory)` Deprecated. Initializes the context.
`void` `startMonitoring()` Deprecated. Starts or restarts monitoring, by opening in append-mode, the file specified by the `fileName` attribute, if specified.
`void` `stopMonitoring()` Deprecated. 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

    @InterfaceAudience.Private
    protected static final String FILE_NAME_PROPERTY

  Deprecated.
  See Also:
    Constant Field Values

### PERIOD_PROPERTY

    @InterfaceAudience.Private
    protected static final String PERIOD_PROPERTY

  Deprecated.
  See Also:
    Constant Field Values

Constructor Detail

### FileContext

    @InterfaceAudience.Private
    public FileContext()

  Deprecated.
  Creates a new instance of FileContext

Method Detail

### init

    @InterfaceAudience.Private
    public void init(String contextName,
                                               ContextFactory factory)

  Deprecated.
  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

    @InterfaceAudience.Private
    public String getFileName()

  Deprecated.
  Returns the configured file name, or null.

### startMonitoring

    @InterfaceAudience.Private
    public void startMonitoring()
                         throws IOException

  Deprecated.
  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

    @InterfaceAudience.Private
    public void stopMonitoring()

  Deprecated.
  Stops monitoring, closing the file.

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

### emitRecord

    @InterfaceAudience.Private
    public void emitRecord(String contextName,
                                                     String recordName,
                                                     OutputRecord outRec)

  Deprecated.
  Emits a metrics record to a file.

  Specified by:
    `emitRecord` in class `AbstractMetricsContext`

### flush

    @InterfaceAudience.Private
    public void flush()

  Deprecated.
  Flushes the output writer, forcing updates to disk.

  Overrides:
    `flush` in class `AbstractMetricsContext`

Copyright © 2009 The Apache Software Foundation