public class RrdNioBackend extends ByteBufferBackend implements RrdFileBackend
This version buffers all stat files in a single temporary buffer file sequentially, keeping track of each file's offset and length, then flushes all to the mapped file in batch.
BYTEORDER| Modifier | Constructor and Description |
|---|---|
protected | RrdNioBackend(String path,
boolean readOnly,
RrdSyncThreadPool threadPool,
int syncPeriod)Creates RrdFileBackend object for the given file path, backed by java.nio.* classes. |
| Modifier and Type | Method and Description |
|---|---|
void | bufferStatFile(ByteBuffer data,
long targetFileOffset)Buffers one stat file's data into the single temp buffer file sequentially. |
void | close()Closes the underlying RRD file. |
void | flushBufferedStatFiles()Flushes all buffered stat files sequentially from the temp buffer file into their designated
positions in the mapped RRD file in one batch operation. |
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()Override sync to disable unbuffered flush. |
getCharBuffer, isDirty, read, readDouble, readDouble, readInt, readLong, readShort, rrdClose, setByteBuffer, write, writeDouble, writeDouble, writeDouble, writeInt, writeLong, writeShort, writeStringdone, getFactory, getPath, getUri, isCachingAllowed, isInstanceCreated, readAll, readString, writeStringprotected RrdNioBackend(String path, boolean readOnly, RrdSyncThreadPool threadPool, int syncPeriod) throws IOException
path - Path to a filereadOnly - True, if file should be open in read-only mode. False otherwisethreadPool - Sync thread pool; can be nullsyncPeriod - Sync period in secondsIOException - On I/O errorpublic void bufferStatFile(ByteBuffer data, long targetFileOffset) throws IOException
data - ByteBuffer containing the stat file's bytes to buffertargetFileOffset - Position in the mapped RRD file to write this stat file to on flushIOException - If writing to temp file failspublic void close()
throws IOExceptionclose in class ByteBufferBackendIOException - On I/O errorpublic void flushBufferedStatFiles()
public String getCanonicalPath()
RrdFileBackendgetCanonicalPath in interface RrdFileBackendpublic long getLength()
throws IOExceptionRrdBackendgetLength in class RrdBackendIOException - Thrown in case of I/O error.protected void setLength(long newLength)
throws IOExceptionsetLength in class RrdBackendnewLength - Length of the underlying RRD storage in bytes.IllegalArgumentException - if the length is bigger than the possible mapping position
(2GiB).IOException - Thrown in case of I/O error.protected void sync()