Class MySqlConnection
java.lang.Object
io.debezium.jdbc.JdbcConnection
io.debezium.connector.mysql.strategy.AbstractConnectorConnection
io.debezium.connector.mysql.strategy.mysql.MySqlConnection
- All Implemented Interfaces:
AutoCloseable
An
AbstractConnectorConnection
to be used with MySQL.- Author:
- Jiri Pechanec, Randell Hauch, Chris Cranford
-
Nested Class Summary
Modifier and TypeClassDescriptionprivate static final class
Helper to gain access to protected methodNested classes/interfaces inherited from class io.debezium.connector.mysql.strategy.AbstractConnectorConnection
AbstractConnectorConnection.DatabaseLocales
Nested classes/interfaces inherited from class io.debezium.jdbc.JdbcConnection
JdbcConnection.BlockingMultiResultSetConsumer, JdbcConnection.BlockingResultSetConsumer, JdbcConnection.CallPreparer, JdbcConnection.ConnectionFactory, JdbcConnection.MultiResultSetConsumer, JdbcConnection.Operations, JdbcConnection.ParameterResultSetConsumer, JdbcConnection.ResultSetConsumer, JdbcConnection.ResultSetExtractor<T extends Object>, JdbcConnection.ResultSetMapper<T extends Object>, JdbcConnection.StatementFactory, JdbcConnection.StatementPreparer
-
Field Summary
-
Constructor Summary
ConstructorDescriptionMySqlConnection
(MySqlConnectionConfiguration connectionConfig, MySqlFieldReader fieldReader) -
Method Summary
Modifier and TypeMethodDescriptionprotected GtidSet
createGtidSet
(String gtids) filterGtidSet
(Predicate<String> gtidSourceFilter, String offsetGtids, GtidSet availableServerGtidSet, GtidSet purgedServerGtidSet) Apply the include/exclude GTID source filters to the currentGTID set
and merge them onto the currently available GTID set from a MySQL server.static String
getJavaEncodingForCharSet
(String charSetName) boolean
Determine whether the server has enabled GTID support.boolean
Returns the most recent executed GTID set or position.Get the purged GTID values from the server.subtractGtidSet
(GtidSet set1, GtidSet set2) Determines the difference between two GTID sets.Methods inherited from class io.debezium.connector.mysql.strategy.AbstractConnectorConnection
availableBinlogFiles, availableDatabases, connectionConfig, connectionString, earliestBinlogFilename, getColumnValue, getEstimatedTableSize, getQualifiedTableName, getSessionVariableForSslVersion, isBinlogFormatRow, isBinlogPositionAvailable, isBinlogRowImageFull, isTableIdCaseSensitive, quotedTableIdString, readCharsetSystemVariables, readDatabaseCollations, readSystemVariables, setStatementFor, userHasPrivileges
Methods inherited from class io.debezium.jdbc.JdbcConnection
buildReselectColumnQuery, buildSelectWithRowLimits, call, close, commit, config, connect, connection, connection, connectionString, createTableId, database, escapeEscapeSequence, execute, execute, executeWithoutCommitting, getAttributeDetails, getColumnsDetails, getCurrentTimestamp, isConnected, isNullable, isTableType, isTableUniqueIndexIncluded, isValid, loadKeyStore, overrideColumn, parseSqlStatementString, patternBasedFactory, patternBasedFactory, prepareQuery, prepareQuery, prepareQuery, prepareQuery, prepareQuery, prepareQueryAndMap, prepareQueryWithBlockingConsumer, prepareUpdate, print, print, query, query, queryAndMap, queryAndMap, querySingleValue, queryWithBlockingConsumer, quotedColumnIdString, readAllCatalogNames, readAllSchemaNames, readAllTableNames, readPrimaryKeyNames, readPrimaryKeyOrUniqueIndexNames, readSchema, readTableColumn, readTableNames, readTablePreparedStatement, readTableStatement, readTableUniqueIndices, reselectColumns, resolveCatalogName, resolveJdbcType, resolveNativeType, rollback, rowToArray, setAutoCommit, setQueryColumnValue, singleResultMapper, supportedTableTypes, tableTypes, username
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
-
Constructor Details
-
MySqlConnection
-
-
Method Details
-
isGtidModeEnabled
public boolean isGtidModeEnabled()Description copied from class:AbstractConnectorConnection
Determine whether the server has enabled GTID support.- Specified by:
isGtidModeEnabled
in classAbstractConnectorConnection
- Returns:
false
if the server has not enabled GTIDs,true
otherwise
-
knownGtidSet
Description copied from class:AbstractConnectorConnection
Returns the most recent executed GTID set or position.- Specified by:
knownGtidSet
in classAbstractConnectorConnection
- 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
Description copied from class:AbstractConnectorConnection
Determines the difference between two GTID sets.- Specified by:
subtractGtidSet
in classAbstractConnectorConnection
- Parameters:
set1
- the first set; should never be nullset2
- the second set; should never be null- Returns:
- the subtraction of the two sets in a new GtidSet instance; never null
-
purgedGtidSet
Description copied from class:AbstractConnectorConnection
Get the purged GTID values from the server.- Specified by:
purgedGtidSet
in classAbstractConnectorConnection
- 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 currentGTID 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 classAbstractConnectorConnection
- Parameters:
gtidSourceFilter
- the source filteroffsetGtids
- the gtids from the offsetsavailableServerGtidSet
- the GTID set currently available in the MySQL serverpurgedServerGtidSet
- 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 classAbstractConnectorConnection
-
createGtidSet
- Specified by:
createGtidSet
in classAbstractConnectorConnection
-
getJavaEncodingForCharSet
-