Class ChangelogBackend


  • public class ChangelogBackend
    extends LocalBackend<LocalBackendCfg>
    A backend that provides access to the changelog, i.e. the "cn=changelog" suffix. It is a read-only backend that is created by a ReplicationServer and is not configurable.

    There are two modes to search the changelog:

    • Cookie mode: when a "ECL Cookie Exchange Control" is provided with the request. The cookie provided in the control is used to retrieve entries from the ReplicaDBs. The changeNumber attribute is not returned with the entries.
    • Change number mode: when no "ECL Cookie Exchange Control" is provided with the request. The entries are retrieved using the ChangeNumberIndexDB and their attributes are set with the information from the ReplicasDBs. The changeNumber attribute value is set from the content of ChangeNumberIndexDB.

    Searches flow

    Here is the flow of searches within the changelog backend APIs:

    See Also:
    ReplicationServer
    • Field Detail

      • CHANGELOG_BASE_DN

        public static final DN CHANGELOG_BASE_DN
        The base DN for the external change log.
    • Constructor Detail

      • ChangelogBackend

        public ChangelogBackend​(ReplicationServer replicationServer,
                                ECLEnabledDomainPredicate domainPredicate)
        Creates a new backend with the provided replication server.
        Parameters:
        replicationServer - The replication server on which the changes are read.
        domainPredicate - Returns whether a domain is enabled for the external changelog.
    • Method Detail

      • getInstance

        @Deprecated
        public static ChangelogBackend getInstance()
        Deprecated.
        instead inject the required object where needed
        Returns the ChangelogBackend configured for "cn=changelog" in this directory server.
        Returns:
        the ChangelogBackend configured for "cn=changelog" in this directory server
      • configureBackend

        public void configureBackend​(LocalBackendCfg config,
                                     ServerContext serverContext)
                              throws ConfigException
        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 class Backend<LocalBackendCfg>
        Parameters:
        config - The configuration of this backend.
        serverContext - The server context for this instance
        Throws:
        ConfigException - If there is an error in the configuration.
      • 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 class LocalBackend<LocalBackendCfg>
      • 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 class Backend<LocalBackendCfg>
        Returns:
        The set of base-level DNs that may be used within this backend.
      • 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 return true for the specified attribute and index type.
        Specified by:
        isIndexed in class LocalBackend<LocalBackendCfg>
        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, or false if not.
      • getEntry

        public Entry getEntry​(DN entryDN)
                       throws DirectoryException
        Retrieves the requested entry from this backend. The caller is not required to hold any locks on the specified DN.

        Only the base changelog entry can be retrieved by DN. Change records are streamed by search(SearchOperation), which needs the search filter and the change number range to position its cursors, so they cannot be looked up individually and null is returned for them. None of them is ever an alias, so callers dereferencing aliases get the answer they need.

        Specified by:
        getEntry in class LocalBackend<LocalBackendCfg>
        Parameters:
        entryDN - The distinguished name of the entry to retrieve.
        Returns:
        The requested entry, or null if the entry does not exist.
        Throws:
        DirectoryException - If a problem occurs while trying to retrieve the entry.
      • hasSubordinates

        public ConditionResult hasSubordinates​(DN entryDN)
                                        throws DirectoryException
        Description copied from class: LocalBackend
        Indicates whether the requested entry has any subordinates.
        Specified by:
        hasSubordinates in class LocalBackend<LocalBackendCfg>
        Parameters:
        entryDN - The distinguished name of the entry.
        Returns:
        ConditionResult.TRUE if the entry has one or more subordinates or ConditionResult.FALSE otherwise or ConditionResult.UNDEFINED if 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: 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 class LocalBackend<LocalBackendCfg>
        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: LocalBackend
        Retrieves the number of subordinates immediately below the requested entry.
        Specified by:
        getNumberOfChildren in class LocalBackend<LocalBackendCfg>
        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.
      • notifyCookieEntryAdded

        public void notifyCookieEntryAdded​(DN baseDN,
                                           UpdateMsg updateMsg)
                                    throws ChangelogException
        Notifies persistent searches of this backend that a new cookie entry was added to it.

        Note: This method correspond to the "persistent search" phase. It is executed multiple times per persistent search, multi-threaded, until the persistent search is cancelled.

        This method must only be called after the provided data have been persisted to disk.

        Parameters:
        baseDN - the baseDN of the newly added entry.
        updateMsg - the update message of the newly added entry
        Throws:
        ChangelogException - If a problem occurs while notifying of the newly added entry.
      • notifyChangeNumberEntryAdded

        public void notifyChangeNumberEntryAdded​(DN baseDN,
                                                 long changeNumber,
                                                 String cookieString,
                                                 UpdateMsg updateMsg)
                                          throws ChangelogException
        Notifies persistent searches of this backend that a new change number entry was added to it.

        Note: This method correspond to the "persistent search" phase. It is executed multiple times per persistent search, multi-threaded, until the persistent search is cancelled.

        This method must only be called after the provided data have been persisted to disk.

        Parameters:
        baseDN - the baseDN of the newly added entry.
        changeNumber - the change number of the newly added entry. It will be greater than zero for entries added to the change number index and less than or equal to zero for entries added to any replica DB
        cookieString - a string representing the cookie of the newly added entry. This is only meaningful for entries added to the change number index
        updateMsg - the update message of the newly added entry
        Throws:
        ChangelogException - If a problem occurs while notifying of the newly added entry.
      • addEntry

        public void addEntry​(Entry entry,
                             AddOperation addOperation)
                      throws DirectoryException,
                             CanceledOperationException
        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 class LocalBackend<LocalBackendCfg>
        Parameters:
        entry - The entry to add to this backend.
        addOperation - The add operation with which the new entry is associated. This may be null for adds performed internally.
        Throws:
        DirectoryException - If a problem occurs while trying to add the entry.
        CanceledOperationException - 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 DirectoryException,
                                CanceledOperationException
        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 class LocalBackend<LocalBackendCfg>
        Parameters:
        entryDN - The DN of the entry to remove from this backend.
        deleteOperation - The delete operation with which this action is associated. This may be null for deletes performed internally.
        Throws:
        DirectoryException - If a problem occurs while trying to remove the entry.
        CanceledOperationException - 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 DirectoryException,
                                 CanceledOperationException
        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 class LocalBackend<LocalBackendCfg>
        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 be null for modifications performed internally.
        Throws:
        DirectoryException - If a problem occurs while trying to replace the entry.
        CanceledOperationException - 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 DirectoryException,
                                CanceledOperationException
        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 class LocalBackend<LocalBackendCfg>
        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 be null for modify DN operations performed internally.
        Throws:
        DirectoryException - If a problem occurs while trying to perform the rename.
        CanceledOperationException - If this backend noticed and reacted to a request to cancel or abandon the modify DN operation.
      • search

        public void search​(SearchOperation searchOperation)
                    throws DirectoryException
        Processes the specified search in this backend. Matching entries should be provided back to the core server using the SearchOperation.returnEntry method. The caller is not required to have any locks when calling this operation.

        Runs the "initial search" phase (as opposed to a "persistent search" phase). The "initial search" phase is the only search run by normal searches, but it is also run by persistent searches with changesOnly=false. Persistent searches with changesOnly=true never execute this code.

        Note: this method is executed only once per persistent search, single threaded.

        Specified by:
        search in class LocalBackend<LocalBackendCfg>
        Parameters:
        searchOperation - The search operation to be processed.
        Throws:
        DirectoryException - If a problem occurs while processing the search.
      • getSupportedControls

        public Set<String> getSupportedControls()
        Description copied from class: Backend
        Retrieves the OIDs of the controls that may be supported by this backend.
        Specified by:
        getSupportedControls in class Backend<LocalBackendCfg>
        Returns:
        The OIDs of the controls that may be supported by this backend.
      • getSupportedFeatures

        public Set<String> getSupportedFeatures()
        Description copied from class: Backend
        Retrieves the OIDs of the features that may be supported by this backend.
        Specified by:
        getSupportedFeatures in class Backend<LocalBackendCfg>
        Returns:
        The OIDs of the features that may be supported by this backend.
      • supports

        public boolean supports​(LocalBackend.BackendOperation backendOperation)
        Description copied from class: LocalBackend
        Indicates whether this backend supports the provided backend operation.
        Specified by:
        supports in class LocalBackend<LocalBackendCfg>
        Parameters:
        backendOperation - the backend operation
        Returns:
        true if this backend supports the provided backend operation, false otherwise.
      • removeBackup

        public void removeBackup​(BackupDirectory backupDirectory,
                                 String backupID)
                          throws DirectoryException
        Description copied from class: LocalBackend
        Removes the specified backup if it is possible to do so.
        Specified by:
        removeBackup in class LocalBackend<LocalBackendCfg>
        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).
      • 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 class LocalBackend<LocalBackendCfg>
        Returns:
        The total number of entries contained in this backend, or -1 if that information is not available.
      • registerPersistentSearch

        public void registerPersistentSearch​(PersistentSearch pSearch)
                                      throws DirectoryException
        Description copied from class: LocalBackend
        Registers the provided persistent search operation with this backend so that it will be notified of any add, delete, modify, or modify DN operations that are performed.
        Overrides:
        registerPersistentSearch in class LocalBackend<LocalBackendCfg>
        Parameters:
        pSearch - The persistent search operation to register with this backend
        Throws:
        DirectoryException - If a problem occurs while registering the persistent search
      • updateCookieToMediumConsistencyPoint

        public static void updateCookieToMediumConsistencyPoint​(MultiDomainServerState cookie,
                                                                ECLMultiDomainDBCursor cursor,
                                                                ChangeNumberIndexRecord cnIndexRecord)
                                                         throws ChangelogException
        Rebuilds the changelogcookie starting at the newest change number index record.

        It updates the provided cookie with the changes from the provided ECL cursor, up to (and including) the provided change number index record.

        Therefore, after calling this method, the cursor is positioned to the change immediately following the provided change number index record.

        Parameters:
        cookie - the cookie to update
        cursor - the cursor where to read changes from
        cnIndexRecord - the change number index record to go right after
        Throws:
        ChangelogException - if any problem occurs