Package org.opends.server.core
Class BackendConfigManager
- java.lang.Object
-
- org.opends.server.core.BackendConfigManager
-
- All Implemented Interfaces:
ConfigurationAddListener<BackendCfg>
,ConfigurationChangeListener<BackendCfg>
,ConfigurationDeleteListener<BackendCfg>
public class BackendConfigManager extends Object implements ConfigurationChangeListener<BackendCfg>, ConfigurationAddListener<BackendCfg>, ConfigurationDeleteListener<BackendCfg>
Responsible for managing the lifecycle of backends in the Directory Server.It performs the necessary initialization of the backends when the server is first started, and then manages any changes to them while the server is running.
-
-
Field Summary
Fields Modifier and Type Field Description static Predicate<org.opends.server.core.BackendConfigManager.NamingContext>
LOCAL
A naming suffix corresponding to a local backend.static Predicate<org.opends.server.core.BackendConfigManager.NamingContext>
NON_LOCAL
A naming suffix corresponding to a non-local backend.static Predicate<org.opends.server.core.BackendConfigManager.NamingContext>
PRIVATE
A naming context corresponding to a private backend.static Predicate<org.opends.server.core.BackendConfigManager.NamingContext>
PUBLIC
A public naming context (strict opposite of private).static Predicate<org.opends.server.core.BackendConfigManager.NamingContext>
TOP_LEVEL
A top-level naming context, which is not a subordinate of another naming context.
-
Constructor Summary
Constructors Constructor Description BackendConfigManager(ServerContext serverContext)
Creates a new instance of this backend config manager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activateBackend(String backendId)
Loads and registers a configured and enabled backend.ConfigChangeResult
applyConfigurationAdd(BackendCfg cfg)
Adds a new configuration to this add listener.ConfigChangeResult
applyConfigurationChange(BackendCfg cfg)
Applies the configuration changes to this change listener.ConfigChangeResult
applyConfigurationDelete(BackendCfg cfg)
Deletes an existing configuration from this delete listener.boolean
containsLocalNamingContext(Dn dn)
Indicates whether the specified DN is contained in the local backends as a naming context.void
deactivateBackend(String backendId)
Deregisters and finalizes a configured and active backend.void
deregisterBackend(Backend<? extends BackendCfg> backend)
Deregisters a backend.void
deregisterBaseDNs(Backend<? extends BackendCfg> backend)
Deregisters all the base DNs for the provided backend.void
deregisterLocalBackendInitializationListener(LocalBackendInitializationListener listener)
Deregisters a local backend initialization listener.Backend<?>
findBackendForEntry(Dn entryDn)
Retrieves the backend that should be used to handle operations on the specified entry.LocalBackend<?>
findLocalBackendForEntry(Dn entryDn)
Retrieves the local backend and the corresponding baseDN that should be used to handle operations on the specified entry.Iterator<Dn>
findNamingContextChildren(Dn entryDn)
Retrieves the set of local naming contexts that are subordinates of the naming context that should be used to handle operations on the specified entry.Dn
findNamingContextForEntry(Dn entryDn)
Retrieves the naming context that should be used to handle operations on the specified entry.Set<Backend<?>>
getAllBackends()
Returns the set of all backends.Backend<?>
getBackendWithBaseDn(Dn baseDn)
Retrieves the backend with the specified base DN.LocalBackend<?>
getLocalBackendById(String backendId)
Retrieves a local backend provided its identifier.LocalBackend<?>
getLocalBackendWithBaseDN(Dn baseDn)
Retrieves the local backend with the specified base DN.Set<Dn>
getNamingContexts(Predicate<org.opends.server.core.BackendConfigManager.NamingContext> filter)
Retrieves naming contexts corresponding to backends, according to the specified filter.Dn
getParentDNInSuffix(Dn dn)
Retrieves the DN that is the immediate parent for this DN.RootDSEBackend
getRootDSEBackend()
Retrieves the Root DSE backend.Set<Backend<?>>
getSubordinateBackends(Backend<?> backend)
Retrieves the set of subordinate backends of the provided backend.boolean
hasBackend(String backendId)
Indicates whether the backend with the provided id exists.boolean
hasSubordinateNamingContextsForEntry(Dn entryDn)
Returns whether the provided Dn has subordinate base DNs.void
initializeBackendConfig(Collection<String> backendIdsToStart)
Initializes the configuration associated with the Directory Server backends.void
initializeBackends(Collection<String> backendIDsToStart, RootCfg root)
Initializes specified backends.boolean
isConfigurationAddAcceptable(BackendCfg backendCfg, List<LocalizableMessage> unacceptableReason)
Indicates whether the proposed addition of a new configuration is acceptable to this add listener.boolean
isConfigurationChangeAcceptable(BackendCfg backendCfg, List<LocalizableMessage> unacceptableReason)
Indicates whether the proposed change to the configuration is acceptable to this change listener.boolean
isConfigurationDeleteAcceptable(BackendCfg cfg, List<LocalizableMessage> unacceptableReason)
Indicates whether the proposed deletion of an existing configuration is acceptable to this delete listener.void
registerBackend(Backend<? extends BackendCfg> backend)
Registers a backend.Pair<Set<Dn>,Set<Dn>>
registerBaseDNs(Backend<? extends BackendCfg> backend, Set<Dn> newBaseDns)
Registers the provided base DNs for the provided backend.void
registerLocalBackendInitializationListener(LocalBackendInitializationListener listener)
Registers a local backend initialization listener.void
shutdownBackends()
Shutdown all backends.
-
-
-
Field Detail
-
PRIVATE
public static final Predicate<org.opends.server.core.BackendConfigManager.NamingContext> PRIVATE
A naming context corresponding to a private backend.
-
PUBLIC
public static final Predicate<org.opends.server.core.BackendConfigManager.NamingContext> PUBLIC
A public naming context (strict opposite of private).
-
TOP_LEVEL
public static final Predicate<org.opends.server.core.BackendConfigManager.NamingContext> TOP_LEVEL
A top-level naming context, which is not a subordinate of another naming context.
-
LOCAL
public static final Predicate<org.opends.server.core.BackendConfigManager.NamingContext> LOCAL
A naming suffix corresponding to a local backend.
-
NON_LOCAL
public static final Predicate<org.opends.server.core.BackendConfigManager.NamingContext> NON_LOCAL
A naming suffix corresponding to a non-local backend.
-
-
Constructor Detail
-
BackendConfigManager
public BackendConfigManager(ServerContext serverContext)
Creates a new instance of this backend config manager.- Parameters:
serverContext
- The server context.
-
-
Method Detail
-
initializeBackendConfig
public void initializeBackendConfig(Collection<String> backendIdsToStart) throws ConfigException, InitializationException
Initializes the configuration associated with the Directory Server backends. This should only be called at Directory Server startup.- Parameters:
backendIdsToStart
- The list of backendID to start. Everything will be started if empty.- Throws:
ConfigException
- If a critical configuration problem prevents the backend initialization from succeeding.InitializationException
- If a problem occurs while initializing the backends that is not related to the server configuration.
-
initializeBackends
public void initializeBackends(Collection<String> backendIDsToStart, RootCfg root) throws ConfigException
Initializes specified backends. If a backend has been already initialized, do nothing. This should only be called at Directory Server startup, after #initializeBackendConfig()- Parameters:
backendIDsToStart
- The list of backendID to start. Everything will be started if empty.root
- The configuration of the server's Root backend- Throws:
ConfigException
- If a critical configuration problem prevents the backend initialization from succeeding.
-
getAllBackends
public Set<Backend<?>> getAllBackends()
Returns the set of all backends.- Returns:
- all backends
-
getLocalBackendWithBaseDN
public LocalBackend<?> getLocalBackendWithBaseDN(Dn baseDn)
Retrieves the local backend with the specified base DN.- Parameters:
baseDn
- The DN that is registered as one of the base DNs for the backend to retrieve.- Returns:
- The local backend with the specified base DN, or
null
if there is no active local backend for the specified base DN.
-
getBackendWithBaseDn
public Backend<?> getBackendWithBaseDn(Dn baseDn) throws LdapException
Retrieves the backend with the specified base DN.- Parameters:
baseDn
- The DN that is registered as one of the base DNs for the backend to retrieve.- Returns:
- The backend with the specified base DN, or
null
if none exist - Throws:
LdapException
- if no backend is found with the specified base DN
-
getRootDSEBackend
public RootDSEBackend getRootDSEBackend()
Retrieves the Root DSE backend.- Returns:
- the Root DSE backend.
-
getParentDNInSuffix
public Dn getParentDNInSuffix(Dn dn)
Retrieves the DN that is the immediate parent for this DN. This method does take the server's naming context configuration into account, so if the current DN is a naming context for the server, then it will not be considered to have a parent.- Parameters:
dn
- the- Returns:
- The DN that is the immediate parent for this DN, or
null
if this DN does not have a parent (either because there is only a single RDN component or because this DN is a suffix defined in the server).
-
findBackendForEntry
public Backend<?> findBackendForEntry(Dn entryDn)
Retrieves the backend that should be used to handle operations on the specified entry.- Parameters:
entryDn
- The DN of the entry for which to retrieve the corresponding backend.- Returns:
- The backend or
null
if no appropriate backend is registered with the server.
-
findNamingContextForEntry
public Dn findNamingContextForEntry(Dn entryDn)
Retrieves the naming context that should be used to handle operations on the specified entry.- Parameters:
entryDn
- The DN of the entry for which to retrieve the corresponding naming context.- Returns:
- The naming context or
null
if no appropriate naming context is registered with the server.
-
findLocalBackendForEntry
public LocalBackend<?> findLocalBackendForEntry(Dn entryDn)
Retrieves the local backend and the corresponding baseDN that should be used to handle operations on the specified entry.- Parameters:
entryDn
- The DN of the entry for which to retrieve the corresponding backend.- Returns:
- The local backend with its matching base DN or
null
if no appropriate local backend is registered with the server.
-
getLocalBackendById
public LocalBackend<?> getLocalBackendById(String backendId)
Retrieves a local backend provided its identifier.- Parameters:
backendId
- Identifier of the backend- Returns:
- the local backend, or
null
if there is no local backend registered with the specified id.
-
hasBackend
public boolean hasBackend(String backendId)
Indicates whether the backend with the provided id exists.- Parameters:
backendId
- The backend ID for which to make the determination.- Returns:
true
if a backend with the specified backend ID exists,false
otherwise
-
getSubordinateBackends
public Set<Backend<?>> getSubordinateBackends(Backend<?> backend)
Retrieves the set of subordinate backends of the provided backend.- Parameters:
backend
- The backend for which to retrieve the subordinates backends.- Returns:
- The set of subordinates backends, which is never
null
-
hasSubordinateNamingContextsForEntry
public boolean hasSubordinateNamingContextsForEntry(Dn entryDn)
Returns whether the provided Dn has subordinate base DNs.- Parameters:
entryDn
- The entry DN to test- Returns:
- whether the provided Dn has subordinate base DNs.
-
findNamingContextChildren
public Iterator<Dn> findNamingContextChildren(Dn entryDn)
Retrieves the set of local naming contexts that are subordinates of the naming context that should be used to handle operations on the specified entry.- Parameters:
entryDn
- The DN of the entry for which to retrieve the corresponding naming contexts.- Returns:
- The naming contexts or
null
if no appropriate naming context is registered with the server.
-
getNamingContexts
public Set<Dn> getNamingContexts(Predicate<org.opends.server.core.BackendConfigManager.NamingContext> filter)
Retrieves naming contexts corresponding to backends, according to the specified filter.- Parameters:
filter
- filter the naming contexts- Returns:
- the DNs of naming contexts for which all the filters apply.
- See Also:
BackendConfigManager.NamingContext
-
containsLocalNamingContext
public boolean containsLocalNamingContext(Dn dn)
Indicates whether the specified DN is contained in the local backends as a naming context.- Parameters:
dn
- The DN for which to make the determination.- Returns:
true
if the specified DN is a naming context in one backend, orfalse
if it is not.
-
registerLocalBackendInitializationListener
public void registerLocalBackendInitializationListener(LocalBackendInitializationListener listener)
Registers a local backend initialization listener.- Parameters:
listener
- The listener to register.
-
deregisterLocalBackendInitializationListener
public void deregisterLocalBackendInitializationListener(LocalBackendInitializationListener listener)
Deregisters a local backend initialization listener.- Parameters:
listener
- The listener to deregister.
-
isConfigurationChangeAcceptable
public boolean isConfigurationChangeAcceptable(BackendCfg backendCfg, List<LocalizableMessage> unacceptableReason)
Description copied from interface:ConfigurationChangeListener
Indicates whether the proposed change to the configuration is acceptable to this change listener.- Specified by:
isConfigurationChangeAcceptable
in interfaceConfigurationChangeListener<BackendCfg>
- Parameters:
backendCfg
- The new configuration containing the changes.unacceptableReason
- 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.
-
registerBaseDNs
public Pair<Set<Dn>,Set<Dn>> registerBaseDNs(Backend<? extends BackendCfg> backend, Set<Dn> newBaseDns) throws LdapException
Registers the provided base DNs for the provided backend.Backends should call this method when their baseDNs are updated.
- Parameters:
backend
- The non-null
backend responsible for the provided base DNs.newBaseDns
- the new base DNs for the backend. An empty set asks to deregister this backend.- Returns:
- a pair composed of the previous base DNs associated to this backend prior to calling this method, and the current based DNs associated to this backend after calling this method
- Throws:
LdapException
- If a problem occurs while attempting to register the provided base DNs.
-
deregisterBaseDNs
public void deregisterBaseDNs(Backend<? extends BackendCfg> backend)
Deregisters all the base DNs for the provided backend.- Parameters:
backend
- The non-null
backend for which to deregister al the base DNs.
-
applyConfigurationChange
public ConfigChangeResult applyConfigurationChange(BackendCfg cfg)
Description copied from interface:ConfigurationChangeListener
Applies the configuration changes to this change listener.- Specified by:
applyConfigurationChange
in interfaceConfigurationChangeListener<BackendCfg>
- Parameters:
cfg
- The new configuration containing the changes.- Returns:
- Returns information about the result of changing the configuration.
-
activateBackend
public void activateBackend(String backendId) throws LdapException
Loads and registers a configured and enabled backend.Load the backend's implementation class,
configures
,opens
and registers it.Trying to activate a backend which is already activated does nothing.
- Parameters:
backendId
- Identifies the backend to be activated.- Throws:
LdapException
- If the backend cannot be loaded or registered because it does not exist (NO_SUCH_OBJECT
) orOTHER
for all other reasons.
-
deactivateBackend
public void deactivateBackend(String backendId) throws LdapException
Deregisters and finalizes a configured and active backend.Trying to deactivate a backend which is already deactivated does nothing.
- Parameters:
backendId
- Identifies the backend to be deactivated.- Throws:
LdapException
- If the backend cannot be found (ResultCode.NO_SUCH_OBJECT
NO_SUCH_OBJECT).ResultCode.OTHER
is used for all other reasons.
-
registerBackend
public void registerBackend(Backend<? extends BackendCfg> backend) throws LdapException
Registers a backend.Register an already initialized backend. The backend will then be in charge of processing operations targeting entries with a DN being a subordinate of the base DNs this backend declares being in charge of.
- Parameters:
backend
- The backend to register with the server. Neither the backend nor its backend ID may benull
.- Throws:
LdapException
- If the backend ID for the provided backend conflicts with the backend ID of an already registered backend.
-
isConfigurationAddAcceptable
public boolean isConfigurationAddAcceptable(BackendCfg backendCfg, List<LocalizableMessage> unacceptableReason)
Description copied from interface:ConfigurationAddListener
Indicates whether the proposed addition of a new configuration is acceptable to this add listener.- Specified by:
isConfigurationAddAcceptable
in interfaceConfigurationAddListener<BackendCfg>
- Parameters:
backendCfg
- The configuration that will be added.unacceptableReason
- A list that can be used to hold messages about why the provided configuration is not acceptable.- Returns:
- Returns
true
if the proposed addition is acceptable, orfalse
if it is not.
-
applyConfigurationAdd
public ConfigChangeResult applyConfigurationAdd(BackendCfg cfg)
Description copied from interface:ConfigurationAddListener
Adds a new configuration to this add listener.- Specified by:
applyConfigurationAdd
in interfaceConfigurationAddListener<BackendCfg>
- Parameters:
cfg
- The configuration that will be added.- Returns:
- Returns information about the result of adding the configuration.
-
isConfigurationDeleteAcceptable
public boolean isConfigurationDeleteAcceptable(BackendCfg cfg, List<LocalizableMessage> unacceptableReason)
Description copied from interface:ConfigurationDeleteListener
Indicates whether the proposed deletion of an existing configuration is acceptable to this delete listener.- Specified by:
isConfigurationDeleteAcceptable
in interfaceConfigurationDeleteListener<BackendCfg>
- Parameters:
cfg
- The configuration that will be deleted.unacceptableReason
- A list that can be used to hold messages about why the provided configuration is not acceptable.- Returns:
- Returns
true
if the proposed deletion is acceptable, orfalse
if it is not.
-
applyConfigurationDelete
public ConfigChangeResult applyConfigurationDelete(BackendCfg cfg)
Description copied from interface:ConfigurationDeleteListener
Deletes an existing configuration from this delete listener.- Specified by:
applyConfigurationDelete
in interfaceConfigurationDeleteListener<BackendCfg>
- Parameters:
cfg
- The existing configuration that will be deleted.- Returns:
- Returns information about the result of deleting the configuration.
-
deregisterBackend
public void deregisterBackend(Backend<? extends BackendCfg> backend)
Deregisters a backend.- Parameters:
backend
- The backend to deregister with the server. It must not benull
.
-
shutdownBackends
public void shutdownBackends()
Shutdown all backends.
-
-