public final class JEStorage extends Object implements Storage, Backupable, ConfigurationChangeListener<JeBackendCfg>, DiskSpaceMonitorHandler
Storage
engine.Constructor and Description |
---|
JEStorage(JeBackendCfg cfg,
ServerContext serverContext)
Creates a new JE storage with the provided configuration.
|
Modifier and Type | Method and Description |
---|---|
void |
afterRestore(Path restoreDirectory,
Path saveDirectory)
Called after the restore operation has finished successfully.
|
ConfigChangeResult |
applyConfigurationChange(JeBackendCfg cfg)
Applies the configuration changes to this change listener.
|
Path |
beforeRestore()
Called before the restore operation begins.
|
void |
close() |
void |
createBackup(BackupConfig backupConfig)
Creates a backup for this storage.
|
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.
|
File |
getDirectory()
Returns the directory which acts as the root of all files to backup and restore.
|
ListIterator<Path> |
getFilesToBackup()
Returns the files to backup.
|
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.
|
boolean |
isDirectRestore()
Indicates if restore is done directly in the restore directory.
|
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 |
removeBackup(BackupDirectory backupDirectory,
String backupID)
Removes a backup for this storage.
|
void |
removeStorageFiles()
Remove all files for a backend of this storage.
|
void |
restoreBackup(RestoreConfig restoreConfig)
Restores a backup for this storage.
|
Importer |
startImport()
Starts the import operation.
|
boolean |
supportsBackupAndRestore()
Returns
true if this storage supports backup and restore. |
void |
write(WriteOperation operation)
Executes a write operation.
|
public JEStorage(JeBackendCfg cfg, ServerContext serverContext)
cfg
- The configuration.serverContext
- This server instance contextpublic void close()
public void open(AccessMode accessMode) throws ConfigException, StorageRuntimeException
Storage
open
in interface Storage
accessMode
- Specify the access mode to this storage.ConfigException
StorageRuntimeException
to release all resources once import is finished
public <T> T read(ReadOperation<T> operation) throws Exception
Storage
public Importer startImport() throws ConfigException, StorageRuntimeException
Storage
startImport
in interface Storage
ConfigException
- if there is a problem with the configurationStorageRuntimeException
- if a problem occurs with the underlying storage engineto release all resources once import is finished
public void write(WriteOperation operation) throws Exception
Storage
public boolean supportsBackupAndRestore()
Storage
true
if this storage supports backup and restore.supportsBackupAndRestore
in interface Storage
true
if this storage supports backup and restore.public File getDirectory()
Backupable
getDirectory
in interface Backupable
public ListIterator<Path> getFilesToBackup() throws LdapException
Backupable
getFilesToBackup
in interface Backupable
null
LdapException
- If an error occurs.public Path beforeRestore()
Backupable
In case of direct restore, the backupable entity should take any action to save a copy of existing data before restore operation. Saving includes removing the existing data and copying it in a save directory.
beforeRestore
in interface Backupable
null
if not applicable.public boolean isDirectRestore()
Backupable
isDirectRestore
in interface Backupable
true
if restore is done directly in the restore directory provided by getDirectory()
method, or false
if restore is done in a temporary directory.public void afterRestore(Path restoreDirectory, Path saveDirectory) throws LdapException
Backupable
For direct restore, the backupable entity can safely discard the saved copy. For indirect restore, the backupable entity should switch the restored directory to the final restore directory.
afterRestore
in interface Backupable
restoreDirectory
- The directory in which files have actually been restored. It is never null
.saveDirectory
- The directory in which current files have been saved. It may be null
if
beforeRestore()
returned null
.LdapException
- If an error occurs.public void createBackup(BackupConfig backupConfig) throws LdapException
Storage
createBackup
in interface Storage
backupConfig
- The configuration to use when performing the backup.LdapException
- If a Directory Server error occurs.public void removeBackup(BackupDirectory backupDirectory, String backupID) throws LdapException
Storage
removeBackup
in interface Storage
backupDirectory
- The backup directory structure with which the specified backup is associated.backupID
- The backup ID for the backup to be removed.LdapException
- If it is not possible to remove the specified backup.public void restoreBackup(RestoreConfig restoreConfig) throws LdapException
Storage
restoreBackup
in interface Storage
restoreConfig
- The configuration to use when performing the restore.LdapException
- If a Directory Server error occurs.public Set<TreeName> listTrees()
Storage
public boolean isConfigurationChangeAcceptable(JeBackendCfg newCfg, List<LocalizableMessage> unacceptableReasons)
ConfigurationChangeListener
isConfigurationChangeAcceptable
in interface ConfigurationChangeListener<JeBackendCfg>
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.true
if the proposed change is acceptable,
or false
if it is not.public ConfigChangeResult applyConfigurationChange(JeBackendCfg cfg)
ConfigurationChangeListener
applyConfigurationChange
in interface ConfigurationChangeListener<JeBackendCfg>
cfg
- The new configuration containing the changes.public void removeStorageFiles() throws StorageRuntimeException
Storage
removeStorageFiles
in interface Storage
StorageRuntimeException
- if removal failspublic StorageStatus getStorageStatus()
Storage
getStorageStatus
in interface Storage
public void diskFullThresholdReached(File directory, long thresholdInBytes)
DiskSpaceMonitorHandler
diskFullThresholdReached
in interface DiskSpaceMonitorHandler
directory
- the directory for which the threshold has been triggeredthresholdInBytes
- the threshold value in bytespublic void diskLowThresholdReached(File directory, long thresholdInBytes)
DiskSpaceMonitorHandler
diskLowThresholdReached
in interface DiskSpaceMonitorHandler
directory
- the directory for which the threshold has been triggeredthresholdInBytes
- the threshold value in bytespublic void diskSpaceRestored(File directory, long lowThresholdInBytes, long fullThresholdInBytes)
DiskSpaceMonitorHandler
diskSpaceRestored
in interface DiskSpaceMonitorHandler
directory
- the directory for which the threshold has been triggeredTODOlowThresholdInBytes
- the low threshold value in bytesfullThresholdInBytes
- the full threshold value in bytesCopyright 2010-2022 ForgeRock AS.