org.jrobin.core

Class RrdBackendFactory

public abstract class RrdBackendFactory extends Object

Base (abstract) backend factory class which holds references to all concrete backend factories and defines abstract methods which must be implemented in all concrete factory implementations.

Factory classes are used to create concrete RrdBackend implementations. Each factory creates unlimited number of specific backend objects.

JRobin supports four different backend types (backend factories) out of the box:

Each backend factory is identifed by its 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.

Method Summary
protected abstract booleanexists(String path)
Method to determine if a storage with the given path already exists.
static RrdBackendFactorygetDefaultFactory()
Returns the defaul backend factory.
static RrdBackendFactorygetFactory(String name)
Returns backend factory for the given backend factory name.
abstract StringgetFactoryName()
Returns the name (primary ID) for the factory.
protected abstract RrdBackendopen(String path, boolean readOnly)
Creates RrdBackend object for the given storage path.
static voidregisterAndSetAsDefaultFactory(RrdBackendFactory factory)
Registers new (custom) backend factory within the JRobin framework and sets this factory as the default.
static voidregisterFactory(RrdBackendFactory factory)
Registers new (custom) backend factory within the JRobin framework.
static voidsetDefaultFactory(String factoryName)
Replaces the default backend factory with a new one.

Method Detail

exists

protected abstract boolean exists(String path)
Method to determine if a storage with the given path already exists.

Parameters: path Storage path

Returns: True, if such storage exists, false otherwise.

getDefaultFactory

public static RrdBackendFactory getDefaultFactory()
Returns the defaul backend factory. This factory is used to construct RrdDb objects if no factory is specified in the RrdDb constructor.

Returns: Default backend factory.

getFactory

public static RrdBackendFactory getFactory(String name)
Returns backend factory for the given backend factory name.

Parameters: name Backend factory name. Initially supported names are:

Returns: Backend factory for the given factory name

Throws: RrdException Thrown if no factory with the given name is available.

getFactoryName

public abstract String getFactoryName()
Returns the name (primary ID) for the factory.

Returns: Name of the factory.

open

protected abstract RrdBackend open(String path, boolean readOnly)
Creates RrdBackend object for the given storage path.

Parameters: path Storage path readOnly True, if the storage should be accessed in read/only mode. False otherwise.

Returns: Backend object which handles all I/O operations for the given storage path

Throws: IOException Thrown in case of I/O error.

registerAndSetAsDefaultFactory

public static void registerAndSetAsDefaultFactory(RrdBackendFactory factory)
Registers new (custom) backend factory within the JRobin framework and sets this factory as the default.

Parameters: factory Factory to be registered and set as default

Throws: RrdException Thrown if the name of the specified factory is already used.

registerFactory

public static void registerFactory(RrdBackendFactory factory)
Registers new (custom) backend factory within the JRobin framework.

Parameters: factory Factory to be registered

Throws: RrdException Thrown if the name of the specified factory is already used.

setDefaultFactory

public static void setDefaultFactory(String factoryName)
Replaces the default backend factory with a new one. This method must be called before the first RRD gets created.

Parameters: factoryName Name of the default factory. Out of the box, JRobin 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).

Throws: RrdException Thrown if invalid factory name is supplied or not called before the first RRD is created.