Class BackendImpl<C extends PluggableBackendCfg>
- java.lang.Object
-
- org.opends.server.api.Backend<C>
-
- org.opends.server.api.LocalBackend<C>
-
- org.opends.server.backends.pluggable.BackendImpl<C>
-
- Type Parameters:
C- the type of the BackendCfg for the current backend
- All Implemented Interfaces:
ConfigurationChangeListener<PluggableBackendCfg>,RequestHandler,Backupable,HealthStatusProvider
- Direct Known Subclasses:
JEBackend
public abstract class BackendImpl<C extends PluggableBackendCfg> extends LocalBackend<C> implements ConfigurationChangeListener<PluggableBackendCfg>, Backupable
This is an implementation of a Directory Server Backend which stores entries locally in a pluggable storage.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.opends.server.api.LocalBackend
LocalBackend.BackendOperation
-
-
Constructor Summary
Constructors Constructor Description BackendImpl()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddEntry(Entry entry, AddOperation addOperation)Adds the provided entry to this backend.ConfigChangeResultapplyConfigurationChange(PluggableBackendCfg newCfg)Applies the configuration changes to this change listener.voidclearBackend()Clears the contents of this backend, including any database files.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(C cfg, ServerContext serverContext)Configure this backend based on the information in the provided configuration.protected abstract StorageconfigureStorage(C cfg, ServerContext serverContext)Creates the storage engine which will be used by this pluggable backend.voiddeleteEntry(Dn entryDN, DeleteOperation deleteOperation)Removes the specified entry from this backend.booleanentryExists(Dn entryDN)Indicates whether an entry with the specified DN exists in the 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.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.HealthStatusgetHealthStatus()Returns theHealthStatusfor the underlying component.protected abstract PluggableBackendMonitorgetLocalBackendMonitor()Returns the local backend monitor associated with this backend.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.protected ServerContextgetServerContext()Returns the server context used by this backend.Set<String>getSupportedControls()Retrieves the OIDs of the controls that may be supported by this backend.ConditionResulthasSubordinates(Dn entryDN)Indicates whether the requested entry has any subordinates.LDIFImportResultimportLDIF(LDIFImportConfig importConfig, ServerContext serverContext)Imports information from an LDIF file into this backend.booleanisConfigurationAcceptable(C config, List<LocalizableMessage> unacceptableReasons, ServerContext serverContext)Indicates whether the provided configuration is acceptable for this backend.booleanisConfigurationChangeAcceptable(PluggableBackendCfg cfg, List<LocalizableMessage> unacceptableReasons)Indicates whether the proposed change to the configuration is acceptable to this change listener.booleanisIndexed(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.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.booleanisPublicBackend()Indicates whether the base DNs of this backend should be considered public or private.voidopenBackend()Opens this backend based on the information provided when the backend was configured.voidrebuildBackend(RebuildConfig rebuildConfig, ServerContext serverContext, Consumer<Task.WorkCounters> progressCallback)Rebuild indexes in the backend instance.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.voidsampleEntries(Consumer<Entry> consumer, Dn baseDn)Consumes all or a subset of entries contained in this backend under the provided base DN.voidsearch(SearchOperation searchOperation)Processes the specified search in this backend.booleansupports(LocalBackend.BackendOperation backendOperation)Indicates whether this backend supports the provided backend operation.longverifyBackend(VerifyConfig verifyConfig)Verify the integrity of the backend instance.-
Methods inherited from class org.opends.server.api.LocalBackend
deregisterBackendMonitor, finalizeBackend, getAndClearOfflineChanges, getPersistentSearches, getWritabilityMode, handle, handlesEntry, handlesEntry, isIndexed, registerBackendMonitor, registerPersistentSearch, setWritabilityMode, supportsControl
-
Methods inherited from class org.opends.server.api.Backend
getBackendID, 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
afterBackup, afterRestore, beforeBackup, beforeRestore, getBackendFiles, getBackendID, getDirectory
-
-
-
-
Method Detail
-
configureBackend
public void configureBackend(C 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<C extends PluggableBackendCfg>- Parameters:
cfg- The configuration of this backend.serverContext- The server context for this instance- Throws:
ConfigException- If there is an error in the configuration.
-
getServerContext
protected ServerContext getServerContext()
Description copied from class:LocalBackendReturns the server context used by this backend.- Overrides:
getServerContextin classLocalBackend<C extends PluggableBackendCfg>- Returns:
- the server context used by this backend
-
getLocalBackendMonitor
protected abstract PluggableBackendMonitor getLocalBackendMonitor()
Description copied from class:LocalBackendReturns the local backend monitor associated with this backend.Implementations may override this method in order to provide custom implementations.
- Overrides:
getLocalBackendMonitorin classLocalBackend<C extends PluggableBackendCfg>- Returns:
- The local backend monitor associated with this backend.
-
openBackend
public void openBackend() throws 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<C extends PluggableBackendCfg>- 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:BackendIndicates 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:
isPublicBackendin classBackend<C extends PluggableBackendCfg>- Returns:
trueif this backend's baseDNs could be exposed as a public naming context,falseif they must remain private naming contexts.
-
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<C extends PluggableBackendCfg>
-
clearBackend
public void clearBackend() throws InitializationExceptionClears the contents of this backend, including any database files. The backend will remain in the same state that it was at the time of calling.- Throws:
InitializationException- If a problem occurs during opening that is not related to the server configuration.
-
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<C extends PluggableBackendCfg>- 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.
-
sampleEntries
public void sampleEntries(Consumer<Entry> consumer, Dn baseDn) throws LdapException
Description copied from class:LocalBackendConsumes all or a subset of entries contained in this backend under the provided base DN. Intent is to consume a restricted set of entries (for backend having more than a small number of entries) which would allow to differentiate two instances of the same backend containing different entries, without having to compare every entries contained in the backend. The sample always contains the entry corresponding to the provided base DN. All other entries being consumed and the order at which they're consumed is not defined but it is guaranteed that a backend implementation will consume the exact same set of entries in the exact same order while the backend contains the exact same set of entries.- Overrides:
sampleEntriesin classLocalBackend<C extends PluggableBackendCfg>- Parameters:
consumer- the consumer of entry to process the data samplebaseDn- the base DN of the domain- Throws:
LdapException- if an error occurs
-
isIndexed
public boolean isIndexed(AttributeType attributeType, MatchingRule matchingRule)
Description copied from class:LocalBackendIndicates whether extensible match search operations that target the specified attribute with the given matching rule should be considered indexed in this backend.- Specified by:
isIndexedin classLocalBackend<C extends PluggableBackendCfg>- Parameters:
attributeType- The attribute type for which to make the determination.matchingRule- The matching rule for which to make the determination.- Returns:
trueif extensible match search operations targeting the specified attribute with the given matching rule should be considered indexed, orfalseif not.
-
supports
public boolean supports(LocalBackend.BackendOperation backendOperation)
Description copied from class:LocalBackendIndicates whether this backend supports the provided backend operation.- Overrides:
supportsin classLocalBackend<C extends PluggableBackendCfg>- Parameters:
backendOperation- the backend operation- Returns:
trueif this backend supports the provided backend operation,falseotherwise.
-
getSupportedControls
public Set<String> getSupportedControls()
Description copied from class:BackendRetrieves the OIDs of the controls that may be supported by this backend.- Overrides:
getSupportedControlsin classBackend<C extends PluggableBackendCfg>- Returns:
- The OIDs of the controls that may be supported by this backend.
-
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<C extends PluggableBackendCfg>- 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<C extends PluggableBackendCfg>- Returns:
- The total number of entries contained in this backend, or -1 if that information is not available.
-
hasSubordinates
public ConditionResult hasSubordinates(Dn entryDN) throws LdapException
Description copied from class:LocalBackendIndicates whether the requested entry has any subordinates.- Specified by:
hasSubordinatesin classLocalBackend<C extends PluggableBackendCfg>- 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:
LdapException- If a problem occurs while trying to retrieve the entry.
-
getNumberOfEntriesInBaseDN
public long getNumberOfEntriesInBaseDN(Dn baseDN) throws LdapException
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<C extends PluggableBackendCfg>- Parameters:
baseDN- The base distinguished name.- Returns:
- The number of subordinate entries including the base dn.
- Throws:
LdapException- 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 LdapException
Description copied from class:LocalBackendRetrieves the number of subordinates immediately below the requested entry.- Specified by:
getNumberOfChildrenin classLocalBackend<C extends PluggableBackendCfg>- Parameters:
parentDN- The distinguished name of the parent.- Returns:
- The number of subordinate entries for the requested entry.
- Throws:
LdapException- If baseDN isn't a base dn managed by this backend or if a problem occurs while trying to retrieve the entry.
-
entryExists
public boolean entryExists(Dn entryDN) throws LdapException
Description copied from class:LocalBackendIndicates whether an entry with the specified DN exists in the backend. The default implementation callsgetEntry, but backend implementations may override this with a more efficient version. The caller is not required to hold any locks on the specified DN.- Overrides:
entryExistsin classLocalBackend<C extends PluggableBackendCfg>- Parameters:
entryDN- The DN of the entry for which to determine existence.- Returns:
trueif the specified entry exists in this backend, orfalseif it does not.- Throws:
LdapException- If a problem occurs while trying to make the determination.
-
getEntry
public Entry getEntry(Dn entryDN) throws LdapException
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<C extends PluggableBackendCfg>- Parameters:
entryDN- The distinguished name of the entry to retrieve.- Returns:
- The requested entry, or
nullif 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: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<C extends PluggableBackendCfg>- 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:
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: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<C extends PluggableBackendCfg>- 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:
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: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<C extends PluggableBackendCfg>- 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: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<C extends PluggableBackendCfg>- 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:
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 searchOperation) throws LdapException
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<C extends PluggableBackendCfg>- Parameters:
searchOperation- 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.
-
exportLDIF
public void exportLDIF(LDIFExportConfig exportConfig) throws LdapException
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.
- Overrides:
exportLDIFin classLocalBackend<C extends PluggableBackendCfg>- Parameters:
exportConfig- The configuration to use when performing the export.- Throws:
LdapException- If a problem occurs while performing the LDIF export.
-
importLDIF
public LDIFImportResult importLDIF(LDIFImportConfig importConfig, ServerContext serverContext) throws LdapException
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.
- Overrides:
importLDIFin classLocalBackend<C extends PluggableBackendCfg>- Parameters:
importConfig- The configuration to use when performing the import.serverContext- The server context- Returns:
- Information about the result of the import processing.
- Throws:
LdapException- If a problem occurs while performing the LDIF import.
-
verifyBackend
public long verifyBackend(VerifyConfig verifyConfig) throws InitializationException, LdapException
Description copied from class:LocalBackendVerify the integrity of the backend instance.- Overrides:
verifyBackendin classLocalBackend<C extends PluggableBackendCfg>- Parameters:
verifyConfig- The verify configuration.- Returns:
- The results of the operation.
- Throws:
InitializationException- If a problem occurs during initialization that is not related to the server configuration.LdapException- If a Directory Server error occurs.
-
rebuildBackend
public void rebuildBackend(RebuildConfig rebuildConfig, ServerContext serverContext, Consumer<Task.WorkCounters> progressCallback) throws LdapException, InitializationException, ConfigException
Description copied from class:LocalBackendRebuild indexes in the backend instance. Note that the server will not explicitly initialize this backend before calling this method.- Overrides:
rebuildBackendin classLocalBackend<C extends PluggableBackendCfg>- Parameters:
rebuildConfig- The rebuild configuration.serverContext- The server context for this instanceprogressCallback- Callback to be notified about progress made- Throws:
LdapException- If a Directory Server error occurs.InitializationException- If a problem occurs during initialization that is not related to the server configuration.ConfigException- If an unrecoverable problem arises during initialization.
-
configureStorage
protected abstract Storage configureStorage(C cfg, ServerContext serverContext) throws ConfigException
Creates the storage engine which will be used by this pluggable backend. Implementations should create and configure a new storage engine but not open it.- Parameters:
cfg- the configuration objectserverContext- this Directory Server instance's server context- Returns:
- The storage engine to be used by this pluggable backend.
- Throws:
ConfigException- If there is an error in the configuration.
-
isConfigurationAcceptable
public boolean isConfigurationAcceptable(C config, List<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.- Overrides:
isConfigurationAcceptablein classBackend<C extends PluggableBackendCfg>- 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(PluggableBackendCfg cfg, List<LocalizableMessage> unacceptableReasons)
Description copied from interface:ConfigurationChangeListenerIndicates whether the proposed change to the configuration is acceptable to this change listener.- Specified by:
isConfigurationChangeAcceptablein interfaceConfigurationChangeListener<C extends PluggableBackendCfg>- Parameters:
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.- Returns:
- Returns
trueif the proposed change is acceptable, orfalseif it is not.
-
applyConfigurationChange
public ConfigChangeResult applyConfigurationChange(PluggableBackendCfg newCfg)
Description copied from interface:ConfigurationChangeListenerApplies the configuration changes to this change listener.- Specified by:
applyConfigurationChangein interfaceConfigurationChangeListener<C extends PluggableBackendCfg>- Parameters:
newCfg- The new configuration containing the changes.- Returns:
- Returns information about the result of changing the configuration.
-
getHealthStatus
public HealthStatus getHealthStatus()
Description copied from interface:HealthStatusProviderReturns theHealthStatusfor the underlying component.- Specified by:
getHealthStatusin interfaceHealthStatusProvider- Overrides:
getHealthStatusin classBackend<C extends PluggableBackendCfg>- Returns:
- The
HealthStatus.
-
-