Class TaskBackend
- java.lang.Object
-
- org.opends.server.api.Backend<C>
-
- org.opends.server.api.LocalBackend<TaskBackendCfg>
-
- org.opends.server.backends.task.TaskBackend
-
- All Implemented Interfaces:
ConfigurationChangeListener<TaskBackendCfg>,Backupable
public class TaskBackend extends LocalBackend<TaskBackendCfg> implements ConfigurationChangeListener<TaskBackendCfg>, Backupable
This class provides an implementation of a Directory Server backend that may be used to execute various kinds of administrative tasks on a one-time or recurring basis.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.opends.server.api.LocalBackend
LocalBackend.BackendOperation
-
-
Constructor Summary
Constructors Constructor Description TaskBackend()Creates a new backend with the provided information.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddEntry(Entry entry, AddOperation addOperation)Adds the provided entry to this backend.voidafterRestore(Path restoreDirectory, Path saveDirectory)Called after the restore operation has finished successfully.ConfigChangeResultapplyConfigurationChange(TaskBackendCfg configEntry)Applies the configuration changes to this change listener.PathbeforeRestore()Called before the restore operation begins.voidcloseBackend()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.voidconfigureBackend(TaskBackendCfg cfg, ServerContext serverContext)Configure this backend based on the information in the provided configuration.voidcreateBackup(BackupConfig backupConfig)Creates a backup of the contents of this backend in a form that may be restored at a later date if necessary.voiddeleteEntry(DN entryDN, DeleteOperation deleteOperation)Removes the specified entry from this backend.voidexportLDIF(LDIFExportConfig exportConfig)Exports the contents of this backend to LDIF.Set<DN>getBaseDNs()Retrieves the set of base-level DNs that may be used within this backend.DNgetConfigEntryDN()Retrieves the DN of the configuration entry for this task backend.FilegetDirectory()Returns the directory which acts as the root of all files to backup and restore.EntrygetEntry(DN entryDN)Retrieves the requested entry from this backend.longgetEntryCount()Retrieves the total number of entries contained in this backend, if that information is available.ListIterator<Path>getFilesToBackup()Returns the files to backup.StringgetNotificationSenderAddress()Retrieves the sender address that should be used for e-mail notifications of task completion.longgetNumberOfChildren(DN parentDN)Retrieves the number of subordinates immediately below the requested entry.longgetNumberOfEntriesInBaseDN(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.RecurringTaskgetRecurringTask(DN taskEntryDN)Retrieves the recurring task for the entry with the provided DN.DNgetRecurringTasksParentDN()Retrieves the DN of the entry that is the immediate parent for all recurring task information in the Directory Server.longgetRetentionTime()Retrieves the length of time in seconds that information for a task should be retained after processing on it has completed.TaskgetScheduledTask(DN taskEntryDN)Retrieves the scheduled task for the entry with the provided DN.DNgetScheduledTasksParentDN()Retrieves the DN of the entry that is the immediate parent for all scheduled task information in the Directory Server.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.StringgetTaskBackingFile()Retrieves the path to the backing file that will hold the scheduled and recurring task definitions.DNgetTaskRootDN()Retrieves the DN of the entry that is the root for all task information in the Directory Server.ConditionResulthasSubordinates(DN entryDN)Indicates whether the requested entry has any subordinates.LDIFImportResultimportLDIF(LDIFImportConfig importConfig, ServerContext sContext)Imports information from an LDIF file into this backend.booleanisConfigurationAcceptable(TaskBackendCfg config, List<org.forgerock.i18n.LocalizableMessage> unacceptableReasons, ServerContext serverContext)Indicates whether the provided configuration is acceptable for this backend.booleanisConfigurationChangeAcceptable(TaskBackendCfg configEntry, List<org.forgerock.i18n.LocalizableMessage> unacceptableReasons)Indicates whether the proposed change to the configuration is acceptable to this change listener.booleanisDirectRestore()Indicates if restore is done directly in the restore directory.booleanisIndexed(AttributeType attributeType, IndexType indexType)Indicates whether search operations which target the specified attribute in the indicated manner would be considered indexed in this backend.voidopenBackend()Opens this backend based on the information provided when the backend was configured.voidremoveBackup(BackupDirectory backupDirectory, String backupID)Removes the specified backup if it is possible to do so.voidrenameEntry(DN currentDN, Entry entry, ModifyDNOperation modifyDNOperation)Moves and/or renames the provided entry in this backend, altering any subordinate entries as necessary.voidreplaceEntry(Entry oldEntry, Entry newEntry, ModifyOperation modifyOperation)Replaces the specified entry with the provided entry in this backend.voidrestoreBackup(RestoreConfig restoreConfig)Restores a backup of the contents of this backend.voidsearch(SearchOperation searchOperation)Processes the specified search in this backend.booleansupports(LocalBackend.BackendOperation backendOperation)Indicates whether this backend supports the provided backend operation.-
Methods inherited from class org.opends.server.api.LocalBackend
entryExists, finalizeBackend, getBackendMonitor, getPersistentSearches, getWritabilityMode, handlesEntry, handlesEntry, isDefaultRoute, isIndexed, isPrivateBackend, rebuildBackend, registerPersistentSearch, setBackendMonitor, setPrivateBackend, setWritabilityMode, supportsControl, verifyBackend
-
Methods inherited from class org.opends.server.api.Backend
getBackendID, setBackendID
-
-
-
-
Method Detail
-
configureBackend
public void configureBackend(TaskBackendCfg cfg, ServerContext serverContext) throws ConfigException
Description copied from class:BackendConfigure this backend based on the information in the provided configuration. When the method returns, the backend will have been configured (ready to be opened) but still unable to process operations.- Specified by:
configureBackendin classBackend<TaskBackendCfg>- Parameters:
cfg- The configuration of this backend.serverContext- The server context for this instance- Throws:
ConfigException- If there is an error in the configuration.
-
openBackend
public void openBackend() throws ConfigException, InitializationExceptionDescription copied from class:LocalBackendOpens this backend based on the information provided when the backend was configured. It also should open any underlying storage and register all suffixes with the server.- Specified by:
openBackendin classLocalBackend<TaskBackendCfg>- Throws:
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.- See Also:
Backend.configureBackend(C, org.opends.server.core.ServerContext)
-
closeBackend
public void closeBackend()
Description copied from class:LocalBackendPerforms 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.It will be called as final step of
finalizeBackend(), so subclasses might override it.- Overrides:
closeBackendin classLocalBackend<TaskBackendCfg>
-
getBaseDNs
public Set<DN> getBaseDNs()
Description copied from class:BackendRetrieves the set of base-level DNs that may be used within this backend.- Specified by:
getBaseDNsin classBackend<TaskBackendCfg>- Returns:
- The set of base-level DNs that may be used within this backend.
-
getEntryCount
public long getEntryCount()
Description copied from class:LocalBackendRetrieves the total number of entries contained in this backend, if that information is available.- Specified by:
getEntryCountin classLocalBackend<TaskBackendCfg>- Returns:
- The total number of entries contained in this backend, or -1 if that information is not available.
-
isIndexed
public boolean isIndexed(AttributeType attributeType, IndexType indexType)
Description copied from class:LocalBackendIndicates whether search operations which target the specified attribute in the indicated manner would be considered indexed in this backend. The operation should be considered indexed only if the specified operation can be completed efficiently within the backend.
Note that this method should return a general result that covers all values of the specified attribute. If a the specified attribute is indexed in the indicated manner but some particular values may still be treated as unindexed (e.g., if the number of entries with that attribute value exceeds some threshold), then this method should still returntruefor the specified attribute and index type.- Specified by:
isIndexedin classLocalBackend<TaskBackendCfg>- Parameters:
attributeType- The attribute type for which to make the determination.indexType- The index type for which to make the determination.- Returns:
trueif search operations targeting the specified attribute in the indicated manner should be considered indexed, orfalseif not.
-
hasSubordinates
public ConditionResult hasSubordinates(DN entryDN) throws DirectoryException
Description copied from class:LocalBackendIndicates whether the requested entry has any subordinates.- Specified by:
hasSubordinatesin classLocalBackend<TaskBackendCfg>- Parameters:
entryDN- The distinguished name of the entry.- Returns:
ConditionResult.TRUEif the entry has one or more subordinates orConditionResult.FALSEotherwise orConditionResult.UNDEFINEDif it can not be determined.- Throws:
DirectoryException- If a problem occurs while trying to retrieve the entry.
-
getNumberOfEntriesInBaseDN
public long getNumberOfEntriesInBaseDN(DN baseDN) throws DirectoryException
Description copied from class:LocalBackendRetrieves the number of entries for the specified base DN including all entries from the requested entry to the lowest level in the tree.- Specified by:
getNumberOfEntriesInBaseDNin classLocalBackend<TaskBackendCfg>- Parameters:
baseDN- The base distinguished name.- Returns:
- The number of subordinate entries including the base dn.
- Throws:
DirectoryException- If baseDN isn't a base dn managed by this backend or if a problem occurs while trying to retrieve the entry.
-
getNumberOfChildren
public long getNumberOfChildren(DN parentDN) throws DirectoryException
Description copied from class:LocalBackendRetrieves the number of subordinates immediately below the requested entry.- Specified by:
getNumberOfChildrenin classLocalBackend<TaskBackendCfg>- Parameters:
parentDN- The distinguished name of the parent.- Returns:
- The number of subordinate entries for the requested entry.
- Throws:
DirectoryException- If baseDN isn't a base dn managed by this backend or if a problem occurs while trying to retrieve the entry.
-
getEntry
public Entry getEntry(DN entryDN) throws DirectoryException
Description copied from class:LocalBackendRetrieves the requested entry from this backend. The caller is not required to hold any locks on the specified DN.- Specified by:
getEntryin classLocalBackend<TaskBackendCfg>- Parameters:
entryDN- The distinguished name of the entry to retrieve.- Returns:
- The requested entry, or
nullif the entry does not exist. - Throws:
DirectoryException- If a problem occurs while trying to retrieve the entry.
-
addEntry
public void addEntry(Entry entry, AddOperation addOperation) throws DirectoryException
Description copied from class:LocalBackendAdds the provided entry to this backend. This method must ensure that the entry is appropriate for the backend and that no entry already exists with the same DN. The caller must hold a write lock on the DN of the provided entry.- Specified by:
addEntryin classLocalBackend<TaskBackendCfg>- Parameters:
entry- The entry to add to this backend.addOperation- The add operation with which the new entry is associated. This may benullfor adds performed internally.- Throws:
DirectoryException- If a problem occurs while trying to add the entry.
-
deleteEntry
public void deleteEntry(DN entryDN, DeleteOperation deleteOperation) throws DirectoryException
Description copied from class:LocalBackendRemoves the specified entry from this backend. This method must ensure that the entry exists and that it does not have any subordinate entries (unless the backend supports a subtree delete operation and the client included the appropriate information in the request). The caller must hold a write lock on the provided entry DN.- Specified by:
deleteEntryin classLocalBackend<TaskBackendCfg>- Parameters:
entryDN- The DN of the entry to remove from this backend.deleteOperation- The delete operation with which this action is associated. This may benullfor deletes performed internally.- Throws:
DirectoryException- If a problem occurs while trying to remove the entry.
-
replaceEntry
public void replaceEntry(Entry oldEntry, Entry newEntry, ModifyOperation modifyOperation) throws DirectoryException
Description copied from class:LocalBackendReplaces the specified entry with the provided entry in this backend. The backend must ensure that an entry already exists with the same DN as the provided entry. The caller must hold a write lock on the DN of the provided entry.- Specified by:
replaceEntryin classLocalBackend<TaskBackendCfg>- Parameters:
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 benullfor modifications performed internally.- Throws:
DirectoryException- If a problem occurs while trying to replace the entry.
-
renameEntry
public void renameEntry(DN currentDN, Entry entry, ModifyDNOperation modifyDNOperation) throws DirectoryException
Description copied from class:LocalBackendMoves and/or renames the provided entry in this backend, altering any subordinate entries as necessary. This must ensure that an entry already exists with the provided current DN, and that no entry exists with the target DN of the provided entry. The caller must hold write locks on both the current DN and the new DN for the entry.- Specified by:
renameEntryin classLocalBackend<TaskBackendCfg>- Parameters:
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 benullfor modify DN operations performed internally.- Throws:
DirectoryException- If a problem occurs while trying to perform the rename.
-
search
public void search(SearchOperation searchOperation) throws DirectoryException, CanceledOperationException
Description copied from class:LocalBackendProcesses the specified search in this backend. Matching entries should be provided back to the core server using theSearchOperation.returnEntrymethod. The caller is not required to have any locks when calling this operation.- Specified by:
searchin classLocalBackend<TaskBackendCfg>- Parameters:
searchOperation- The search operation to be processed.- Throws:
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.
-
getSupportedControls
public Set<String> getSupportedControls()
Description copied from class:BackendRetrieves the OIDs of the controls that may be supported by this backend.- Specified by:
getSupportedControlsin classBackend<TaskBackendCfg>- Returns:
- The OIDs of the controls that may be supported by this backend.
-
getSupportedFeatures
public Set<String> getSupportedFeatures()
Description copied from class:BackendRetrieves the OIDs of the features that may be supported by this backend.- Specified by:
getSupportedFeaturesin classBackend<TaskBackendCfg>- Returns:
- The OIDs of the features that may be supported by this backend.
-
supports
public boolean supports(LocalBackend.BackendOperation backendOperation)
Description copied from class:LocalBackendIndicates whether this backend supports the provided backend operation.- Specified by:
supportsin classLocalBackend<TaskBackendCfg>- Parameters:
backendOperation- the backend operation- Returns:
trueif this backend supports the provided backend operation,falseotherwise.
-
exportLDIF
public void exportLDIF(LDIFExportConfig exportConfig) throws DirectoryException
Description copied from class:LocalBackendExports the contents of this backend to LDIF. This method should only be called ifLocalBackend.supports(BackendOperation)withLocalBackend.BackendOperation.LDIF_EXPORTreturnstrue.Note that the server will not explicitly initialize this backend before calling this method.
- Specified by:
exportLDIFin classLocalBackend<TaskBackendCfg>- Parameters:
exportConfig- The configuration to use when performing the export.- Throws:
DirectoryException- If a problem occurs while performing the LDIF export.
-
importLDIF
public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext sContext) throws DirectoryException
Description copied from class:LocalBackendImports information from an LDIF file into this backend. This method should only be called ifLocalBackend.supports(BackendOperation)withLocalBackend.BackendOperation.LDIF_IMPORTreturnstrue.Note that the server will not explicitly initialize this backend before calling this method.
- Specified by:
importLDIFin classLocalBackend<TaskBackendCfg>- Parameters:
importConfig- The configuration to use when performing the import.sContext- The server context- Returns:
- Information about the result of the import processing.
- Throws:
DirectoryException- If a problem occurs while performing the LDIF import.
-
createBackup
public void createBackup(BackupConfig backupConfig) throws DirectoryException
Description copied from class:LocalBackendCreates a backup of the contents of this backend in a form that may be restored at a later date if necessary. This method should only be called ifLocalBackend.supports(BackendOperation)withLocalBackend.BackendOperation.BACKUPreturnstrue.Note that the server will not explicitly initialize this backend before calling this method.
- Specified by:
createBackupin classLocalBackend<TaskBackendCfg>- Parameters:
backupConfig- The configuration to use when performing the backup.- Throws:
DirectoryException- If a problem occurs while performing the backup.
-
removeBackup
public void removeBackup(BackupDirectory backupDirectory, String backupID) throws DirectoryException
Description copied from class:LocalBackendRemoves the specified backup if it is possible to do so.- Specified by:
removeBackupin classLocalBackend<TaskBackendCfg>- 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 for some reason (e.g., no such backup exists or there are other backups that are dependent upon it).
-
restoreBackup
public void restoreBackup(RestoreConfig restoreConfig) throws DirectoryException
Description copied from class:LocalBackendRestores a backup of the contents of this backend. This method should only be called ifLocalBackend.supports(BackendOperation)withLocalBackend.BackendOperation.RESTOREreturnstrue.Note that the server will not explicitly initialize this backend before calling this method.
- Specified by:
restoreBackupin classLocalBackend<TaskBackendCfg>- Parameters:
restoreConfig- The configuration to use when performing the restore.- Throws:
DirectoryException- If a problem occurs while performing the restore.
-
isConfigurationAcceptable
public boolean isConfigurationAcceptable(TaskBackendCfg config, List<org.forgerock.i18n.LocalizableMessage> unacceptableReasons, ServerContext serverContext)
Description copied from class:BackendIndicates whether the provided configuration is acceptable for this backend. It should be possible to call this method on an uninitialized backend instance in order to determine whether the backend would be able to use the provided configuration.
Note that implementations which use a subclass of the provided configuration class will likely need to cast the configuration to the appropriate subclass type.- Overrides:
isConfigurationAcceptablein classBackend<TaskBackendCfg>- Parameters:
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 context- Returns:
trueif the provided configuration is acceptable for this backend, orfalseif not.
-
isConfigurationChangeAcceptable
public boolean isConfigurationChangeAcceptable(TaskBackendCfg configEntry, List<org.forgerock.i18n.LocalizableMessage> unacceptableReasons)
Description copied from interface:ConfigurationChangeListenerIndicates whether the proposed change to the configuration is acceptable to this change listener.- Specified by:
isConfigurationChangeAcceptablein interfaceConfigurationChangeListener<TaskBackendCfg>- Parameters:
configEntry- 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(TaskBackendCfg configEntry)
Description copied from interface:ConfigurationChangeListenerApplies the configuration changes to this change listener.- Specified by:
applyConfigurationChangein interfaceConfigurationChangeListener<TaskBackendCfg>- Parameters:
configEntry- The new configuration containing the changes.- Returns:
- Returns information about the result of changing the configuration.
-
getConfigEntryDN
public DN getConfigEntryDN()
Retrieves the DN of the configuration entry for this task backend.- Returns:
- The DN of the configuration entry for this task backend.
-
getTaskBackingFile
public String getTaskBackingFile()
Retrieves the path to the backing file that will hold the scheduled and recurring task definitions.- Returns:
- The path to the backing file that will hold the scheduled and recurring task definitions.
-
getNotificationSenderAddress
public String getNotificationSenderAddress()
Retrieves the sender address that should be used for e-mail notifications of task completion.- Returns:
- The sender address that should be used for e-mail notifications of task completion.
-
getRetentionTime
public long getRetentionTime()
Retrieves the length of time in seconds that information for a task should be retained after processing on it has completed.- Returns:
- The length of time in seconds that information for a task should be retained after processing on it has completed.
-
getTaskRootDN
public DN getTaskRootDN()
Retrieves the DN of the entry that is the root for all task information in the Directory Server.- Returns:
- The DN of the entry that is the root for all task information in the Directory Server.
-
getRecurringTasksParentDN
public DN getRecurringTasksParentDN()
Retrieves the DN of the entry that is the immediate parent for all recurring task information in the Directory Server.- Returns:
- The DN of the entry that is the immediate parent for all recurring task information in the Directory Server.
-
getScheduledTasksParentDN
public DN getScheduledTasksParentDN()
Retrieves the DN of the entry that is the immediate parent for all scheduled task information in the Directory Server.- Returns:
- The DN of the entry that is the immediate parent for all scheduled task information in the Directory Server.
-
getScheduledTask
public Task getScheduledTask(DN taskEntryDN)
Retrieves the scheduled task for the entry with the provided DN.- Parameters:
taskEntryDN- The DN of the entry for the task to retrieve.- Returns:
- The requested task, or
nullif there is no task with the specified entry DN.
-
getRecurringTask
public RecurringTask getRecurringTask(DN taskEntryDN)
Retrieves the recurring task for the entry with the provided DN.- Parameters:
taskEntryDN- The DN of the entry for the recurring task to retrieve.- Returns:
- The requested recurring task, or
nullif there is no task with the specified entry DN.
-
getDirectory
public File getDirectory()
Description copied from interface:BackupableReturns the directory which acts as the root of all files to backup and restore.- Specified by:
getDirectoryin interfaceBackupable- Returns:
- the root directory
-
getFilesToBackup
public ListIterator<Path> getFilesToBackup() throws DirectoryException
Description copied from interface:BackupableReturns the files to backup.- Specified by:
getFilesToBackupin interfaceBackupable- Returns:
- an iterator of files to backup, which may be empty but never
null - Throws:
DirectoryException- If an error occurs.
-
isDirectRestore
public boolean isDirectRestore()
Description copied from interface:BackupableIndicates if restore is done directly in the restore directory.- Specified by:
isDirectRestorein interfaceBackupable- Returns:
trueif restore is done directly in the restore directory provided bygetDirectory()method, orfalseif restore is done in a temporary directory.
-
beforeRestore
public Path beforeRestore() throws DirectoryException
Description copied from interface:BackupableCalled before the restore operation begins.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.
- Specified by:
beforeRestorein interfaceBackupable- Returns:
- the directory where current files are saved. It may be
nullif not applicable. - Throws:
DirectoryException- If an error occurs.
-
afterRestore
public void afterRestore(Path restoreDirectory, Path saveDirectory) throws DirectoryException
Description copied from interface:BackupableCalled after the restore operation has finished successfully.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.
- Specified by:
afterRestorein interfaceBackupable- Parameters:
restoreDirectory- The directory in which files have actually been restored. It is nevernull.saveDirectory- The directory in which current files have been saved. It may benullifbeforeRestore()returnednull.- Throws:
DirectoryException- If an error occurs.
-
-