Class PersistentSearch
- java.lang.Object
-
- org.opends.server.core.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 thePersistentSearch
are released. This may included removing thePersistentSearch
from a list, or abandoning a persistent search operation that has been sent to a remote server.Finally, the
PersistentSearch
should be enabled usingenable()
. This method will register thePersistentSearch
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
PersistentSearch.CancellationCallback
A cancellation callback which can be used in order to register for resource cleanup when a persistent search is cancelled.
-
Constructor Summary
Constructors Constructor Description PersistentSearch(SearchOperation searchOperation, Set<PersistentSearchChangeType> changeTypes, boolean changesOnly, boolean returnEntryChangeNotificationControls, ServerContext serverContext)
Creates a new persistent search object with the provided information.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
abort()
Server side abort of this persistent search operation.void
cancel()
Cancels this persistent search operation.void
enable()
Enable this persistent search.int
getMessageID()
Gets the message ID associated with this persistent search.SearchOperation
getSearchOperation()
Get the search operation associated with this persistent search.boolean
isCancelled()
Returns whether this persistent search is cancelled.boolean
isChangesOnly()
Returns whether only entries updated after the beginning of this persistent search should be returned.void
processAdd(Entry entry)
Notifies the persistent searches that an entry has been added.void
processDelete(Entry entry)
Notifies the persistent searches that an entry has been deleted.void
processModify(Entry entry, Entry oldEntry)
Notifies persistent searches that an entry has been modified.void
processModifyDN(Entry entry, Dn oldDN)
Notifies the persistent searches that an entry has been renamed.void
registerCancellationCallback(PersistentSearch.CancellationCallback callback)
Registers a cancellation callback with this persistent search.String
toString()
Retrieves a string representation of this persistent search.
-
-
-
Constructor Detail
-
PersistentSearch
public PersistentSearch(SearchOperation searchOperation, Set<PersistentSearchChangeType> changeTypes, boolean changesOnly, boolean returnEntryChangeNotificationControls, 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 searchreturnEntryChangeNotificationControls
- Indicates whether to include the entry change notification response 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 cancelcancel()
, (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.
-
-