Interface Snapshotter
- All Known Implementing Classes:
AlwaysSnapshotter,InitialOnlySnapshotter,InitialSnapshotter,NeverSnapshotter,QueryingSnapshotter
@Incubating
public interface Snapshotter
This interface is used to determine details about the snapshot process:
Namely:
- Should a snapshot occur at all
- Should streaming occur
- What queries should be used to snapshot
While many default snapshot modes are provided with debezium (see documentation for details)
a custom implementation of this interface can be provided by the implementor which
can provide more advanced functionality, such as partial snapshots
Implementor's must return true for either
shouldSnapshot() or shouldStream()
or true for both.-
Method Summary
Modifier and TypeMethodDescriptionbuildSnapshotQuery(TableId tableId, List<String> snapshotSelectColumns) Generate a valid postgres query string for the specified table, or an emptyOptionalto skip snapshotting this table (but that table will still be streamed from)voidinit(PostgresConnectorConfig config, OffsetState sourceInfo, SlotState slotState) booleanbooleandefault booleandefault voidLifecycle hook called once the snapshot phase is aborted.default voidLifecycle hook called once the snapshot phase is successful.snapshotTableLockingStatement(Duration lockTimeout, Set<TableId> tableIds) Returns a SQL statement for locking the given tables during snapshotting, if required by the specific snapshotter implementation.default StringReturn a new string that set up the transaction for snapshotting
-
Method Details
-
init
-
shouldSnapshot
boolean shouldSnapshot()- Returns:
- true if the snapshotter should take a snapshot
-
shouldStream
boolean shouldStream()- Returns:
- true if the snapshotter should stream after taking a snapshot
-
shouldStreamEventsStartingFromSnapshot
default boolean shouldStreamEventsStartingFromSnapshot()- Returns:
- true if streaming should resume from the start of the snapshot transaction, or false for when a connector resumes and takes a snapshot, streaming should resume from where streaming previously left off.
-
buildSnapshotQuery
Generate a valid postgres query string for the specified table, or an emptyOptionalto skip snapshotting this table (but that table will still be streamed from)- Parameters:
tableId- the table to generate a query forsnapshotSelectColumns- the columns to be used in the snapshot select based on the column include/exclude filters- Returns:
- a valid query string, or none to skip snapshotting this table
-
snapshotTransactionIsolationLevelStatement
Return a new string that set up the transaction for snapshotting- Parameters:
newSlotInfo- if a new slot was created for snapshotting, this contains information from the `create_replication_slot` command
-
snapshotTableLockingStatement
Returns a SQL statement for locking the given tables during snapshotting, if required by the specific snapshotter implementation. -
snapshotCompleted
default void snapshotCompleted()Lifecycle hook called once the snapshot phase is successful. -
snapshotAborted
default void snapshotAborted()Lifecycle hook called once the snapshot phase is aborted.
-