Class MySqlConnection

All Implemented Interfaces:
AutoCloseable

public class MySqlConnection extends AbstractConnectorConnection
An AbstractConnectorConnection to be used with MySQL.
Author:
Jiri Pechanec, Randell Hauch, Chris Cranford
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
  • Constructor Details

  • Method Details

    • isGtidModeEnabled

      public boolean isGtidModeEnabled()
      Description copied from class: AbstractConnectorConnection
      Determine whether the server has enabled GTID support.
      Specified by:
      isGtidModeEnabled in class AbstractConnectorConnection
      Returns:
      false if the server has not enabled GTIDs, true otherwise
    • knownGtidSet

      public GtidSet knownGtidSet()
      Description copied from class: AbstractConnectorConnection
      Returns the most recent executed GTID set or position.
      Specified by:
      knownGtidSet in class AbstractConnectorConnection
      Returns:
      the string representation of the most recent executed GTID set or position; never null but will be empty if the server does not support or has not processed any GTID
    • subtractGtidSet

      public GtidSet subtractGtidSet(GtidSet set1, GtidSet set2)
      Description copied from class: AbstractConnectorConnection
      Determines the difference between two GTID sets.
      Specified by:
      subtractGtidSet in class AbstractConnectorConnection
      Parameters:
      set1 - the first set; should never be null
      set2 - the second set; should never be null
      Returns:
      the subtraction of the two sets in a new GtidSet instance; never null
    • purgedGtidSet

      public GtidSet purgedGtidSet()
      Description copied from class: AbstractConnectorConnection
      Get the purged GTID values from the server.
      Specified by:
      purgedGtidSet in class AbstractConnectorConnection
      Returns:
      A GTID set; may be empty of GTID support is not enabled or if none have been purged
    • filterGtidSet

      public GtidSet filterGtidSet(Predicate<String> gtidSourceFilter, String offsetGtids, GtidSet availableServerGtidSet, GtidSet purgedServerGtidSet)
      Description copied from class: AbstractConnectorConnection
      Apply the include/exclude GTID source filters to the current GTID set and merge them onto the currently available GTID set from a MySQL server. The merging behavior of this method might seem a bit strange at first. It's required in order for Debezium to consume a MySQL binlog that has multi-source replication enabled, if a failover has to occur. In such a case, the server that Debezium is failed over to might have a different set of sources, but still include the sources required for Debezium to continue to function. MySQL does not allow downstream replicas to connect if the GTID set does not contain GTIDs for all channels that the server is replicating from, even if the server does have the data needed by the client. To get around this, we can have Debezium merge its GTID set with whatever is on the server, so that MySQL will allow it to connect. See DBZ-143 for details. This method does not mutate any state in the context.
      Specified by:
      filterGtidSet in class AbstractConnectorConnection
      Parameters:
      gtidSourceFilter - the source filter
      offsetGtids - the gtids from the offsets
      availableServerGtidSet - the GTID set currently available in the MySQL server
      purgedServerGtidSet - the GTID set already purged by the MySQL server
      Returns:
      A GTID set meant for consuming from a MySQL binlog; may return null if the SourceInfo has no GTIDs and therefore none were filtered
    • isMariaDb

      public boolean isMariaDb()
      Specified by:
      isMariaDb in class AbstractConnectorConnection
    • createGtidSet

      protected GtidSet createGtidSet(String gtids)
      Specified by:
      createGtidSet in class AbstractConnectorConnection
    • getJavaEncodingForCharSet

      public static String getJavaEncodingForCharSet(String charSetName)