java.lang.Object
org.rrd4j.core.RrdDb.Builder
Enclosing class:
RrdDb

public static class RrdDb.Builderextends Object
Builder for RrdDb instances.
  • Field Details

    • path

      private String path
      Path of the database file.
    • uri

      private URI uri
      The URI of the database.
    • factory

      private RrdBackendFactory factory
      The backend factory for the database.
    • readOnly

      private boolean readOnly
      True if the database is opened read-only.
    • externalPath

      private String externalPath
      External file to import data from.
    • importer

      private DataImporter importer
      The importer for the external data.
    • rrdDef

      private RrdDef rrdDef
      Definition of a database being created.
    • usePool

      private boolean usePool
      True if the db pool is used.
    • pool

      private RrdDbPool pool
      The pool holding the database.
  • Constructor Details

    • Builder

      private Builder()
      Builds a builder for a database request.
  • Method Details

    • build

      public RrdDb build() throws IOException
      Builds or imports a RrdDb instance.
      Returns:
      a new build RrdDb
      Throws:
      IOException - in case of I/O error.
      IllegalArgumentException - if the builder settings were incomplete
      IllegalStateException - if the thread was interrupted in pool usage
    • doimport

      public void doimport() throws IOException
      Import an external rrd data, import definition must have been done using setExternalPath(String) or setImporter(DataImporter).

      It can be used when it's not need to keep a reference to the rrd.

      Throws:
      IOException - in case of I/O error.
      IllegalArgumentException - if the builder settings were incomplete
      IllegalStateException - if the thread was interrupted in pool usage
    • setPath

      public RrdDb.Builder setPath(String path)
      Set the path to an existing RRD.
      Parameters:
      path - a String object.
      Returns:
      the same builder.
    • setPath

      public RrdDb.Builder setPath(URI uri)
      Set the URI to an existing RRD.
      Parameters:
      uri - a URI object.
      Returns:
      the same builder.
    • setBackendFactory

      public RrdDb.Builder setBackendFactory(RrdBackendFactory factory)
      Set the backend factory for this RRD.
      Parameters:
      factory - The backend factory to use for that rrd.
      Returns:
      the same builder.
    • setReadOnly

      public RrdDb.Builder setReadOnly(boolean readOnly)
      Set whether the RRD is read-only.
      Parameters:
      readOnly - true if the rrd is to be read only
      Returns:
      the same builder.
    • readOnly

      public RrdDb.Builder readOnly()
      Set the rrd as readonly
      Returns:
      the same builder.
    • setUsePool

      public RrdDb.Builder setUsePool(boolean usePool)
      Set whether to use the pool.
      Parameters:
      usePool - true if the pool should be used
      Returns:
      the same builder.
    • usePool

      public RrdDb.Builder usePool()
      Activate the pool usage. If the pool is not declared using setPool(RrdDbPool), the singleton instance will be used.
      Returns:
      the same builder.
    • setPool

      public RrdDb.Builder setPool(RrdDbPool pool)
      Set the pool that will be used and set usePool to true.
      Parameters:
      pool - true if a pool is going to be used
      Returns:
      the same builder.
    • setPoolInternal

      RrdDb.Builder setPoolInternal(RrdDbPool pool)
      Internal method used to memorize the pool, without generating a loop
      Parameters:
      pool - the pool the database will belong to; the pool-use flag is left off
      Returns:
      this same builder, so that calls can be chained
    • setExternalPath

      public RrdDb.Builder setExternalPath(String externalPath)
      Set when the builder will be used to import external data with a predefined source: XML or RRDTool.
      Parameters:
      externalPath - an URI-like indication of RRD data to import
      Returns:
      the same builder.
    • setImporter

      public RrdDb.Builder setImporter(DataImporter importer)
      Set when the builder will be used to import external data with a custom source.
      Parameters:
      importer - a custom import
      Returns:
      the same builder.
    • setRrdToolImporter

      public RrdDb.Builder setRrdToolImporter(String externalPath) throws IOException
      Set when the builder will be used to import a RRDTool file.
      Parameters:
      externalPath - the path to a RRDTool file
      Returns:
      the same builder.
      Throws:
      IOException - if the RRDTool file can‘t be read
    • setRrdDef

      public RrdDb.Builder setRrdDef(RrdDef rrdDef)
      Set the RRD definition for creating a new RRD.
      Parameters:
      rrdDef - a RrdDef to a new rrd file.
      Returns:
      the same builder.
    • checkFactory

      private static RrdBackendFactory checkFactory(URI uri, RrdBackendFactory factory)
      Resolves the backend factory for a request.
      Parameters:
      uri - the database URI
      factory - the requested factory, may be null
      Returns:
      the factory to use
    • buildUri

      private static URI buildUri(String rrdPath, URI rrdUri, RrdBackendFactory factory)
      Builds the URI for a database request.
      Parameters:
      rrdPath - the database path
      rrdUri - the requested URI, may be null
      factory - the backend factory
      Returns:
      the built URI
    • resoleImporter

      private static DataImporter resoleImporter(String externalPath, DataImporter importer) throws IOException
      Resolves the importer for an external file.
      Parameters:
      externalPath - the external file path
      importer - the requested importer, may be null
      Returns:
      the importer to use
      Throws:
      IOException - if the importer cannot be created
    • resolvePool

      private static RrdDbPool resolvePool(RrdDbPool pool)
      Returns the pool to use or the default.
      Parameters:
      pool - the requested pool, may be null
      Returns:
      the pool in effect