All Implemented Interfaces:
Closeable, AutoCloseable

@RrdBackendAnnotation(name="SAFE", shouldValidateHeader=true, cachingAllowed=false) public class RrdSafeFileBackendFactoryextends RrdRandomAccessFileBackendFactory
Factory class which creates actual RrdSafeFileBackend objects.

Because of locking, each RrdDb can be open only once even from within the JVM. So usage of the RrdDbPool is mandatory with this backend.

  • Field Details

    • LOCK_WAIT_TIME

      public static final long LOCK_WAIT_TIME
      Default time (in milliseconds) this backend will wait for a file lock.
      See Also:
    • defaultLockWaitTime

      private static long defaultLockWaitTime
      How long a lock is retried, in ms.
    • LOCK_RETRY_PERIOD

      public static final long LOCK_RETRY_PERIOD
      Default time between two consecutive file locking attempts.
      See Also:
    • defaultLockRetryPeriod

      private static long defaultLockRetryPeriod
      Pause between lock attempts, in ms.
    • lockWaitTime

      private final long lockWaitTime
      Wait time this factory hands to its backends.
    • lockRetryPeriod

      private final long lockRetryPeriod
      Retry period this factory hands to its backends.
  • Constructor Details

    • RrdSafeFileBackendFactory

      public RrdSafeFileBackendFactory()
      Generate a factory using the default system wide lock settings
    • RrdSafeFileBackendFactory

      public RrdSafeFileBackendFactory(long lockWaitTime, long lockRetryPeriod)
      Generate a factory with custom lock settings
      Parameters:
      lockWaitTime - wait time in ms
      lockRetryPeriod - retry period in ms
  • Method Details

    • open

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

      Creates RrdFileBackend object for the given file path.

      Creates RrdSafeFileBackend object for the given file path.

      Overrides:
      open in class RrdRandomAccessFileBackendFactory
      Parameters:
      path - 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
      Throws:
      IOException - if the storage cannot be opened
    • getLockWaitTime

      public static long getLockWaitTime()
      Returns time this backend will wait for a file lock.
      Returns:
      Time (in milliseconds) this backend will wait for a file lock.
    • setLockWaitTime

      public static void setLockWaitTime(long lockWaitTime)
      Sets time this backend will wait for a file lock.
      Parameters:
      lockWaitTime - Maximum lock wait time (in milliseconds)
    • getLockRetryPeriod

      public static long getLockRetryPeriod()
      Returns time between two consecutive file locking attempts.
      Returns:
      Time (im milliseconds) between two consecutive file locking attempts.
    • setLockRetryPeriod

      public static void setLockRetryPeriod(long lockRetryPeriod)
      Sets time between two consecutive file locking attempts.
      Parameters:
      lockRetryPeriod - time (in milliseconds) between two consecutive file locking attempts.