Class MySqlTaskContext


  • public final class MySqlTaskContext
    extends CdcSourceTaskContext
    A Kafka Connect source task reads the MySQL binary log and generate the corresponding data change events.
    Author:
    Randall Hauch
    See Also:
    MySqlConnector
    • Method Detail

      • connectorName

        public String connectorName()
      • gtidSourceFilter

        public Predicate<String> gtidSourceFilter()
        Get the predicate function that will return true if a GTID source is to be included, or false if a GTID source is to be excluded.
        Returns:
        the GTID source predicate function; never null
      • initializeHistory

        public void initializeHistory()
        Initialize the database history with any server-specific information. This should be done only upon connector startup when the connector has no prior history.
      • loadHistory

        public void loadHistory​(SourceInfo startingPoint)
        Load the database schema information using the previously-recorded history, and stop reading the history when the the history reaches the supplied starting point.
        Parameters:
        startingPoint - the source information with the current SourceInfo.partition() and offset at which the database schemas are to reflect; may not be null
      • historyExists

        public boolean historyExists()
        Return true if the database history entity exists
      • initializeHistoryStorage

        public void initializeHistoryStorage()
        Initialize permanent storage for database history
      • serverId

        public long serverId()
      • rowCountForLargeTable

        public long rowCountForLargeTable()
      • bufferSizeForBinlogReader

        public int bufferSizeForBinlogReader()
      • includeSchemaChangeRecords

        public boolean includeSchemaChangeRecords()
      • includeSqlQuery

        public boolean includeSqlQuery()
      • isSnapshotAllowedWhenNeeded

        public boolean isSnapshotAllowedWhenNeeded()
      • isSnapshotNeverAllowed

        public boolean isSnapshotNeverAllowed()
      • isInitialSnapshotOnly

        public boolean isInitialSnapshotOnly()
      • isSchemaOnlySnapshot

        public boolean isSchemaOnlySnapshot()
      • isSchemaOnlyRecoverySnapshot

        public boolean isSchemaOnlyRecoverySnapshot()
      • start

        public void start()
      • shutdown

        public void shutdown()
      • temporaryLoggingContext

        public void temporaryLoggingContext​(String contextName,
                                            Runnable operation)
        Run the supplied function in the temporary connector MDC context, and when complete always return the MDC context to its state before this method was called.
        Parameters:
        contextName - the name of the context; may not be null
        operation - the function to run in the new MDC context; may not be null
        Throws:
        IllegalArgumentException - if any of the parameters are null
      • filterGtidSet

        public GtidSet filterGtidSet​(GtidSet availableServerGtidSet,
                                     GtidSet purgedServerGtid)
        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.
        Parameters:
        availableServerGtidSet - the GTID set currently available in the MySQL server
        purgedServerGtid - 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
      • ddlFilter

        public Predicate<String> ddlFilter()
        Get the predicate function that will return true if a DDL has to be skipped over and left out of the schema history or false when it should be processed.
        Returns:
        the DDL predicate function; never null
      • isTableIdCaseInsensitive

        public boolean isTableIdCaseInsensitive()