Class WalPositionLocator


  • public class WalPositionLocator
    extends Object
    This class is responsible for finding out a LSN from which Debezium should resume streaming after connector restarts. The LSNs are not guaranteed to be ordered in the WAL. LSN of commits are ordered and LSNs inside a transaction are ordered. It is thus necessary to find out the beginning of the unprocessed transaction and the LSN from which the streaming should start.
    Author:
    Jiri Pechanec
    • Field Detail

      • LOGGER

        private static final org.slf4j.Logger LOGGER
      • lastCommitStoredLsn

        private final Lsn lastCommitStoredLsn
      • lastEventStoredLsn

        private final Lsn lastEventStoredLsn
      • txStartLsn

        private Lsn txStartLsn
      • lsnAfterLastEventStoredLsn

        private Lsn lsnAfterLastEventStoredLsn
      • firstLsnReceived

        private Lsn firstLsnReceived
      • passMessages

        private boolean passMessages
      • startStreamingLsn

        private Lsn startStreamingLsn
      • storeLsnAfterLastEventStoredLsn

        private boolean storeLsnAfterLastEventStoredLsn
    • Constructor Detail

      • WalPositionLocator

        public WalPositionLocator​(Lsn lastCommitStoredLsn,
                                  Lsn lastEventStoredLsn)
      • WalPositionLocator

        public WalPositionLocator()
    • Method Detail

      • resumeFromLsn

        public Optional<Lsn> resumeFromLsn​(Lsn currentLsn,
                                           ReplicationMessage message)
        Returns:
        the first LSN from which processing should be started or empty if the position has not been found yet
      • skipMessage

        public boolean skipMessage​(Lsn lsn)
        Decides whether the message with given LSN should be removed or not based on previously located LSN point.
        Parameters:
        lsn -
        Returns:
        true if the message should be skipped, false otherwise
      • enableFiltering

        public void enableFiltering()
        Enables filtering of message LSNs based on calculated position.
      • searchingEnabled

        public boolean searchingEnabled()
        Returns:
        true if searching of WAL position should be executed
      • getLastEventStoredLsn

        public Lsn getLastEventStoredLsn()