public abstract class RrdByteArrayBackendextends ByteBufferBackend
Abstract byte array based backend.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private byte[]
    The whole rrd file held in memory.

    Fields inherited from class RrdBackend

    BYTEORDER
    Modifier and Type
    Field
    Description
    protected static final ByteOrder
    All ByteBuffer usage should use this standard order.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Path to the RRD file.
  • Method Summary

    Public Methods
    Modifier and Type
    Method
    Description
    protected byte[]
    Underlying byte buffer.
    long
    Returns the number of RRD bytes in the underlying storage.
    protected void
    read(long offset, byte[] bytes)
    Read bytes from the in-memory buffer at the given offset.
    protected void
    setBuffer(byte[] buffer)
    Byte array to wrap as backend storage.
    protected void
    setLength(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, writeString
    Modifier and Type
    Method
    Description
    protected void
    Closes the underlying backend.
    protected CharBuffer
    getCharBuffer(long offset, int size)
    Extract a CharBuffer from the backend, used by readString
    protected boolean
    Check whether the buffer has been modified since the last sync.
    double
    readDouble(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 int
    readInt(long offset)
    Reads an integer value from the underlying storage at the given offset.
    protected long
    readLong(long offset)
    Reads a long value from the underlying storage at the given offset.
    protected short
    readShort(long offset)
    Reads a short value from the underlying storage at the given offset.
    protected void
    Closes the underlying backend.
    protected void
    Set the byte buffer to use for backing storage.
    protected void
    write(long offset, byte[] b)
    Writes bytes to the underlying RRD file on the disk
    protected void
    writeDouble(long offset, double value)
    Writes a double value to the underlying storage at the given offset.
    protected void
    writeDouble(long offset, double[] values)
    Writes an array of double values to the underlying storage at the given offset.
    protected void
    writeDouble(long offset, double value, int count)
    Writes multiple copies of a double value to the underlying storage at the given offset.
    protected void
    writeInt(long offset, int value)
    Writes an integer value to the underlying storage at the given offset.
    protected void
    writeLong(long offset, long value)
    Writes a long value to the underlying storage at the given offset.
    protected void
    writeShort(long offset, short value)
    Writes a short value to the underlying storage at the given offset.
    protected void
    writeString(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, writeString
    Modifier and Type
    Method
    Description
    (package private) void
    Set the factory and reference for this backend.
    Get the factory for this backend.
    Returns path to the storage.
    Return the URI associated to this backend, using the factory to generate it from the path.
    protected boolean
    This method suggests the caching policy to the Rrd4j frontend (high-level) classes.
    (package private) static boolean
    Checks if a backend instance has been created.
    final byte[]
    Reads all RRD bytes from the underlying storage.
    protected final String
    readString(long offset)
    Reads a string from the underlying storage at the given offset.
    protected final void
    writeString(long offset, String value)
    Writes a string to the underlying storage at the given offset.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • buffer

      private byte[] buffer
      The whole rrd file held in memory.
  • Constructor Details

    • RrdByteArrayBackend

      protected RrdByteArrayBackend(String path)
      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

      protected void read(long offset, byte[] bytes) throws IOException
      Read bytes from the in-memory buffer at the given offset.
      Overrides:
      read in class ByteBufferBackend
      Parameters:
      offset - starting position in the buffer
      bytes - array to receive the data
      Throws:
      IOException - if the read fails
      IllegalArgumentException - if offset exceeds buffer length
    • getLength

      public long getLength()
      Returns the number of RRD bytes in the underlying storage.
      Specified by:
      getLength in class RrdBackend
      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:
      setLength in class RrdBackend
      Parameters:
      length - Length of the underlying RRD storage in bytes.