java.lang.Object
org.rrd4j.core.RrdDb.Builder
- Enclosing class:
RrdDb
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringExternal file to import data from.private RrdBackendFactoryThe backend factory for the database.private DataImporterThe importer for the external data.private StringPath of the database file.private RrdDbPoolThe pool holding the database.private booleanTrue if the database is opened read-only.private RrdDefDefinition of a database being created.private URIThe URI of the database.private booleanTrue if the db pool is used.Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionbuild()Builds or imports aRrdDbinstance.private static URIbuildUri(String rrdPath, URI rrdUri, RrdBackendFactory factory) Builds the URI for a database request.private static RrdBackendFactorycheckFactory(URI uri, RrdBackendFactory factory) Resolves the backend factory for a request.voiddoimport()Import an external rrd data, import definition must have been done usingsetExternalPath(String)orsetImporter(DataImporter).readOnly()Set the rrd as readonlyprivate static DataImporterresoleImporter(String externalPath, DataImporter importer) Resolves the importer for an external file.private static RrdDbPoolresolvePool(RrdDbPool pool) Returns the pool to use or the default.setBackendFactory(RrdBackendFactory factory) Set the backend factory for this RRD.setExternalPath(String externalPath) Set when the builder will be used to import external data with a predefined source: XML or RRDTool.setImporter(DataImporter importer) Set when the builder will be used to import external data with a custom source.Set the path to an existing RRD.Set the URI to an existing RRD.Set the pool that will be used and set usePool to true.(package private) RrdDb.BuildersetPoolInternal(RrdDbPool pool) Internal method used to memorize the pool, without generating a loopsetReadOnly(boolean readOnly) Set whether the RRD is read-only.Set the RRD definition for creating a new RRD.setRrdToolImporter(String externalPath) Set when the builder will be used to import a RRDTool file.setUsePool(boolean usePool) Set whether to use the pool.usePool()Activate the pool usage.
Field Details
path
Path of the database file.uri
The URI of the database.factory
The backend factory for the database.readOnly
private boolean readOnlyTrue if the database is opened read-only.externalPath
External file to import data from.importer
The importer for the external data.rrdDef
Definition of a database being created.usePool
private boolean usePoolTrue if the db pool is used.pool
The pool holding the database.
Constructor Details
Builder
private Builder()Builds a builder for a database request.
Method Details
build
Builds or imports aRrdDbinstance.- Returns:
- a new build RrdDb
- Throws:
IOException- in case of I/O error.IllegalArgumentException- if the builder settings were incompleteIllegalStateException- if the thread was interrupted in pool usage
doimport
Import an external rrd data, import definition must have been done usingsetExternalPath(String)orsetImporter(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 incompleteIllegalStateException- if the thread was interrupted in pool usage
setPath
Set the path to an existing RRD.- Parameters:
path- aStringobject.- Returns:
- the same builder.
setPath
Set the URI to an existing RRD.- Parameters:
uri- aURIobject.- Returns:
- the same builder.
setBackendFactory
Set the backend factory for this RRD.- Parameters:
factory- The backend factory to use for that rrd.- Returns:
- the same builder.
setReadOnly
Set whether the RRD is read-only.- Parameters:
readOnly- true if the rrd is to be read only- Returns:
- the same builder.
readOnly
setUsePool
Set whether to use the pool.- Parameters:
usePool- true if the pool should be used- Returns:
- the same builder.
usePool
Activate the pool usage. If the pool is not declared usingsetPool(RrdDbPool), the singleton instance will be used.- Returns:
- the same builder.
setPool
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
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
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
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
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
Set the RRD definition for creating a new RRD.- Parameters:
rrdDef- aRrdDefto a new rrd file.- Returns:
- the same builder.
checkFactory
Resolves the backend factory for a request.- Parameters:
uri- the database URIfactory- the requested factory, may be null- Returns:
- the factory to use
buildUri
Builds the URI for a database request.- Parameters:
rrdPath- the database pathrrdUri- the requested URI, may be nullfactory- 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 pathimporter- the requested importer, may be null- Returns:
- the importer to use
- Throws:
IOException- if the importer cannot be created
resolvePool