Class MongoDbConnection
java.lang.Object
io.debezium.connector.mongodb.connection.MongoDbConnection
- All Implemented Interfaces:
AutoCloseable
Scoped Mongodb Connection which applies filter configuration and replica set specification when required
Internally this wrapper attempts to obtain regular
MongoClient instance-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interface -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringprivate final MongoDbConnectorConfigprivate final Supplier<com.mongodb.client.MongoClient>private final MongoDbConnection.ErrorHandlerprivate final Filtersprivate final Stringprivate static final DurationA pause between failed MongoDB operations to prevent CPU throttling and DoS of target MongoDB database.private final AtomicBoolean -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMongoDbConnection(ReplicaSet replicaSet, MongoDbClientFactory clientFactory, MongoDbConnectorConfig config, Filters filters, MongoDbConnection.ErrorHandler errorHandler) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Get the identifiers of all the collections, applying the current collection filter configuration.Get the names of all the databases applying the current database filter configuration.voidexecute(String desc, BlockingConsumer<com.mongodb.client.MongoClient> operation) Execute the supplied operation.<T> Texecute(String desc, BlockingFunction<com.mongodb.client.MongoClient, T> operation) Execute the supplied operation.org.bson.BsonTimestamphello()Executes the ping command (Ping) using the first available databaseprivate boolean
-
Field Details
-
AUTHORIZATION_FAILURE_MESSAGE
- See Also:
-
PAUSE_AFTER_ERROR
A pause between failed MongoDB operations to prevent CPU throttling and DoS of target MongoDB database. -
filters
-
errorHandler
-
running
-
name
-
connectionSupplier
-
config
-
-
Constructor Details
-
MongoDbConnection
protected MongoDbConnection(ReplicaSet replicaSet, MongoDbClientFactory clientFactory, MongoDbConnectorConfig config, Filters filters, MongoDbConnection.ErrorHandler errorHandler)
-
-
Method Details
-
execute
public void execute(String desc, BlockingConsumer<com.mongodb.client.MongoClient> operation) throws InterruptedException Execute the supplied operation. Whenever the operation fails the error handler is called and the operation is repeated- Parameters:
desc- the description of the operation, for logging purposesoperation- the operation to be performed- Throws:
InterruptedException
-
execute
public <T> T execute(String desc, BlockingFunction<com.mongodb.client.MongoClient, T> operation) throws InterruptedExceptionExecute the supplied operation. Whenever the operation fails the error handler is called and the operation is repeated- Parameters:
desc- the description of the operation, for logging purposesoperation- the operation to be performed- Returns:
- return value of the executed operation
- Throws:
InterruptedException
-
databaseNames
Get the names of all the databases applying the current database filter configuration.- Returns:
- the database names; never null but possibly empty
- Throws:
InterruptedException
-
collections
Get the identifiers of all the collections, applying the current collection filter configuration.- Returns:
- the collection identifiers; never null
- Throws:
InterruptedException
-
hello
Executes the ping command (Ping) using the first available database- Returns:
- timestamp of the executed operation
- Throws:
InterruptedException
-
isRunning
private boolean isRunning() -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-