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>
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 static final Stringprotected final Clockprivate final ConnectionContextprivate 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, ReplicaSets replicaSets, EventDispatcher<MongoDbPartition, CollectionId> dispatcher, Clock clock, SnapshotProgressListener<MongoDbPartition> snapshotProgressListener, ErrorHandler errorHandler) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcreateDataEvents(ChangeEventSource.ChangeEventSourceContext sourceContext, MongoDbSnapshotChangeEventSource.MongoDbSnapshotContext snapshotContext, ReplicaSet replicaSet, ConnectionContext.MongoPrimary primaryClient) private voidcreateDataEventsForCollection(ChangeEventSource.ChangeEventSourceContext sourceContext, MongoDbSnapshotChangeEventSource.MongoDbSnapshotContext snapshotContext, EventDispatcher.SnapshotReceiver<MongoDbPartition> snapshotReceiver, ReplicaSet replicaSet, CollectionId collectionId, ConnectionContext.MongoPrimary primaryClient) private voidcreateDataEventsForReplicaSet(ChangeEventSource.ChangeEventSourceContext sourceContext, MongoDbSnapshotChangeEventSource.MongoDbSnapshotContext snapshotContext, EventDispatcher.SnapshotReceiver<MongoDbPartition> snapshotReceiver, ReplicaSet replicaSet, ConnectionContext.MongoPrimary primaryClient) Dispatches the data change events for the records of a single replica-set.protected voiddetermineSnapshotOffsets(MongoDbSnapshotChangeEventSource.MongoDbSnapshotContext ctx, ReplicaSets replicaSets) protected SnapshotResult<MongoDbOffsetContext>doExecute(ChangeEventSource.ChangeEventSourceContext context, MongoDbOffsetContext previousOffset, AbstractSnapshotChangeEventSource.SnapshotContext<MongoDbPartition, MongoDbOffsetContext> snapshotContext, AbstractSnapshotChangeEventSource.SnapshottingTask snapshottingTask) private ConnectionContext.MongoPrimaryestablishConnectionToPrimary(MongoDbPartition partition, ReplicaSet replicaSet) protected ChangeRecordEmitter<MongoDbPartition>getChangeRecordEmitter(AbstractSnapshotChangeEventSource.SnapshotContext<MongoDbPartition, MongoDbOffsetContext> snapshotContext, CollectionId collectionId, org.bson.BsonDocument document, ReplicaSet replicaSet) protected ClockgetClock()getSnapshottingTask(MongoDbPartition partition, MongoDbOffsetContext previousOffset) private booleanisSnapshotExpected(ConnectionContext.MongoPrimary primaryClient, ReplicaSetOffsetContext offsetContext) prepare(MongoDbPartition partition) private voidsnapshotReplicaSet(ChangeEventSource.ChangeEventSourceContext sourceContext, MongoDbSnapshotChangeEventSource.MongoDbSnapshotContext ctx, ReplicaSet replicaSet) Methods inherited from class io.debezium.pipeline.source.AbstractSnapshotChangeEventSource
complete, delaySnapshotIfNeeded, determineDataCollectionsToBeSnapshotted, execute
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
AUTHORIZATION_FAILURE_MESSAGE
- See Also:
-
connectorConfig
-
taskContext
-
connectionContext
-
replicaSets
-
dispatcher
-
clock
-
snapshotProgressListener
-
errorHandler
-
aborted
-
-
Constructor Details
-
MongoDbSnapshotChangeEventSource
public MongoDbSnapshotChangeEventSource(MongoDbConnectorConfig connectorConfig, MongoDbTaskContext taskContext, ReplicaSets replicaSets, EventDispatcher<MongoDbPartition, CollectionId> dispatcher, Clock clock, SnapshotProgressListener<MongoDbPartition> snapshotProgressListener, ErrorHandler errorHandler)
-
-
Method Details
-
doExecute
protected SnapshotResult<MongoDbOffsetContext> doExecute(ChangeEventSource.ChangeEventSourceContext context, MongoDbOffsetContext previousOffset, AbstractSnapshotChangeEventSource.SnapshotContext<MongoDbPartition, MongoDbOffsetContext> snapshotContext, AbstractSnapshotChangeEventSource.SnapshottingTask snapshottingTask) throws Exception- Specified by:
doExecutein classAbstractSnapshotChangeEventSource<MongoDbPartition,MongoDbOffsetContext> - Throws:
Exception
-
getSnapshottingTask
protected AbstractSnapshotChangeEventSource.SnapshottingTask getSnapshottingTask(MongoDbPartition partition, MongoDbOffsetContext previousOffset) - Specified by:
getSnapshottingTaskin classAbstractSnapshotChangeEventSource<MongoDbPartition,MongoDbOffsetContext>
-
prepare
protected AbstractSnapshotChangeEventSource.SnapshotContext<MongoDbPartition,MongoDbOffsetContext> prepare(MongoDbPartition partition) throws Exception - Specified by:
preparein classAbstractSnapshotChangeEventSource<MongoDbPartition,MongoDbOffsetContext> - Throws:
Exception
-
snapshotReplicaSet
private void snapshotReplicaSet(ChangeEventSource.ChangeEventSourceContext sourceContext, MongoDbSnapshotChangeEventSource.MongoDbSnapshotContext ctx, ReplicaSet replicaSet) throws InterruptedException - Throws:
InterruptedException
-
establishConnectionToPrimary
private ConnectionContext.MongoPrimary establishConnectionToPrimary(MongoDbPartition partition, ReplicaSet replicaSet) -
isSnapshotExpected
private boolean isSnapshotExpected(ConnectionContext.MongoPrimary primaryClient, ReplicaSetOffsetContext offsetContext) -
determineSnapshotOffsets
protected void determineSnapshotOffsets(MongoDbSnapshotChangeEventSource.MongoDbSnapshotContext ctx, ReplicaSets replicaSets) -
createDataEvents
private void createDataEvents(ChangeEventSource.ChangeEventSourceContext sourceContext, MongoDbSnapshotChangeEventSource.MongoDbSnapshotContext snapshotContext, ReplicaSet replicaSet, ConnectionContext.MongoPrimary primaryClient) throws InterruptedException - Throws:
InterruptedException
-
createDataEventsForReplicaSet
private void createDataEventsForReplicaSet(ChangeEventSource.ChangeEventSourceContext sourceContext, MongoDbSnapshotChangeEventSource.MongoDbSnapshotContext snapshotContext, EventDispatcher.SnapshotReceiver<MongoDbPartition> snapshotReceiver, ReplicaSet replicaSet, ConnectionContext.MongoPrimary primaryClient) 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, ConnectionContext.MongoPrimary primaryClient) throws InterruptedException - Throws:
InterruptedException
-
getChangeRecordEmitter
protected ChangeRecordEmitter<MongoDbPartition> getChangeRecordEmitter(AbstractSnapshotChangeEventSource.SnapshotContext<MongoDbPartition, MongoDbOffsetContext> snapshotContext, CollectionId collectionId, org.bson.BsonDocument document, ReplicaSet replicaSet) -
getClock
-