Package org.ldaptive.control.util
Class SyncReplClient
java.lang.Object
org.ldaptive.control.util.SyncReplClient
Client that simplifies using the sync repl control.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ConnectionFactoryConnection factory to get a connection from.private SearchOperationHandleSearch operation handle.private static final intNumber of I/O worker threads.protected final LoggerLogger for this class.private static final intNumber of message worker threads.Invoked when an entry is received.Invoked when an exception is received.private Consumer<SyncInfoMessage>Invoked when a sync info message is received.private Consumer<SearchResultReference>Invoked when a reference is received.Invoked when a result is received.private booleanWhether the sync repl search has received a result response.private final booleanControls which mode the sync repl control should use.private final booleanControls the sync repl request reload hint. -
Constructor Summary
ConstructorsConstructorDescriptionSyncReplClient(ConnectionFactory cf, boolean persist) Creates a new sync repl client.SyncReplClient(ConnectionFactory cf, boolean persist, boolean hint) Creates a new sync repl client. -
Method Summary
Modifier and TypeMethodDescriptionprivate RequestControl[]appendRequestControls(SearchRequest request, CookieManager manager) Creates a new array of request controls which includes the sync request control.cancel()Sends a cancel operation on the underlying search operation.voidclose()Closes the connection factory.static voidConfigures the supplied factory for use with aSyncReplClient.static SingleConnectionFactoryCreates a new single connection factory.private static TransportReturns a transport configured to use for sync repl.Returns the connection factory.booleanReturns whether a search result has been received by this client.send(SearchRequest request) Invokessend(SearchRequest, CookieManager)with aDefaultCookieManager.send(SearchRequest request, CookieManager manager) Performs an async search operation with theSyncRequestControl.voidsetOnEntry(Consumer<LdapEntry> consumer) Sets the onEntry consumer.voidsetOnException(Consumer<Exception> consumer) Sets the onException consumer.voidsetOnMessage(Consumer<SyncInfoMessage> consumer) Sets the onMessage consumer.voidsetOnReference(Consumer<SearchResultReference> consumer) Sets the onReference consumer.voidsetOnResult(Consumer<Result> consumer) Sets the onResult consumer.toString()
-
Field Details
-
IO_WORKER_THREADS
private static final int IO_WORKER_THREADSNumber of I/O worker threads.- See Also:
-
MESSAGE_WORKER_THREADS
private static final int MESSAGE_WORKER_THREADSNumber of message worker threads.- See Also:
-
logger
Logger for this class. -
factory
Connection factory to get a connection from. -
refreshAndPersist
private final boolean refreshAndPersistControls which mode the sync repl control should use. -
reloadHint
private final boolean reloadHintControls the sync repl request reload hint. -
handle
Search operation handle. -
onEntry
Invoked when an entry is received. -
onReference
Invoked when a reference is received. -
onResult
Invoked when a result is received. -
onMessage
Invoked when a sync info message is received. -
onException
Invoked when an exception is received. -
receivedResult
private boolean receivedResultWhether the sync repl search has received a result response.
-
-
Constructor Details
-
SyncReplClient
Creates a new sync repl client.- Parameters:
cf- to get a connection frompersist- whether to refresh and persist or just refresh
-
SyncReplClient
Creates a new sync repl client.- Parameters:
cf- to get a connection frompersist- whether to refresh and persist or just refreshhint- sync repl request reload hint
-
-
Method Details
-
createConnectionFactory
Creates a new single connection factory. SeecreateTransport().- Parameters:
config- sync repl connection configuration- Returns:
- single connection factory for use with a sync repl client
-
configureConnectionFactory
Configures the supplied factory for use with aSyncReplClient. The factory's configuration will have the following modifications:- Parameters:
factory- to configure
-
createTransport
Returns a transport configured to use for sync repl. UseIO_WORKER_THREADSnumber of I/O threads andMESSAGE_WORKER_THREADSnumber of message threads. This transport is configured to be shutdown when the connection factory closes.- Returns:
- transport
-
getConnectionFactory
Returns the connection factory.- Returns:
- connection factory
-
setOnEntry
Sets the onEntry consumer.- Parameters:
consumer- to invoke when an entry is received
-
setOnReference
Sets the onReference consumer.- Parameters:
consumer- to invoke when a reference is received
-
setOnResult
Sets the onResult consumer.- Parameters:
consumer- to invoke when a result is received
-
setOnMessage
Sets the onMessage consumer.- Parameters:
consumer- to invoke when a sync info message is received
-
setOnException
Sets the onException consumer.- Parameters:
consumer- to invoke when a sync info message is received
-
send
Invokessend(SearchRequest, CookieManager)with aDefaultCookieManager.- Parameters:
request- search request to execute- Returns:
- search operation handle
- Throws:
LdapException- if the search fails
-
send
public SearchOperationHandle send(SearchRequest request, CookieManager manager) throws LdapException Performs an async search operation with theSyncRequestControl. The supplied request is modified in the following way:AbstractRequestMessage.setControls(org.ldaptive.control.RequestControl...)is invoked withSyncRequestControl
The search request object should not be reused for any other search operations.
- Parameters:
request- search request to executemanager- for reading and writing cookies- Returns:
- search operation handle
- Throws:
LdapException- if the search fails
-
isComplete
public boolean isComplete()Returns whether a search result has been received by this client.- Returns:
- whether a search result has been received
-
cancel
Sends a cancel operation on the underlying search operation. SeeDefaultOperationHandle.cancel().- Returns:
- cancel operation result
-
close
public void close()Closes the connection factory. -
toString
-
appendRequestControls
Creates a new array of request controls which includes the sync request control. Any other request controls are included.- Parameters:
request- to read controls frommanager- to read the cookie from- Returns:
- array of request controls ready to be used in a search operation
-