Package org.jrobin.core
Class RrdNioBackend
- java.lang.Object
-
- org.jrobin.core.RrdBackend
-
- org.jrobin.core.RrdFileBackend
-
- org.jrobin.core.RrdNioBackend
-
public class RrdNioBackend extends RrdFileBackend
JRobin backend which is used to store RRD data to ordinary disk files by using fast java.nio.* package. This is the default backend engine since JRobin 1.4.0.
-
-
Field Summary
-
Fields inherited from class org.jrobin.core.RrdFileBackend
file
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
RrdNioBackend(String path, boolean readOnly, int syncPeriod)
Creates RrdFileBackend object for the given file path, backed by java.nio.* classes.protected
RrdNioBackend(String path, boolean readOnly, SyncManager syncManager)
Creates RrdFileBackend object for the given file path, backed by java.nio.* classes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the underlying RRD file.protected void
finalize()
protected void
read(long offset, byte[] b)
Reads a number of bytes from the RRD file on the diskprotected void
setLength(long newLength)
Sets length of the underlying RRD file.protected void
sync()
This method forces all data cached in memory but not yet stored in the file, to be stored in it.protected void
write(long offset, byte[] b)
Writes bytes to the underlying RRD file on the disk-
Methods inherited from class org.jrobin.core.RrdFileBackend
getCanonicalPath, getCanonicalPath, getLength
-
Methods inherited from class org.jrobin.core.RrdBackend
getPath, isCachingAllowed, isInstanceCreated, isReadOnly, readAll, readDouble, readDouble, readInt, readLong, readString, writeDouble, writeDouble, writeDouble, writeInt, writeLong, writeString
-
-
-
-
Constructor Detail
-
RrdNioBackend
protected RrdNioBackend(String path, boolean readOnly, int syncPeriod) throws IOException
Creates RrdFileBackend object for the given file path, backed by java.nio.* classes. This constructor will create aSyncManager
for each instance, which is very inefficient. It is recommended that you instead use theRrdNioBackend(String, boolean, SyncManager)
constructor instead.- Parameters:
path
- Path to a JRB file.readOnly
- True, if file should be open in a read-only mode. False otherwisesyncPeriod
- How often (in seconds) to sync MMAP'd RRD data to disk- Throws:
IOException
- Thrown in case of I/O error
-
RrdNioBackend
protected RrdNioBackend(String path, boolean readOnly, SyncManager syncManager) throws IOException
Creates RrdFileBackend object for the given file path, backed by java.nio.* classes.- Parameters:
path
- Path to a filereadOnly
- True, if file should be open in a read-only mode. False otherwise.syncManager
- An object for managing synchronization of NIO-backed RRDs, generally owned by the backend factory. If null, MMAP'd data will only be synchronized to disk upon unmap. Note that if the file is opened read-only, the SyncManager is ignored.unmapFile()
- Throws:
IOException
- Thrown in case of I/O error
-
-
Method Detail
-
finalize
protected void finalize() throws Throwable
-
setLength
protected void setLength(long newLength) throws IOException
Sets length of the underlying RRD file. This method is called only once, immediately after a new RRD file gets created.- Overrides:
setLength
in classRrdFileBackend
- Parameters:
newLength
- Length of the RRD file- 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- Overrides:
write
in classRrdFileBackend
- 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 IOException
Reads a number of bytes from the RRD file on the disk- Overrides:
read
in classRrdFileBackend
- Parameters:
offset
- Starting file offsetb
- Buffer which receives bytes read from the file.- Throws:
IOException
- Thrown in case of I/O error.
-
close
public void close() throws IOException
Closes the underlying RRD file.- Overrides:
close
in classRrdFileBackend
- Throws:
IOException
- Thrown in case of I/O error
-
sync
protected void sync()
This method forces all data cached in memory but not yet stored in the file, to be stored in it.
-
-