## org.jrobin.core
Class Datasource

    java.lang.Object
      org.jrobin.core.Datasource

All Implemented Interfaces:
  org.jrobin.core.RrdUpdater

public class Datasource
extends java.lang.Object
implements org.jrobin.core.RrdUpdater

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.

Method Summary
`void` `copyStateTo(org.jrobin.core.RrdUpdater other)` Copies object's internal state to another Datasource object.
`double` `getAccumValue()` Returns value this datasource accumulated so far.
`int` `getDsIndex()` Returns index of this Datasource object in the RRD.
`java.lang.String` `getDsName()` Returns datasource name.
`java.lang.String` `getDsType()` Returns datasource type (GAUGE, COUNTER, DERIVE, ABSOLUTE).
`long` `getHeartbeat()` Returns datasource heartbeat
`double` `getLastValue()` Returns last known value of the datasource.
`double` `getMaxValue()` Returns maximal allowed value for this datasource.
`double` `getMinValue()` Returns mimimal allowed value for this datasource.
`long` `getNanSeconds()` Returns the number of accumulated NaN seconds.
`org.jrobin.core.RrdAllocator` `getRrdAllocator()` Required to implement RrdUpdater interface.
`RrdBackend` `getRrdBackend()` Returns the underlying storage (backend) object which actually performs all I/O operations.
`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.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### getDsName

    public java.lang.String getDsName()
                               throws java.io.IOException

  Returns datasource name.

  Returns:
    Datasource name
  Throws:
    `java.io.IOException` - Thrown in case of I/O error

### getDsType

    public java.lang.String getDsType()
                               throws java.io.IOException

  Returns datasource type (GAUGE, COUNTER, DERIVE, ABSOLUTE).

  Returns:
    Datasource type.
  Throws:
    `java.io.IOException` - Thrown in case of I/O error

### getHeartbeat

    public long getHeartbeat()
                      throws java.io.IOException

  Returns datasource heartbeat

  Returns:
    Datasource heartbeat
  Throws:
    `java.io.IOException` - Thrown in case of I/O error

### getMinValue

    public double getMinValue()
                       throws java.io.IOException

  Returns mimimal allowed value for this datasource.

  Returns:
    Minimal value allowed.
  Throws:
    `java.io.IOException` - Thrown in case of I/O error

### getMaxValue

    public double getMaxValue()
                       throws java.io.IOException

  Returns maximal allowed value for this datasource.

  Returns:
    Maximal value allowed.
  Throws:
    `java.io.IOException` - Thrown in case of I/O error

### getLastValue

    public double getLastValue()
                        throws java.io.IOException

  Returns last known value of the datasource.

  Returns:
    Last datasource value.
  Throws:
    `java.io.IOException` - Thrown in case of I/O error

### getAccumValue

    public double getAccumValue()
                         throws java.io.IOException

  Returns value this datasource accumulated so far.

  Returns:
    Accumulated datasource value.
  Throws:
    `java.io.IOException` - Thrown in case of I/O error

### getNanSeconds

    public long getNanSeconds()
                       throws java.io.IOException

  Returns the number of accumulated NaN seconds.

  Returns:
    Accumulated NaN seconds.
  Throws:
    `java.io.IOException` - Thrown in case of I/O error

### copyStateTo

    public void copyStateTo(org.jrobin.core.RrdUpdater other)
                     throws java.io.IOException,
                            RrdException

  Copies object's internal state to another Datasource object.

  Specified by:
    `copyStateTo` in interface `org.jrobin.core.RrdUpdater`
  Parameters:
    `other` - New Datasource object to copy state to
  Throws:
    `java.io.IOException` - Thrown in case of I/O error
    `RrdException` - Thrown if supplied argument is not a Datasource object

### getDsIndex

    public int getDsIndex()
                   throws java.io.IOException

  Returns index of this Datasource object in the RRD.

  Returns:
    Datasource index in the RRD.
  Throws:
    `java.io.IOException` - Thrown in case of I/O error

### setHeartbeat

    public void setHeartbeat(long heartbeat)
                      throws RrdException,
                             java.io.IOException

  Sets datasource heartbeat to a new value.

  Parameters:
    `heartbeat` - New heartbeat value
  Throws:
    `java.io.IOException` - Thrown in case of I/O error
    `RrdException` - Thrown if invalid (non-positive) heartbeat value is specified.

### setMinValue

    public void setMinValue(double minValue,
                            boolean filterArchivedValues)
                     throws java.io.IOException,
                            RrdException

  Sets minimum allowed value for this datasource. If `filterArchivedValues` argment is set to true, all archived values less then `minValue` will be fixed to NaN.

  Parameters:
    `minValue` - New minimal value. Specify `Double.NaN` if no minimal value should be set
    `filterArchivedValues` - true, if archived datasource values should be fixed; false, otherwise.
  Throws:
    `java.io.IOException` - Thrown in case of I/O error
    `RrdException` - Thrown if invalid minValue was supplied (not less then maxValue)

### setMaxValue

    public void setMaxValue(double maxValue,
                            boolean filterArchivedValues)
                     throws java.io.IOException,
                            RrdException

  Sets maximum allowed value for this datasource. If `filterArchivedValues` argment is set to true, all archived values greater then `maxValue` will be fixed to NaN.

  Parameters:
    `maxValue` - New maximal value. Specify `Double.NaN` if no max value should be set.
    `filterArchivedValues` - true, if archived datasource values should be fixed; false, otherwise.
  Throws:
    `java.io.IOException` - Thrown in case of I/O error
    `RrdException` - Thrown if invalid maxValue was supplied (not greater then minValue)

### setMinMaxValue

    public void setMinMaxValue(double minValue,
                               double maxValue,
                               boolean filterArchivedValues)
                        throws java.io.IOException,
                               RrdException

  Sets min/max values allowed for this datasource. If `filterArchivedValues` argment is set to true, all archived values less then `minValue` or greater then `maxValue` will be fixed to NaN.

  Parameters:
    `minValue` - New minimal value. Specify `Double.NaN` if no min value should be set.
    `maxValue` - New maximal value. Specify `Double.NaN` if no max value should be set.
    `filterArchivedValues` - true, if archived datasource values should be fixed; false, otherwise.
  Throws:
    `java.io.IOException` - Thrown in case of I/O error
    `RrdException` - 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:
    `getRrdBackend` in interface `org.jrobin.core.RrdUpdater`
  Returns:
    I/O backend object

### getRrdAllocator

    public org.jrobin.core.RrdAllocator getRrdAllocator()

  Required to implement RrdUpdater interface. You should never call this method directly.

  Specified by:
    `getRrdAllocator` in interface `org.jrobin.core.RrdUpdater`
  Returns:
    Allocator object