java.lang.Object
org.rrd4j.core.DataImporter
org.rrd4j.core.XmlReader
- All Implemented Interfaces:
Closeable, AutoCloseable
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
Constructor Summary
Method Summary
All MethodsModifier and TypeMethodDescriptiondoublegetAccumValue(int dsIndex) Reads the partial total a data source is carrying into the current step.intCounts the archives (RRAs) declared by the RRD.getConsolFun(int arcIndex) Reads the consolidation function of an archive.intCounts 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.longgetHeartbeat(int dsIndex) Reads the heartbeat of a data source.longGets the last update time from the XML file.doublegetLastValue(int dsIndex) Reads the last value recorded for a data source.doublegetMaxValue(int dsIndex) Reads the upper bound a data source accepts.doublegetMinValue(int dsIndex) Reads the lower bound a data source accepts.longgetNanSeconds(int dsIndex) Reads when a data source last saw a usable sample.intgetRows(int arcIndex) Counts the rows an archive currently holds.doublegetStateAccumValue(int arcIndex, int dsIndex) Reads the value an archive is accumulating for one data source.intgetStateNanSteps(int arcIndex, int dsIndex) Counts the unknown primary data points an archive is holding.longgetStep()Gets the step interval from the XML file.intgetSteps(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.doublegetXff(int arcIndex) Reads the xfiles factor of an archive.Methods inherited from class DataImporter
close, getEstimatedSize, release
Field Details
root
The document's root element.dsNodes
The data source elements.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
Gets the RRD version from the XML file.- Specified by:
getVersionin classDataImporter- Returns:
- the version string
getLastUpdateTime
public long getLastUpdateTime()Gets the last update time from the XML file.- Specified by:
getLastUpdateTimein classDataImporter- Returns:
- the last update time as Unix timestamp
getStep
public long getStep()Gets the step interval from the XML file.- Specified by:
getStepin classDataImporter- Returns:
- the step interval in seconds
getDsCount
public int getDsCount()Description copied from class:DataImporterCounts the data sources declared by the RRD.- Specified by:
getDsCountin classDataImporter- Returns:
- the number of data sources
getArcCount
public int getArcCount()Description copied from class:DataImporterCounts the archives (RRAs) declared by the RRD.- Specified by:
getArcCountin classDataImporter- Returns:
- the number of archives
getDsName
Description copied from class:DataImporterReads the name of a data source.- Specified by:
getDsNamein classDataImporter- Parameters:
dsIndex- zero-based index of the data source- Returns:
- the data source name
getDsType
Description copied from class:DataImporterReads the type of a data source.- Specified by:
getDsTypein classDataImporter- 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:DataImporterReads the heartbeat of a data source.- Specified by:
getHeartbeatin classDataImporter- 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:DataImporterReads the lower bound a data source accepts.- Specified by:
getMinValuein classDataImporter- 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:DataImporterReads the upper bound a data source accepts.- Specified by:
getMaxValuein classDataImporter- 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:DataImporterReads the last value recorded for a data source.- Specified by:
getLastValuein classDataImporter- 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:DataImporterReads the partial total a data source is carrying into the current step.- Specified by:
getAccumValuein classDataImporter- 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:DataImporterReads when a data source last saw a usable sample.- Specified by:
getNanSecondsin classDataImporter- 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
Description copied from class:DataImporterReads the consolidation function of an archive.- Specified by:
getConsolFunin classDataImporter- 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:DataImporterReads the xfiles factor of an archive.- Specified by:
getXffin classDataImporter- 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:DataImporterReads how many primary data points one archive row covers.- Specified by:
getStepsin classDataImporter- 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:DataImporterReads the value an archive is accumulating for one data source.- Specified by:
getStateAccumValuein classDataImporter- Parameters:
arcIndex- zero-based index of the archivedsIndex- 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:DataImporterCounts the unknown primary data points an archive is holding.- Specified by:
getStateNanStepsin classDataImporter- Parameters:
arcIndex- zero-based index of the archivedsIndex- 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:DataImporterCounts the rows an archive currently holds.- Specified by:
getRowsin classDataImporter- 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:DataImporterReads one data source's series from an archive.- Specified by:
getValuesin classDataImporter- Parameters:
arcIndex- zero-based index of the archivedsIndex- zero-based index of the data source- Returns:
- the archive's stored values, oldest first, one per
DataImporter.getRows(int)row