Package org.opends.server.backends.task
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>
,RequestHandler
,Backupable
,HealthStatusProvider
public final 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()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEntry(Entry entry, AddOperation addOperation)
Adds the provided entry to this backend.void
afterBackup()
Performs any necessary processing after a backup is performed.void
afterRestore()
Performs any necessary processing after a restore is performed.ConfigChangeResult
applyConfigurationChange(TaskBackendCfg configEntry)
Applies the configuration changes to this change listener.void
beforeBackup()
Performs any necessary processing before a backup is performed.void
beforeRestore()
Performs any necessary processing before a restore is performed.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(TaskBackendCfg cfg, ServerContext serverContext)
Configure this backend based on the information in the provided configuration.void
deleteEntry(Dn entryDN, DeleteOperation deleteOperation)
Removes the specified entry from this backend.void
exportLDIF(LDIFExportConfig exportConfig)
Exports the contents of this backend to LDIF.BackupManager.CountedIterator<BackendFile>
getBackendFiles()
Returns an iterator that goes over all the backend files.Set<Dn>
getBaseDNs()
Retrieves the set of base-level DNs that may be used within this backend.Dn
getConfigEntryDN()
Retrieves the DN of the configuration entry for this task backend.Path
getDirectory()
Returns the directory containing all the backend files to be backed up.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.String
getNotificationSenderAddress()
Retrieves the sender address that should be used for e-mail notifications of task completion.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.Dn
getRecurringTasksParentDN()
Retrieves the DN of the entry that is the immediate parent for all recurring task information in the Directory Server.long
getRetentionTime()
Retrieves the length of time in seconds that information for a task should be retained after processing on it has completed.Task
getScheduledTask(Dn taskEntryDN)
Retrieves the scheduled task for the entry with the provided DN.Dn
getScheduledTasksParentDN()
Retrieves the DN of the entry that is the immediate parent for all scheduled task information in the Directory Server.protected ServerContext
getServerContext()
Returns the server context used by this backend.Path
getTaskBackingFile()
Retrieves the path to the backing file that will hold the scheduled and recurring task definitions.Dn
getTaskRootDN()
Retrieves the DN of the entry that is the root for all task information in the Directory Server.ConditionResult
hasSubordinates(Dn entryDN)
Indicates whether the requested entry has any subordinates.LDIFImportResult
importLDIF(LDIFImportConfig importConfig, ServerContext sContext)
Imports information from an LDIF file into this backend.boolean
isConfigurationAcceptable(TaskBackendCfg config, List<LocalizableMessage> unacceptableReasons, ServerContext serverContext)
Indicates whether the provided configuration is acceptable for this backend.boolean
isConfigurationChangeAcceptable(TaskBackendCfg configEntry, List<LocalizableMessage> unacceptableReasons)
Indicates whether the proposed change to the configuration is acceptable to this change listener.boolean
isIndexed(AttributeType attributeType, MatchingRule matchingRule)
Indicates whether extensible match search operations that target the specified attribute with the given matching rule should be considered indexed in this backend.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.boolean
isPublicBackend()
Indicates whether the base DNs of this backend should be considered public or private.void
openBackend()
Opens this backend based on the information provided when the backend was configured.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
search(SearchOperation searchOp)
Processes the specified search in this backend.boolean
supports(LocalBackend.BackendOperation backendOperation)
Indicates whether this backend supports the provided backend operation.-
Methods inherited from class org.opends.server.api.LocalBackend
deregisterBackendMonitor, entryExists, finalizeBackend, getAndClearOfflineChanges, getLocalBackendMonitor, getPersistentSearches, getWritabilityMode, handle, handlesEntry, handlesEntry, isIndexed, rebuildBackend, registerBackendMonitor, registerPersistentSearch, sampleEntries, setWritabilityMode, supportsControl, verifyBackend
-
Methods inherited from class org.opends.server.api.Backend
getBackendID, getHealthStatus, getSupportedControls, getSupportedFeatures, setBackendID, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.opends.server.backup.Backupable
getBackendID
-
-
-
-
Method Detail
-
configureBackend
public void configureBackend(TaskBackendCfg cfg, ServerContext serverContext)
Description copied from class:Backend
Configure 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:
configureBackend
in classBackend<TaskBackendCfg>
- Parameters:
cfg
- The configuration of this backend.serverContext
- The server context for this instance
-
getServerContext
protected ServerContext getServerContext()
Description copied from class:Backend
Returns the server context used by this backend.- Overrides:
getServerContext
in classBackend<TaskBackendCfg>
- Returns:
- the server context used by this backend
-
openBackend
public void openBackend() throws InitializationException
Description copied from class:LocalBackend
Opens 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:
openBackend
in classLocalBackend<TaskBackendCfg>
- Throws:
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)
-
isPublicBackend
public boolean isPublicBackend()
Description copied from class:Backend
Indicates whether the base DNs of this backend should be considered public or private.This method also controls the visibility of the associated naming contexts. i.e. if any base DN of this backend is a naming context, then it will be public or private, based on the value returned by this method.
Reminder: Public naming contexts are returned when querying the root DSE entry.
- Specified by:
isPublicBackend
in classBackend<TaskBackendCfg>
- Returns:
true
if this backend's baseDNs could be exposed as a public naming context,false
if they must remain private naming contexts.
-
closeBackend
public void closeBackend()
Description copied from class:LocalBackend
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.It will be called as final step of
finalizeBackend()
, so subclasses might override it.- Overrides:
closeBackend
in classLocalBackend<TaskBackendCfg>
-
getBaseDNs
public Set<Dn> getBaseDNs()
Description copied from class:Backend
Retrieves the set of base-level DNs that may be used within this backend.- Specified by:
getBaseDNs
in classBackend<TaskBackendCfg>
- Returns:
- The set of base-level DNs that may be used within this backend.
-
getEntryCount
public long getEntryCount()
Description copied from class:LocalBackend
Retrieves the total number of entries contained in this backend, if that information is available.- Specified by:
getEntryCount
in 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:LocalBackend
Indicates 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 returntrue
for the specified attribute and index type.- Specified by:
isIndexed
in classLocalBackend<TaskBackendCfg>
- Parameters:
attributeType
- The attribute type for which to make the determination.indexType
- The index type for which to make the determination.- Returns:
true
if search operations targeting the specified attribute in the indicated manner should be considered indexed, orfalse
if not.
-
isIndexed
public boolean isIndexed(AttributeType attributeType, MatchingRule matchingRule)
Description copied from class:LocalBackend
Indicates whether extensible match search operations that target the specified attribute with the given matching rule should be considered indexed in this backend.- Specified by:
isIndexed
in classLocalBackend<TaskBackendCfg>
- Parameters:
attributeType
- The attribute type for which to make the determination.matchingRule
- The matching rule for which to make the determination.- Returns:
true
if extensible match search operations targeting the specified attribute with the given matching rule should be considered indexed, orfalse
if not.
-
hasSubordinates
public ConditionResult hasSubordinates(Dn entryDN)
Description copied from class:LocalBackend
Indicates whether the requested entry has any subordinates.- Specified by:
hasSubordinates
in classLocalBackend<TaskBackendCfg>
- Parameters:
entryDN
- The distinguished name of the entry.- Returns:
ConditionResult.TRUE
if the entry has one or more subordinates orConditionResult.FALSE
otherwise orConditionResult.UNDEFINED
if it can not be determined.
-
getNumberOfEntriesInBaseDN
public long getNumberOfEntriesInBaseDN(Dn baseDN)
Description copied from class:LocalBackend
Retrieves 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:
getNumberOfEntriesInBaseDN
in classLocalBackend<TaskBackendCfg>
- Parameters:
baseDN
- The base distinguished name.- Returns:
- The number of subordinate entries including the base dn.
-
getNumberOfChildren
public long getNumberOfChildren(Dn parentDN)
Description copied from class:LocalBackend
Retrieves the number of subordinates immediately below the requested entry.- Specified by:
getNumberOfChildren
in classLocalBackend<TaskBackendCfg>
- Parameters:
parentDN
- The distinguished name of the parent.- Returns:
- The number of subordinate entries for the requested entry.
-
getEntry
public Entry getEntry(Dn entryDN) throws LdapException
Description copied from class:LocalBackend
Retrieves the requested entry from this backend. The caller is not required to hold any locks on the specified DN.- Specified by:
getEntry
in classLocalBackend<TaskBackendCfg>
- Parameters:
entryDN
- The distinguished name of the entry to retrieve.- Returns:
- The requested entry, or
null
if the entry does not exist. - Throws:
LdapException
- If a problem occurs while trying to retrieve the entry.
-
addEntry
public void addEntry(Entry entry, AddOperation addOperation) throws LdapException
Description copied from class:LocalBackend
Adds 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:
addEntry
in classLocalBackend<TaskBackendCfg>
- Parameters:
entry
- The entry to add to this backend.addOperation
- The add operation with which the new entry is associated. This may benull
for adds performed internally.- Throws:
LdapException
- If a problem occurs while trying to add the entry.CancelledResultException
- If this backend noticed and reacted to a request to cancel or abandon the add operation.
-
deleteEntry
public void deleteEntry(Dn entryDN, DeleteOperation deleteOperation) throws LdapException
Description copied from class:LocalBackend
Removes 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:
deleteEntry
in 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 benull
for deletes performed internally.- Throws:
LdapException
- If a problem occurs while trying to remove the entry.CancelledResultException
- If this backend noticed and reacted to a request to cancel or abandon the delete operation.
-
replaceEntry
public void replaceEntry(Entry oldEntry, Entry newEntry, ModifyOperation modifyOperation) throws LdapException
Description copied from class:LocalBackend
Replaces 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:
replaceEntry
in 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.- Throws:
LdapException
- If a problem occurs while trying to replace the entry.CancelledResultException
- If this backend noticed and reacted to a request to cancel or abandon the modify operation.
-
renameEntry
public void renameEntry(Dn currentDN, Entry entry, ModifyDnOperation modifyDNOperation) throws LdapException
Description copied from class:LocalBackend
Moves 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:
renameEntry
in 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 benull
for modify DN operations performed internally.- Throws:
LdapException
- If a problem occurs while trying to perform the rename.CancelledResultException
- If this backend noticed and reacted to a request to cancel or abandon the modify DN operation.
-
search
public void search(SearchOperation searchOp) throws LdapException
Description copied from class:LocalBackend
Processes the specified search in this backend. Matching entries should be provided back to the core server using theSearchOperation.returnEntry
method. The caller is not required to have any locks when calling this operation.- Specified by:
search
in classLocalBackend<TaskBackendCfg>
- Parameters:
searchOp
- The search operation to be processed.- Throws:
LdapException
- If a problem occurs while processing the search.CancelledResultException
- If this backend noticed and reacted to a request to cancel or abandon the search operation.
-
supports
public boolean supports(LocalBackend.BackendOperation backendOperation)
Description copied from class:LocalBackend
Indicates whether this backend supports the provided backend operation.- Overrides:
supports
in classLocalBackend<TaskBackendCfg>
- Parameters:
backendOperation
- the backend operation- Returns:
true
if this backend supports the provided backend operation,false
otherwise.
-
exportLDIF
public void exportLDIF(LDIFExportConfig exportConfig)
Description copied from class:LocalBackend
Exports the contents of this backend to LDIF. This method should only be called ifLocalBackend.supports(BackendOperation)
withLocalBackend.BackendOperation.LDIF_EXPORT
returnstrue
.Note that the server will not explicitly initialize this backend before calling this method.
- Overrides:
exportLDIF
in classLocalBackend<TaskBackendCfg>
- Parameters:
exportConfig
- The configuration to use when performing the export.
-
importLDIF
public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext sContext) throws LdapException
Description copied from class:LocalBackend
Imports information from an LDIF file into this backend. This method should only be called ifLocalBackend.supports(BackendOperation)
withLocalBackend.BackendOperation.LDIF_IMPORT
returnstrue
.Note that the server will not explicitly initialize this backend before calling this method.
- Overrides:
importLDIF
in 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:
LdapException
- If a problem occurs while performing the LDIF import.
-
beforeBackup
public void beforeBackup()
Description copied from interface:Backupable
Performs 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:
beforeBackup
in interfaceBackupable
-
afterBackup
public void afterBackup()
Description copied from interface:Backupable
Performs any necessary processing after a backup is performed. This method is called even if backup has failed. For example, this can release a shared lock.- Specified by:
afterBackup
in interfaceBackupable
-
getDirectory
public Path getDirectory()
Description copied from interface:Backupable
Returns the directory containing all the backend files to be backed up.- Specified by:
getDirectory
in interfaceBackupable
- Returns:
- the directory containing all the backend files to be backed up.
-
beforeRestore
public void beforeRestore()
Description copied from interface:Backupable
Performs any necessary processing before a restore is performed. For example, this can take an exclusive lock.- Specified by:
beforeRestore
in interfaceBackupable
-
getBackendFiles
public BackupManager.CountedIterator<BackendFile> getBackendFiles()
Description copied from interface:Backupable
Returns an iterator that goes over all the backend files. The iterator may return deleted files, such files must be ignored during iteration.- Specified by:
getBackendFiles
in interfaceBackupable
- Returns:
- A backend file iterator.
-
afterRestore
public void afterRestore()
Description copied from interface:Backupable
Performs any necessary processing after a restore is performed. This method is called even if restore has failed. For example, this can release an exclusive lock or load the restored files into memory.- Specified by:
afterRestore
in interfaceBackupable
-
isConfigurationAcceptable
public boolean isConfigurationAcceptable(TaskBackendCfg config, List<LocalizableMessage> unacceptableReasons, ServerContext serverContext)
Description copied from class:Backend
Indicates 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.- Overrides:
isConfigurationAcceptable
in 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:
true
if the provided configuration is acceptable for this backend, orfalse
if not.
-
isConfigurationChangeAcceptable
public boolean isConfigurationChangeAcceptable(TaskBackendCfg configEntry, List<LocalizableMessage> unacceptableReasons)
Description copied from interface:ConfigurationChangeListener
Indicates whether the proposed change to the configuration is acceptable to this change listener.- Specified by:
isConfigurationChangeAcceptable
in 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
true
if the proposed change is acceptable, orfalse
if it is not.
-
applyConfigurationChange
public ConfigChangeResult applyConfigurationChange(TaskBackendCfg configEntry)
Description copied from interface:ConfigurationChangeListener
Applies the configuration changes to this change listener.- Specified by:
applyConfigurationChange
in 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 Path 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.
-
-