Package org.jrobin.core
Class RrdJRobin14FileBackend
- java.lang.Object
-
- org.jrobin.core.RrdBackend
-
- org.jrobin.core.RrdJRobin14FileBackend
-
public class RrdJRobin14FileBackend 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).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRrdJRobin14FileBackend.LockMode
-
Field Summary
Fields Modifier and Type Field Description protected RandomAccessFilem_filerandom access file handleprotected FileLockm_fileLockfile lockprotected RrdJRobin14FileBackend.LockModem_lockModelocking mode
-
Constructor Summary
Constructors Modifier Constructor Description protectedRrdJRobin14FileBackend(String path, boolean readOnly, RrdJRobin14FileBackend.LockMode lockMode)Creates RrdFileBackend object for the given file path, backed by RandomAccessFile object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the underlying RRD file.StringgetCanonicalPath()Returns canonical path to the file on the disk.longgetLength()Returns RRD file length.protected voidread(long offset, byte[] b)Reads a number of bytes from the RRD file on the diskprotected voidsetLength(long length)Sets length of the underlying RRD file.protected voidwrite(long offset, byte[] b)Writes bytes to the underlying RRD file on the disk-
Methods inherited from class org.jrobin.core.RrdBackend
getPath, isCachingAllowed, isInstanceCreated, isReadOnly, readAll, readDouble, readDouble, readInt, readLong, readString, writeDouble, writeDouble, writeDouble, writeInt, writeLong, writeString
-
-
-
-
Field Detail
-
m_lockMode
protected RrdJRobin14FileBackend.LockMode m_lockMode
locking mode
-
m_file
protected RandomAccessFile m_file
random access file handle
-
m_fileLock
protected FileLock m_fileLock
file lock
-
-
Constructor Detail
-
RrdJRobin14FileBackend
protected RrdJRobin14FileBackend(String path, boolean readOnly, RrdJRobin14FileBackend.LockMode lockMode) throws IOException
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 otherwiselockMode- Locking mode: Exception if locked, Wait if locked, or no locks.- Throws:
IOException- Thrown in case of I/O error
-
-
Method Detail
-
close
public void close() throws IOExceptionCloses the underlying RRD file.- Overrides:
closein classRrdBackend- 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 IOExceptionWrites 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
protected void read(long offset, byte[] b) throws IOExceptionReads 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.
-
getLength
public long getLength() throws IOExceptionReturns RRD file length.- Specified by:
getLengthin classRrdBackend- Returns:
- File length.
- Throws:
IOException- Thrown in case of I/O error.
-
setLength
protected void setLength(long length) throws IOExceptionSets 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 RRD file- Throws:
IOException- Thrown in case of I/O error.
-
-