Class BinlogHistoryRecordComparator

java.lang.Object
io.debezium.relational.history.HistoryRecordComparator
io.debezium.connector.binlog.history.BinlogHistoryRecordComparator

public abstract class BinlogHistoryRecordComparator extends HistoryRecordComparator
Base implementation of the HistoryRecordComparator for binlog-based connectors.
Author:
Chris Cranford
  • Field Details

  • Constructor Details

  • Method Details

    • isPositionAtOrBefore

      @VisibleForTesting public boolean isPositionAtOrBefore(Document recorded, Document desired)
      Determine whether the first offset is at or before the point in time of the second offset, where the offsets are given in JSON representations of maps returned by the connector's offset context.

      This logic makes a significant assumption: once a server enables GTID, they are never disabled. This is the only way to compare a position with a GTID to a position without a GTID, and any change with a GTID is after positions without.

      When both positions have GTIDs, the positions are compared using the GTIDs. If the GTID values are identical, then we compare whether they have snapshots enabled.
      Overrides:
      isPositionAtOrBefore in class HistoryRecordComparator
      Parameters:
      recorded - the position obtained from the recorded history; never null
      desired - the desired position that we want to obtain, which should be after some recorded positions at some recorded positions, and before other recorded positions; never null
      Returns:
      true if the recorded position is at or before the desired position; false otherwise.
    • getGtidSet

      protected String getGtidSet(Document document)
      Get the global transaction identifier set.
      Parameters:
      document - the document to inspect, should not be null
      Returns:
      the global transaction identifier set as a string
    • getServerId

      protected int getServerId(Document document)
      Get the server unique identifier.
      Parameters:
      document - the document to inspect, should not be null
      Returns:
      the unique server identifier
    • isSnapshot

      protected boolean isSnapshot(Document document)
      Get whether the event is part of the connector's snapshot phase.
      Parameters:
      document - the document to inspect, should not be null
      Returns:
      true if its part of the snapshot, false otherwise
    • getTimestamp

      protected long getTimestamp(Document document)
      Get the timestamp.
      Parameters:
      document - the document to inspect, should not be null
      Returns:
      the timestamp value
    • getBinlogFileName

      protected BinlogHistoryRecordComparator.BinlogFileName getBinlogFileName(Document document)
      Get the binlog file name.
      Parameters:
      document - the document to inspect, should not be null
      Returns:
      the binlog file name value
    • getBinlogPosition

      protected int getBinlogPosition(Document document)
      Get the binlog position.
      Parameters:
      document - the document to inspect, should not be null
      Returns:
      the binlog position value
    • getEventsToSkip

      protected int getEventsToSkip(Document document)
      Get the number of events to skip.
      Parameters:
      document - the document to inspect, should not be null
      Returns:
      the binlog number of events to skip value
    • getBinlogRowInEvent

      protected int getBinlogRowInEvent(Document document)
      Get the binlog row in event value.
      Parameters:
      document - the document to inspect, should not be null
      Returns:
      the binlog row in event value