|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jrobin.core.RrdBackend
public abstract class RrdBackend
Base implementation class for all backend classes. Each Round Robin Database 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.
RrdBackendFactory
to
find out how to do this
Constructor Summary | |
---|---|
protected |
RrdBackend(java.lang.String path)
Creates backend for a RRD storage with the given path. |
Method Summary | |
---|---|
protected void |
afterCreate()
Method called by the framework immediatelly after RrdDb obejct is created. |
protected void |
afterFetch()
Method called by the framework immediatelly after RRD fetch operation is completed. |
protected void |
afterUpdate()
Method called by the framework immediatelly after RRD update operation is completed. |
protected void |
beforeFetch()
Method called by the framework immediatelly before RRD fetch operation starts. |
protected void |
beforeUpdate()
Method called by the framework immediatelly before RRD update operation starts. |
void |
close()
Closes the underlying storage. |
abstract long |
getLength()
Returns the number of RRD bytes in the underlying storage. |
java.lang.String |
getPath()
Returns path to the storage. |
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 |
protected abstract void |
setLength(long length)
Sets the number of bytes in the underlying RRD storage. |
void |
sync()
This method forces all data cached in memory but not yet stored in the persistant storage, to be stored in it. |
protected abstract void |
write(long offset,
byte[] b)
Writes an array of bytes to the underlying storage starting from the given storage offset. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
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.Method Detail |
---|
public java.lang.String getPath()
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 storage
java.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 storage
java.io.IOException
- Thrown in case of I/O errorpublic final byte[] readAll() throws java.io.IOException
java.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 errorprotected void beforeUpdate() throws java.io.IOException
java.io.IOException
protected void afterUpdate() throws java.io.IOException
java.io.IOException
protected void beforeFetch() throws java.io.IOException
java.io.IOException
protected void afterFetch() throws java.io.IOException
java.io.IOException
protected void afterCreate() throws java.io.IOException
java.io.IOException
public void sync() throws java.io.IOException
java.io.IOException
- Thrown in case of I/O error
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |