org.rrd4j.core

## Class Archive

- java.lang.Object
- - org.rrd4j.core.Archive

- All Implemented Interfaces:
    RrdUpdater<Archive>

      public class Archive
      extends Object
      implements RrdUpdater<Archive>

  Class to represent single RRD archive in a RRD with its internal state. Normally, you don't need methods to manipulate archive objects directly because Rrd4j framework does it automatically for you.

  Each archive object consists of three parts: archive definition, archive state objects (one state object for each datasource) and round robin archives (one round robin for each datasource). API (read-only) is provided to access each of these parts.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected RrdInt<Archive>` | `rows`
    `protected RrdInt<Archive>` | `steps`
    `protected RrdDouble<Archive>` | `xff`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Archive(RrdDb parentDb, ArcDef arcDef)`
    `Archive(RrdDb parentDb, DataImporter reader, int arcIndex)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `(package private) void` | `appendXml(XmlWriter writer)`
    `(package private) void` | `archive(int dsIndex, double value, long numUpdates)` Archives a value for the specified datasource.
    `void` | `copyStateTo(Archive arc)` copyStateTo.
    `(package private) String` | `dump()` Returns a string representation of the archive information.
    `(package private) FetchData` | `fetchData(FetchRequest request)`
    `ArcState` | `getArcState(int dsIndex)` Returns the underlying archive state object.
    `long` | `getArcStep()` Returns archive time step in seconds.
    `ConsolFun` | `getConsolFun()` Returns archive consolidation function ("AVERAGE", "MIN", "MAX", "FIRST", "LAST" or "TOTAL").
    `long` | `getEndTime()` Returns current ending timestamp.
    `(package private) RrdDb` | `getParentDb()` Returns the parent RRD database.
    `Robin` | `getRobin(int dsIndex)` Returns the underlying round robin archive.
    `int` | `getRows()` Returns the number of archive rows.
    `RrdAllocator` | `getRrdAllocator()` Required to implement RrdUpdater interface.
    `RrdBackend` | `getRrdBackend()` Returns the underlying storage (backend) object which actually performs all I/O operations.
    `long` | `getStartTime()` Returns current starting timestamp.
    `int` | `getSteps()` Returns the number of archive steps.
    `double` | `getXff()` Returns archive X-files factor.
    `void` | `setXff(double xff)` Sets X-files factor to a new value.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### rows

          protected final RrdInt<Archive> rows

    - #### steps

          protected final RrdInt<Archive> steps

    - #### xff

          protected final RrdDouble<Archive> xff

  - ### Constructor Detail

    - #### Archive

          Archive(RrdDb parentDb,
                  ArcDef arcDef)
           throws IOException

      Throws:
        `IOException`

    - #### Archive

          Archive(RrdDb parentDb,
                  DataImporter reader,
                  int arcIndex)
           throws IOException

      Throws:
        `IOException`

  - ### Method Detail

    - #### appendXml

          void appendXml(XmlWriter writer)
                  throws IOException

      Throws:
        `IOException`

    - #### archive

          void archive(int dsIndex,
                       double value,
                       long numUpdates)
                throws IOException

      Archives a value for the specified datasource.
      Parameters:
        `dsIndex` - index of the datasource
        `value` - value to archive
        `numUpdates` - number of updates to perform
      Throws:
        `IOException` - if an I/O error occurs

    - #### copyStateTo

          public void copyStateTo(Archive arc)
                           throws IOException

      copyStateTo.

      Copies object's internal state to another Archive object.

      Specified by:
        `copyStateTo` in interface `RrdUpdater<Archive>`
      Parameters:
        `arc` - a `RrdUpdater` object.
      Throws:
        `IOException` - if any.

    - #### dump

          String dump()
               throws IOException

      Returns a string representation of the archive information.
      Returns:
        a string containing archive information
      Throws:
        `IOException` - if an I/O error occurs

    - #### fetchData

          FetchData fetchData(FetchRequest request)
                       throws IOException

      Throws:
        `IOException`

    - #### getArcState

          public ArcState getArcState(int dsIndex)

      Returns the underlying archive state object. Each datasource has its corresponding ArcState object (archive states are managed independently for each RRD datasource).
      Parameters:
        `dsIndex` - Datasource index
      Returns:
        Underlying archive state object

    - #### getArcStep

          public long getArcStep()
                          throws IOException

      Returns archive time step in seconds. Archive step is equal to RRD step multiplied with the number of archive steps.
      Returns:
        Archive time step in seconds
      Throws:
        `IOException` - Thrown in case of I/O error.

    - #### getConsolFun

          public ConsolFun getConsolFun()
                                 throws IOException

      Returns archive consolidation function ("AVERAGE", "MIN", "MAX", "FIRST", "LAST" or "TOTAL").
      Returns:
        Archive consolidation function.
      Throws:
        `IOException` - Thrown in case of I/O error.

    - #### getEndTime

          public long getEndTime()
                          throws IOException

      Returns current ending timestamp. This value is not constant.
      Returns:
        Timestamp corresponding to the last archive row
      Throws:
        `IOException` - Thrown in case of I/O error.

    - #### getParentDb

          RrdDb getParentDb()

      Returns the parent RRD database.
      Returns:
        the parent RRD database

    - #### getRobin

          public Robin getRobin(int dsIndex)

      Returns the underlying round robin archive. Robins are used to store actual archive values on a per-datasource basis.
      Parameters:
        `dsIndex` - Index of the datasource in the RRD.
      Returns:
        Underlying round robin archive for the given datasource.

    - #### getRows

          public int getRows()
                      throws IOException

      Returns the number of archive rows.
      Returns:
        Number of archive rows.
      Throws:
        `IOException` - Thrown in case of I/O error.

    - #### getRrdAllocator

          public RrdAllocator getRrdAllocator()

      Required to implement RrdUpdater interface. You should never call this method directly.
      Specified by:
        `getRrdAllocator` in interface `RrdUpdater<Archive>`
      Returns:
        Allocator object

    - #### getRrdBackend

          public RrdBackend getRrdBackend()

      Returns the underlying storage (backend) object which actually performs all I/O operations.
      Specified by:
        `getRrdBackend` in interface `RrdUpdater<Archive>`
      Returns:
        I/O backend object

    - #### getStartTime

          public long getStartTime()
                            throws IOException

      Returns current starting timestamp. This value is not constant.
      Returns:
        Timestamp corresponding to the first archive row
      Throws:
        `IOException` - Thrown in case of I/O error.

    - #### getSteps

          public int getSteps()
                       throws IOException

      Returns the number of archive steps.
      Returns:
        Number of archive steps.
      Throws:
        `IOException` - Thrown in case of I/O error.

    - #### getXff

          public double getXff()
                        throws IOException

      Returns archive X-files factor.
      Returns:
        Archive X-files factor (between 0 and 1).
      Throws:
        `IOException` - Thrown in case of I/O error.

    - #### setXff

          public void setXff(double xff)
                      throws IOException

      Sets X-files factor to a new value.
      Parameters:
        `xff` - New X-files factor value. Must be >= 0 and < 1.
      Throws:
        `IOException` - Thrown in case of I/O error