RrdFileBackend
, RrdJRobin14FileBackend
, RrdMemoryBackend
public abstract class RrdBackend
extends java.lang.Object
RrdDb
object) is backed with a single RrdBackend object which performs
actual I/O operations on the underlying storage. JRobin supports
three different bakcends out of the box:
RrdFileBackend
: objects of this class are created from the
RrdFileBackendFactory
class. This was the default backend used in all
JRobin releases prior to 1.4.0. It uses java.io.* package and
RandomAccessFile class to store RRD data in files on the disk.
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 backend is fast, very fast,
but consumes a lot of memory (borrowed not from the JVM but from the underlying operating system
directly). This is the default backend used in JRobin 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.
To create your own backend in order to provide some custom type of RRD storage, you should do the following:
RrdBackendFactory
to
find out how to do this
修飾子 | コンストラクタ | 説明 |
---|---|---|
protected |
RrdBackend(java.lang.String path) |
Creates backend for a RRD storage with the given path.
|
protected |
RrdBackend(java.lang.String path,
boolean readOnly) |
修飾子とタイプ | メソッド | 説明 |
---|---|---|
void |
close() |
Closes the underlying backend.
|
abstract long |
getLength() |
Returns the number of RRD bytes in the underlying storage.
|
java.lang.String |
getPath() |
Returns path to the storage.
|
protected boolean |
isCachingAllowed() |
This method suggests the caching policy to the JRobin frontend (high-level) classes.
|
(package private) static boolean |
isInstanceCreated() |
|
boolean |
isReadOnly() |
Is the RRD ReadOnly?
|
protected abstract void |
read(long offset,
byte[] b) |
Reads an array of bytes from the underlying storage starting from the given
storage offset.
|
byte[] |
readAll() |
Reads all RRD bytes from the underlying storage
|
(package private) double |
readDouble(long offset) |
|
(package private) double[] |
readDouble(long offset,
int count) |
|
(package private) int |
readInt(long offset) |
|
(package private) long |
readLong(long offset) |
|
(package private) java.lang.String |
readString(long offset) |
|
protected abstract void |
setLength(long length) |
Sets the number of bytes in the underlying RRD storage.
|
protected abstract void |
write(long offset,
byte[] b) |
Writes an array of bytes to the underlying storage starting from the given
storage offset.
|
(package private) void |
writeDouble(long offset,
double value) |
|
(package private) void |
writeDouble(long offset,
double[] values) |
|
(package private) void |
writeDouble(long offset,
double value,
int count) |
|
(package private) void |
writeInt(long offset,
int value) |
|
(package private) void |
writeLong(long offset,
long value) |
|
(package private) void |
writeString(long offset,
java.lang.String rawValue) |
protected RrdBackend(java.lang.String path)
path
- String identifying RRD storage. For files on the disk, this
argument should represent file path. Other storage types might interpret
this argument differently.protected RrdBackend(java.lang.String path, boolean readOnly)
public java.lang.String getPath()
public boolean isReadOnly()
protected abstract void write(long offset, byte[] b) throws java.io.IOException
offset
- Storage offset.b
- Array of bytes that should be copied to the underlying storagejava.io.IOException
- Thrown in case of I/O errorprotected abstract void read(long offset, byte[] b) throws java.io.IOException
offset
- Storage offset.b
- Array which receives bytes from the underlying storagejava.io.IOException
- Thrown in case of I/O errorpublic abstract long getLength() throws java.io.IOException
java.io.IOException
- Thrown in case of I/O error.protected abstract void setLength(long length) throws java.io.IOException
length
- Length of the underlying RRD storage in bytes.java.io.IOException
- Thrown in case of I/O error.public void close() throws java.io.IOException
java.io.IOException
- Thrown in case of I/O error.protected boolean isCachingAllowed()
true
is returned, frontent classes will cache frequently used parts of a RRD file in memory to improve
performance. If false
is returned, high level classes will never cache RRD file sections
in memory.true
if file caching is enabled, false
otherwise. By default, the
method returns true
but it can be overriden in subclasses.public final byte[] readAll() throws java.io.IOException
java.io.IOException
- Thrown in case of I/O errorfinal void writeInt(long offset, int value) throws java.io.IOException
java.io.IOException
final void writeLong(long offset, long value) throws java.io.IOException
java.io.IOException
final void writeDouble(long offset, double value) throws java.io.IOException
java.io.IOException
final void writeDouble(long offset, double value, int count) throws java.io.IOException
java.io.IOException
final void writeDouble(long offset, double[] values) throws java.io.IOException
java.io.IOException
final void writeString(long offset, java.lang.String rawValue) throws java.io.IOException
java.io.IOException
final int readInt(long offset) throws java.io.IOException
java.io.IOException
final long readLong(long offset) throws java.io.IOException
java.io.IOException
final double readDouble(long offset) throws java.io.IOException
java.io.IOException
final double[] readDouble(long offset, int count) throws java.io.IOException
java.io.IOException
final java.lang.String readString(long offset) throws java.io.IOException
java.io.IOException
static boolean isInstanceCreated()