Package io.debezium.pipeline.source
Class AbstractSnapshotChangeEventSource
- java.lang.Object
-
- io.debezium.pipeline.source.AbstractSnapshotChangeEventSource
-
- All Implemented Interfaces:
ChangeEventSource,SnapshotChangeEventSource
- Direct Known Subclasses:
RelationalSnapshotChangeEventSource
public abstract class AbstractSnapshotChangeEventSource extends Object implements SnapshotChangeEventSource
An abstract implementation ofSnapshotChangeEventSourcethat all implementations should extend to inherit common functionality.- Author:
- Chris Cranford
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractSnapshotChangeEventSource.SnapshotContextMutable context which is populated in the course of snapshottingstatic classAbstractSnapshotChangeEventSource.SnapshottingTaskA configuration describing the task to be performed during snapshotting.-
Nested classes/interfaces inherited from interface io.debezium.pipeline.source.spi.ChangeEventSource
ChangeEventSource.ChangeEventSourceContext
-
-
Field Summary
Fields Modifier and Type Field Description private CommonConnectorConfigconnectorConfigprivate static org.slf4j.LoggerLOGGERprotected OffsetContextpreviousOffsetprivate SnapshotProgressListenersnapshotProgressListener
-
Constructor Summary
Constructors Constructor Description AbstractSnapshotChangeEventSource(CommonConnectorConfig connectorConfig, OffsetContext previousOffset, SnapshotProgressListener snapshotProgressListener)
-
Method Summary
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
connectorConfig
private final CommonConnectorConfig connectorConfig
-
previousOffset
protected final OffsetContext previousOffset
-
snapshotProgressListener
private final SnapshotProgressListener snapshotProgressListener
-
-
Constructor Detail
-
AbstractSnapshotChangeEventSource
public AbstractSnapshotChangeEventSource(CommonConnectorConfig connectorConfig, OffsetContext previousOffset, SnapshotProgressListener snapshotProgressListener)
-
-
Method Detail
-
execute
public SnapshotResult execute(ChangeEventSource.ChangeEventSourceContext context) throws InterruptedException
Description copied from interface:SnapshotChangeEventSourceExecutes this source. Implementations should regularly check via the given context if they should stop. If that's the case, they should abort their processing and perform any clean-up needed, such as rolling back pending transactions, releasing locks etc.- Specified by:
executein interfaceSnapshotChangeEventSource- Parameters:
context- contextual information for this source's execution- Returns:
- an indicator to the position at which the snapshot was taken
- Throws:
InterruptedException- in case the snapshot was aborted before completion
-
determineDataCollectionsToBeSnapshotted
protected <T extends DataCollectionId> Stream<T> determineDataCollectionsToBeSnapshotted(Collection<T> allDataCollections)
-
delaySnapshotIfNeeded
protected void delaySnapshotIfNeeded(ChangeEventSource.ChangeEventSourceContext context) throws InterruptedException
Delays snapshot execution as per theCommonConnectorConfig.SNAPSHOT_DELAY_MSparameter.- Throws:
InterruptedException
-
doExecute
protected abstract SnapshotResult doExecute(ChangeEventSource.ChangeEventSourceContext context, AbstractSnapshotChangeEventSource.SnapshotContext snapshotContext, AbstractSnapshotChangeEventSource.SnapshottingTask snapshottingTask) throws Exception
Executes this source. Implementations should regularly check via the given context if they should stop. If that's the case, they should abort their processing and perform any clean-up needed, such as rolling back pending transactions, releasing locks, etc.- Parameters:
context- contextual information for this source's executionsnapshotContext- mutable context information populated throughout the snapshot processsnapshottingTask- immutable information about what tasks should be performed during snapshot- Returns:
- an indicator to the position at which the snapshot was taken
- Throws:
Exception
-
getSnapshottingTask
protected abstract AbstractSnapshotChangeEventSource.SnapshottingTask getSnapshottingTask(OffsetContext previousOffset)
Returns the snapshotting task based on the previous offset (if available) and the connector's snapshotting mode.
-
prepare
protected abstract AbstractSnapshotChangeEventSource.SnapshotContext prepare(ChangeEventSource.ChangeEventSourceContext changeEventSourceContext) throws Exception
Prepares the taking of a snapshot and returns an initialAbstractSnapshotChangeEventSource.SnapshotContext.- Throws:
Exception
-
complete
protected void complete(AbstractSnapshotChangeEventSource.SnapshotContext snapshotContext)
Completes the snapshot, doing any required clean-up (resource disposal etc.). The snapshot may have run successfully or have been aborted at this point.- Parameters:
snapshotContext- snapshot context
-
-