Package org.ldaptive.control.util
Class SyncReplRunner
- java.lang.Object
-
- org.ldaptive.control.util.SyncReplRunner
-
public class SyncReplRunner extends java.lang.ObjectClass that executes aSyncReplClientand 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 a consumer throws an exception, 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.- Author:
- Middleware Services
-
-
Constructor Summary
Constructors Constructor Description SyncReplRunner(ConnectionConfig config, SearchRequest request, CookieManager manager)Creates a new sync repl runner.SyncReplRunner(Transport transport, ConnectionConfig config, SearchRequest request, CookieManager manager)Creates a new sync repl runner.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidinitialize(boolean refreshAndPersist, java.time.Duration reconnectWait)Prepare this runner for use.booleanisStarted()Returns whether this runner is started.protected static SingleConnectionFactoryreconnectFactory(Transport transport, ConnectionConfig cc, java.time.Duration wait)Creates a new single connection factory that will attempt to reconnect indefinitely.voidrestartSearch()Cancels the sync repl search and sends a new search request.voidsetOnEntry(java.util.function.Consumer<LdapEntry> consumer)Sets the onEntry consumer.voidsetOnMessage(java.util.function.Consumer<SyncInfoMessage> consumer)Sets the onMessage consumer.voidsetOnResult(java.util.function.Consumer<Result> consumer)Sets the onResult consumer.voidsetOnStart(java.util.function.Supplier<java.lang.Boolean> supplier)Sets the onStart supplier.voidstart()Starts this runner.voidstop()Stops this runner.java.lang.StringtoString()
-
-
-
Constructor Detail
-
SyncReplRunner
public SyncReplRunner(ConnectionConfig config, SearchRequest request, CookieManager manager)
Creates a new sync repl runner. Uses a customConnectionFactoryTransportfor processing I/O and messages.- Parameters:
config- sync repl connection configurationrequest- sync repl search requestmanager- sync repl cookie manager
-
SyncReplRunner
public SyncReplRunner(Transport transport, ConnectionConfig config, SearchRequest request, CookieManager manager)
Creates a new sync repl runner.- Parameters:
transport- sync repl connection transportconfig- sync repl connection configurationrequest- sync repl search requestmanager- sync repl cookie manager
-
-
Method Detail
-
setOnStart
public void setOnStart(java.util.function.Supplier<java.lang.Boolean> supplier)
Sets the onStart supplier.- Parameters:
supplier- to invoke on start
-
setOnEntry
public void setOnEntry(java.util.function.Consumer<LdapEntry> consumer)
Sets the onEntry consumer.- Parameters:
consumer- to invoke when an entry is received
-
setOnResult
public void setOnResult(java.util.function.Consumer<Result> consumer)
Sets the onResult consumer.- Parameters:
consumer- to invoke when a result is received
-
setOnMessage
public void setOnMessage(java.util.function.Consumer<SyncInfoMessage> consumer)
Sets the onMessage consumer.- Parameters:
consumer- to invoke when a sync info message is received
-
initialize
public void initialize(boolean refreshAndPersist, java.time.Duration reconnectWait)Prepare this runner for use.- Parameters:
refreshAndPersist- whether to refresh and persist or just refreshreconnectWait- time to wait between open attempts
-
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
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
reconnectFactory
protected static SingleConnectionFactory reconnectFactory(Transport transport, ConnectionConfig cc, java.time.Duration wait)
Creates a new single connection factory that will attempt to reconnect indefinitely. This method creates a copy of the supplied config makes the following modifications:ConnectionConfig.setAutoReconnect(boolean)to trueConnectionConfig.setAutoReconnectCondition(Predicate)to sleep and return true for InitialRetryMetadataConnectionConfig.setAutoReplay(boolean)to false
- Parameters:
transport- connection transportcc- connection configurationwait- length of time to wait between consecutive calls to open- Returns:
- single connection factory
-
-