All Implemented Interfaces:
Closeable, AutoCloseable

class RrdToolReaderextends DataImporter
Reader for RRDTool format RRD files.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private RRDatabase
    The database being read, set when one is opened.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new RRDTool reader.
  • Method Summary

    Public Methods
    Modifier and Type
    Method
    Description
    double
    getAccumValue(int dsIndex)
    Reads the partial total a data source is carrying into the current step.
    int
    Counts the archives (RRAs) declared by the RRD.
    getConsolFun(int arcIndex)
    Reads the consolidation function of an archive.
    int
    Counts the data sources declared by the RRD.
    getDsName(int dsIndex)
    Reads the name of a data source.
    getDsType(int dsIndex)
    Reads the type of a data source.
    long
    getHeartbeat(int dsIndex)
    Reads the heartbeat of a data source.
    long
    Reads the moment the RRD was last updated.
    double
    getLastValue(int dsIndex)
    Reads the last value recorded for a data source.
    double
    getMaxValue(int dsIndex)
    Reads the upper bound a data source accepts.
    double
    getMinValue(int dsIndex)
    Reads the lower bound a data source accepts.
    long
    getNanSeconds(int dsIndex)
    Reads when a data source last saw a usable sample.
    int
    getRows(int arcIndex)
    Counts the rows an archive currently holds.
    double
    getStateAccumValue(int arcIndex, int dsIndex)
    Reads the value an archive is accumulating for one data source.
    int
    getStateNanSteps(int arcIndex, int dsIndex)
    Counts the unknown primary data points an archive is holding.
    long
    Reads the base interval between two primary data points.
    int
    getSteps(int arcIndex)
    Reads how many primary data points one archive row covers.
    double[]
    getValues(int arcIndex, int dsIndex)
    Reads one data source's series from an archive.
    Reads the RRD file format version the export was written with.
    double
    getXff(int arcIndex)
    Reads the xfiles factor of an archive.
    (package private) void
    Releases the RRDTool reader and closes the underlying RRD database.

    Methods inherited from class DataImporter

    close, getEstimatedSize
    Modifier and Type
    Method
    Description
    void
    Releases the import source once the RRD has been written.
    protected long
    Estimates the byte length needed to hold everything this importer exposes.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • rrd

      private RRDatabase rrd
      The database being read, set when one is opened.
  • Constructor Details

    • RrdToolReader

      RrdToolReader(String rrdPath) throws IOException
      Creates a new RRDTool reader.
      Parameters:
      rrdPath - path to the RRDTool file
      Throws:
      IOException - if an I/O error occurs
  • Method Details

    • getVersion

      public String getVersion()
      Description copied from class: DataImporter
      Reads the RRD file format version the export was written with.
      Specified by:
      getVersion in class DataImporter
      Returns:
      the version string, such as "008"
    • getLastUpdateTime

      public long getLastUpdateTime()
      Description copied from class: DataImporter
      Reads the moment the RRD was last updated.
      Specified by:
      getLastUpdateTime in class DataImporter
      Returns:
      a unix timestamp in seconds, aligned to the step boundary
    • getStep

      public long getStep()
      Description copied from class: DataImporter
      Reads the base interval between two primary data points.
      Specified by:
      getStep in class DataImporter
      Returns:
      the step size in seconds
    • getDsCount

      public int getDsCount()
      Description copied from class: DataImporter
      Counts the data sources declared by the RRD.
      Specified by:
      getDsCount in class DataImporter
      Returns:
      the number of data sources
    • getArcCount

      public int getArcCount()
      Description copied from class: DataImporter
      Counts the archives (RRAs) declared by the RRD.
      Specified by:
      getArcCount in class DataImporter
      Returns:
      the number of archives
    • getDsName

      public String getDsName(int dsIndex)
      Description copied from class: DataImporter
      Reads the name of a data source.
      Specified by:
      getDsName in class DataImporter
      Parameters:
      dsIndex - zero-based index of the data source
      Returns:
      the data source name
    • getDsType

      public DsType getDsType(int dsIndex)
      Description copied from class: DataImporter
      Reads the type of a data source.
      Specified by:
      getDsType in class DataImporter
      Parameters:
      dsIndex - zero-based index of the data source
      Returns:
      the type driving how consecutive samples are combined
    • getHeartbeat

      public long getHeartbeat(int dsIndex)
      Description copied from class: DataImporter
      Reads the heartbeat of a data source.
      Specified by:
      getHeartbeat in class DataImporter
      Parameters:
      dsIndex - zero-based index of the data source
      Returns:
      the maximum gap in seconds between two updates before the data source is declared dead
    • getMinValue

      public double getMinValue(int dsIndex)
      Description copied from class: DataImporter
      Reads the lower bound a data source accepts.
      Specified by:
      getMinValue in class DataImporter
      Parameters:
      dsIndex - zero-based index of the data source
      Returns:
      the minimum value, or NaN when unbounded
    • getMaxValue

      public double getMaxValue(int dsIndex)
      Description copied from class: DataImporter
      Reads the upper bound a data source accepts.
      Specified by:
      getMaxValue in class DataImporter
      Parameters:
      dsIndex - zero-based index of the data source
      Returns:
      the maximum value, or NaN when unbounded
    • getLastValue

      public double getLastValue(int dsIndex)
      Description copied from class: DataImporter
      Reads the last value recorded for a data source.
      Specified by:
      getLastValue in class DataImporter
      Parameters:
      dsIndex - zero-based index of the data source
      Returns:
      the most recent value, unknown until the next update lands
    • getAccumValue

      public double getAccumValue(int dsIndex)
      Description copied from class: DataImporter
      Reads the partial total a data source is carrying into the current step.
      Specified by:
      getAccumValue in class DataImporter
      Parameters:
      dsIndex - zero-based index of the data source
      Returns:
      the value accumulated so far for the step being built
    • getNanSeconds

      public long getNanSeconds(int dsIndex)
      Description copied from class: DataImporter
      Reads when a data source last saw a usable sample.
      Specified by:
      getNanSeconds in class DataImporter
      Parameters:
      dsIndex - zero-based index of the data source
      Returns:
      a unix timestamp in seconds of the last valid sample, or 0 if it never had one
    • getConsolFun

      public ConsolFun getConsolFun(int arcIndex)
      Description copied from class: DataImporter
      Reads the consolidation function of an archive.
      Specified by:
      getConsolFun in class DataImporter
      Parameters:
      arcIndex - zero-based index of the archive
      Returns:
      the function folding primary data points into one row
    • getXff

      public double getXff(int arcIndex)
      Description copied from class: DataImporter
      Reads the xfiles factor of an archive.
      Specified by:
      getXff in class DataImporter
      Parameters:
      arcIndex - zero-based index of the archive
      Returns:
      the share of a step that an unknown value occupies, from 0 to 1
    • getSteps

      public int getSteps(int arcIndex)
      Description copied from class: DataImporter
      Reads how many primary data points one archive row covers.
      Specified by:
      getSteps in class DataImporter
      Parameters:
      arcIndex - zero-based index of the archive
      Returns:
      the number of steps consolidated into a single row
    • getRows

      public int getRows(int arcIndex)
      Description copied from class: DataImporter
      Counts the rows an archive currently holds.
      Specified by:
      getRows in class DataImporter
      Parameters:
      arcIndex - zero-based index of the archive
      Returns:
      the number of archive rows stored, which bounds DataImporter.getValues(int, int) in length
    • getStateAccumValue

      public double getStateAccumValue(int arcIndex, int dsIndex)
      Description copied from class: DataImporter
      Reads the value an archive is accumulating for one data source.
      Specified by:
      getStateAccumValue in class DataImporter
      Parameters:
      arcIndex - zero-based index of the archive
      dsIndex - zero-based index of the data source
      Returns:
      the accumulated value held in the archive state, waiting for the next step
    • getStateNanSteps

      public int getStateNanSteps(int arcIndex, int dsIndex)
      Description copied from class: DataImporter
      Counts the unknown primary data points an archive is holding.
      Specified by:
      getStateNanSteps in class DataImporter
      Parameters:
      arcIndex - zero-based index of the archive
      dsIndex - zero-based index of the data source
      Returns:
      the number of unknown steps inside the archive state, waiting for the next step
    • getValues

      public double[] getValues(int arcIndex, int dsIndex)
      Description copied from class: DataImporter
      Reads one data source's series from an archive.
      Specified by:
      getValues in class DataImporter
      Parameters:
      arcIndex - zero-based index of the archive
      dsIndex - zero-based index of the data source
      Returns:
      the archive's stored values, oldest first, one per DataImporter.getRows(int) row
    • release

      void release() throws IOException
      Releases the RRDTool reader and closes the underlying RRD database.
      Overrides:
      release in class DataImporter
      Throws:
      IOException - if an I/O error occurs