use of io.debezium.util.LoggingContext.PreviousContext in project debezium by debezium.
the class MongoDbConnectorTask method stop.
@Override
public void stop() {
PreviousContext previousLogContext = this.taskContext.configureLoggingContext(taskName);
try {
// Signal to the 'poll()' method that it should stop what its doing ...
if (this.running.compareAndSet(true, false)) {
logger.info("Stopping MongoDB task");
// Stop all running replicators ...
Replicator replicator = null;
int counter = 0;
while ((replicator = this.replicators.poll()) != null) {
replicator.stop();
++counter;
}
logger.info("Stopped MongoDB replication task by stopping {} replicator threads", counter);
}
} catch (Throwable e) {
logger.error("Unexpected error shutting down the MongoDB replication task", e);
} finally {
previousLogContext.restore();
}
}
Aggregations