Class JEStorage

java.lang.Object
org.opends.server.backends.jeb.JEStorage
All Implemented Interfaces:
Closeable, AutoCloseable, ConfigurationChangeListener<JeBackendCfg>, DiskSpaceMonitorHandler, Storage, Backupable

public final class JEStorage extends Object implements Storage, ConfigurationChangeListener<JeBackendCfg>, DiskSpaceMonitorHandler
Berkeley DB Java Edition (JE for short) database implementation of the Storage engine.
  • Constructor Details

    • JEStorage

      public JEStorage(JeBackendCfg cfg, ServerContext serverContext) throws ConfigException
      Creates a new JE storage with the provided configuration.
      Parameters:
      cfg - The configuration.
      serverContext - This server instance context
      Throws:
      ConfigException - If there is an error when trying to find the server ID.
  • Method Details

    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface Storage
    • open

      public void open(AccessMode accessMode) throws ConfigException, StorageRuntimeException
      Description copied from interface: Storage
      Opens the storage engine to allow executing operations on it.
      Specified by:
      open in interface Storage
      Parameters:
      accessMode - Specify the access mode to this storage.
      Throws:
      ConfigException
      StorageRuntimeException
      See Also:
    • read

      public <T> T read(ReadOperation<T> operation) throws Exception
      Description copied from interface: Storage
      Executes a read operation. In case of a read operation rollback, implementations must ensure the read operation is retried until it succeeds.
      Specified by:
      read in interface Storage
      Type Parameters:
      T - type of the value returned
      Parameters:
      operation - the read operation to execute
      Returns:
      the value read by the read operation
      Throws:
      Exception - if a problem occurs with the underlying storage engine
    • startImport

      public Importer startImport() throws ConfigException, StorageRuntimeException
      Description copied from interface: Storage
      Starts the import operation.
      Specified by:
      startImport in interface Storage
      Returns:
      a new Importer object which must be closed to release all resources
      Throws:
      ConfigException - if there is a problem with the configuration
      StorageRuntimeException - if a problem occurs with the underlying storage engine
      See Also:
    • write

      public void write(WriteOperation operation) throws Exception
      Description copied from interface: Storage
      Executes a write operation. In case of a write operation rollback, implementations must ensure the write operation is retried until it succeeds.
      Specified by:
      write in interface Storage
      Parameters:
      operation - the write operation to execute
      Throws:
      Exception - if a problem occurs with the underlying storage engine
    • write

      public void write(WriteOperation operation, WriteableTransaction.WriteTransactionOption option) throws Exception
      Description copied from interface: Storage
      Executes a write operation. In case of a write operation rollback, implementations must ensure the write operation is retried until it succeeds.
      Specified by:
      write in interface Storage
      Parameters:
      operation - the write operation to execute
      option - the option to apply to this transaction
      Throws:
      Exception - if a problem occurs with the underlying storage engine
    • getDirectory

      public Path getDirectory()
      Description copied from interface: Backupable
      Returns the directory containing all the backend files to be backed up.
      Specified by:
      getDirectory in interface Backupable
      Returns:
      the directory containing all the backend files to be backed up.
    • getBackendID

      public String getBackendID()
      Description copied from interface: Backupable
      Returns the backend name.
      Specified by:
      getBackendID in interface Backupable
      Returns:
      the backend name.
    • getBackendFiles

      public BackupManager.CountedIterator<BackendFile> getBackendFiles() throws IOException
      Returns an iterator that goes over all the log files, including files created after this method is called. The iterator may return files that have been deleted, such files should be ignored during iteration.

      A file fingerprint is calculated just before the file is sent to the backup storage , this means that, by the time the last byte of a file is sent to a backup storage, the fingerprint may be inaccurate. At worse this will cause two identical files to be stored twice in a backup storage, consider the following as an example: the Computed fingerprint is serverId_appData_100, the actual fingerprint is serverId_appData_150. It is impossible for the backup storage to already have a file with fingerprint serverId_appData_150 because files are append only.

      • The backup storage already contains a file with fingerprint serverId_appData_100: the backup reuses that file and the last 50 bytes are not backed up.
      • The backup storage does not contain a file with fingerprint serverId_appData_100: the file is transferred to the backup storage with fingerprint serverId_appData_100 but actual fingerprint is serverId_appData_150.

        During the next backup:

      • The file has not changed: computed fingerprint is serverId_appData_150, the backup storage does not have any record of a file with fingerprint serverId_appData_150, the file is stored again in the backup storage even though it was already stored during the last backup.
      • The file has changed: computed fingerprint is serverId_appData_200, the new file is sent to the backup storage.
      Specified by:
      getBackendFiles in interface Backupable
      Returns:
      A backend file iterator.
      Throws:
      IOException - If there is an error when trying to find the backend files.
    • beforeBackup

      public void beforeBackup()
      Description copied from interface: Backupable
      Performs any necessary processing before a backup is performed. For example, this can take a shared lock or flush out a memory cache to backend files or delete stale data files.
      Specified by:
      beforeBackup in interface Backupable
    • listTrees

      public Set<TreeName> listTrees()
      Description copied from interface: Storage
      Lists the trees that exist in this storage.
      Specified by:
      listTrees in interface Storage
      Returns:
      a set of TreeNames representing the trees that exist in this storage
    • isConfigurationChangeAcceptable

      public boolean isConfigurationChangeAcceptable(JeBackendCfg newCfg, List<LocalizableMessage> unacceptableReasons)
      Description copied from interface: ConfigurationChangeListener
      Indicates whether the proposed change to the configuration is acceptable to this change listener.
      Specified by:
      isConfigurationChangeAcceptable in interface ConfigurationChangeListener<JeBackendCfg>
      Parameters:
      newCfg - The new configuration containing the changes.
      unacceptableReasons - A list that can be used to hold messages about why the provided configuration is not acceptable.
      Returns:
      Returns true if the proposed change is acceptable, or false if it is not.
    • applyConfigurationChange

      public ConfigChangeResult applyConfigurationChange(JeBackendCfg cfg)
      Description copied from interface: ConfigurationChangeListener
      Applies the configuration changes to this change listener.
      Specified by:
      applyConfigurationChange in interface ConfigurationChangeListener<JeBackendCfg>
      Parameters:
      cfg - The new configuration containing the changes.
      Returns:
      Returns information about the result of changing the configuration.
    • removeStorageFiles

      public void removeStorageFiles() throws StorageRuntimeException
      Description copied from interface: Storage
      Remove all files for a backend of this storage.
      Specified by:
      removeStorageFiles in interface Storage
      Throws:
      StorageRuntimeException - if removal fails
    • getStorageStatus

      public StorageStatus getStorageStatus()
      Description copied from interface: Storage
      Returns the current status of the storage.
      Specified by:
      getStorageStatus in interface Storage
      Returns:
      the current status of the storage
    • diskFullThresholdReached

      public void diskFullThresholdReached(File directory, long thresholdInBytes)
      Description copied from interface: DiskSpaceMonitorHandler
      Notifies that the registered "full" threshold have been reached.
      Specified by:
      diskFullThresholdReached in interface DiskSpaceMonitorHandler
      Parameters:
      directory - the directory for which the threshold has been triggered
      thresholdInBytes - the threshold value in bytes
    • diskLowThresholdReached

      public void diskLowThresholdReached(File directory, long thresholdInBytes)
      Description copied from interface: DiskSpaceMonitorHandler
      Notifies that the registered "low" threshold have been reached.
      Specified by:
      diskLowThresholdReached in interface DiskSpaceMonitorHandler
      Parameters:
      directory - the directory for which the threshold has been triggered
      thresholdInBytes - the threshold value in bytes
    • diskSpaceRestored

      public void diskSpaceRestored(File directory, long lowThresholdInBytes, long fullThresholdInBytes)
      Description copied from interface: DiskSpaceMonitorHandler
      Notifies that the free disk space is now above both "low" and "full" thresholds.
      Specified by:
      diskSpaceRestored in interface DiskSpaceMonitorHandler
      Parameters:
      directory - the directory for which the threshold has been triggeredTODO
      lowThresholdInBytes - the low threshold value in bytes
      fullThresholdInBytes - the full threshold value in bytes