All Implemented Interfaces:
Closeable, AutoCloseable

class XmlReaderextends DataImporter
Reader for importing RRD data from XML format.

This class extends DataImporter to provide functionality for reading RRD definitions and data from XML files. It parses the XML structure and provides methods to access various RRD components like datasources, archives, and their properties.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Node[]
    The archive elements.
    private final Node[]
    The data source elements.
    private final Element
    The document's root element.
  • Constructor Summary

    Constructors
    Constructor
    Description
    XmlReader(String xmlFilePath)
    Creates an XmlReader for the specified XML file.
  • Method Summary

    All 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
    Gets the last update time from the XML file.
    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
    Gets the step interval from the XML file.
    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.
    Gets the RRD version from the XML file.
    double
    getXff(int arcIndex)
    Reads the xfiles factor of an archive.

    Methods inherited from class DataImporter

    close, getEstimatedSize, release
    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.
    (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
  • Field Details

    • root

      private final Element root
      The document's root element.
    • dsNodes

      private final Node[] dsNodes
      The data source elements.
    • arcNodes

      private final Node[] arcNodes
      The archive elements.
  • Constructor Details

    • XmlReader

      XmlReader(String xmlFilePath) throws IOException
      Creates an XmlReader for the specified XML file.
      Parameters:
      xmlFilePath - the path to the XML file to read
      Throws:
      IOException - if an I/O error occurs while reading the file
  • Method Details

    • getVersion

      public String getVersion()
      Gets the RRD version from the XML file.
      Specified by:
      getVersion in class DataImporter
      Returns:
      the version string
    • getLastUpdateTime

      public long getLastUpdateTime()
      Gets the last update time from the XML file.
      Specified by:
      getLastUpdateTime in class DataImporter
      Returns:
      the last update time as Unix timestamp
    • getStep

      public long getStep()
      Gets the step interval from the XML file.
      Specified by:
      getStep in class DataImporter
      Returns:
      the step interval 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
    • 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
    • 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
    • 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