Class RrdNioBackend

All Implemented Interfaces:
RrdFileBackend

public class RrdNioBackend extends ByteBufferBackend implements RrdFileBackend
Backend which is used to store RRD data to ordinary disk files using java.nio.* package. This is the default backend engine.
  • Constructor Details

    • RrdNioBackend

      protected RrdNioBackend(String path, boolean readOnly, RrdSyncThreadPool threadPool, int syncPeriod) throws IOException
      Creates RrdFileBackend object for the given file path, backed by java.nio.* classes.
      Parameters:
      path - Path to a file
      readOnly - True, if file should be open in a read-only mode. False otherwise
      threadPool - a RrdSyncThreadPool object, it can be null.
      syncPeriod - See RrdNioBackendFactory.setSyncPeriod(int) for explanation
      Throws:
      IOException - Thrown in case of I/O error
  • Method Details

    • setLength

      protected void setLength(long newLength) 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:
      newLength - Length of the underlying RRD storage in bytes.
      Throws:
      IllegalArgumentException - if the length is bigger that the possible mapping position (2GiB).
      IOException - Thrown in case of I/O error.
    • close

      public void close() throws IOException
      Closes the underlying RRD file.
      Overrides:
      close in class ByteBufferBackend
      Throws:
      IOException - Thrown in case of I/O error.
    • sync

      protected void sync()
      This method forces all data cached in memory but not yet stored in the file, to be stored in it.
    • getLength

      public long getLength() throws IOException
      Description copied from class: RrdBackend
      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.
    • getCanonicalPath

      public String getCanonicalPath() throws IOException
      Description copied from interface: RrdFileBackend
      Returns canonical path to the file on the disk.
      Specified by:
      getCanonicalPath in interface RrdFileBackend
      Returns:
      Canonical file path
      Throws:
      IOException - Thrown in case of I/O error