public class RrdDbPool extends Object
It can also be used a factory for RrdDb, using a default backend factory.
In case of interruptions, it throws IllegalStateException.
| Modifier and Type | Field and Description |
|---|---|
static int |
INITIAL_CAPACITY
Initial capacity of the pool i.e.
|
| Constructor and Description |
|---|
RrdDbPool()
Constructor for RrdDbPool.
|
RrdDbPool(RrdBackendFactory defaultFactory)
Constructor for RrdDbPool.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getCapacity()
Returns the maximum number of simultaneously open RRD.
|
static RrdDbPool |
getInstance()
Creates a single instance of the class on the first call, or returns already existing one.
|
int |
getOpenCount(RrdDb rrdDb)
Returns the number of usage for a RRD.
|
int |
getOpenCount(String path)
Returns the number of usage for a RRD.
|
int |
getOpenCount(URI uri)
Returns the number of usage for a RRD.
|
int |
getOpenFileCount()
Returns the number of open RRD.
|
String[] |
getOpenFiles()
Returns an array of open RRD.
|
URI[] |
getOpenUri()
Returns an array of open RRD URI.
|
java.util.stream.Stream<URI> |
getOpenUriStream()
Returns an stream open RRD.
|
Lock |
lockEmpty(long timeout,
TimeUnit unit)
Wait until the pool is empty and return a lock that prevent any additions of new RrdDb
references until it's released.
|
RrdDb |
requestRrdDb(RrdDef rrdDef)
Requests a RrdDb reference for the given RRD definition object.
|
(package private) RrdDb |
requestRrdDb(RrdDef rrdDef,
RrdBackendFactory factory) |
RrdDb |
requestRrdDb(String path)
Requests a RrdDb reference for the given RRD path.
|
RrdDb |
requestRrdDb(String path,
String sourcePath)
Requests a RrdDb reference for the given path.
|
RrdDb |
requestRrdDb(URI uri)
Requests a RrdDb reference for the given RRD URI.
|
(package private) RrdDb |
requestRrdDb(URI uri,
RrdBackendFactory factory) |
(package private) RrdDb |
requestRrdDb(URI uri,
RrdBackendFactory factory,
DataImporter importer) |
RrdDb |
requestRrdDb(URI uri,
String sourcePath)
Requests a RrdDb reference for the given URI.
|
void |
setCapacity(int newCapacity)
Sets the maximum number of simultaneously open RRD.
|
public static final int INITIAL_CAPACITY
public RrdDbPool()
public RrdDbPool(RrdBackendFactory defaultFactory)
defaultFactory - the default factory used when given a simple path of a RRD.public int getCapacity()
IllegalStateException - if the thread was interruptedpublic static RrdDbPool getInstance()
public int getOpenCount(RrdDb rrdDb)
rrdDb - RrdDb reference for which informations is needed.IllegalStateException - if the thread was interruptedpublic int getOpenCount(String path)
The path is transformed to an URI using the default factory.
path - RRD's path for which informations is needed.IllegalStateException - if the thread was interruptedpublic int getOpenCount(URI uri)
uri - RRD's URI for which informations is needed.IllegalStateException - if the thread was interruptedpublic int getOpenFileCount()
public String[] getOpenFiles()
public URI[] getOpenUri()
URI to open RRD held in the pool.public java.util.stream.Stream<URI> getOpenUriStream()
public Lock lockEmpty(long timeout, TimeUnit unit) throws InterruptedException
timeout - the time to wait for the write lockunit - the time unit of the timeout argumentInterruptedException - if interrupted whole waiting for the lockpublic RrdDb requestRrdDb(RrdDef rrdDef) throws IOException
getCapacity(), a new RRD will be created and it's RrdDb reference will be returned.
If the RRD is not already open and the number of already open RRD is equal to getCapacity(), the method blocks until some RrdDb references are closed.
If the factory defined when creating the pool can handle the URI, it will be used, or else
RrdBackendFactory.findFactory(URI) will be used.
rrdDef - Definition of the RRD file to be created.IOException - Thrown in case of I/O errorIllegalStateException - if the thread was interruptedRrdDb requestRrdDb(RrdDef rrdDef, RrdBackendFactory factory) throws IOException
IOExceptionpublic RrdDb requestRrdDb(String path) throws IOException
getCapacity(), it will be opened and a new RrdDb reference will be returned. If the
RRD is not already open and the number of already open RRD is equal to getCapacity(), the method blocks until some RRD are closed.
The path is transformed to an URI using the default factory defined at the creation of the pool.
path - Path to existing RRD.IOException - Thrown in case of I/O errorpublic RrdDb requestRrdDb(String path, String sourcePath) throws IOException
getCapacity(), a new RRD will be created and it's RrdDb reference will be returned.
If the RRD is not already open and the number of already open RRD is equal to getCapacity(), the method blocks until some RrdDb references are closed.
The path is transformed to an URI using the default factory of the pool.
path - Path to the RRD that should be created.sourcePath - Path to external data which is to be converted to Rrd4j's native RRD file
format.IOException - Thrown in case of I/O errorIllegalStateException - if the thread was interruptedpublic RrdDb requestRrdDb(URI uri) throws IOException
getCapacity(), it will be opened and a new RrdDb reference will be returned. If the
RRD is not already open and the number of already open RRD is equal to getCapacity(), the method blocks until some RRD are closed.
If the default backend factory for the pool can handle this URI, it will be used, or else
RrdBackendFactory.findFactory(URI) will be used to find the backend factory used.
uri - URI to existing RRD fileIOException - Thrown in case of I/O errorRrdDb requestRrdDb(URI uri, RrdBackendFactory factory) throws IOException
IOExceptionRrdDb requestRrdDb(URI uri, RrdBackendFactory factory, DataImporter importer) throws IOException
IOExceptionpublic RrdDb requestRrdDb(URI uri, String sourcePath) throws IOException
getCapacity(), a new RRD will be created and it's RrdDb reference will be returned.
If the RRD is not already open and the number of already open RRD is equal to getCapacity(), the method blocks until some RrdDb references are closed.
RrdBackendFactory.findFactory(URI) will be used to choose the factory.uri - URI to the RRD that should be createdsourcePath - Path to external data which is to be converted to Rrd4j's native RRD file
formatIOException - Thrown in case of I/O errorIllegalStateException - if the thread was interruptedpublic void setCapacity(int newCapacity)
newCapacity - Maximum number of simultaneously open RRD.IllegalStateException - if called while the pool is not empty or the thread was
interrupted.