Package org.rrd4j.core
Class RrdRandomAccessFileBackend
java.lang.Object
org.rrd4j.core.RrdBackend
org.rrd4j.core.RrdRandomAccessFileBackend
- All Implemented Interfaces:
RrdFileBackend
- Direct Known Subclasses:
RrdSafeFileBackend
public class RrdRandomAccessFileBackend extends RrdBackend implements 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
Fields Modifier and Type Field Description protected RandomAccessFilerafileRandom access file handle. -
Constructor Summary
Constructors Modifier Constructor Description protectedRrdRandomAccessFileBackend(String path, boolean readOnly)Creates RrdFileBackend object for the given file path, backed by RandomAccessFile object. -
Method Summary
Modifier and Type Method Description protected voidclose()Closes the underlying RRD file.StringgetCanonicalPath()Returns canonical path to the file on the disk.longgetLength()Returns the number of RRD bytes in the underlying storage.voidread(long offset, byte[] b)Reads a number of bytes from the RRD file on the diskprotected voidsetLength(long length)Sets the number of bytes in the underlying RRD storage.protected voidwrite(long offset, byte[] b)Writes bytes to the underlying RRD file on the diskMethods inherited from class org.rrd4j.core.RrdBackend
done, getCharBuffer, getFactory, getPath, getUri, isCachingAllowed, isInstanceCreated, readAll, readDouble, readDouble, readInt, readLong, readShort, readString, rrdClose, writeDouble, writeDouble, writeDouble, writeInt, writeLong, writeShort, writeString, writeString
-
Field Details
-
rafile
Random access file handle.
-
-
Constructor Details
-
RrdRandomAccessFileBackend
Creates RrdFileBackend object for the given file path, backed by RandomAccessFile object.- Parameters:
path- Path to a filereadOnly- True, if file should be open in a read-only mode. False otherwise- Throws:
IOException- Thrown in case of I/O error
-
-
Method Details
-
close
Closes the underlying RRD file.- Specified by:
closein classRrdBackend- Throws:
IOException- Thrown in case of I/O error
-
write
Writes bytes to the underlying RRD file on the disk- Specified by:
writein classRrdBackend- Parameters:
offset- Starting file offsetb- Bytes to be written.- Throws:
IOException- Thrown in case of I/O error
-
read
Reads a number of bytes from the RRD file on the disk- Specified by:
readin classRrdBackend- Parameters:
offset- Starting file offsetb- Buffer which receives bytes read from the file.- Throws:
IOException- Thrown in case of I/O error.
-
getCanonicalPath
Description copied from interface:RrdFileBackendReturns canonical path to the file on the disk.- Specified by:
getCanonicalPathin interfaceRrdFileBackend- Returns:
- Canonical file path
- Throws:
IOException- Thrown in case of I/O error
-
getLength
Returns the number of RRD bytes in the underlying storage.- Specified by:
getLengthin classRrdBackend- Returns:
- Number of RRD bytes in the storage.
- Throws:
IOException- Thrown in case of I/O error.
-
setLength
Sets the number of bytes in the underlying RRD storage. This method is called only once, immediately after a new RRD storage gets created. Sets length of the underlying RRD file. This method is called only once, immediately after a new RRD file gets created.- Specified by:
setLengthin classRrdBackend- Parameters:
length- Length of the underlying RRD storage in bytes.- Throws:
IOException- Thrown in case of I/O error.
-