Package org.rrd4j.core
Class Datasource
java.lang.Object
org.rrd4j.core.Datasource
- All Implemented Interfaces:
RrdUpdater<Datasource>
public class Datasource extends Object implements RrdUpdater<Datasource>
Class to represent single datasource within RRD. Each datasource object holds the following information: datasource definition (once set, never changed) and datasource state variables (changed whenever RRD gets updated).
Normally, you don't need to manipulate Datasource objects directly, it's up to Rrd4j framework to do it for you.
- Author:
- Sasa Markovic
-
Constructor Summary
Constructors Constructor Description Datasource(RrdDb parentDb, DataImporter reader, int dsIndex)
Datasource(RrdDb parentDb, DsDef dsDef)
-
Method Summary
Modifier and Type Method Description (package private) void
appendXml(XmlWriter writer)
void
copyStateTo(Datasource datasource)
copyStateTo.(package private) String
dump()
double
getAccumValue()
Returns value this datasource accumulated so far.int
getDsIndex()
Returns index of this Datasource object in the RRD.long
getHeartbeat()
Returns datasource heartbeatdouble
getLastValue()
Returns last known value of the datasource.double
getMaxValue()
Returns maximal allowed value for this datasource.double
getMinValue()
Returns minimal allowed value for this datasource.String
getName()
Returns datasource name.long
getNanSeconds()
Returns the number of accumulated NaN seconds.RrdAllocator
getRrdAllocator()
Required to implement RrdUpdater interface.RrdBackend
getRrdBackend()
Returns the underlying storage (backend) object which actually performs all I/O operations.DsType
getType()
Returns datasource type (GAUGE, COUNTER, DERIVE, ABSOLUTE).(package private) void
process(long newTime, double newValue)
void
setDsName(String newDsName)
Sets datasource name to a new valuevoid
setDsType(DsType newDsType)
Setter for the fielddsType
.void
setHeartbeat(long heartbeat)
Sets datasource heartbeat to a new value.void
setMaxValue(double maxValue, boolean filterArchivedValues)
Sets maximum allowed value for this datasource.void
setMinMaxValue(double minValue, double maxValue, boolean filterArchivedValues)
Sets min/max values allowed for this datasource.void
setMinValue(double minValue, boolean filterArchivedValues)
Sets minimum allowed value for this datasource.
-
Constructor Details
-
Datasource
- Throws:
IOException
-
Datasource
- Throws:
IOException
-
-
Method Details
-
dump
- Throws:
IOException
-
getName
Returns datasource name.- Returns:
- Datasource name
- Throws:
IOException
- Thrown in case of I/O error
-
getType
Returns datasource type (GAUGE, COUNTER, DERIVE, ABSOLUTE).- Returns:
- Datasource type.
- Throws:
IOException
- Thrown in case of I/O error
-
getHeartbeat
Returns datasource heartbeat- Returns:
- Datasource heartbeat
- Throws:
IOException
- Thrown in case of I/O error
-
getMinValue
Returns minimal allowed value for this datasource.- Returns:
- Minimal value allowed.
- Throws:
IOException
- Thrown in case of I/O error
-
getMaxValue
Returns maximal allowed value for this datasource.- Returns:
- Maximal value allowed.
- Throws:
IOException
- Thrown in case of I/O error
-
getLastValue
Returns last known value of the datasource.- Returns:
- Last datasource value.
- Throws:
IOException
- Thrown in case of I/O error
-
getAccumValue
Returns value this datasource accumulated so far.- Returns:
- Accumulated datasource value.
- Throws:
IOException
- Thrown in case of I/O error
-
getNanSeconds
Returns the number of accumulated NaN seconds.- Returns:
- Accumulated NaN seconds.
- Throws:
IOException
- Thrown in case of I/O error
-
process
- Throws:
IOException
-
appendXml
- Throws:
IOException
-
copyStateTo
copyStateTo.
Copies object's internal state to another Datasource object.- Specified by:
copyStateTo
in interfaceRrdUpdater<Datasource>
- Parameters:
datasource
- aRrdUpdater
object.- Throws:
IOException
- if any.
-
getDsIndex
Returns index of this Datasource object in the RRD.- Returns:
- Datasource index in the RRD.
- Throws:
IOException
- Thrown in case of I/O error
-
setHeartbeat
Sets datasource heartbeat to a new value.- Parameters:
heartbeat
- New heartbeat value- Throws:
IOException
- Thrown in case of I/O errorIllegalArgumentException
- Thrown if invalid (non-positive) heartbeat value is specified.
-
setDsName
Sets datasource name to a new value- Parameters:
newDsName
- New datasource name- Throws:
IOException
- Thrown in case of I/O error
-
setDsType
Setter for the field
dsType
.- Parameters:
newDsType
- aDsType
object.- Throws:
IOException
- if any.
-
setMinValue
Sets minimum allowed value for this datasource. IffilterArchivedValues
argument is set to true, all archived values less thenminValue
will be fixed to NaN.- Parameters:
minValue
- New minimal value. SpecifyDouble.NaN
if no minimal value should be setfilterArchivedValues
- true, if archived datasource values should be fixed; false, otherwise.- Throws:
IOException
- Thrown in case of I/O errorIllegalArgumentException
- Thrown if invalid minValue was supplied (not less then maxValue)
-
setMaxValue
Sets maximum allowed value for this datasource. IffilterArchivedValues
argument is set to true, all archived values greater thenmaxValue
will be fixed to NaN.- Parameters:
maxValue
- New maximal value. SpecifyDouble.NaN
if no max value should be set.filterArchivedValues
- true, if archived datasource values should be fixed; false, otherwise.- Throws:
IOException
- Thrown in case of I/O errorIllegalArgumentException
- Thrown if invalid maxValue was supplied (not greater then minValue)
-
setMinMaxValue
public void setMinMaxValue(double minValue, double maxValue, boolean filterArchivedValues) throws IOExceptionSets min/max values allowed for this datasource. IffilterArchivedValues
argument is set to true, all archived values less thenminValue
or greater thenmaxValue
will be fixed to NaN.- Parameters:
minValue
- New minimal value. SpecifyDouble.NaN
if no min value should be set.maxValue
- New maximal value. SpecifyDouble.NaN
if no max value should be set.filterArchivedValues
- true, if archived datasource values should be fixed; false, otherwise.- Throws:
IOException
- Thrown in case of I/O errorIllegalArgumentException
- Thrown if invalid min/max values were supplied
-
getRrdBackend
Returns the underlying storage (backend) object which actually performs all I/O operations.- Specified by:
getRrdBackend
in interfaceRrdUpdater<Datasource>
- Returns:
- I/O backend object
-
getRrdAllocator
Required to implement RrdUpdater interface. You should never call this method directly.- Specified by:
getRrdAllocator
in interfaceRrdUpdater<Datasource>
- Returns:
- Allocator object
-