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.

- - ### Constructor Summary

    Constructors
    Constructor and 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 and Description
    --- | ---
    `(package private) void` | `appendXml(XmlWriter writer)`
    `void` | `copyStateTo(Datasource datasource)` copyStateTo.
    `(package private) String` | `dump()` Returns a string representation of datasource information.
    `double` | `getAccumValue()` Returns value this datasource accumulated so far.
    `int` | `getDsIndex()` Returns index of this Datasource object in the RRD.
    `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 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 value
    `void` | `setDsType(DsType newDsType)` Setter for the field `dsType`.
    `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`

- - ### Constructor Detail

    - #### Datasource

          Datasource(RrdDb parentDb,
                     DataImporter reader,
                     int dsIndex)
              throws IOException

      Throws:
        `IOException`

    - #### Datasource

          Datasource(RrdDb parentDb,
                     DsDef dsDef)
              throws IOException

      Throws:
        `IOException`

  - ### Method Detail

    - #### appendXml

          void appendXml(XmlWriter writer)
                  throws IOException

      Throws:
        `IOException`

    - #### copyStateTo

          public void copyStateTo(Datasource datasource)
                           throws IOException

      copyStateTo.

      Copies object's internal state to another Datasource object.

      Specified by:
        `copyStateTo` in interface `RrdUpdater<Datasource>`
      Parameters:
        `datasource` - a `RrdUpdater` object.
      Throws:
        `IOException` - if any.

    - #### dump

          String dump()
               throws IOException

      Returns a string representation of datasource information.
      Returns:
        a string containing datasource information
      Throws:
        `IOException` - if an I/O error occurs

    - #### getAccumValue

          public double getAccumValue()
                               throws IOException

      Returns value this datasource accumulated so far.
      Returns:
        Accumulated datasource value.
      Throws:
        `IOException` - Thrown in case of I/O error

    - #### getDsIndex

          public int getDsIndex()
                         throws IOException

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

    - #### getHeartbeat

          public long getHeartbeat()
                            throws IOException

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

    - #### getLastValue

          public double getLastValue()
                              throws IOException

      Returns last known value of the datasource.
      Returns:
        Last datasource value.
      Throws:
        `IOException` - Thrown in case of I/O error

    - #### getMaxValue

          public double getMaxValue()
                             throws IOException

      Returns maximal allowed value for this datasource.
      Returns:
        Maximal value allowed.
      Throws:
        `IOException` - Thrown in case of I/O error

    - #### getMinValue

          public double getMinValue()
                             throws IOException

      Returns minimal allowed value for this datasource.
      Returns:
        Minimal value allowed.
      Throws:
        `IOException` - Thrown in case of I/O error

    - #### getName

          public String getName()
                         throws IOException

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

    - #### getNanSeconds

          public long getNanSeconds()
                             throws IOException

      Returns the number of accumulated NaN seconds.
      Returns:
        Accumulated NaN seconds.
      Throws:
        `IOException` - Thrown in case of I/O error

    - #### getRrdAllocator

          public RrdAllocator getRrdAllocator()

      Required to implement RrdUpdater interface. You should never call this method directly.
      Specified by:
        `getRrdAllocator` in interface `RrdUpdater<Datasource>`
      Returns:
        Allocator object

    - #### getRrdBackend

          public RrdBackend getRrdBackend()

      Returns the underlying storage (backend) object which actually performs all I/O operations.
      Specified by:
        `getRrdBackend` in interface `RrdUpdater<Datasource>`
      Returns:
        I/O backend object

    - #### getType

          public DsType getType()
                         throws IOException

      Returns datasource type (GAUGE, COUNTER, DERIVE, ABSOLUTE).
      Returns:
        Datasource type.
      Throws:
        `IOException` - Thrown in case of I/O error

    - #### process

          final void process(long newTime,
                             double newValue)
                      throws IOException

      Throws:
        `IOException`

    - #### setDsName

          public void setDsName(String newDsName)
                         throws IOException

      Sets datasource name to a new value
      Parameters:
        `newDsName` - New datasource name
      Throws:
        `IOException` - Thrown in case of I/O error

    - #### setDsType

          public void setDsType(DsType newDsType)
                         throws IOException

      Setter for the field `dsType`.
      Parameters:
        `newDsType` - a `DsType` object.
      Throws:
        `IOException` - if any.

    - #### setHeartbeat

          public void setHeartbeat(long heartbeat)
                            throws IOException

      Sets datasource heartbeat to a new value.
      Parameters:
        `heartbeat` - New heartbeat value
      Throws:
        `IOException` - Thrown in case of I/O error
        `IllegalArgumentException` - Thrown if invalid (non-positive) heartbeat value is specified.

    - #### setMaxValue

          public void setMaxValue(double maxValue,
                                  boolean filterArchivedValues)
                           throws IOException

      Sets maximum allowed value for this datasource. If `filterArchivedValues` argument 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:
        `IOException` - Thrown in case of I/O error
        `IllegalArgumentException` - Thrown if invalid maxValue was supplied (not greater then minValue)

    - #### setMinMaxValue

          public void setMinMaxValue(double minValue,
                                     double maxValue,
                                     boolean filterArchivedValues)
                              throws IOException

      Sets min/max values allowed for this datasource. If `filterArchivedValues` argument 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:
        `IOException` - Thrown in case of I/O error
        `IllegalArgumentException` - Thrown if invalid min/max values were supplied

    - #### setMinValue

          public void setMinValue(double minValue,
                                  boolean filterArchivedValues)
                           throws IOException

      Sets minimum allowed value for this datasource. If `filterArchivedValues` argument 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:
        `IOException` - Thrown in case of I/O error
        `IllegalArgumentException` - Thrown if invalid minValue was supplied (not less then maxValue)