java.lang.Object
org.rrd4j.core.FetchRequest

public class FetchRequestextends Object
Class to represent fetch request. For the complete explanation of all fetch parameters consult RRDTool's rrdfetch man page.

You cannot create FetchRequest directly (no public constructor is provided). Use createFetchRequest() method of your RrdDb object.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final ConsolFun
    Consolidation function to read with.
    private final long
    Last time to fetch.
    private final long
    First time to fetch.
    private String[]
    Data sources to fetch, all if empty.
    private final RrdDb
    The database being read.
    private final long
    Spacing between fetched values, in seconds.
  • Constructor Summary

    Constructors
    Constructor
    Description
    FetchRequest(RrdDb parentDb, ConsolFun consolFun, long fetchStart, long fetchEnd, long resolution)
    Create a fetch request covering the given time range.
  • Method Summary

    Public Methods
    Modifier and Type
    Method
    Description
    Dumps the content of fetch request using the syntax of RRDTool's fetch command.
    Returns data from the underlying RRD and puts it in a single FetchData object.
    Returns consolidation function to be used during the fetch process.
    long
    Returns ending timestamp to be used for the fetch request.
    long
    Returns starting timestamp to be used for the fetch request.
    Returns request filter.
    Returns the underlying RrdDb object.
    long
    Returns fetch resolution to be used for the fetch request.
    (package private) String
    Render this request as the equivalent rrdtool fetch command.
    void
    setFilter(String filter)
    Sets request filter in order to fetch data only for a single datasource (datasource name).
    void
    setFilter(String... filter)
    Sets request filter in order to fetch data only for the specified array of datasources (datasource names).
    void
    setFilter(Set<String> filter)
    Sets request filter in order to fetch data only for the specified set of datasources (datasource names).

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • parentDb

      private final RrdDb parentDb
      The database being read.
    • consolFun

      private final ConsolFun consolFun
      Consolidation function to read with.
    • fetchStart

      private final long fetchStart
      First time to fetch.
    • fetchEnd

      private final long fetchEnd
      Last time to fetch.
    • resolution

      private final long resolution
      Spacing between fetched values, in seconds.
    • filter

      private String[] filter
      Data sources to fetch, all if empty.
  • Constructor Details

    • FetchRequest

      FetchRequest(RrdDb parentDb, ConsolFun consolFun, long fetchStart, long fetchEnd, long resolution)
      Create a fetch request covering the given time range.
      Parameters:
      parentDb - the parent RrdDb
      consolFun - the consolidation function
      fetchStart - the start timestamp
      fetchEnd - the end timestamp
      resolution - the archive resolution to fetch from
  • Method Details

    • setFilter

      public void setFilter(String... filter)
      Sets request filter in order to fetch data only for the specified array of datasources (datasource names). If not set (or set to null), fetched data will contain values of all datasources defined in the corresponding RRD. To fetch data only from selected datasources, specify an array of datasource names as method argument.
      Parameters:
      filter - Array of datasources (datasource names) to fetch data from.
    • setFilter

      public void setFilter(Set<String> filter)
      Sets request filter in order to fetch data only for the specified set of datasources (datasource names). If the filter is not set (or set to null), fetched data will contain values of all datasources defined in the corresponding RRD. To fetch data only from selected datasources, specify a set of datasource names as method argument.
      Parameters:
      filter - Set of datasource names to fetch data for.
    • setFilter

      public void setFilter(String filter)
      Sets request filter in order to fetch data only for a single datasource (datasource name). If not set (or set to null), fetched data will contain values of all datasources defined in the corresponding RRD. To fetch data for a single datasource only, specify an array of datasource names as method argument.
      Parameters:
      filter - A single datasource (datasource name) to fetch data from.
    • getFilter

      public String[] getFilter()
      Returns request filter. See setFilter() for complete explanation.
      Returns:
      Request filter (array of datasource names), null if not set.
    • getConsolFun

      public ConsolFun getConsolFun()
      Returns consolidation function to be used during the fetch process.
      Returns:
      the ConsolFun used to consolidate fetched archive rows, never null as the constructor rejects one
    • getFetchStart

      public long getFetchStart()
      Returns starting timestamp to be used for the fetch request.
      Returns:
      Starting timestamp in seconds.
    • getFetchEnd

      public long getFetchEnd()
      Returns ending timestamp to be used for the fetch request.
      Returns:
      Ending timestamp in seconds.
    • getResolution

      public long getResolution()
      Returns fetch resolution to be used for the fetch request.
      Returns:
      Fetch resolution in seconds.
    • dump

      public String dump()
      Dumps the content of fetch request using the syntax of RRDTool's fetch command.
      Returns:
      Fetch request dump.
    • getRrdToolCommand

      String getRrdToolCommand()
      Render this request as the equivalent rrdtool fetch command.
      Returns:
      the rrdtool command string
    • fetchData

      public FetchData fetchData() throws IOException
      Returns data from the underlying RRD and puts it in a single FetchData object.
      Returns:
      FetchData object filled with timestamps and datasource values.
      Throws:
      IOException - Thrown in case of I/O error.
    • getParentDb

      public RrdDb getParentDb()
      Returns the underlying RrdDb object.
      Returns:
      RrdDb object used to create this FetchRequest object.