public final class ReplicaSetMonitorThread extends Object implements Runnable
| Modifier and Type | Field and Description |
|---|---|
private CountDownLatch |
initialized |
private org.slf4j.Logger |
logger |
private Metronome |
metronome |
private Supplier<ReplicaSets> |
monitor |
private Consumer<ReplicaSets> |
onChange |
private Runnable |
onStartup |
private ReplicaSets |
replicaSets |
| Constructor and Description |
|---|
ReplicaSetMonitorThread(Supplier<ReplicaSets> monitor,
Duration period,
Clock clock,
Runnable onStartup,
Consumer<ReplicaSets> onChange) |
| Modifier and Type | Method and Description |
|---|---|
ReplicaSets |
getReplicaSets(long timeout,
TimeUnit unit)
Get the information about each of the replica sets.
|
void |
run() |
private final org.slf4j.Logger logger
private final Metronome metronome
private final CountDownLatch initialized
private final Supplier<ReplicaSets> monitor
private final Consumer<ReplicaSets> onChange
private final Runnable onStartup
private volatile ReplicaSets replicaSets
public ReplicaSetMonitorThread(Supplier<ReplicaSets> monitor, Duration period, Clock clock, Runnable onStartup, Consumer<ReplicaSets> onChange)
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 neededpublic ReplicaSets getReplicaSets(long timeout, TimeUnit unit)
timeout - the time to block until the replica sets are first obtained from MongoDB; may not be negativeunit - the time unit for the timeout; may not be nullnull if the timeout occurred before the replica set information was obtainedCopyright © 2020 JBoss by Red Hat. All rights reserved.