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 the
Storage
engine.-
Constructor Summary
ConstructorDescriptionJEStorage
(JeBackendCfg cfg, ServerContext serverContext) Creates a new JE storage with the provided configuration. -
Method Summary
Modifier and TypeMethodDescriptionApplies the configuration changes to this change listener.void
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.Returns an iterator that goes over all the log files, including files created after this method is called.Returns the backend name.Returns the directory containing all the backend files to be backed up.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.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
Remove all files for a backend of this storage.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 Details
-
JEStorage
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() -
open
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:
-
read
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
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:
-
write
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
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
Description copied from interface:Backupable
Returns the backend name.- Specified by:
getBackendID
in interfaceBackupable
- Returns:
- the backend name.
-
getBackendFiles
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
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
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
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
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
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
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
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
-