Package io.debezium.connector.mongodb
Class ReplicaSetMonitorThread
- java.lang.Object
-
- io.debezium.connector.mongodb.ReplicaSetMonitorThread
-
- All Implemented Interfaces:
Runnable
public final class ReplicaSetMonitorThread extends Object implements 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
Fields Modifier and Type Field Description private CountDownLatchinitializedprivate org.slf4j.Loggerloggerprivate Metronomemetronomeprivate Supplier<ReplicaSets>monitorprivate Consumer<ReplicaSets>onChangeprivate RunnableonStartupprivate ReplicaSetsreplicaSets
-
Constructor Summary
Constructors Constructor Description ReplicaSetMonitorThread(Supplier<ReplicaSets> monitor, Duration period, Clock clock, Runnable onStartup, Consumer<ReplicaSets> onChange)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ReplicaSetsgetReplicaSets(long timeout, TimeUnit unit)Get the information about each of the replica sets.voidrun()
-
-
-
Field Detail
-
logger
private final org.slf4j.Logger logger
-
metronome
private final Metronome metronome
-
initialized
private final CountDownLatch initialized
-
monitor
private final Supplier<ReplicaSets> monitor
-
onChange
private final Consumer<ReplicaSets> onChange
-
onStartup
private final Runnable onStartup
-
replicaSets
private volatile ReplicaSets replicaSets
-
-
Constructor Detail
-
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 Detail
-
getReplicaSets
public ReplicaSets getReplicaSets(long timeout, TimeUnit unit)
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
-
-