Class RrdRandomAccessFileBackend

  • All Implemented Interfaces:
    RrdFileBackend
    Direct Known Subclasses:
    RrdSafeFileBackend

    public class RrdRandomAccessFileBackend
    extends RrdBackend
    implements RrdFileBackend
    Backend which is used to store RRD data to ordinary files on the disk. This was the default factory before 1.4.0 version. This backend is based on the RandomAccessFile class (java.io.* package).
    • Constructor Detail

      • RrdRandomAccessFileBackend

        protected RrdRandomAccessFileBackend​(String path,
                                             boolean readOnly)
                                      throws IOException
        Creates RrdFileBackend object for the given file path, backed by RandomAccessFile object.
        Parameters:
        path - Path to a file
        readOnly - True, if file should be open in a read-only mode. False otherwise
        Throws:
        IOException - Thrown in case of I/O error
    • Method Detail

      • write

        protected void write​(long offset,
                             byte[] b)
                      throws IOException
        Writes bytes to the underlying RRD file on the disk
        Specified by:
        write in class RrdBackend
        Parameters:
        offset - Starting file offset
        b - Bytes to be written.
        Throws:
        IOException - Thrown in case of I/O error
      • read

        public void read​(long offset,
                         byte[] b)
                  throws IOException
        Reads a number of bytes from the RRD file on the disk
        Specified by:
        read in class RrdBackend
        Parameters:
        offset - Starting file offset
        b - Buffer which receives bytes read from the file.
        Throws:
        IOException - Thrown in case of I/O error.
      • getLength

        public long getLength()
                       throws IOException
        Returns the number of RRD bytes in the underlying storage.
        Specified by:
        getLength in class RrdBackend
        Returns:
        Number of RRD bytes in the storage.
        Throws:
        IOException - Thrown in case of I/O error.
      • setLength

        protected void setLength​(long length)
                          throws IOException
        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 class RrdBackend
        Parameters:
        length - Length of the underlying RRD storage in bytes.
        Throws:
        IOException - Thrown in case of I/O error.