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 multi-threaded 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.static classA configuration describing the task to be performed during snapshotting.Nested classes/interfaces inherited from class io.debezium.pipeline.source.AbstractSnapshotChangeEventSource
AbstractSnapshotChangeEventSource.SnapshotContext<P extends Partition,O extends OffsetContext>, AbstractSnapshotChangeEventSource.SnapshottingTask Nested classes/interfaces inherited from interface io.debezium.pipeline.source.spi.ChangeEventSource
ChangeEventSource.ChangeEventSourceContext -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AtomicBooleanprivate final Clockprivate final ConnectionContextprivate final MongoDbConnection.ChangeEventSourceConnectionFactoryprivate final MongoDbConnectorConfigprivate final EventDispatcher<MongoDbPartition,CollectionId> private final ErrorHandlerprivate static final org.slf4j.Loggerprivate final ReplicaSetsprivate final SnapshotProgressListener<MongoDbPartition>private final MongoDbTaskContextFields inherited from class io.debezium.pipeline.source.AbstractSnapshotChangeEventSource
LOG_INTERVAL -
Constructor Summary
ConstructorsConstructorDescriptionMongoDbSnapshotChangeEventSource(MongoDbConnectorConfig connectorConfig, MongoDbTaskContext taskContext, MongoDbConnection.ChangeEventSourceConnectionFactory connections, ReplicaSets replicaSets, EventDispatcher<MongoDbPartition, CollectionId> dispatcher, Clock clock, SnapshotProgressListener<MongoDbPartition> snapshotProgressListener, ErrorHandler errorHandler) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcreateDataEvents(ChangeEventSource.ChangeEventSourceContext sourceCtx, MongoDbSnapshotChangeEventSource.MongoDbSnapshotContext snapshotCtx, ReplicaSet replicaSet, MongoDbConnection mongo) private voidcreateDataEventsForCollection(ChangeEventSource.ChangeEventSourceContext sourceContext, MongoDbSnapshotChangeEventSource.MongoDbSnapshotContext snapshotContext, EventDispatcher.SnapshotReceiver<MongoDbPartition> snapshotReceiver, ReplicaSet replicaSet, CollectionId collectionId, MongoDbConnection mongo) private voidcreateDataEventsForReplicaSet(ChangeEventSource.ChangeEventSourceContext sourceContext, MongoDbSnapshotChangeEventSource.MongoDbSnapshotContext snapshotContext, EventDispatcher.SnapshotReceiver<MongoDbPartition> snapshotReceiver, ReplicaSet replicaSet, MongoDbConnection mongo) Dispatches the data change events for the records of a single replica-set.protected SnapshotResult<MongoDbOffsetContext>doExecute(ChangeEventSource.ChangeEventSourceContext context, MongoDbOffsetContext prevOffsetCtx, AbstractSnapshotChangeEventSource.SnapshotContext<MongoDbPartition, MongoDbOffsetContext> snapshotContext, AbstractSnapshotChangeEventSource.SnapshottingTask snapshottingTask) private ChangeRecordEmitter<MongoDbPartition>getChangeRecordEmitter(AbstractSnapshotChangeEventSource.SnapshotContext<MongoDbPartition, MongoDbOffsetContext> snapshotContext, CollectionId collectionId, org.bson.BsonDocument document, ReplicaSet replicaSet) private ClockgetClock()getSnapshottingTask(MongoDbPartition partition, MongoDbOffsetContext offsetContext) private voidinitReplicaSetSnapshotStartOffsets(MongoDbSnapshotChangeEventSource.MongoDbSnapshotContext snapshotCtx, ReplicaSet replicaSet, MongoDbConnection mongo) private voidprivate booleanisSnapshotExpected(MongoDbPartition partition, ReplicaSet replicaSet, MongoDbOffsetContext offsetContext) private booleanisValidResumeToken(MongoDbPartition partition, ReplicaSet replicaSet, org.bson.BsonDocument token) prepare(MongoDbPartition partition) private voidsnapshotReplicaSet(ChangeEventSource.ChangeEventSourceContext sourceCtx, MongoDbSnapshotChangeEventSource.MongoDbSnapshotContext snapshotCtx, ReplicaSet replicaSet) Methods inherited from class io.debezium.pipeline.source.AbstractSnapshotChangeEventSource
aborted, close, completed, delaySnapshotIfNeeded, determineDataCollectionsToBeSnapshotted, execute
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
connectorConfig
-
taskContext
-
connections
-
connectionContext
-
replicaSets
-
dispatcher
-
clock
-
snapshotProgressListener
-
errorHandler
-
aborted
-
-
Constructor Details
-
MongoDbSnapshotChangeEventSource
public MongoDbSnapshotChangeEventSource(MongoDbConnectorConfig connectorConfig, MongoDbTaskContext taskContext, MongoDbConnection.ChangeEventSourceConnectionFactory connections, ReplicaSets replicaSets, EventDispatcher<MongoDbPartition, CollectionId> dispatcher, Clock clock, SnapshotProgressListener<MongoDbPartition> snapshotProgressListener, ErrorHandler errorHandler)
-
-
Method Details
-
doExecute
protected SnapshotResult<MongoDbOffsetContext> doExecute(ChangeEventSource.ChangeEventSourceContext context, MongoDbOffsetContext prevOffsetCtx, AbstractSnapshotChangeEventSource.SnapshotContext<MongoDbPartition, MongoDbOffsetContext> snapshotContext, AbstractSnapshotChangeEventSource.SnapshottingTask snapshottingTask) - Specified by:
doExecutein classAbstractSnapshotChangeEventSource<MongoDbPartition,MongoDbOffsetContext>
-
getSnapshottingTask
protected AbstractSnapshotChangeEventSource.SnapshottingTask getSnapshottingTask(MongoDbPartition partition, MongoDbOffsetContext offsetContext) - Specified by:
getSnapshottingTaskin classAbstractSnapshotChangeEventSource<MongoDbPartition,MongoDbOffsetContext>
-
prepare
protected AbstractSnapshotChangeEventSource.SnapshotContext<MongoDbPartition,MongoDbOffsetContext> prepare(MongoDbPartition partition) - Specified by:
preparein classAbstractSnapshotChangeEventSource<MongoDbPartition,MongoDbOffsetContext>
-
snapshotReplicaSet
private void snapshotReplicaSet(ChangeEventSource.ChangeEventSourceContext sourceCtx, MongoDbSnapshotChangeEventSource.MongoDbSnapshotContext snapshotCtx, ReplicaSet replicaSet) throws InterruptedException - Throws:
InterruptedException
-
isSnapshotExpected
private boolean isSnapshotExpected(MongoDbPartition partition, ReplicaSet replicaSet, MongoDbOffsetContext offsetContext) -
isValidResumeToken
private boolean isValidResumeToken(MongoDbPartition partition, ReplicaSet replicaSet, org.bson.BsonDocument token) -
initSnapshotStartOffsets
private void initSnapshotStartOffsets(MongoDbSnapshotChangeEventSource.MongoDbSnapshotContext snapshotCtx) -
initReplicaSetSnapshotStartOffsets
private void initReplicaSetSnapshotStartOffsets(MongoDbSnapshotChangeEventSource.MongoDbSnapshotContext snapshotCtx, ReplicaSet replicaSet, MongoDbConnection mongo) throws InterruptedException - Throws:
InterruptedException
-
createDataEvents
private void createDataEvents(ChangeEventSource.ChangeEventSourceContext sourceCtx, MongoDbSnapshotChangeEventSource.MongoDbSnapshotContext snapshotCtx, ReplicaSet replicaSet, MongoDbConnection mongo) throws InterruptedException - Throws:
InterruptedException
-
createDataEventsForReplicaSet
private void createDataEventsForReplicaSet(ChangeEventSource.ChangeEventSourceContext sourceContext, MongoDbSnapshotChangeEventSource.MongoDbSnapshotContext snapshotContext, EventDispatcher.SnapshotReceiver<MongoDbPartition> snapshotReceiver, ReplicaSet replicaSet, MongoDbConnection mongo) throws InterruptedException Dispatches the data change events for the records of a single replica-set.- Throws:
InterruptedException
-
createDataEventsForCollection
private void createDataEventsForCollection(ChangeEventSource.ChangeEventSourceContext sourceContext, MongoDbSnapshotChangeEventSource.MongoDbSnapshotContext snapshotContext, EventDispatcher.SnapshotReceiver<MongoDbPartition> snapshotReceiver, ReplicaSet replicaSet, CollectionId collectionId, MongoDbConnection mongo) throws InterruptedException - Throws:
InterruptedException
-
getChangeRecordEmitter
private ChangeRecordEmitter<MongoDbPartition> getChangeRecordEmitter(AbstractSnapshotChangeEventSource.SnapshotContext<MongoDbPartition, MongoDbOffsetContext> snapshotContext, CollectionId collectionId, org.bson.BsonDocument document, ReplicaSet replicaSet) -
getClock
-