public abstract class RrdBackendFactory extends Object
Factory classes are used to create concrete RrdBackend
implementations.
Each factory creates unlimited number of specific backend objects.
Rrd4j supports four different backend types (backend factories) out of the box:
RrdRandomAccessFileBackend
: objects of this class are created from the
RrdRandomAccessFileBackendFactory
class. This was the default backend used in all
Rrd4j releases before 1.4.0 release. It uses java.io.* package and RandomAccessFile class to store
RRD data in files on the disk.
RrdSafeFileBackend
: objects of this class are created from the
RrdSafeFileBackendFactory
class. It uses java.io.* package and RandomAccessFile class to store
RRD data in files on the disk. This backend is SAFE:
it locks the underlying RRD file during update/fetch operations, and caches only static
parts of a RRD file in memory. Therefore, this backend is safe to be used when RRD files should
be shared between several JVMs at the same time. However, this backend is *slow* since it does
not use fast java.nio.* package (it's still based on the RandomAccessFile class).
RrdNioBackend
: objects of this class are created from the
RrdNioBackendFactory
class. The backend uses java.io.* and java.nio.*
classes (mapped ByteBuffer) to store RRD data in files on the disk. This is the default backend
since 1.4.0 release.
RrdMemoryBackend
: objects of this class are created from the
RrdMemoryBackendFactory
class. This backend stores all data in memory. Once
JVM exits, all data gets lost. The backend is extremely fast and memory hungry.
name
. Constructors
are provided in the RrdDb
class to create RrdDb objects (RRD databases)
backed with a specific backend.
See javadoc for RrdBackend
to find out how to create your custom backends.
Constructor and Description |
---|
RrdBackendFactory() |
Modifier and Type | Method and Description |
---|---|
protected abstract boolean |
exists(String path)
Determines if a storage with the given path already exists.
|
static RrdBackendFactory |
getDefaultFactory()
Returns the default backend factory.
|
static RrdBackendFactory |
getFactory(String name)
Returns backend factory for the given backend factory name.
|
abstract String |
getName()
Returns the name (primary ID) for the factory.
|
protected abstract RrdBackend |
open(String path,
boolean readOnly)
Creates RrdBackend object for the given storage path.
|
static void |
registerAndSetAsDefaultFactory(RrdBackendFactory factory)
Registers new (custom) backend factory within the Rrd4j framework and sets this
factory as the default.
|
static void |
registerFactory(RrdBackendFactory factory)
Registers new (custom) backend factory within the Rrd4j framework.
|
static void |
setDefaultFactory(String factoryName)
Replaces the default backend factory with a new one.
|
protected abstract boolean |
shouldValidateHeader(String path)
Determines if the header should be validated.
|
public static RrdBackendFactory getFactory(String name)
name
- Backend factory name. Initially supported names are:
public static void registerFactory(RrdBackendFactory factory)
factory
- Factory to be registeredpublic static void registerAndSetAsDefaultFactory(RrdBackendFactory factory)
factory
- Factory to be registered and set as defaultpublic static RrdBackendFactory getDefaultFactory()
RrdDb
objects if no factory is specified in the RrdDb constructor.public static void setDefaultFactory(String factoryName)
factoryName
- Name of the default factory. Out of the box, Rrd4j supports four
different RRD backends: "FILE" (java.io.* based), "SAFE" (java.io.* based - use this
backend if RRD files may be accessed from several JVMs at the same time),
"NIO" (java.nio.* based) and "MEMORY" (byte[] based).protected abstract RrdBackend open(String path, boolean readOnly) throws IOException
path
- Storage pathreadOnly
- True, if the storage should be accessed in read/only mode.
False otherwise.IOException
- Thrown in case of I/O error.protected abstract boolean exists(String path) throws IOException
path
- Storage pathIOException
- if any.protected abstract boolean shouldValidateHeader(String path) throws IOException
path
- Storage pathIOException
- if header validation failspublic abstract String getName()
Copyright © 2015. All rights reserved.