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 Details

    • 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 empty Optional to skip snapshotting this table (but that table will still be streamed from)
      Parameters:
      tableId - the table to generate a query for
      snapshotSelectColumns - 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 slot 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 successful.
    • snapshotAborted

      default void snapshotAborted()
      Lifecycle hook called once the snapshot phase is aborted.