java.lang.Object
org.rrd4j.core.RrdBackend
org.rrd4j.core.ByteBufferBackend
org.rrd4j.core.RrdByteArrayBackend
Abstract byte array based backend.
Field Summary
FieldsFields inherited from class RrdBackend
BYTEORDERModifier and TypeFieldDescriptionprotected static final ByteOrderAllByteBufferusage should use this standard order.Constructor Summary
ConstructorsMethod Summary
Public MethodsModifier and TypeMethodDescriptionprotected byte[]Underlying byte buffer.longReturns the number of RRD bytes in the underlying storage.protected voidread(long offset, byte[] bytes) Read bytes from the in-memory buffer at the given offset.protected voidsetBuffer(byte[] buffer) Byte array to wrap as backend storage.protected voidsetLength(long length) Sets the number of bytes in the underlying RRD storage.Methods inherited from class ByteBufferBackend
close, getCharBuffer, isDirty, readDouble, readDouble, readInt, readLong, readShort, rrdClose, setByteBuffer, write, writeDouble, writeDouble, writeDouble, writeInt, writeLong, writeShort, writeStringModifier and TypeMethodDescriptionprotected voidclose()Closes the underlying backend.protected CharBuffergetCharBuffer(long offset, int size) Extract a CharBuffer from the backend, used by readStringprotected booleanisDirty()Check whether the buffer has been modified since the last sync.doublereadDouble(long offset) Reads a double value from the underlying storage at the given offset.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 voidrrdClose()Closes the underlying backend.protected voidsetByteBuffer(ByteBuffer byteBuffer) Set the byte buffer to use for backing storage.protected voidwrite(long offset, byte[] b) Writes bytes to the underlying RRD file on the diskprotected 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 voidwriteString(long offset, String value, int length) Writes a string to the underlying storage at the given offset with a fixed length.Methods inherited from class RrdBackend
done, getFactory, getPath, getUri, isCachingAllowed, isInstanceCreated, readAll, readString, writeStringModifier and TypeMethodDescription(package private) voiddone(RrdBackendFactory factory, PhantomReference<RrdDb> ref) Set the factory and reference for this backend.Get 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 final StringreadString(long offset) Reads a string from 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.
Field Details
buffer
private byte[] bufferThe whole rrd file held in memory.
Constructor Details
RrdByteArrayBackend
Path to the RRD file.- Parameters:
path- path to the RRD file
Method Details
setBuffer
protected void setBuffer(byte[] buffer) Byte array to wrap as backend storage.- Parameters:
buffer- byte array to wrap as backend storage
getBuffer
protected byte[] getBuffer()Underlying byte buffer.- Returns:
- the live buffer, not a copy
read
Read bytes from the in-memory buffer at the given offset.- Overrides:
readin classByteBufferBackend- Parameters:
offset- starting position in the bufferbytes- array to receive the data- Throws:
IOException- if the read failsIllegalArgumentException- if offset exceeds buffer length
getLength
public long getLength()Returns the number of RRD bytes in the underlying storage.- Specified by:
getLengthin classRrdBackend- Returns:
- Number of RRD bytes held in memory.
setLength
protected void setLength(long length) Sets the number of bytes in the underlying RRD storage. This method is called only once, immediately after a new RRD storage gets created.It will reserves a memory section as a RRD storage.
- Specified by:
setLengthin classRrdBackend- Parameters:
length- Length of the underlying RRD storage in bytes.