Class PersistentSearch


  • public final class PersistentSearch
    extends Object
    This class defines a data structure that will be used to hold the information necessary for processing a persistent search.

    Operations are responsible for managing the persistent searches that they are currently handling.

    Typically, a search operation will first decode the persistent search control and construct a new PersistentSearch.

    Once the initial search result set has been returned and no errors encountered, the search operation should register a cancellation callback which will be invoked when the persistent search is cancelled. This is achieved using registerCancellationCallback(CancellationCallback). The callback should make sure that any resources associated with the PersistentSearch are released. This may included removing the PersistentSearch from a list, or abandoning a persistent search operation that has been sent to a remote server.

    Finally, the PersistentSearch should be enabled using enable(). This method will register the PersistentSearch with the client connection and notify the underlying search operation that no result should be sent to the client.

    Persistent searches should be shutdown with cancel(boolean) when the operation fails, or its backend is shutdown, etc.

    • Constructor Detail

      • PersistentSearch

        public PersistentSearch​(SearchOperation searchOperation,
                                Set<PersistentSearchChangeType> changeTypes,
                                boolean changesOnly,
                                boolean returnECs,
                                ServerContext serverContext)
        Creates a new persistent search object with the provided information.
        Parameters:
        searchOperation - The search operation for this persistent search.
        changeTypes - The change types for which changes should be examined.
        changesOnly - whether to only return entries that have been updated since the beginning of the search
        returnECs - Indicates whether to include entry change notification controls in search result entries sent to the client.
        serverContext - the server context
    • Method Detail

      • enable

        public void enable()
        Enable this persistent search. The persistent search will be registered with the client connection and will be prevented from sending responses to the client.
      • cancel

        public void cancel()
        Cancels this persistent search operation. On exit this persistent search will no longer be valid and any resources associated with it will have been released. In addition, any other persistent searches that are associated with this persistent search will also be cancelled.
      • abort

        public void abort()
        Server side abort of this persistent search operation. Has the same behaviour as client cancel cancel(), (invalidate persistent search, associated searches cancelled) and it sends a result code to the client to warn of the server error.
      • isCancelled

        public boolean isCancelled()
        Returns whether this persistent search is cancelled.
        Returns:
        true if this persistent search is cancelled,false otherwise
      • getMessageID

        public int getMessageID()
        Gets the message ID associated with this persistent search.
        Returns:
        The message ID associated with this persistent search.
      • getSearchOperation

        public SearchOperation getSearchOperation()
        Get the search operation associated with this persistent search.
        Returns:
        The search operation associated with this persistent search.
      • isChangesOnly

        public boolean isChangesOnly()
        Returns whether only entries updated after the beginning of this persistent search should be returned.
        Returns:
        true if only entries updated after the beginning of this search should be returned, false otherwise
      • processAdd

        public void processAdd​(Entry entry)
        Notifies the persistent searches that an entry has been added.
        Parameters:
        entry - The entry that was added.
      • processDelete

        public void processDelete​(Entry entry)
        Notifies the persistent searches that an entry has been deleted.
        Parameters:
        entry - The entry that was deleted.
      • processModify

        public void processModify​(Entry entry,
                                  Entry oldEntry)
        Notifies persistent searches that an entry has been modified.
        Parameters:
        entry - The entry after it was modified.
        oldEntry - The entry before it was modified.
      • processModifyDN

        public void processModifyDN​(Entry entry,
                                    Dn oldDN)
        Notifies the persistent searches that an entry has been renamed.
        Parameters:
        entry - The entry after it was modified.
        oldDN - The DN of the entry before it was renamed.
      • registerCancellationCallback

        public void registerCancellationCallback​(PersistentSearch.CancellationCallback callback)
        Registers a cancellation callback with this persistent search. The cancellation callback will be notified when this persistent search has been cancelled.
        Parameters:
        callback - The cancellation callback.
      • toString

        public String toString()
        Retrieves a string representation of this persistent search.
        Overrides:
        toString in class Object
        Returns:
        A string representation of this persistent search.