Package org.ldaptive.control.util
Class SyncReplRunner
java.lang.Object
org.ldaptive.control.util.SyncReplRunner
Class that executes a
SyncReplClient and expects to run continuously, reconnecting if the server is
unavailable. Consumers must be registered to handle entries, results, and messages as they are returned from the
server. If the connection validator fails, the runner will be stopped and started, then the sync repl search
will execute again. Consumers cannot execute blocking LDAP operations on the same connection because the next
incoming message is not read until the consumer has completed.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final CookieManagerSync repl cookie manager.private static final intNumber of I/O worker threads.private static final LoggerLogger for this class.private static final intNumber of message worker threads.Invoked when an entry is received.Invoked when an exception occurs.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.Invoked whenstart()begins.private final SearchRequestSync repl search request.private booleanWhether the sync repl search is running.private final SyncReplClientSearch operation handle. -
Constructor Summary
ConstructorsConstructorDescriptionSyncReplRunner(SingleConnectionFactory cf, SearchRequest request, CookieManager manager) Creates a new sync repl runner. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidConfigures the supplied factory for use with aSyncReplRunner.static SingleConnectionFactoryCreates a new single connection factory.static SingleConnectionFactorycreateConnectionFactory(ConnectionConfig config, ConnectionValidator validator) Creates a new single connection factory.static SingleConnectionFactorycreateConnectionFactory(Transport transport, ConnectionConfig config, ConnectionValidator validator) Creates a new single connection factory.private static TransportReturns a transport configured to use for sync repl.voidPrepare this runner for use.booleanReturns whether this runner is started.voidCancels the sync repl search and sends a new search request.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.voidsetOnStart(Supplier<Boolean> supplier) Sets the onStart supplier.voidstart()Starts this runner.voidstop()Stops this runner.toString()
-
Field Details
-
LOGGER
Logger for this class. -
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:
-
searchRequest
Sync repl search request. -
cookieManager
Sync repl cookie manager. -
syncReplClient
Search operation handle. -
onStart
Invoked whenstart()begins. -
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 occurs. -
started
private boolean startedWhether the sync repl search is running.
-
-
Constructor Details
-
SyncReplRunner
Creates a new sync repl runner. The supplied connection factory is modified to invokeSyncReplClient.send(SearchRequest, CookieManager)when the connection opens andSyncReplClient.cancel()when the connection closes.- Parameters:
cf- to get a connection fromrequest- sync repl search requestmanager- sync repl cookie manager
-
-
Method Details
-
createConnectionFactory
Creates a new single connection factory. Uses aSearchConnectionValidatorfor connection validation. SeecreateTransport()- Parameters:
config- sync repl connection configuration- Returns:
- single connection factory for use with a sync repl runner
-
createConnectionFactory
public static SingleConnectionFactory createConnectionFactory(ConnectionConfig config, ConnectionValidator validator) Creates a new single connection factory. SeecreateTransport().- Parameters:
config- sync repl connection configurationvalidator- connection validator- Returns:
- single connection factory for use with a sync repl runner
-
createConnectionFactory
public static SingleConnectionFactory createConnectionFactory(Transport transport, ConnectionConfig config, ConnectionValidator validator) Creates a new single connection factory.- Parameters:
transport- sync repl connection transportconfig- sync repl connection configurationvalidator- connection validator- Returns:
- single connection factory for use with a sync repl runner
-
configureConnectionFactory
Configures the supplied factory for use with aSyncReplRunner. The factory's configuration will have the following modifications:ConnectionConfig.setAutoReconnect(boolean)to falseConnectionConfig.setAutoReplay(boolean)to falseConnectionConfig.setAutoRead(boolean)to falseSingleConnectionFactory.setFailFastInitialize(boolean)to falseSingleConnectionFactory.setNonBlockingInitialize(boolean)to falseAbstractConnectionValidator.setOnFailure(Consumer)toSingleConnectionFactory.ReinitializeConnectionConsumer
- 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 never to be shutdown.- Returns:
- transport
-
setOnStart
Sets the onStart supplier.- Parameters:
supplier- to invoke on start
-
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 an exception is received
-
initialize
public void initialize()Prepare this runner for use. -
start
public void start()Starts this runner. -
stop
public void stop()Stops this runner. -
isStarted
public boolean isStarted()Returns whether this runner is started.- Returns:
- whether this runner is started
-
restartSearch
public void restartSearch()Cancels the sync repl search and sends a new search request. -
toString
-