java.lang.Object
org.rrd4j.core.RrdBackend
org.rrd4j.core.RrdRandomAccessFileBackend
org.rrd4j.core.RrdSafeFileBackend
- All Implemented Interfaces:
RrdFileBackend
Backend which is used to store RRD data to ordinary files on the disk, using locking. This backend is SAFE: it locks the underlying RRD file during update/fetch operations, and caches only static parts of a RRD file in memory. Therefore, this backend is safe to be used when RRD files should be shared between several JVMs at the same time. However, this backend is a little bit slow since it does not use fast java.nio.* package (it's still based on the RandomAccessFile class).
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classInternal counters for tracking file locking operations.Field Summary
Fields inherited from class RrdRandomAccessFileBackend
rafileFields inherited from class RrdBackend
BYTEORDERModifier and TypeFieldDescriptionprotected static final ByteOrderAllByteBufferusage should use this standard order.Constructor Summary
ConstructorsConstructorDescriptionRrdSafeFileBackend(String path, long lockWaitTime, long lockRetryPeriod) Creates RrdFileBackend object for the given file path, backed by RandomAccessFile object.Method Summary
Methods inherited from class RrdRandomAccessFileBackend
getCanonicalPath, getLength, read, setLength, writeModifier and TypeMethodDescriptionReturns canonical path to the file on the disk.longReturns 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 RrdBackend
done, getCharBuffer, getFactory, getPath, getUri, isCachingAllowed, isInstanceCreated, readAll, readDouble, readDouble, readInt, readLong, readShort, readString, rrdClose, writeDouble, writeDouble, writeDouble, writeInt, writeLong, writeShort, writeString, writeStringModifier and TypeMethodDescription(package private) voiddone(RrdBackendFactory factory, PhantomReference<RrdDb> ref) Set the factory and reference for this backend.protected CharBuffergetCharBuffer(long offset, int size) Extract a CharBuffer from the backend, used by readStringGet the factory for this backend.getPath()Returns path to the storage.getUri()Return the URI associated to this backend, using the factory to generate it from the path.protected booleanThis method suggests the caching policy to the Rrd4j frontend (high-level) classes.(package private) static booleanChecks if a backend instance has been created.final byte[]readAll()Reads all RRD bytes from the underlying storage.protected doublereadDouble(long offset) Reads a double value from the underlying storage at the given offset.protected double[]readDouble(long offset, int count) Reads an array of double values from the underlying storage at the given offset.protected intreadInt(long offset) Reads an integer value from the underlying storage at the given offset.protected longreadLong(long offset) Reads a long value from the underlying storage at the given offset.protected shortreadShort(long offset) Reads a short value from the underlying storage at the given offset.protected final StringreadString(long offset) Reads a string from the underlying storage at the given offset.protected voidrrdClose()Closes the underlying backend.protected voidwriteDouble(long offset, double value) Writes a double value to the underlying storage at the given offset.protected voidwriteDouble(long offset, double[] values) Writes an array of double values to the underlying storage at the given offset.protected voidwriteDouble(long offset, double value, int count) Writes multiple copies of a double value to the underlying storage at the given offset.protected voidwriteInt(long offset, int value) Writes an integer value to the underlying storage at the given offset.protected voidwriteLong(long offset, long value) Writes a long value to the underlying storage at the given offset.protected voidwriteShort(long offset, short value) Writes a short value to the underlying storage at the given offset.protected final voidwriteString(long offset, String value) Writes a string to the underlying storage at the given offset.protected voidwriteString(long offset, String value, int length) Writes a string to the underlying storage at the given offset with a fixed length.
Constructor Details
RrdSafeFileBackend
Creates RrdFileBackend object for the given file path, backed by RandomAccessFile object.- Parameters:
path- Path to a filelockWaitTime- lock waiting time in milliseconds.lockRetryPeriod- lock retry period in milliseconds.- Throws:
IOException- Thrown in case of I/O error.
Method Details
close
Releases the exclusive file lock, if held, then closes the underlying file.- Overrides:
closein classRrdRandomAccessFileBackend- Throws:
IOException- if the lock cannot be released or the file cannot be closed.
getLockInfo