org.rrd4j.core
Class RrdRandomAccessFileBackend

java.lang.Object
  extended by org.rrd4j.core.RrdBackend
      extended by org.rrd4j.core.RrdFileBackend
          extended by org.rrd4j.core.RrdRandomAccessFileBackend
Direct Known Subclasses:
RrdNioBackend, RrdSafeFileBackend

public class RrdRandomAccessFileBackend
extends RrdFileBackend

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  RandomAccessFile rafile
          Random access file handle.
 
Fields inherited from class org.rrd4j.core.RrdFileBackend
file, readOnly
 
Constructor Summary
protected RrdRandomAccessFileBackend(String path, boolean readOnly)
          Creates RrdFileBackend object for the given file path, backed by RandomAccessFile object.
 
Method Summary
 void close()
          Closes the underlying RRD file.
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.rrd4j.core.RrdFileBackend
getCanonicalPath, getCanonicalPath, getLength
 
Methods inherited from class org.rrd4j.core.RrdBackend
getPath, isCachingAllowed, readAll
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rafile

protected final RandomAccessFile rafile
Random access file handle.

Constructor Detail

RrdRandomAccessFileBackend

protected RrdRandomAccessFileBackend(String path,
                                     boolean readOnly)
                              throws IOException
Creates RrdFileBackend object for the given file path, backed by RandomAccessFile object.

Parameters:
path - Path to a file
readOnly - True, if file should be open in a read-only mode. False otherwise
Throws:
IOException - Thrown in case of I/O error
Method Detail

close

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

Specified by:
close in class RrdFileBackend
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.

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.


Copyright © 2011. All Rights Reserved.