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 theStorageengine.
-
-
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 ConfigChangeResultapplyConfigurationChange(JeBackendCfg cfg)Applies the configuration changes to this change listener.voidbeforeBackup()Performs any necessary processing before a backup is performed.voidclose()voiddiskFullThresholdReached(File directory, long thresholdInBytes)Notifies that the registered "full" threshold have been reached.voiddiskLowThresholdReached(File directory, long thresholdInBytes)Notifies that the registered "low" threshold have been reached.voiddiskSpaceRestored(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.StringgetBackendID()Returns the backend name.PathgetDirectory()Returns the directory containing all the backend files to be backed up.StorageStatusgetStorageStatus()Returns the current status of the storage.booleanisConfigurationChangeAcceptable(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.voidopen(AccessMode accessMode)Opens the storage engine to allow executing operations on it.<T> Tread(ReadOperation<T> operation)Executes a read operation.voidremoveStorageFiles()Remove all files for a backend of this storage.ImporterstartImport()Starts the import operation.voidwrite(WriteOperation operation)Executes a write operation.voidwrite(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:StorageOpens the storage engine to allow executing operations on it.- Specified by:
openin interfaceStorage- Parameters:
accessMode- Specify the access mode to this storage.- Throws:
ConfigExceptionStorageRuntimeException- See Also:
to release all resources once import is finished
-
read
public <T> T read(ReadOperation<T> operation) throws Exception
Description copied from interface:StorageExecutes 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:StorageStarts the import operation.- Specified by:
startImportin 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:StorageExecutes 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:StorageExecutes 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:BackupableReturns the directory containing all the backend files to be backed up.- Specified by:
getDirectoryin interfaceBackupable- Returns:
- the directory containing all the backend files to be backed up.
-
getBackendID
public String getBackendID()
Description copied from interface:BackupableReturns the backend name.- Specified by:
getBackendIDin 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:
getBackendFilesin 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:BackupablePerforms 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:
beforeBackupin interfaceBackupable
-
listTrees
public Set<TreeName> listTrees()
Description copied from interface:StorageLists the trees that exist in this storage.
-
isConfigurationChangeAcceptable
public boolean isConfigurationChangeAcceptable(JeBackendCfg newCfg, List<LocalizableMessage> unacceptableReasons)
Description copied from interface:ConfigurationChangeListenerIndicates whether the proposed change to the configuration is acceptable to this change listener.- Specified by:
isConfigurationChangeAcceptablein 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
trueif the proposed change is acceptable, orfalseif it is not.
-
applyConfigurationChange
public ConfigChangeResult applyConfigurationChange(JeBackendCfg cfg)
Description copied from interface:ConfigurationChangeListenerApplies the configuration changes to this change listener.- Specified by:
applyConfigurationChangein 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 StorageRuntimeExceptionDescription copied from interface:StorageRemove all files for a backend of this storage.- Specified by:
removeStorageFilesin interfaceStorage- Throws:
StorageRuntimeException- if removal fails
-
getStorageStatus
public StorageStatus getStorageStatus()
Description copied from interface:StorageReturns the current status of the storage.- Specified by:
getStorageStatusin interfaceStorage- Returns:
- the current status of the storage
-
diskFullThresholdReached
public void diskFullThresholdReached(File directory, long thresholdInBytes)
Description copied from interface:DiskSpaceMonitorHandlerNotifies that the registered "full" threshold have been reached.- Specified by:
diskFullThresholdReachedin 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:DiskSpaceMonitorHandlerNotifies that the registered "low" threshold have been reached.- Specified by:
diskLowThresholdReachedin 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:DiskSpaceMonitorHandlerNotifies that the free disk space is now above both "low" and "full" thresholds.- Specified by:
diskSpaceRestoredin interfaceDiskSpaceMonitorHandler- Parameters:
directory- the directory for which the threshold has been triggeredTODOlowThresholdInBytes- the low threshold value in bytesfullThresholdInBytes- the full threshold value in bytes
-
-