java.lang.Object
org.rrd4j.core.RrdBackendFactory
org.rrd4j.core.RrdMemoryBackendFactory
All Implemented Interfaces:
Closeable, AutoCloseable

@RrdBackendAnnotation(name="MEMORY", shouldValidateHeader=false) public class RrdMemoryBackendFactoryextends RrdBackendFactory
Factory class which creates actual RrdMemoryBackend objects. Rrd4j's support for in-memory RRDs is still experimental. You should know that all active RrdMemoryBackend objects are held in memory, each backend object stores RRD data in one big byte array. This implementation is therefore quite basic and memory hungry but runs very fast.

Calling close() on RrdDb objects does not release any memory at all (RRD data must be available for the next new RrdDb(path) call. To release allocated memory, you'll have to call delete(path) method of this class.

  • Field Details

  • Constructor Details

    • RrdMemoryBackendFactory

      public RrdMemoryBackendFactory()
      A factory holding no open backends; the map starts empty and is filled by open(String, boolean) as RRDs are opened and released by delete(String).
  • Method Details

    • open

      protected RrdBackend open(String id, boolean readOnly)
      Opens the backend serving a storage path.

      Creates RrdMemoryBackend object.

      Specified by:
      open in class RrdBackendFactory
      Parameters:
      id - the storage path, relative to this factory's root URI
      readOnly - true to open the storage for reading only, false to allow writes
      Returns:
      the backend that performs all I/O for the given storage path
    • canStore

      public boolean canStore(URI uri)
      Accepts only URIs whose scheme matches this backend's memory scheme.
      Overrides:
      canStore in class RrdBackendFactory
      Parameters:
      uri - the candidate storage URI to test against this factory
      Returns:
      false unless a subclass overrides this to recognise its own URIs
    • exists

      protected boolean exists(String id)
      Determines if a storage with the given path already exists.

      Method to determine if a memory storage with the given ID already exists.

      Specified by:
      exists in class RrdBackendFactory
      Parameters:
      id - File system path to probe for.
      Returns:
      true if a storage already exists at the given path
    • delete

      public boolean delete(String id)
      Removes the storage with the given ID from the memory.
      Parameters:
      id - Storage ID, the key this factory registered the storage under
      Returns:
      true if a storage was removed, false if the ID was unknown