Interface Storage
-
- All Superinterfaces:
AutoCloseable,Closeable
- All Known Implementing Classes:
CASStorage,JDBCStorage,JEStorage,PDBStorage
public interface Storage extends Closeable
This interface abstracts the underlying storage engine, isolating the pluggable backend generic code from a particular storage engine implementation.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclose()voidcreateBackup(BackupConfig backupConfig)Creates a backup for this storage.StorageStatusgetStorageStatus()Returns the current status of the storage.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> readOperation)Executes a read operation.voidremoveBackup(BackupDirectory backupDirectory, String backupID)Removes a backup for this storage.voidremoveStorageFiles()Remove all files for a backend of this storage.voidrestoreBackup(RestoreConfig restoreConfig)Restores a backup for this storage.ImporterstartImport()Starts the import operation.booleansupportsBackupAndRestore()Returnstrueif this storage supports backup and restore.voidwrite(WriteOperation writeOperation)Executes a write operation.
-
-
-
Method Detail
-
startImport
Importer startImport() throws ConfigException, StorageRuntimeException
Starts the import operation.- 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
-
open
void open(AccessMode accessMode) throws Exception
Opens the storage engine to allow executing operations on it.- Parameters:
accessMode- Specify the access mode to this storage.- Throws:
NullPointerException- if accessMode is null.Exception- if a problem occurs with the underlying storage engine- See Also:
to release all resources once import is finished
-
read
<T> T read(ReadOperation<T> readOperation) throws Exception
Executes a read operation. In case of a read operation rollback, implementations must propagate the failure to the caller rather than replay the operation: unlikeWriteOperation, aReadOperationis not required to be idempotent, and several of them are not - they write to a stream, print, or accumulate state that a second attempt would double.- Type Parameters:
T- type of the value returned- Parameters:
readOperation- the read operation to execute- Returns:
- the value read by the read operation
- Throws:
Exception- if a problem occurs with the underlying storage engine
-
write
void write(WriteOperation writeOperation) throws Exception
Executes a write operation. In case of a write operation rollback, implementations may replay the write operation rather than propagate the failure: aWriteOperationis required to be idempotent for exactly that reason. A replay may be bounded - by a number of attempts, by a window of time, or by both - so that a conflict which does not clear reaches the caller, or may go on for as long as the conflict lasts, the way a writer of a lock based engine waits for a lock; an engine which resolves every conflict by a rollback should bound it by time only, since a healthy write under concurrent load loses several in a row. The pluggable backend holds locks across this method, up to the exclusive lock of an entry container, and every thread waiting on one of those locks waits for as long as this method does.A caller that mutates state around this method must handle that bound being spent. Removing an entry from an in-memory map before the write so that a replay still finds the work to do, or reading configuration back out of the operation once it returns, both assume the write is applied; when it is not, this method throws with that state already changed and the transaction not applied, and the caller is the only place that can reconcile the two.
- Parameters:
writeOperation- the write operation to execute- Throws:
Exception- if a problem occurs with the underlying storage engine, including a conflict that outlasted the replays the implementation makes
-
removeStorageFiles
void removeStorageFiles() throws StorageRuntimeExceptionRemove all files for a backend of this storage.- Throws:
StorageRuntimeException- if removal fails
-
getStorageStatus
StorageStatus getStorageStatus()
Returns the current status of the storage.- Returns:
- the current status of the storage
-
supportsBackupAndRestore
boolean supportsBackupAndRestore()
Returnstrueif this storage supports backup and restore.- Returns:
trueif this storage supports backup and restore.
-
createBackup
void createBackup(BackupConfig backupConfig) throws DirectoryException
Creates a backup for this storage.- Parameters:
backupConfig- The configuration to use when performing the backup.- Throws:
DirectoryException- If a Directory Server error occurs.
-
removeBackup
void removeBackup(BackupDirectory backupDirectory, String backupID) throws DirectoryException
Removes a backup for this storage.- Parameters:
backupDirectory- The backup directory structure with which the specified backup is associated.backupID- The backup ID for the backup to be removed.- Throws:
DirectoryException- If it is not possible to remove the specified backup.
-
restoreBackup
void restoreBackup(RestoreConfig restoreConfig) throws DirectoryException
Restores a backup for this storage.- Parameters:
restoreConfig- The configuration to use when performing the restore.- Throws:
DirectoryException- If a Directory Server error occurs.
-
listTrees
Set<TreeName> listTrees()
Lists the trees that exist in this storage.- Returns:
- a set of
TreeNames representing the trees that exist in this storage
-
close
void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
-