Package io.debezium.connector.mongodb
Class ReplicaSetMonitorThread
java.lang.Object
io.debezium.connector.mongodb.ReplicaSetMonitorThread
- All Implemented Interfaces:
Runnable
A thread that can be used to when new replica sets are added or existing replica sets are removed. The logic does not evaluate
membership changes of individual replica sets, since that is handled independently by each task.
- Author:
- Randall Hauch
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final CountDownLatchprivate final org.slf4j.Loggerprivate final Metronomeprivate final Supplier<ReplicaSets>private final Consumer<ReplicaSets>private final Runnableprivate ReplicaSets -
Constructor Summary
ConstructorsConstructorDescriptionReplicaSetMonitorThread(Supplier<ReplicaSets> monitor, Duration period, Clock clock, Runnable onStartup, Consumer<ReplicaSets> onChange) -
Method Summary
Modifier and TypeMethodDescriptiongetReplicaSets(long timeout, TimeUnit unit) Get the information about each of the replica sets.voidrun()
-
Field Details
-
logger
private final org.slf4j.Logger logger -
metronome
-
initialized
-
monitor
-
onChange
-
onStartup
-
replicaSets
-
-
Constructor Details
-
ReplicaSetMonitorThread
public ReplicaSetMonitorThread(Supplier<ReplicaSets> monitor, Duration period, Clock clock, Runnable onStartup, Consumer<ReplicaSets> onChange) - Parameters:
monitor- the component used to periodically obtain the replica set specifications; may not be nullperiod- the time period between polling checks; must be non-negativeclock- the clock to use; may be null if the system clock should be usedonStartup- the function to call when the thread is started; may be null if not neededonChange- the function to call when the set of replica set specifications has changed; may be null if not needed
-
-
Method Details
-
run
public void run() -
getReplicaSets
Get the information about each of the replica sets.- Parameters:
timeout- the time to block until the replica sets are first obtained from MongoDB; may not be negativeunit- the time unit for thetimeout; may not be null- Returns:
- the replica sets, or
nullif the timeout occurred before the replica set information was obtained
-