Package io.debezium.connector.mongodb
Class MongoDbSnapshotChangeEventSource
java.lang.Object
io.debezium.pipeline.source.AbstractSnapshotChangeEventSource<MongoDbPartition,MongoDbOffsetContext>
io.debezium.connector.mongodb.MongoDbSnapshotChangeEventSource
- All Implemented Interfaces:
ChangeEventSource,SnapshotChangeEventSource<MongoDbPartition,,MongoDbOffsetContext> AutoCloseable
public class MongoDbSnapshotChangeEventSource
extends AbstractSnapshotChangeEventSource<MongoDbPartition,MongoDbOffsetContext>
A
SnapshotChangeEventSource that performs multithreaded snapshots of replica sets.- Author:
- Chris Cranford
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classMutable context that is populated in the course of snapshotting.Nested classes/interfaces inherited from class io.debezium.pipeline.source.AbstractSnapshotChangeEventSource
AbstractSnapshotChangeEventSource.SnapshotContext<P extends Partition,O extends OffsetContext> Nested classes/interfaces inherited from interface io.debezium.pipeline.source.spi.ChangeEventSource
ChangeEventSource.ChangeEventSourceContext -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Clockprivate final MongoDbConnectorConfigprivate final EventDispatcher<MongoDbPartition,CollectionId> private final ErrorHandlerprivate static final org.slf4j.Loggerprivate final SnapshotProgressListener<MongoDbPartition>private final SnapshotterServiceprivate final MongoDbTaskContextFields inherited from class io.debezium.pipeline.source.AbstractSnapshotChangeEventSource
LOG_INTERVAL, notificationService -
Constructor Summary
ConstructorsConstructorDescriptionMongoDbSnapshotChangeEventSource(MongoDbConnectorConfig connectorConfig, MongoDbTaskContext taskContext, EventDispatcher<MongoDbPartition, CollectionId> dispatcher, Clock clock, SnapshotProgressListener<MongoDbPartition> snapshotProgressListener, ErrorHandler errorHandler, NotificationService<MongoDbPartition, MongoDbOffsetContext> notificationService, SnapshotterService snapshotterService) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcreateDataEvents(ChangeEventSource.ChangeEventSourceContext sourceContext, MongoDbSnapshotChangeEventSource.MongoDbSnapshotContext snapshotContext, EventDispatcher.SnapshotReceiver<MongoDbPartition> snapshotReceiver, MongoDbConnection mongo, SnapshottingTask snapshottingTask) Dispatches the data change events for the records of a single replica-set.private voidcreateDataEventsForCollection(ChangeEventSource.ChangeEventSourceContext sourceContext, MongoDbSnapshotChangeEventSource.MongoDbSnapshotContext snapshotContext, EventDispatcher.SnapshotReceiver<MongoDbPartition> snapshotReceiver, CollectionId collectionId, MongoDbConnection mongo, Map<String, String> snapshotFilterQueryForCollection) protected <T extends io.debezium.spi.schema.DataCollectionId>
Stream<T>determineDataCollectionsToBeSnapshotted(Collection<T> allDataCollections, Set<Pattern> snapshotAllowedDataCollections) determineSnapshotQuery(Map<String, String> snapshotFilterQueryForCollection, CollectionId collectionId) protected SnapshotResult<MongoDbOffsetContext>doExecute(ChangeEventSource.ChangeEventSourceContext context, MongoDbOffsetContext prevOffsetCtx, AbstractSnapshotChangeEventSource.SnapshotContext<MongoDbPartition, MongoDbOffsetContext> snapshotContext, SnapshottingTask snapshottingTask) private voiddoSnapshot(ChangeEventSource.ChangeEventSourceContext sourceCtx, MongoDbSnapshotChangeEventSource.MongoDbSnapshotContext snapshotCtx, SnapshottingTask snapshottingTask) getBlockingSnapshottingTask(MongoDbPartition partition, MongoDbOffsetContext previousOffset, SnapshotConfiguration snapshotConfiguration) private ChangeRecordEmitter<MongoDbPartition>getChangeRecordEmitter(AbstractSnapshotChangeEventSource.SnapshotContext<MongoDbPartition, MongoDbOffsetContext> snapshotContext, CollectionId collectionId, org.bson.BsonDocument document) private ClockgetClock()getSnapshottingTask(MongoDbPartition partition, MongoDbOffsetContext previousOffset) private voidprivate voidinitSnapshotStartOffsets(MongoDbSnapshotChangeEventSource.MongoDbSnapshotContext snapshotCtx, MongoDbConnection mongo) prepare(MongoDbPartition partition, boolean onDemand) Methods inherited from class io.debezium.pipeline.source.AbstractSnapshotChangeEventSource
aborted, close, completed, delaySnapshotIfNeeded, execute, getDataCollectionPattern, getOffsets
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
connectorConfig
-
taskContext
-
dispatcher
-
clock
-
snapshotProgressListener
-
errorHandler
-
snapshotterService
-
-
Constructor Details
-
MongoDbSnapshotChangeEventSource
public MongoDbSnapshotChangeEventSource(MongoDbConnectorConfig connectorConfig, MongoDbTaskContext taskContext, EventDispatcher<MongoDbPartition, CollectionId> dispatcher, Clock clock, SnapshotProgressListener<MongoDbPartition> snapshotProgressListener, ErrorHandler errorHandler, NotificationService<MongoDbPartition, MongoDbOffsetContext> notificationService, SnapshotterService snapshotterService)
-
-
Method Details
-
doExecute
protected SnapshotResult<MongoDbOffsetContext> doExecute(ChangeEventSource.ChangeEventSourceContext context, MongoDbOffsetContext prevOffsetCtx, AbstractSnapshotChangeEventSource.SnapshotContext<MongoDbPartition, MongoDbOffsetContext> snapshotContext, SnapshottingTask snapshottingTask) - Specified by:
doExecutein classAbstractSnapshotChangeEventSource<MongoDbPartition,MongoDbOffsetContext>
-
getBlockingSnapshottingTask
public SnapshottingTask getBlockingSnapshottingTask(MongoDbPartition partition, MongoDbOffsetContext previousOffset, SnapshotConfiguration snapshotConfiguration) -
getSnapshottingTask
public SnapshottingTask getSnapshottingTask(MongoDbPartition partition, MongoDbOffsetContext previousOffset) -
prepare
protected AbstractSnapshotChangeEventSource.SnapshotContext<MongoDbPartition,MongoDbOffsetContext> prepare(MongoDbPartition partition, boolean onDemand) - Specified by:
preparein classAbstractSnapshotChangeEventSource<MongoDbPartition,MongoDbOffsetContext>
-
doSnapshot
private void doSnapshot(ChangeEventSource.ChangeEventSourceContext sourceCtx, MongoDbSnapshotChangeEventSource.MongoDbSnapshotContext snapshotCtx, SnapshottingTask snapshottingTask) throws InterruptedException - Throws:
InterruptedException
-
initSnapshotStartOffsets
private void initSnapshotStartOffsets(MongoDbSnapshotChangeEventSource.MongoDbSnapshotContext snapshotCtx) -
initSnapshotStartOffsets
private void initSnapshotStartOffsets(MongoDbSnapshotChangeEventSource.MongoDbSnapshotContext snapshotCtx, MongoDbConnection mongo) throws InterruptedException - Throws:
InterruptedException
-
createDataEvents
private void createDataEvents(ChangeEventSource.ChangeEventSourceContext sourceContext, MongoDbSnapshotChangeEventSource.MongoDbSnapshotContext snapshotContext, EventDispatcher.SnapshotReceiver<MongoDbPartition> snapshotReceiver, MongoDbConnection mongo, SnapshottingTask snapshottingTask) throws InterruptedException Dispatches the data change events for the records of a single replica-set.- Throws:
InterruptedException
-
determineDataCollectionsToBeSnapshotted
protected <T extends io.debezium.spi.schema.DataCollectionId> Stream<T> determineDataCollectionsToBeSnapshotted(Collection<T> allDataCollections, Set<Pattern> snapshotAllowedDataCollections) -
createDataEventsForCollection
private void createDataEventsForCollection(ChangeEventSource.ChangeEventSourceContext sourceContext, MongoDbSnapshotChangeEventSource.MongoDbSnapshotContext snapshotContext, EventDispatcher.SnapshotReceiver<MongoDbPartition> snapshotReceiver, CollectionId collectionId, MongoDbConnection mongo, Map<String, String> snapshotFilterQueryForCollection) throws InterruptedException- Throws:
InterruptedException
-
determineSnapshotQuery
-
getChangeRecordEmitter
private ChangeRecordEmitter<MongoDbPartition> getChangeRecordEmitter(AbstractSnapshotChangeEventSource.SnapshotContext<MongoDbPartition, MongoDbOffsetContext> snapshotContext, CollectionId collectionId, org.bson.BsonDocument document) -
getClock
-