Package org.jrobin.core
Class Datasource
- java.lang.Object
-
- org.jrobin.core.Datasource
-
- All Implemented Interfaces:
DsTypes,RrdUpdater
public class Datasource extends Object implements RrdUpdater, DsTypes
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 manipluate Datasource objects directly, it's up to JRobin framework to do it for you.
- Author:
- Sasa Markovic
-
-
Field Summary
-
Fields inherited from interface org.jrobin.core.DsTypes
DT_ABSOLUTE, DT_COUNTER, DT_DERIVE, DT_GAUGE
-
-
Constructor Summary
Constructors Constructor Description Datasource(RrdDb parentDb, DataImporter reader, int dsIndex)Datasource(RrdDb parentDb, DsDef dsDef)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidappendXml(XmlWriter writer)voidcopyStateTo(RrdUpdater other)Copies object's internal state to another Datasource object.(package private) Stringdump()doublegetAccumValue()Returns value this datasource accumulated so far.intgetDsIndex()Returns index of this Datasource object in the RRD.StringgetDsName()Returns datasource name.StringgetDsType()Returns datasource type (GAUGE, COUNTER, DERIVE, ABSOLUTE).longgetHeartbeat()Returns datasource heartbeatdoublegetLastValue()Returns last known value of the datasource.doublegetMaxValue()Returns maximal allowed value for this datasource.doublegetMinValue()Returns mimimal allowed value for this datasource.longgetNanSeconds()Returns the number of accumulated NaN seconds.RrdAllocatorgetRrdAllocator()Required to implement RrdUpdater interface.RrdBackendgetRrdBackend()Returns the underlying storage (backend) object which actually performs all I/O operations.(package private) voidprocess(long newTime, double newValue)voidsetDsName(String newDsName)Sets datasource name to a new valuevoidsetDsType(String newDsType)voidsetHeartbeat(long heartbeat)Sets datasource heartbeat to a new value.voidsetMaxValue(double maxValue, boolean filterArchivedValues)Sets maximum allowed value for this datasource.voidsetMinMaxValue(double minValue, double maxValue, boolean filterArchivedValues)Sets min/max values allowed for this datasource.voidsetMinValue(double minValue, boolean filterArchivedValues)Sets minimum allowed value for this datasource.StringtoString()
-
-
-
Constructor Detail
-
Datasource
Datasource(RrdDb parentDb, DsDef dsDef) throws IOException
- Throws:
IOException
-
Datasource
Datasource(RrdDb parentDb, DataImporter reader, int dsIndex) throws IOException, RrdException
- Throws:
IOExceptionRrdException
-
-
Method Detail
-
dump
String dump() throws IOException
- Throws:
IOException
-
getDsName
public String getDsName() throws IOException
Returns datasource name.- Returns:
- Datasource name
- Throws:
IOException- Thrown in case of I/O error
-
getDsType
public String getDsType() throws IOException
Returns datasource type (GAUGE, COUNTER, DERIVE, ABSOLUTE).- Returns:
- Datasource type.
- Throws:
IOException- Thrown in case of I/O error
-
getHeartbeat
public long getHeartbeat() throws IOExceptionReturns datasource heartbeat- Returns:
- Datasource heartbeat
- Throws:
IOException- Thrown in case of I/O error
-
getMinValue
public double getMinValue() throws IOExceptionReturns mimimal allowed value for this datasource.- Returns:
- Minimal value allowed.
- Throws:
IOException- Thrown in case of I/O error
-
getMaxValue
public double getMaxValue() throws IOExceptionReturns maximal allowed value for this datasource.- Returns:
- Maximal value allowed.
- Throws:
IOException- Thrown in case of I/O error
-
getLastValue
public double getLastValue() throws IOExceptionReturns last known value of the datasource.- Returns:
- Last datasource value.
- Throws:
IOException- Thrown in case of I/O error
-
getAccumValue
public double getAccumValue() throws IOExceptionReturns value this datasource accumulated so far.- Returns:
- Accumulated datasource value.
- Throws:
IOException- Thrown in case of I/O error
-
getNanSeconds
public long getNanSeconds() throws IOExceptionReturns the number of accumulated NaN seconds.- Returns:
- Accumulated NaN seconds.
- Throws:
IOException- Thrown in case of I/O error
-
process
void process(long newTime, double newValue) throws IOException, RrdException- Throws:
IOExceptionRrdException
-
appendXml
void appendXml(XmlWriter writer) throws IOException
- Throws:
IOException
-
copyStateTo
public void copyStateTo(RrdUpdater other) throws IOException, RrdException
Copies object's internal state to another Datasource object.- Specified by:
copyStateToin interfaceRrdUpdater- Parameters:
other- New Datasource object to copy state to- Throws:
IOException- Thrown in case of I/O errorRrdException- Thrown if supplied argument is not a Datasource object
-
getDsIndex
public int getDsIndex() throws IOExceptionReturns index of this Datasource object in the RRD.- Returns:
- Datasource index in the RRD.
- Throws:
IOException- Thrown in case of I/O error
-
setHeartbeat
public void setHeartbeat(long heartbeat) throws RrdException, IOExceptionSets datasource heartbeat to a new value.- Parameters:
heartbeat- New heartbeat value- Throws:
IOException- Thrown in case of I/O errorRrdException- Thrown if invalid (non-positive) heartbeat value is specified.
-
setDsName
public void setDsName(String newDsName) throws RrdException, IOException
Sets datasource name to a new value- Parameters:
newDsName- New datasource name- Throws:
RrdException- Thrown if invalid data source name is specified (name too long, or name already defined in the RRDIOException- Thrown in case of I/O error
-
setDsType
public void setDsType(String newDsType) throws RrdException, IOException
- Throws:
RrdExceptionIOException
-
setMinValue
public void setMinValue(double minValue, boolean filterArchivedValues) throws IOException, RrdExceptionSets minimum allowed value for this datasource. IffilterArchivedValuesargment is set to true, all archived values less thenminValuewill be fixed to NaN.- Parameters:
minValue- New minimal value. SpecifyDouble.NaNif no minimal value should be setfilterArchivedValues- true, if archived datasource values should be fixed; false, otherwise.- Throws:
IOException- Thrown in case of I/O errorRrdException- Thrown if invalid minValue was supplied (not less then maxValue)
-
setMaxValue
public void setMaxValue(double maxValue, boolean filterArchivedValues) throws IOException, RrdExceptionSets maximum allowed value for this datasource. IffilterArchivedValuesargment is set to true, all archived values greater thenmaxValuewill be fixed to NaN.- Parameters:
maxValue- New maximal value. SpecifyDouble.NaNif 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 errorRrdException- Thrown if invalid maxValue was supplied (not greater then minValue)
-
setMinMaxValue
public void setMinMaxValue(double minValue, double maxValue, boolean filterArchivedValues) throws IOException, RrdExceptionSets min/max values allowed for this datasource. IffilterArchivedValuesargment is set to true, all archived values less thenminValueor greater thenmaxValuewill be fixed to NaN.- Parameters:
minValue- New minimal value. SpecifyDouble.NaNif no min value should be set.maxValue- New maximal value. SpecifyDouble.NaNif 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 errorRrdException- Thrown if invalid min/max values were supplied
-
getRrdBackend
public RrdBackend getRrdBackend()
Returns the underlying storage (backend) object which actually performs all I/O operations.- Specified by:
getRrdBackendin interfaceRrdUpdater- Returns:
- I/O backend object
-
getRrdAllocator
public RrdAllocator getRrdAllocator()
Required to implement RrdUpdater interface. You should never call this method directly.- Specified by:
getRrdAllocatorin interfaceRrdUpdater- Returns:
- Allocator object
-
-