org.jrobin.core
Class RrdFileBackend

java.lang.Object
  extended by org.jrobin.core.RrdBackend
      extended by org.jrobin.core.RrdFileBackend
Direct Known Subclasses:
RrdNioBackend

public class RrdFileBackend
extends RrdBackend

JRobin backend which is used to store RRD data to ordinary files on the disk. This was the default factory before 1.4.0 version

This backend is based on the RandomAccessFile class (java.io.* package).


Field Summary
protected  FileChannel channel
           
protected  RandomAccessFile file
           
protected  FileLock fileLock
           
 
Constructor Summary
protected RrdFileBackend(String path, boolean readOnly, int lockMode)
           
 
Method Summary
 void close()
          Closes the underlying RRD file.
protected  void finalize()
          Closes the underlying RRD file if not already closed
 String getCanonicalPath()
          Returns canonical path to the file on the disk.
static String getCanonicalPath(String path)
          Returns canonical path to the file on the disk.
 long getLength()
          Returns RRD file length.
protected  void read(long offset, byte[] b)
          Reads a number of bytes from the RRD file on the disk
protected  void setLength(long length)
          Sets length of the underlying RRD file.
protected  void write(long offset, byte[] b)
          Writes bytes to the underlying RRD file on the disk
 
Methods inherited from class org.jrobin.core.RrdBackend
afterCreate, afterFetch, afterUpdate, beforeFetch, beforeUpdate, getPath, readAll, sync
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

file

protected RandomAccessFile file

channel

protected FileChannel channel

fileLock

protected FileLock fileLock
Constructor Detail

RrdFileBackend

protected RrdFileBackend(String path,
                         boolean readOnly,
                         int lockMode)
                  throws IOException
Throws:
IOException
Method Detail

close

public void close()
           throws IOException
Closes the underlying RRD file.

Overrides:
close in class RrdBackend
Throws:
IOException - Thrown in case of I/O error

finalize

protected void finalize()
                 throws IOException
Closes the underlying RRD file if not already closed

Overrides:
finalize in class Object
Throws:
IOException - Thrown in case of I/O error

getCanonicalPath

public static String getCanonicalPath(String path)
                               throws IOException
Returns canonical path to the file on the disk.

Parameters:
path - File path
Returns:
Canonical file path
Throws:
IOException - Thrown in case of I/O error

getCanonicalPath

public String getCanonicalPath()
                        throws IOException
Returns canonical path to the file on the disk.

Returns:
Canonical file path
Throws:
IOException - Thrown in case of I/O error

write

protected void write(long offset,
                     byte[] b)
              throws IOException
Writes bytes to the underlying RRD file on the disk

Specified by:
write in class RrdBackend
Parameters:
offset - Starting file offset
b - Bytes to be written.
Throws:
IOException - Thrown in case of I/O error

read

protected void read(long offset,
                    byte[] b)
             throws IOException
Reads a number of bytes from the RRD file on the disk

Specified by:
read in class RrdBackend
Parameters:
offset - Starting file offset
b - Buffer which receives bytes read from the file.
Throws:
IOException - Thrown in case of I/O error.

getLength

public long getLength()
               throws IOException
Returns RRD file length.

Specified by:
getLength in class RrdBackend
Returns:
File length.
Throws:
IOException - Thrown in case of I/O error.

setLength

protected void setLength(long length)
                  throws IOException
Sets length of the underlying RRD file. This method is called only once, immediately after a new RRD file gets created.

Specified by:
setLength in class RrdBackend
Parameters:
length - Length of the RRD file
Throws:
IOException - Thrown in case of I/O error.