Interface Snapshotter
-
- All Known Implementing Classes:
AlwaysSnapshotter,InitialOnlySnapshotter,InitialSnapshotter,NeverSnapshotter,QueryingSnapshotter
@Incubating public interface SnapshotterThis 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 eithershouldSnapshot()orshouldStream()or true for both.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Optional<String>buildSnapshotQuery(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)booleanshouldSnapshot()booleanshouldStream()default booleanshouldStreamEventsStartingFromSnapshot()default voidsnapshotCompleted()Lifecycle hook called once the snapshot phase is finished.default Optional<String>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 StringsnapshotTransactionIsolationLevelStatement(SlotCreationResult newSlotInfo)Return a new string that set up the transaction for snapshotting
-
-
-
Method Detail
-
init
void init(PostgresConnectorConfig config, OffsetState sourceInfo, SlotState slotState)
-
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
Optional<String> buildSnapshotQuery(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)- 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
default String snapshotTransactionIsolationLevelStatement(SlotCreationResult newSlotInfo)
Return a new string that set up the transaction for snapshotting- Parameters:
newSlotInfo- if a new slow was created for snapshotting, this contains information from the `create_replication_slot` command
-
snapshotTableLockingStatement
default Optional<String> snapshotTableLockingStatement(Duration lockTimeout, Set<TableId> tableIds)
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 finished.
-
-