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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBackendConfigManager.NamingContextRepresents a naming context, determined by its base DN.static classBackendConfigManager.NamingContextFilterFilter on 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 ConfigChangeResultapplyConfigurationAdd(BackendCfg cfg)Adds a new configuration to this add listener.ConfigChangeResultapplyConfigurationChange(BackendCfg cfg)Applies the configuration changes to this change listener.ConfigChangeResultapplyConfigurationDelete(BackendCfg configEntry)Deletes an existing configuration from this delete listener.booleancontainsLocalNamingContext(DN dn)Indicates whether the specified DN is contained in the local backends as a naming context.voidderegisterBaseDN(DN baseDN)Deregisters the provided base DN.voidderegisterLocalBackend(LocalBackend<?> backend)Deregisters a local backend.voidderegisterLocalBackendInitializationListener(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.DNfindNamingContextForEntry(DN entryDN)Retrieves the naming context that should be used to handle operations on the specified entry.Set<DN>findSubordinateLocalNamingContextsForEntry(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.Set<DN>findSubordinateLocalNamingContextsToSearchForEntry(DN entryDN)Retrieves the set of local naming contexts that are subordinates of the naming context that should be used to handle search operation on the specified entry.Set<Backend<?>>getAllBackends()Returns the set of all backends.LocalBackend<?>getLocalBackendById(String backendId)Retrieves a local backend provided its identifier.Set<LocalBackend<?>>getLocalBackends()Returns the set of local backends.LocalBackend<?>getLocalBackendWithBaseDN(DN baseDN)Retrieves the local backend with the specified base DN.Set<DN>getNamingContexts(BackendConfigManager.NamingContextFilter... filters)Retrieves naming contexts corresponding to backends, filtered with the combination of all provided filters.DNgetParentDNInSuffix(DN dn)Retrieves the DN that is the immediate parent for this DN.RootDSEBackendgetRootDSEBackend()Retrieves the Root DSE backend.Set<Backend<?>>getSubordinateBackends(Backend<?> backend)Retrieves the set of subordinate backends of the provided backend.booleanhasLocalBackend(String backendID)Indicates whether the local backend with the provided id exists.voidinitializeBackendConfig(Collection<String> backendIDsToStart)Initializes the configuration associated with the Directory Server backends.voidinitializeBackends(Collection<String> backendIDsToStart, RootCfg root)Initializes specified backends.booleanisConfigurationAddAcceptable(BackendCfg configEntry, List<org.forgerock.i18n.LocalizableMessage> unacceptableReason)Indicates whether the proposed addition of a new configuration is acceptable to this add listener.booleanisConfigurationChangeAcceptable(BackendCfg configEntry, List<org.forgerock.i18n.LocalizableMessage> unacceptableReason)Indicates whether the proposed change to the configuration is acceptable to this change listener.booleanisConfigurationDeleteAcceptable(BackendCfg configEntry, List<org.forgerock.i18n.LocalizableMessage> unacceptableReason)Indicates whether the proposed deletion of an existing configuration is acceptable to this delete listener.voidregisterBaseDN(DN baseDN, Backend<? extends BackendCfg> backend, boolean isPrivate)Registers the provided base DN.voidregisterLocalBackend(LocalBackend<?> backend)Registers a local backend.voidregisterLocalBackendInitializationListener(LocalBackendInitializationListener listener)Registers a local backend initialization listener.voidshutdownLocalBackends()Shutdown all local backends.
-
-
-
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
-
getLocalBackends
public Set<LocalBackend<?>> getLocalBackends()
Returns the set of local backends.- Returns:
- the local 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
nullif there is no local backend registered 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
nullif 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
nullif 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
nullif 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
nullif 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
nullif there is no local backend registered with the specified id.
-
hasLocalBackend
public boolean hasLocalBackend(String backendID)
Indicates whether the local backend with the provided id exists.- Parameters:
backendID- The backend ID for which to make the determination.- Returns:
trueif a backend with the specified backend ID exists,falseotherwise
-
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
-
findSubordinateLocalNamingContextsForEntry
public Set<DN> findSubordinateLocalNamingContextsForEntry(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 context.- Returns:
- The naming context or
nullif no appropriate naming context is registered with the server.
-
findSubordinateLocalNamingContextsToSearchForEntry
public Set<DN> findSubordinateLocalNamingContextsToSearchForEntry(DN entryDN)
Retrieves the set of local naming contexts that are subordinates of the naming context that should be used to handle search operation on the specified entry.The global option that restricts the subordinate DNs to search (when searching "") may apply if the provided set is not empty.
- Parameters:
entryDN- The DN of the entry for which to retrieve the corresponding naming context.- Returns:
- The naming context or
nullif no appropriate naming context is registered with the server.
-
getNamingContexts
public Set<DN> getNamingContexts(BackendConfigManager.NamingContextFilter... filters)
Retrieves naming contexts corresponding to backends, filtered with the combination of all provided filters.- Parameters:
filters- 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:
trueif the specified DN is a naming context in one backend, orfalseif it is not.
-
registerBaseDN
public void registerBaseDN(DN baseDN, Backend<? extends BackendCfg> backend, boolean isPrivate) throws DirectoryException
Registers the provided base DN.- Parameters:
baseDN- The base DN to register. It must not benull.backend- The backend responsible for the provided base DN. It must not benull.isPrivate- Indicates whether the base DN should be considered a private base DN. If the provided base DN is a naming context, then this controls whether it is public or private.- Throws:
DirectoryException- If a problem occurs while attempting to register the provided base DN.
-
registerLocalBackend
public void registerLocalBackend(LocalBackend<?> backend) throws DirectoryException
Registers a local backend.- Parameters:
backend- The backend to register with the server. Neither the backend nor its backend ID may be null.- Throws:
DirectoryException- If the backend ID for the provided backend conflicts with the backend ID of an existing backend.
-
registerLocalBackendInitializationListener
public void registerLocalBackendInitializationListener(LocalBackendInitializationListener listener)
Registers a local backend initialization listener.- Parameters:
listener- The listener to register.
-
deregisterBaseDN
public void deregisterBaseDN(DN baseDN) throws DirectoryException
Deregisters the provided base DN.- Parameters:
baseDN- The base DN to deregister. It must not benull.- Throws:
DirectoryException- If a problem occurs while attempting to deregister the provided base DN.
-
deregisterLocalBackendInitializationListener
public void deregisterLocalBackendInitializationListener(LocalBackendInitializationListener listener)
Deregisters a local backend initialization listener.- Parameters:
listener- The listener to deregister.
-
deregisterLocalBackend
public void deregisterLocalBackend(LocalBackend<?> backend)
Deregisters a local backend.- Parameters:
backend- The backend to deregister with the server. It must not benull.
-
isConfigurationChangeAcceptable
public boolean isConfigurationChangeAcceptable(BackendCfg configEntry, List<org.forgerock.i18n.LocalizableMessage> unacceptableReason)
Description copied from interface:ConfigurationChangeListenerIndicates whether the proposed change to the configuration is acceptable to this change listener.- Specified by:
isConfigurationChangeAcceptablein interfaceConfigurationChangeListener<BackendCfg>- Parameters:
configEntry- 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
trueif the proposed change is acceptable, orfalseif it is not.
-
applyConfigurationChange
public ConfigChangeResult applyConfigurationChange(BackendCfg cfg)
Description copied from interface:ConfigurationChangeListenerApplies the configuration changes to this change listener.- Specified by:
applyConfigurationChangein interfaceConfigurationChangeListener<BackendCfg>- Parameters:
cfg- The new configuration containing the changes.- Returns:
- Returns information about the result of changing the configuration.
-
isConfigurationAddAcceptable
public boolean isConfigurationAddAcceptable(BackendCfg configEntry, List<org.forgerock.i18n.LocalizableMessage> unacceptableReason)
Description copied from interface:ConfigurationAddListenerIndicates whether the proposed addition of a new configuration is acceptable to this add listener.- Specified by:
isConfigurationAddAcceptablein interfaceConfigurationAddListener<BackendCfg>- Parameters:
configEntry- 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
trueif the proposed addition is acceptable, orfalseif it is not.
-
applyConfigurationAdd
public ConfigChangeResult applyConfigurationAdd(BackendCfg cfg)
Description copied from interface:ConfigurationAddListenerAdds a new configuration to this add listener.- Specified by:
applyConfigurationAddin 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 configEntry, List<org.forgerock.i18n.LocalizableMessage> unacceptableReason)
Description copied from interface:ConfigurationDeleteListenerIndicates whether the proposed deletion of an existing configuration is acceptable to this delete listener.- Specified by:
isConfigurationDeleteAcceptablein interfaceConfigurationDeleteListener<BackendCfg>- Parameters:
configEntry- 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
trueif the proposed deletion is acceptable, orfalseif it is not.
-
applyConfigurationDelete
public ConfigChangeResult applyConfigurationDelete(BackendCfg configEntry)
Description copied from interface:ConfigurationDeleteListenerDeletes an existing configuration from this delete listener.- Specified by:
applyConfigurationDeletein interfaceConfigurationDeleteListener<BackendCfg>- Parameters:
configEntry- The existing configuration that will be deleted.- Returns:
- Returns information about the result of deleting the configuration.
-
shutdownLocalBackends
public void shutdownLocalBackends()
Shutdown all local backends.
-
-