Package io.debezium.connector.mongodb
Class ConnectionContext
java.lang.Object
io.debezium.connector.mongodb.ConnectionContext
- All Implemented Interfaces:
AutoCloseable
- Author:
- Randall Hauch
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA supplier of a client that connects only to the primary of a replica set.static interface -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Configurationprivate static final org.slf4j.Loggerprivate static final DurationA pause between failed MongoDB operations to prevent CPU throttling and DoS of target MongoDB database.protected final MongoClientsprotected final DelayStrategyprotected final boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.mongodb.client.MongoClientclientFor(com.mongodb.ConnectionString connectionString) com.mongodb.client.MongoClientclientFor(ReplicaSet replicaSet) com.mongodb.client.MongoClientcom.mongodb.client.MongoClientprotected com.mongodb.client.MongoClientclientForPrimary(ReplicaSet replicaSet) Obtain a client that talks only to the primary node of the replica set.com.mongodb.client.MongoClientclients()final voidclose()Initial connection seed which is either a host specification or connection stringOptional<com.mongodb.ConnectionString>hosts()protected org.slf4j.Loggerlogger()intbooleanprotected Supplier<com.mongodb.client.MongoClient>primaryClientFor(ReplicaSet replicaSet) Obtain a client that will repeated try to obtain a client to the primary node of the replica set, waiting (and using this context's back-off strategy) if required until the primary becomes available.protected Supplier<com.mongodb.client.MongoClient>primaryClientFor(ReplicaSet replicaSet, ConnectionContext.PrimaryConnectFailed handler) Obtain a client that will repeated try to obtain a client to the primary node of the replica set, waiting (and using this context's back-off strategy) if required until the primary becomes available.primaryFor(ReplicaSet replicaSet, Filters filters, BiConsumer<String, Throwable> errorHandler) Obtain a client that will repeated try to obtain a client to the primary node of the replica set, waiting (and using this context's back-off strategy) if required until the primary becomes available.voidshutdown()
-
Field Details
-
PAUSE_AFTER_ERROR
A pause between failed MongoDB operations to prevent CPU throttling and DoS of target MongoDB database. -
LOGGER
private static final org.slf4j.Logger LOGGER -
config
-
pool
-
-
useHostsAsSeeds
protected final boolean useHostsAsSeeds
-
-
Constructor Details
-
ConnectionContext
- Parameters:
config- the configuration
-
-
Method Details
-
shutdown
public void shutdown() -
close
public final void close()- Specified by:
closein interfaceAutoCloseable
-
logger
protected org.slf4j.Logger logger() -
clients
-
performSnapshotEvenIfNotNeeded
public boolean performSnapshotEvenIfNotNeeded() -
clientFor
-
clientFor
-
clientForSeedConnection
public com.mongodb.client.MongoClient clientForSeedConnection() -
clientFor
public com.mongodb.client.MongoClient clientFor(com.mongodb.ConnectionString connectionString) -
clientFor
-
hosts
-
connectionSeed
Initial connection seed which is either a host specification or connection string- Returns:
- hosts or connection string
-
connectionString
-
pollInterval
-
maxConnectionAttemptsForPrimary
public int maxConnectionAttemptsForPrimary() -
primaryFor
public ConnectionContext.MongoPrimary primaryFor(ReplicaSet replicaSet, Filters filters, BiConsumer<String, Throwable> errorHandler) Obtain a client that will repeated try to obtain a client to the primary node of the replica set, waiting (and using this context's back-off strategy) if required until the primary becomes available.- Parameters:
replicaSet- the replica set information; may not be nullfilters- the filter configurationerrorHandler- the function to be called whenever the primary is unable toexecutean operation to completion; may be null- Returns:
- the client, or
nullif no primary could be found for the replica set
-
primaryClientFor
Obtain a client that will repeated try to obtain a client to the primary node of the replica set, waiting (and using this context's back-off strategy) if required until the primary becomes available.- Parameters:
replicaSet- the replica set information; may not be null- Returns:
- the client, or
nullif no primary could be found for the replica set
-
primaryClientFor
protected Supplier<com.mongodb.client.MongoClient> primaryClientFor(ReplicaSet replicaSet, ConnectionContext.PrimaryConnectFailed handler) Obtain a client that will repeated try to obtain a client to the primary node of the replica set, waiting (and using this context's back-off strategy) if required until the primary becomes available.- Parameters:
replicaSet- the replica set information; may not be nullhandler- the function that will be called when the primary could not be obtained; may not be null- Returns:
- the client, or
nullif no primary could be found for the replica set
-
clientForPrimary
Obtain a client that talks only to the primary node of the replica set.- Parameters:
replicaSet- the replica set information; may not be null- Returns:
- the client, or
nullif no primary could be found for the replica set
-