Class MongoDbConnection

java.lang.Object
io.debezium.connector.mongodb.connection.MongoDbConnection
All Implemented Interfaces:
AutoCloseable

public final class MongoDbConnection extends Object implements AutoCloseable
Scoped Mongodb Connection which applies filter configuration and replica set specification when required Internally this wrapper attempts to obtain regular MongoClient instance
  • Field Details

  • Constructor Details

  • Method Details

    • getMongoClient

      public com.mongodb.client.MongoClient getMongoClient()
    • 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 purposes
      operation - the operation to be performed
      Throws:
      InterruptedException
    • execute

      public <T> T execute(String desc, BlockingFunction<com.mongodb.client.MongoClient,T> 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 purposes
      operation - the operation to be performed
      Returns:
      return value of the executed operation
      Throws:
      InterruptedException
    • databaseNames

      public Set<String> databaseNames() throws InterruptedException
      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

      public List<CollectionId> collections() throws InterruptedException
      Get the identifiers of all the collections, applying the current collection filter configuration.
      Returns:
      the collection identifiers; never null
      Throws:
      InterruptedException
    • hello

      public org.bson.BsonTimestamp hello() throws InterruptedException
      Executes the ping command (Ping) using the first available database
      Returns:
      timestamp of the executed operation
      Throws:
      InterruptedException
    • isRunning

      private boolean isRunning()
    • validateLogPosition

      public boolean validateLogPosition(MongoDbOffsetContext offset, MongoDbTaskContext taskContext)
    • isValidResumeToken

      private boolean isValidResumeToken(org.bson.BsonDocument token, MongoDbTaskContext taskContext)
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable