java.lang.Object
org.rrd4j.core.DataImporter
All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
RrdToolReader, XmlReader

public abstract class DataImporterextends Object implements Closeable
An abstract class to import data from external source.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an importer; every subclass reads its source in its own constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Releases the import source once the RRD has been written.
    abstract double
    getAccumValue(int dsIndex)
    Reads the partial total a data source is carrying into the current step.
    abstract int
    Counts the archives (RRAs) declared by the RRD.
    abstract ConsolFun
    getConsolFun(int arcIndex)
    Reads the consolidation function of an archive.
    abstract int
    Counts the data sources declared by the RRD.
    abstract String
    getDsName(int dsIndex)
    Reads the name of a data source.
    abstract DsType
    getDsType(int dsIndex)
    Reads the type of a data source.
    protected long
    Estimates the byte length needed to hold everything this importer exposes.
    abstract long
    getHeartbeat(int dsIndex)
    Reads the heartbeat of a data source.
    abstract long
    Reads the moment the RRD was last updated.
    abstract double
    getLastValue(int dsIndex)
    Reads the last value recorded for a data source.
    abstract double
    getMaxValue(int dsIndex)
    Reads the upper bound a data source accepts.
    abstract double
    getMinValue(int dsIndex)
    Reads the lower bound a data source accepts.
    abstract long
    getNanSeconds(int dsIndex)
    Reads when a data source last saw a usable sample.
    abstract int
    getRows(int arcIndex)
    Counts the rows an archive currently holds.
    abstract double
    getStateAccumValue(int arcIndex, int dsIndex)
    Reads the value an archive is accumulating for one data source.
    abstract int
    getStateNanSteps(int arcIndex, int dsIndex)
    Counts the unknown primary data points an archive is holding.
    abstract long
    Reads the base interval between two primary data points.
    abstract int
    getSteps(int arcIndex)
    Reads how many primary data points one archive row covers.
    abstract double[]
    getValues(int arcIndex, int dsIndex)
    Reads one data source's series from an archive.
    abstract String
    Reads the RRD file format version the export was written with.
    abstract double
    getXff(int arcIndex)
    Reads the xfiles factor of an archive.
    (package private) void
    Frees whatever the importer holds open; the default importer needs nothing.

    Methods inherited from class Object

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

    • DataImporter

      public DataImporter()
      Creates an importer; every subclass reads its source in its own constructor
  • Method Details

    • getVersion

      public abstract String getVersion() throws IOException
      Reads the RRD file format version the export was written with.
      Returns:
      the version string, such as "008"
      Throws:
      IOException - if the export cannot be read
    • getLastUpdateTime

      public abstract long getLastUpdateTime() throws IOException
      Reads the moment the RRD was last updated.
      Returns:
      a unix timestamp in seconds, aligned to the step boundary
      Throws:
      IOException - if the export cannot be read
    • getStep

      public abstract long getStep() throws IOException
      Reads the base interval between two primary data points.
      Returns:
      the step size in seconds
      Throws:
      IOException - if the export cannot be read
    • getDsCount

      public abstract int getDsCount() throws IOException
      Counts the data sources declared by the RRD.
      Returns:
      the number of data sources
      Throws:
      IOException - if the export cannot be read
    • getArcCount

      public abstract int getArcCount() throws IOException
      Counts the archives (RRAs) declared by the RRD.
      Returns:
      the number of archives
      Throws:
      IOException - if the export cannot be read
    • getDsName

      public abstract String getDsName(int dsIndex) throws IOException
      Reads the name of a data source.
      Parameters:
      dsIndex - zero-based index of the data source
      Returns:
      the data source name
      Throws:
      IOException - if the export cannot be read
    • getDsType

      public abstract DsType getDsType(int dsIndex) throws IOException
      Reads the type of a data source.
      Parameters:
      dsIndex - zero-based index of the data source
      Returns:
      the type driving how consecutive samples are combined
      Throws:
      IOException - if the export cannot be read
    • getHeartbeat

      public abstract long getHeartbeat(int dsIndex) throws IOException
      Reads the heartbeat of a data source.
      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
      Throws:
      IOException - if the export cannot be read
    • getMinValue

      public abstract double getMinValue(int dsIndex) throws IOException
      Reads the lower bound a data source accepts.
      Parameters:
      dsIndex - zero-based index of the data source
      Returns:
      the minimum value, or NaN when unbounded
      Throws:
      IOException - if the export cannot be read
    • getMaxValue

      public abstract double getMaxValue(int dsIndex) throws IOException
      Reads the upper bound a data source accepts.
      Parameters:
      dsIndex - zero-based index of the data source
      Returns:
      the maximum value, or NaN when unbounded
      Throws:
      IOException - if the export cannot be read
    • getLastValue

      public abstract double getLastValue(int dsIndex) throws IOException
      Reads the last value recorded for a data source.
      Parameters:
      dsIndex - zero-based index of the data source
      Returns:
      the most recent value, unknown until the next update lands
      Throws:
      IOException - if the export cannot be read
    • getAccumValue

      public abstract double getAccumValue(int dsIndex) throws IOException
      Reads the partial total a data source is carrying into the current step.
      Parameters:
      dsIndex - zero-based index of the data source
      Returns:
      the value accumulated so far for the step being built
      Throws:
      IOException - if the export cannot be read
    • getNanSeconds

      public abstract long getNanSeconds(int dsIndex) throws IOException
      Reads when a data source last saw a usable sample.
      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
      Throws:
      IOException - if the export cannot be read
    • getConsolFun

      public abstract ConsolFun getConsolFun(int arcIndex) throws IOException
      Reads the consolidation function of an archive.
      Parameters:
      arcIndex - zero-based index of the archive
      Returns:
      the function folding primary data points into one row
      Throws:
      IOException - if the export cannot be read
    • getXff

      public abstract double getXff(int arcIndex) throws IOException
      Reads the xfiles factor of an archive.
      Parameters:
      arcIndex - zero-based index of the archive
      Returns:
      the share of a step that an unknown value occupies, from 0 to 1
      Throws:
      IOException - if the export cannot be read
    • getSteps

      public abstract int getSteps(int arcIndex) throws IOException
      Reads how many primary data points one archive row covers.
      Parameters:
      arcIndex - zero-based index of the archive
      Returns:
      the number of steps consolidated into a single row
      Throws:
      IOException - if the export cannot be read
    • getRows

      public abstract int getRows(int arcIndex) throws IOException
      Counts the rows an archive currently holds.
      Parameters:
      arcIndex - zero-based index of the archive
      Returns:
      the number of archive rows stored, which bounds getValues(int, int) in length
      Throws:
      IOException - if the export cannot be read
    • getStateAccumValue

      public abstract double getStateAccumValue(int arcIndex, int dsIndex) throws IOException
      Reads the value an archive is accumulating for one data source.
      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
      Throws:
      IOException - if the export cannot be read
    • getStateNanSteps

      public abstract int getStateNanSteps(int arcIndex, int dsIndex) throws IOException
      Counts the unknown primary data points an archive is holding.
      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
      Throws:
      IOException - if the export cannot be read
    • getValues

      public abstract double[] getValues(int arcIndex, int dsIndex) throws IOException
      Reads one data source's series from an archive.
      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 getRows(int) row
      Throws:
      IOException - if the export cannot be read
    • getEstimatedSize

      protected long getEstimatedSize() throws IOException
      Estimates the byte length needed to hold everything this importer exposes.
      Returns:
      the file size in bytes to reserve before writing the RRD
      Throws:
      IOException - if the export cannot be read
    • release

      void release() throws IOException
      Frees whatever the importer holds open; the default importer needs nothing.
      Throws:
      IOException - if the underlying source cannot be closed
    • close

      public void close() throws IOException
      Releases the import source once the RRD has been written.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException - if the underlying source cannot be closed