Package org.rrd4j.core
Class RrdNioBackend
java.lang.Object
org.rrd4j.core.RrdBackend
org.rrd4j.core.ByteBufferBackend
org.rrd4j.core.RrdNioBackend
- All Implemented Interfaces:
RrdFileBackend
public class RrdNioBackend extends ByteBufferBackend implements RrdFileBackend
Backend which is used to store RRD data to ordinary disk files
using java.nio.* package. This is the default backend engine.
-
Field Summary
-
Constructor Summary
Constructors Modifier Constructor Description protected
RrdNioBackend(String path, boolean readOnly, RrdSyncThreadPool threadPool, int syncPeriod)
Creates RrdFileBackend object for the given file path, backed by java.nio.* classes. -
Method Summary
Modifier and Type Method Description void
close()
Closes the underlying RRD file.String
getCanonicalPath()
Returns canonical path to the file on the disk.long
getLength()
Returns the number of RRD bytes in the underlying storage.protected void
setLength(long newLength)
Sets the number of bytes in the underlying RRD storage.protected void
sync()
This method forces all data cached in memory but not yet stored in the file, to be stored in it.Methods inherited from class org.rrd4j.core.ByteBufferBackend
getCharBuffer, isDirty, read, readDouble, readDouble, readInt, readLong, readShort, rrdClose, setByteBuffer, write, writeDouble, writeDouble, writeDouble, writeInt, writeLong, writeShort, writeString
Methods inherited from class org.rrd4j.core.RrdBackend
done, getFactory, getPath, getUri, isCachingAllowed, isInstanceCreated, readAll, readString, writeString
-
Constructor Details
-
RrdNioBackend
protected RrdNioBackend(String path, boolean readOnly, RrdSyncThreadPool threadPool, int syncPeriod) throws IOExceptionCreates 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 otherwisesyncPeriod
- SeeRrdNioBackendFactory.setSyncPeriod(int)
for explanationthreadPool
- aRrdSyncThreadPool
object, it can be null.- Throws:
IOException
- Thrown in case of I/O error
-
-
Method Details
-
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:
setLength
in classRrdBackend
- Parameters:
newLength
- Length of the underlying RRD storage in bytes.- Throws:
IllegalArgumentException
- if the length is bigger that the possible mapping position (2GiB).IOException
- Thrown in case of I/O error.
-
close
Closes the underlying RRD file.- Overrides:
close
in classByteBufferBackend
- 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. -
getLength
Description copied from class:RrdBackend
Returns the number of RRD bytes in the underlying storage.- Specified by:
getLength
in classRrdBackend
- Returns:
- Number of RRD bytes in the storage.
- Throws:
IOException
- Thrown in case of I/O error.
-
getCanonicalPath
Description copied from interface:RrdFileBackend
Returns canonical path to the file on the disk.- Specified by:
getCanonicalPath
in interfaceRrdFileBackend
- Returns:
- Canonical file path
- Throws:
IOException
- Thrown in case of I/O error
-