Class BinlogConnectorConnection
java.lang.Object
io.debezium.jdbc.JdbcConnection
io.debezium.connector.binlog.jdbc.BinlogConnectorConnection
- All Implemented Interfaces:
AutoCloseable
An abstract binlog-based connector connection implementation of
JdbcConnection.- Author:
- Jiri Pechanec, Randall Hauch, Chris Cranford
-
Nested Class Summary
Nested ClassesNested 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
FieldsModifier and TypeFieldDescriptionprivate final ConnectionConfigurationprivate final BinlogFieldReaderprivate static final org.slf4j.Loggerprivate static final Stringprivate static final Stringprivate static final Stringprivate static final String -
Constructor Summary
ConstructorsConstructorDescriptionBinlogConnectorConnection(ConnectionConfiguration configuration, BinlogFieldReader fieldReader) -
Method Summary
Modifier and TypeMethodDescriptionQuery the database server and get the list of binlog files that are currently available.Query the available databases.Determine the earliest binlog filename that is still available in the server.abstract GtidSetfilterGtidSet(Predicate<String> gtidSourceFilter, String offsetGtids, GtidSet availableServerGtidSet, GtidSet purgedServerGtidSet) Apply the include/exclude GTID source filters to the current offset's GTID set and merge them onto the currently available GTID set from the database server.getColumnValue(ResultSet rs, int columnIndex, Column column, Table table) getEstimatedTableSize(TableId tableId) Get the estimated table size, aka number of rows.getQualifiedTableName(TableId tableId) Read the SSL version session variable.booleanDetermine whether the database server has the row-level binlog enabled.booleanisBinlogPositionAvailable(BinlogConnectorConfig config, String gtid, String binlogFileName) Determine whether the binlog position as set in the offset details is available on the server.booleanDetermines whether the binlog format used by the database server isbinlog_row_image='FULL'.abstract booleanDetermine whether the server has enabled GTID support.booleanReturn whether the table identifiers are case-sensitive.abstract GtidSetReturns the most recent executed GTID set or position.abstract GtidSetGet the purged GTID values from the server.querySystemVariables(String statement) quotedTableIdString(TableId tableId) Read the charset-related system variables.Read the database server's default character sets for existing databases.Read the system variables.setStatementFor(Map<String, String> variables) Executes aSETstatement, setting each variable with it's specified value.abstract GtidSetsubtractGtidSet(GtidSet set1, GtidSet set2) Determines the difference between two GTID sets.booleanuserHasPrivileges(String grantName) Determine whether the current user has the named privilege.booleanvalidateLogPosition(Partition partition, OffsetContext offset, CommonConnectorConfig config) Methods inherited from class io.debezium.jdbc.JdbcConnection
buildSelectWithRowLimits, call, chunkQueryBuilder, 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, reselectColumns, resolveCatalogName, resolveJdbcType, resolveNativeType, rollback, rowToArray, setAutoCommit, setQueryColumnValue, singleResultMapper, supportedTableTypes, tableTypes, username
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
SQL_SHOW_SYSTEM_VARIABLES
- See Also:
-
SQL_SHOW_SYSTEM_VARIABLES_CHARACTER_SET
- See Also:
-
SQL_SHOW_SESSION_VARIABLE_SSL_VERSION
- See Also:
-
QUOTED_CHARACTER
- See Also:
-
connectionConfig
-
fieldReader
-
-
Constructor Details
-
BinlogConnectorConnection
public BinlogConnectorConnection(ConnectionConfiguration configuration, BinlogFieldReader fieldReader)
-
-
Method Details
-
getColumnValue
public Object getColumnValue(ResultSet rs, int columnIndex, Column column, Table table) throws SQLException - Overrides:
getColumnValuein classJdbcConnection- Throws:
SQLException
-
quotedTableIdString
- Overrides:
quotedTableIdStringin classJdbcConnection
-
getQualifiedTableName
- Overrides:
getQualifiedTableNamein classJdbcConnection
-
nullsSortLast
- Overrides:
nullsSortLastin classJdbcConnection
-
connectionString
-
connectionConfig
-
userHasPrivileges
Determine whether the current user has the named privilege. If the user has the "ALL" privilege, this method will always returntrue.- Parameters:
grantName- the name of the database privilege; may not be null- Returns:
trueif the user has the named privilege;falseotherwise
-
earliestBinlogFilename
Determine the earliest binlog filename that is still available in the server.- Returns:
- the name of the earliest binlog filename, or null if there are none
-
availableBinlogFiles
Query the database server and get the list of binlog files that are currently available.- Returns:
- list of binlog files
-
availableDatabases
Query the available databases.- Returns:
- list of databases
-
getEstimatedTableSize
Get the estimated table size, aka number of rows.- Parameters:
tableId- the table identifier; should never be null- Returns:
- an optional long-value that may be empty if no data is available or an exception occurred
-
readCharsetSystemVariables
Read the charset-related system variables.- Returns:
- the system variables that are related to server character sets; never null
-
setStatementFor
Executes aSETstatement, setting each variable with it's specified value.- Parameters:
variables- key/value variable names as keys and the value(s) to be set- Returns:
- the constructed
SETdatabase statement; never null
-
isBinlogRowImageFull
public boolean isBinlogRowImageFull()Determines whether the binlog format used by the database server isbinlog_row_image='FULL'.- Returns:
trueif thebinlog_row_imageis set toFULL,falseotherwise
-
isBinlogFormatRow
public boolean isBinlogFormatRow()Determine whether the database server has the row-level binlog enabled.- Returns:
trueif the server'sbinlog_formatis set toROW,falseotherwise
-
readDatabaseCollations
Read the database server's default character sets for existing databases.- Returns:
- the map of database names and their default character sets; never null
-
isTableIdCaseSensitive
public boolean isTableIdCaseSensitive()Return whether the table identifiers are case-sensitive.- Returns:
trueif the table identifiers are case-sensitive,falseotherwise
-
isBinlogPositionAvailable
public boolean isBinlogPositionAvailable(BinlogConnectorConfig config, String gtid, String binlogFileName) Determine whether the binlog position as set in the offset details is available on the server.- Parameters:
config- the connector configuration; should not be nullgtid- the GTID from the connector offsets; may be nullbinlogFileName- the binlog file name from the connector offsets; may be null- Returns:
trueif the binlog position is available,falseotherwise
-
getSessionVariableForSslVersion
Read the SSL version session variable.- Returns:
- the session variable value related to the session SSL version
-
validateLogPosition
public boolean validateLogPosition(Partition partition, OffsetContext offset, CommonConnectorConfig config) -
isGtidModeEnabled
public abstract boolean isGtidModeEnabled()Determine whether the server has enabled GTID support.- Returns:
falseif the server has not enabled GTIDs,trueotherwise
-
knownGtidSet
Returns the most recent executed GTID set or position.- 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
Determines the difference between two GTID sets.- 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
Get the purged GTID values from the server.- Returns:
- A GTID set; may be empty of GTID support is not enabled or if none have been purged
-
filterGtidSet
public abstract GtidSet filterGtidSet(Predicate<String> gtidSourceFilter, String offsetGtids, GtidSet availableServerGtidSet, GtidSet purgedServerGtidSet) Apply the include/exclude GTID source filters to the current offset's GTID set and merge them onto the currently available GTID set from the database server. The merging behavior of this method might seem a bit strange at first. It's required in order for Debezium to consume a binlog that has multi-source replication enabled, if a fail-over has to occur. In such a case, the server thta Debezium is failing over to might have a different set of sources, but still include the sources required for Debezium to continue to function. The database 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 not have the data needed by the client. To get around this, we can have Debezium merge the GTID set with whatever is on the server, so that the database will allow it to connect. See DBZ-143. This method does not mutate any state in the context.- Parameters:
gtidSourceFilter- the source filteroffsetGtids- the gtids from the offsetsavailableServerGtidSet- the GTID set currently available in the serverpurgedServerGtidSet- the GTID set already purged by the server- Returns:
- A GTID set meant for consuming from a binlog; may return null if the SourceInfo has no GTIDs and none filtered
-
readSystemVariables
Read the system variables.- Returns:
- all the system variables; never null
-
querySystemVariables
-