public class BackendImpl extends Backend<LocalDBBackendCfg> implements ConfigurationChangeListener<LocalDBBackendCfg>, AlertGenerator, DiskSpaceMonitorHandler, Backupable
Backend.BackendOperation
Constructor and Description |
---|
BackendImpl() |
Modifier and Type | Method and Description |
---|---|
void |
addEntry(Entry entry,
AddOperation addOperation)
Adds the provided entry to this backend.
|
void |
afterRestore(Path restoreDirectory,
Path saveDirectory)
Called after the restore operation has finished successfully.
|
ConfigChangeResult |
applyConfigurationChange(LocalDBBackendCfg newCfg)
Applies the configuration changes to this change listener.
|
Path |
beforeRestore()
Called before the restore operation begins.
|
void |
clearBackend()
Clears all the entries from the backend.
|
void |
closeBackend()
Performs any necessary work to finally close this backend, particularly
closing any underlying databases or connections and deregistering
any suffixes that it manages with the Directory Server.
|
void |
configureBackend(LocalDBBackendCfg cfg,
ServerContext serverContext)
Configure this backend based on the information in the provided configuration.
|
void |
createBackup(BackupConfig backupConfig)
Creates a backup of the contents of this backend in a form that may be restored at a later date
if necessary.
|
void |
deleteEntry(DN entryDN,
DeleteOperation deleteOperation)
Removes the specified entry from this backend.
|
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.
|
void |
exportLDIF(LDIFExportConfig exportConfig)
Exports the contents of this backend to LDIF.
|
Map<String,String> |
getAlerts()
Retrieves information about the set of alerts that this generator
may produce.
|
DN[] |
getBaseDNs()
Retrieves the set of base-level DNs that may be used within this
backend.
|
String |
getClassName()
Retrieves the fully-qualified name of the Java class for this
alert generator implementation.
|
DN |
getComponentEntryDN()
Retrieves the DN of the configuration entry with which this alert
generator is associated.
|
File |
getDirectory()
Returns the directory which acts as the root of all files to backup and restore.
|
Entry |
getEntry(DN entryDN)
Retrieves the requested entry from this backend.
|
long |
getEntryCount()
Retrieves the total number of entries contained in this backend,
if that information is available.
|
ListIterator<Path> |
getFilesToBackup()
Returns the files to backup.
|
long |
getNumberOfChildren(DN parentDN)
Retrieves the number of subordinates immediately below the requested entry.
|
long |
getNumberOfEntriesInBaseDN(DN baseDN)
Retrieves the number of entries for the specified base DN including all entries from the requested entry to the
lowest level in the tree.
|
RootContainer |
getReadOnlyRootContainer()
Returns a new read-only handle to the JE root container for this backend.
|
RootContainer |
getRootContainer()
Returns a handle to the JE root container currently used by this backend.
|
Set<String> |
getSupportedControls()
Retrieves the OIDs of the controls that may be supported by this
backend.
|
Set<String> |
getSupportedFeatures()
Retrieves the OIDs of the features that may be supported by this
backend.
|
org.forgerock.opendj.ldap.ConditionResult |
hasSubordinates(DN entryDN)
Indicates whether the requested entry has any subordinates.
|
LDIFImportResult |
importLDIF(LDIFImportConfig importConfig,
ServerContext serverContext)
Imports information from an LDIF file into this backend.
|
boolean |
isConfigurationAcceptable(LocalDBBackendCfg config,
List<LocalizableMessage> unacceptableReasons,
ServerContext serverContext)
Indicates whether the provided configuration is acceptable for
this backend.
|
boolean |
isConfigurationChangeAcceptable(LocalDBBackendCfg cfg,
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.
|
boolean |
isIndexed(AttributeType attributeType,
IndexType indexType)
Indicates whether search operations which target the specified
attribute in the indicated manner would be considered indexed
in this backend.
|
void |
openBackend()
Opens this backend based on the information provided when the backend was configured.
|
void |
rebuildBackend(RebuildConfig rebuildConfig,
ServerContext serverContext)
Rebuild indexes in the backend instance.
|
void |
removeBackup(BackupDirectory backupDirectory,
String backupID)
Removes the specified backup if it is possible to do so.
|
void |
renameEntry(DN currentDN,
Entry entry,
ModifyDNOperation modifyDNOperation)
Moves and/or renames the provided entry in this backend, altering
any subordinate entries as necessary.
|
void |
replaceEntry(Entry oldEntry,
Entry newEntry,
ModifyOperation modifyOperation)
Replaces the specified entry with the provided entry in this
backend.
|
void |
restoreBackup(RestoreConfig restoreConfig)
Restores a backup of the contents of this backend.
|
void |
search(SearchOperation searchOperation)
Processes the specified search in this backend.
|
boolean |
supports(Backend.BackendOperation backendOperation)
Indicates whether this backend supports the provided backend operation.
|
long |
verifyBackend(VerifyConfig verifyConfig)
Verify the integrity of the backend instance.
|
addSubordinateBackend, entryExists, finalizeBackend, getBackendID, getBackendMonitor, getParentBackend, getPersistentSearches, getSubordinateBackends, getWritabilityMode, handlesEntry, handlesEntry, isIndexed, isPrivateBackend, registerPersistentSearch, removeSubordinateBackend, setBackendID, setBackendMonitor, setParentBackend, setPrivateBackend, setWritabilityMode, supportsControl
public BackendImpl()
public void configureBackend(LocalDBBackendCfg cfg, ServerContext serverContext) throws ConfigException
configureBackend
in class Backend<LocalDBBackendCfg>
cfg
- The configuration of this backend.serverContext
- The server context for this instanceConfigException
- If there is an error in the configuration.public void openBackend() throws ConfigException, InitializationException
openBackend
in class Backend<LocalDBBackendCfg>
ConfigException
- If an unrecoverable problem arises while opening the backend.InitializationException
- If a problem occurs during opening that is not
related to the server configuration.Backend.configureBackend(C, org.opends.server.core.ServerContext)
public File getDirectory()
getDirectory
in interface Backupable
public void closeBackend()
It will be called as final step of finalizeBackend()
,
so subclasses might override it.
closeBackend
in class Backend<LocalDBBackendCfg>
public boolean isIndexed(AttributeType attributeType, IndexType indexType)
true
for the specified
attribute and index type.isIndexed
in class Backend<LocalDBBackendCfg>
attributeType
- The attribute type for which to make the
determination.indexType
- The index type for which to make the
determination.true
if search operations targeting the
specified attribute in the indicated manner should be
considered indexed, or false
if not.public boolean supports(Backend.BackendOperation backendOperation)
supports
in class Backend<LocalDBBackendCfg>
backendOperation
- the backend operationtrue
if this backend supports the provided backend operation, false
otherwise.public Set<String> getSupportedFeatures()
getSupportedFeatures
in class Backend<LocalDBBackendCfg>
public Set<String> getSupportedControls()
getSupportedControls
in class Backend<LocalDBBackendCfg>
public DN[] getBaseDNs()
getBaseDNs
in class Backend<LocalDBBackendCfg>
public long getEntryCount()
getEntryCount
in class Backend<LocalDBBackendCfg>
public org.forgerock.opendj.ldap.ConditionResult hasSubordinates(DN entryDN) throws DirectoryException
hasSubordinates
in class Backend<LocalDBBackendCfg>
entryDN
- The distinguished name of the entry.ConditionResult.TRUE
if the entry has one or more
subordinates or ConditionResult.FALSE
otherwise
or ConditionResult.UNDEFINED
if it can not be
determined.DirectoryException
- If a problem occurs while trying to
retrieve the entry.public long getNumberOfEntriesInBaseDN(DN baseDN) throws DirectoryException
getNumberOfEntriesInBaseDN
in class Backend<LocalDBBackendCfg>
baseDN
- The base distinguished name.DirectoryException
- If baseDN isn't a base dn managed by this backend or if a problem occurs while trying to retrieve the
entry.public long getNumberOfChildren(DN parentDN) throws DirectoryException
getNumberOfChildren
in class Backend<LocalDBBackendCfg>
parentDN
- The distinguished name of the parent.DirectoryException
- If baseDN isn't a base dn managed by this backend or if a problem occurs while trying to retrieve the
entry.public Entry getEntry(DN entryDN) throws DirectoryException
getEntry
in class Backend<LocalDBBackendCfg>
entryDN
- The distinguished name of the entry to retrieve.null
if the entry does not exist.DirectoryException
- If a problem occurs while trying to retrieve the entry.public void addEntry(Entry entry, AddOperation addOperation) throws DirectoryException, CanceledOperationException
addEntry
in class Backend<LocalDBBackendCfg>
entry
- The entry to add to this backend.addOperation
- The add operation with which the new entry
is associated. This may be null
for adds performed internally.DirectoryException
- If a problem occurs while trying to
add the entry.CanceledOperationException
- If this backend noticed and
reacted to a request to
cancel or abandon the add
operation.public void deleteEntry(DN entryDN, DeleteOperation deleteOperation) throws DirectoryException, CanceledOperationException
deleteEntry
in class Backend<LocalDBBackendCfg>
entryDN
- The DN of the entry to remove from this
backend.deleteOperation
- The delete operation with which this
action is associated. This may be
null
for deletes performed
internally.DirectoryException
- If a problem occurs while trying to
remove the entry.CanceledOperationException
- If this backend noticed and
reacted to a request to
cancel or abandon the
delete operation.public void replaceEntry(Entry oldEntry, Entry newEntry, ModifyOperation modifyOperation) throws DirectoryException, CanceledOperationException
replaceEntry
in class Backend<LocalDBBackendCfg>
oldEntry
- The original entry that is being replaced.newEntry
- The new entry to use in place of the existing entry with
the same DN.modifyOperation
- The modify operation with which this action is
associated. This may be null
for modifications
performed internally.DirectoryException
- If a problem occurs while trying to replace the entry.CanceledOperationException
- If this backend noticed and reacted to a request to
cancel or abandon the modify operation.public void renameEntry(DN currentDN, Entry entry, ModifyDNOperation modifyDNOperation) throws DirectoryException, CanceledOperationException
renameEntry
in class Backend<LocalDBBackendCfg>
currentDN
- The current DN of the entry to be moved/renamed.entry
- The new content to use for the entry.modifyDNOperation
- The modify DN operation with which this action is
associated. This may be null
for modify DN
operations performed internally.DirectoryException
- If a problem occurs while trying to perform the rename.CanceledOperationException
- If this backend noticed and reacted to a request to
cancel or abandon the modify DN operation.public void search(SearchOperation searchOperation) throws DirectoryException, CanceledOperationException
SearchOperation.returnEntry
method. The caller is not
required to have any locks when calling this operation.search
in class Backend<LocalDBBackendCfg>
searchOperation
- The search operation to be processed.DirectoryException
- If a problem occurs while processing
the search.CanceledOperationException
- If this backend noticed and
reacted to a request to
cancel or abandon the
search operation.public void exportLDIF(LDIFExportConfig exportConfig) throws DirectoryException
Backend.supports(BackendOperation)
with Backend.BackendOperation.LDIF_EXPORT
returns
true
.
Note that the server will not explicitly initialize this backend before calling this method.
exportLDIF
in class Backend<LocalDBBackendCfg>
exportConfig
- The configuration to use when performing the export.DirectoryException
- If a problem occurs while performing the LDIF export.public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext) throws DirectoryException
Backend.supports(BackendOperation)
with Backend.BackendOperation.LDIF_IMPORT
returns
true
.
Note that the server will not explicitly initialize this backend before calling this method.
importLDIF
in class Backend<LocalDBBackendCfg>
importConfig
- The configuration to use when performing the import.serverContext
- The server contextDirectoryException
- If a problem occurs while performing the LDIF import.public long verifyBackend(VerifyConfig verifyConfig) throws InitializationException, ConfigException, DirectoryException
verifyBackend
in class Backend<LocalDBBackendCfg>
verifyConfig
- The verify configuration.InitializationException
- If a problem occurs during initialization that is not related to the server
configuration.ConfigException
- If an unrecoverable problem arises during initialization.DirectoryException
- If a Directory Server error occurs.public void rebuildBackend(RebuildConfig rebuildConfig, ServerContext serverContext) throws InitializationException, ConfigException, DirectoryException
rebuildBackend
in class Backend<LocalDBBackendCfg>
rebuildConfig
- The rebuild configuration.serverContext
- The server context for this instanceInitializationException
- If a problem occurs during initialization that is not related to the server
configuration.ConfigException
- If an unrecoverable problem arises during initialization.DirectoryException
- If a Directory Server error occurs.public void createBackup(BackupConfig backupConfig) throws DirectoryException
Backend.supports(BackendOperation)
with
Backend.BackendOperation.BACKUP
returns true
.
Note that the server will not explicitly initialize this backend before calling this method.
createBackup
in class Backend<LocalDBBackendCfg>
backupConfig
- The configuration to use when performing the backup.DirectoryException
- If a problem occurs while performing the backup.public void removeBackup(BackupDirectory backupDirectory, String backupID) throws DirectoryException
removeBackup
in class Backend<LocalDBBackendCfg>
backupDirectory
- The backup directory structure with
which the specified backup is
associated.backupID
- The backup ID for the backup to be
removed.DirectoryException
- If it is not possible to remove the
specified backup for some reason
(e.g., no such backup exists or
there are other backups that are
dependent upon it).public void restoreBackup(RestoreConfig restoreConfig) throws DirectoryException
Backend.supports(BackendOperation)
with Backend.BackendOperation.RESTORE
returns true
.
Note that the server will not explicitly initialize this backend before calling this method.
restoreBackup
in class Backend<LocalDBBackendCfg>
restoreConfig
- The configuration to use when performing the restore.DirectoryException
- If a problem occurs while performing the restore.public ListIterator<Path> getFilesToBackup() throws DirectoryException
getFilesToBackup
in interface Backupable
null
DirectoryException
- If an error occurs.public boolean isDirectRestore()
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 Path beforeRestore() throws DirectoryException
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.DirectoryException
- If an error occurs.public void afterRestore(Path restoreDirectory, Path saveDirectory) throws DirectoryException
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
.DirectoryException
- If an error occurs.public boolean isConfigurationAcceptable(LocalDBBackendCfg config, List<LocalizableMessage> unacceptableReasons, ServerContext serverContext)
isConfigurationAcceptable
in class Backend<LocalDBBackendCfg>
config
- The backend configuration for which
to make the determination.unacceptableReasons
- A list that may be used to hold the
reasons that the provided
configuration is not acceptable.serverContext
- this Directory Server instance's server contexttrue
if the provided configuration is acceptable
for this backend, or false
if not.public boolean isConfigurationChangeAcceptable(LocalDBBackendCfg cfg, List<LocalizableMessage> unacceptableReasons)
isConfigurationChangeAcceptable
in interface ConfigurationChangeListener<LocalDBBackendCfg>
cfg
- 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(LocalDBBackendCfg newCfg)
applyConfigurationChange
in interface ConfigurationChangeListener<LocalDBBackendCfg>
newCfg
- The new configuration containing the changes.public RootContainer getRootContainer()
public RootContainer getReadOnlyRootContainer() throws ConfigException, InitializationException
ConfigException
- If an unrecoverable problem arises during
initialization.InitializationException
- If a problem occurs during initialization
that is not related to the server
configuration.public void clearBackend() throws ConfigException, JebException
ConfigException
- If an unrecoverable problem arises in the
process of performing the initialization.JebException
- If an error occurs while removing the data.public String getClassName()
getClassName
in interface AlertGenerator
public Map<String,String> getAlerts()
getAlerts
in interface AlertGenerator
public DN getComponentEntryDN()
getComponentEntryDN
in interface AlertGenerator
public void diskLowThresholdReached(File directory, long thresholdInBytes)
diskLowThresholdReached
in interface DiskSpaceMonitorHandler
directory
- the directory for which the threshold has been triggeredthresholdInBytes
- the threshold value in bytespublic void diskFullThresholdReached(File directory, long thresholdInBytes)
diskFullThresholdReached
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)
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-2015 ForgeRock AS. All Rights Reserved.