Package org.opends.server.backends.jeb
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 theStorage
engine.
-
-
Constructor Summary
Constructors Constructor Description JEStorage(JeBackendCfg cfg, ServerContext serverContext)
Creates a new JE storage with the provided configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConfigChangeResult
applyConfigurationChange(JeBackendCfg cfg)
Applies the configuration changes to this change listener.void
beforeBackup()
Performs any necessary processing before a backup is performed.void
close()
void
diskFullThresholdReached(File directory, long thresholdInBytes)
Notifies that the registered "full" threshold have been reached.void
diskLowThresholdReached(File directory, long thresholdInBytes)
Notifies that the registered "low" threshold have been reached.void
diskSpaceRestored(File directory, long lowThresholdInBytes, long fullThresholdInBytes)
Notifies that the free disk space is now above both "low" and "full" thresholds.BackupManager.CountedIterator<BackendFile>
getBackendFiles()
Returns an iterator that goes over all the log files, including files created after this method is called.String
getBackendID()
Returns the backend name.Path
getDirectory()
Returns the directory containing all the backend files to be backed up.StorageStatus
getStorageStatus()
Returns the current status of the storage.boolean
isConfigurationChangeAcceptable(JeBackendCfg newCfg, List<LocalizableMessage> unacceptableReasons)
Indicates whether the proposed change to the configuration is acceptable to this change listener.Set<TreeName>
listTrees()
Lists the trees that exist in this storage.void
open(AccessMode accessMode)
Opens the storage engine to allow executing operations on it.<T> T
read(ReadOperation<T> operation)
Executes a read operation.void
removeStorageFiles()
Remove all files for a backend of this storage.Importer
startImport()
Starts the import operation.void
write(WriteOperation operation)
Executes a write operation.void
write(WriteOperation operation, WriteableTransaction.WriteTransactionOption option)
Executes a write operation.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.opends.server.backup.Backupable
afterBackup, afterRestore, beforeRestore
-
-
-
-
Constructor Detail
-
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 Detail
-
close
public void close()
-
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 interfaceStorage
- Parameters:
accessMode
- Specify the access mode to this storage.- Throws:
ConfigException
StorageRuntimeException
- See Also:
to release all resources once import is finished
-
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.
-
startImport
public Importer startImport() throws ConfigException, StorageRuntimeException
Description copied from interface:Storage
Starts the import operation.- Specified by:
startImport
in interfaceStorage
- Returns:
- a new Importer object which must be closed to release all resources
- Throws:
ConfigException
- if there is a problem with the configurationStorageRuntimeException
- if a problem occurs with the underlying storage engine- See Also:
to release all resources once import is finished
-
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.
-
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.
-
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 interfaceBackupable
- 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 interfaceBackupable
- 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 interfaceBackupable
- 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 interfaceBackupable
-
listTrees
public Set<TreeName> listTrees()
Description copied from interface:Storage
Lists 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 interfaceConfigurationChangeListener<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, orfalse
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 interfaceConfigurationChangeListener<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 interfaceStorage
- 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 interfaceStorage
- 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 interfaceDiskSpaceMonitorHandler
- Parameters:
directory
- the directory for which the threshold has been triggeredthresholdInBytes
- 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 interfaceDiskSpaceMonitorHandler
- Parameters:
directory
- the directory for which the threshold has been triggeredthresholdInBytes
- 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 interfaceDiskSpaceMonitorHandler
- Parameters:
directory
- the directory for which the threshold has been triggeredTODOlowThresholdInBytes
- the low threshold value in bytesfullThresholdInBytes
- the full threshold value in bytes
-
-