Package io.debezium.connector.sqlserver
Class SqlServerSnapshotChangeEventSource
java.lang.Object
io.debezium.pipeline.source.AbstractSnapshotChangeEventSource<P,O>
io.debezium.relational.RelationalSnapshotChangeEventSource<SqlServerPartition,SqlServerOffsetContext>
io.debezium.connector.sqlserver.SqlServerSnapshotChangeEventSource
- All Implemented Interfaces:
ChangeEventSource,SnapshotChangeEventSource<SqlServerPartition,SqlServerOffsetContext>
public class SqlServerSnapshotChangeEventSource
extends RelationalSnapshotChangeEventSource<SqlServerPartition,SqlServerOffsetContext>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classMutable context which is populated in the course of snapshotting.Nested classes/interfaces inherited from class io.debezium.relational.RelationalSnapshotChangeEventSource
RelationalSnapshotChangeEventSource.RelationalSnapshotContext<P extends Partition,O extends OffsetContext> Nested classes/interfaces inherited from class io.debezium.pipeline.source.AbstractSnapshotChangeEventSource
AbstractSnapshotChangeEventSource.SnapshotContext<P extends Partition,O extends OffsetContext>, AbstractSnapshotChangeEventSource.SnapshottingTask Nested classes/interfaces inherited from interface io.debezium.pipeline.source.spi.ChangeEventSource
ChangeEventSource.ChangeEventSourceContext -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map<SqlServerPartition,Map<TableId, SqlServerChangeTable>> private final SqlServerConnectorConfigprivate final SqlServerConnectionprivate static final org.slf4j.Loggerprivate final SqlServerDatabaseSchemaprivate static final intCode 4096 corresponds to SNAPSHOT isolation level, which is not a part of the standard but SQL Server specific.Fields inherited from class io.debezium.relational.RelationalSnapshotChangeEventSource
clock, dispatcher, SELECT_ALL_PATTERNFields inherited from class io.debezium.pipeline.source.AbstractSnapshotChangeEventSource
LOG_INTERVAL -
Constructor Summary
ConstructorsConstructorDescriptionSqlServerSnapshotChangeEventSource(SqlServerConnectorConfig connectorConfig, SqlServerConnection jdbcConnection, SqlServerDatabaseSchema schema, EventDispatcher<SqlServerPartition, TableId> dispatcher, Clock clock, SnapshotProgressListener<SqlServerPartition> snapshotProgressListener) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanadditionalColumnFilter(SqlServerPartition partition, TableId tableId, String columnName) protected voidcomplete(AbstractSnapshotChangeEventSource.SnapshotContext<SqlServerPartition, SqlServerOffsetContext> snapshotContext) protected voidconnectionCreated(RelationalSnapshotChangeEventSource.RelationalSnapshotContext<SqlServerPartition, SqlServerOffsetContext> snapshotContext) protected voiddetermineSnapshotOffset(RelationalSnapshotChangeEventSource.RelationalSnapshotContext<SqlServerPartition, SqlServerOffsetContext> ctx, SqlServerOffsetContext previousOffset) protected StringenhanceOverriddenSelect(RelationalSnapshotChangeEventSource.RelationalSnapshotContext<SqlServerPartition, SqlServerOffsetContext> snapshotContext, String overriddenSelect, TableId tableId) private booleanfilterChangeTableColumns(SqlServerPartition partition, TableId tableId, String columnName) getAllTableIds(RelationalSnapshotChangeEventSource.RelationalSnapshotContext<SqlServerPartition, SqlServerOffsetContext> ctx) protected SchemaChangeEventgetCreateTableEvent(RelationalSnapshotChangeEventSource.RelationalSnapshotContext<SqlServerPartition, SqlServerOffsetContext> snapshotContext, Table table) getSnapshotSelect(RelationalSnapshotChangeEventSource.RelationalSnapshotContext<SqlServerPartition, SqlServerOffsetContext> snapshotContext, TableId tableId, List<String> columns) Generate a valid SQL Server query string for the specified tablegetSnapshottingTask(SqlServerPartition partition, SqlServerOffsetContext previousOffset) protected voidlockTablesForSchemaSnapshot(ChangeEventSource.ChangeEventSourceContext sourceContext, RelationalSnapshotChangeEventSource.RelationalSnapshotContext<SqlServerPartition, SqlServerOffsetContext> snapshotContext) protected AbstractSnapshotChangeEventSource.SnapshotContext<SqlServerPartition,SqlServerOffsetContext> prepare(SqlServerPartition partition) protected voidreadTableStructure(ChangeEventSource.ChangeEventSourceContext sourceContext, RelationalSnapshotChangeEventSource.RelationalSnapshotContext<SqlServerPartition, SqlServerOffsetContext> snapshotContext, SqlServerOffsetContext offsetContext) protected voidreleaseSchemaSnapshotLocks(RelationalSnapshotChangeEventSource.RelationalSnapshotContext<SqlServerPartition, SqlServerOffsetContext> snapshotContext) Methods inherited from class io.debezium.relational.RelationalSnapshotChangeEventSource
createSchemaChangeEventsForTables, createSnapshotConnection, doExecute, getChangeRecordEmitter, getClock, getPreparedColumnNames, getSnapshotSourceTimestamp, lastSnapshotRecord, postSnapshot, readTableStatement, releaseDataSnapshotLocks, rowCountForTable, schema, tryStartingSnapshotMethods inherited from class io.debezium.pipeline.source.AbstractSnapshotChangeEventSource
delaySnapshotIfNeeded, determineDataCollectionsToBeSnapshotted, execute
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
TRANSACTION_SNAPSHOT
private static final int TRANSACTION_SNAPSHOTCode 4096 corresponds to SNAPSHOT isolation level, which is not a part of the standard but SQL Server specific.- See Also:
-
connectorConfig
-
jdbcConnection
-
sqlServerDatabaseSchema
-
changeTablesByPartition
-
-
Constructor Details
-
SqlServerSnapshotChangeEventSource
public SqlServerSnapshotChangeEventSource(SqlServerConnectorConfig connectorConfig, SqlServerConnection jdbcConnection, SqlServerDatabaseSchema schema, EventDispatcher<SqlServerPartition, TableId> dispatcher, Clock clock, SnapshotProgressListener<SqlServerPartition> snapshotProgressListener)
-
-
Method Details
-
getSnapshottingTask
protected AbstractSnapshotChangeEventSource.SnapshottingTask getSnapshottingTask(SqlServerPartition partition, SqlServerOffsetContext previousOffset) - Specified by:
getSnapshottingTaskin classAbstractSnapshotChangeEventSource<SqlServerPartition,SqlServerOffsetContext>
-
prepare
protected AbstractSnapshotChangeEventSource.SnapshotContext<SqlServerPartition,SqlServerOffsetContext> prepare(SqlServerPartition partition) throws Exception - Specified by:
preparein classAbstractSnapshotChangeEventSource<SqlServerPartition,SqlServerOffsetContext> - Throws:
Exception
-
connectionCreated
protected void connectionCreated(RelationalSnapshotChangeEventSource.RelationalSnapshotContext<SqlServerPartition, SqlServerOffsetContext> snapshotContext) throws Exception- Overrides:
connectionCreatedin classRelationalSnapshotChangeEventSource<SqlServerPartition,SqlServerOffsetContext> - Throws:
Exception
-
getAllTableIds
protected Set<TableId> getAllTableIds(RelationalSnapshotChangeEventSource.RelationalSnapshotContext<SqlServerPartition, SqlServerOffsetContext> ctx) throws Exception- Specified by:
getAllTableIdsin classRelationalSnapshotChangeEventSource<SqlServerPartition,SqlServerOffsetContext> - Throws:
Exception
-
lockTablesForSchemaSnapshot
protected void lockTablesForSchemaSnapshot(ChangeEventSource.ChangeEventSourceContext sourceContext, RelationalSnapshotChangeEventSource.RelationalSnapshotContext<SqlServerPartition, SqlServerOffsetContext> snapshotContext) throws SQLException, InterruptedException- Specified by:
lockTablesForSchemaSnapshotin classRelationalSnapshotChangeEventSource<SqlServerPartition,SqlServerOffsetContext> - Throws:
SQLExceptionInterruptedException
-
releaseSchemaSnapshotLocks
protected void releaseSchemaSnapshotLocks(RelationalSnapshotChangeEventSource.RelationalSnapshotContext<SqlServerPartition, SqlServerOffsetContext> snapshotContext) throws SQLException- Specified by:
releaseSchemaSnapshotLocksin classRelationalSnapshotChangeEventSource<SqlServerPartition,SqlServerOffsetContext> - Throws:
SQLException
-
determineSnapshotOffset
protected void determineSnapshotOffset(RelationalSnapshotChangeEventSource.RelationalSnapshotContext<SqlServerPartition, SqlServerOffsetContext> ctx, SqlServerOffsetContext previousOffset) throws Exception- Specified by:
determineSnapshotOffsetin classRelationalSnapshotChangeEventSource<SqlServerPartition,SqlServerOffsetContext> - Throws:
Exception
-
readTableStructure
protected void readTableStructure(ChangeEventSource.ChangeEventSourceContext sourceContext, RelationalSnapshotChangeEventSource.RelationalSnapshotContext<SqlServerPartition, SqlServerOffsetContext> snapshotContext, SqlServerOffsetContext offsetContext) throws SQLException, InterruptedException- Specified by:
readTableStructurein classRelationalSnapshotChangeEventSource<SqlServerPartition,SqlServerOffsetContext> - Throws:
SQLExceptionInterruptedException
-
getCreateTableEvent
protected SchemaChangeEvent getCreateTableEvent(RelationalSnapshotChangeEventSource.RelationalSnapshotContext<SqlServerPartition, SqlServerOffsetContext> snapshotContext, Table table) throws SQLException- Specified by:
getCreateTableEventin classRelationalSnapshotChangeEventSource<SqlServerPartition,SqlServerOffsetContext> - Throws:
SQLException
-
complete
protected void complete(AbstractSnapshotChangeEventSource.SnapshotContext<SqlServerPartition, SqlServerOffsetContext> snapshotContext) - Overrides:
completein classAbstractSnapshotChangeEventSource<SqlServerPartition,SqlServerOffsetContext>
-
getSnapshotSelect
protected Optional<String> getSnapshotSelect(RelationalSnapshotChangeEventSource.RelationalSnapshotContext<SqlServerPartition, SqlServerOffsetContext> snapshotContext, TableId tableId, List<String> columns) Generate a valid SQL Server query string for the specified table- Specified by:
getSnapshotSelectin classRelationalSnapshotChangeEventSource<SqlServerPartition,SqlServerOffsetContext> - Parameters:
tableId- the table to generate a query for- Returns:
- a valid query string
-
enhanceOverriddenSelect
protected String enhanceOverriddenSelect(RelationalSnapshotChangeEventSource.RelationalSnapshotContext<SqlServerPartition, SqlServerOffsetContext> snapshotContext, String overriddenSelect, TableId tableId) -
additionalColumnFilter
protected boolean additionalColumnFilter(SqlServerPartition partition, TableId tableId, String columnName) -
filterChangeTableColumns
private boolean filterChangeTableColumns(SqlServerPartition partition, TableId tableId, String columnName)
-