java.lang.Object
org.rrd4j.core.DataImporter
org.rrd4j.core.RrdToolReader
- All Implemented Interfaces:
Closeable, AutoCloseable
Reader for RRDTool format RRD files.
Field Summary
FieldsConstructor Summary
ConstructorsMethod Summary
Public 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.longReads the moment the RRD was last updated.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()Reads the base interval between two primary data points.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.Reads the RRD file format version the export was written with.doublegetXff(int arcIndex) Reads the xfiles factor of an archive.(package private) voidrelease()Releases the RRDTool reader and closes the underlying RRD database.Methods inherited from class DataImporter
close, getEstimatedSizeModifier and TypeMethodDescriptionvoidclose()Releases the import source once the RRD has been written.protected longEstimates the byte length needed to hold everything this importer exposes.
Field Details
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
Description copied from class:DataImporterReads the RRD file format version the export was written with.- Specified by:
getVersionin classDataImporter- Returns:
- the version string, such as "008"
getLastUpdateTime
public long getLastUpdateTime()Description copied from class:DataImporterReads the moment the RRD was last updated.- Specified by:
getLastUpdateTimein classDataImporter- Returns:
- a unix timestamp in seconds, aligned to the step boundary
getStep
public long getStep()Description copied from class:DataImporterReads the base interval between two primary data points.- Specified by:
getStepin classDataImporter- Returns:
- the step size 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
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
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
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
release
Releases the RRDTool reader and closes the underlying RRD database.- Overrides:
releasein classDataImporter- Throws:
IOException- if an I/O error occurs