Package io.debezium.connector.postgresql
Class PostgresSnapshotChangeEventSource
java.lang.Object
io.debezium.pipeline.source.AbstractSnapshotChangeEventSource<P,O>
io.debezium.relational.RelationalSnapshotChangeEventSource<PostgresPartition,PostgresOffsetContext>
io.debezium.connector.postgresql.PostgresSnapshotChangeEventSource
- All Implemented Interfaces:
ChangeEventSource,SnapshotChangeEventSource<PostgresPartition,PostgresOffsetContext>
public class PostgresSnapshotChangeEventSource
extends RelationalSnapshotChangeEventSource<PostgresPartition,PostgresOffsetContext>
-
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 PostgresConnectorConfigprivate final PostgresConnectionprivate static final org.slf4j.Loggerprivate final PostgresSchemaprivate final SlotCreationResultprivate final Snapshotterprivate final SlotStateFields inherited from class io.debezium.relational.RelationalSnapshotChangeEventSource
clock, dispatcher, SELECT_ALL_PATTERNFields inherited from class io.debezium.pipeline.source.AbstractSnapshotChangeEventSource
LOG_INTERVAL -
Constructor Summary
ConstructorsConstructorDescriptionPostgresSnapshotChangeEventSource(PostgresConnectorConfig connectorConfig, Snapshotter snapshotter, PostgresConnection jdbcConnection, PostgresSchema schema, EventDispatcher<PostgresPartition, TableId> dispatcher, Clock clock, SnapshotProgressListener<PostgresPartition> snapshotProgressListener, SlotCreationResult slotCreatedInfo, SlotState startingSlotInfo) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcomplete(AbstractSnapshotChangeEventSource.SnapshotContext<PostgresPartition, PostgresOffsetContext> snapshotContext) protected voidconnectionCreated(RelationalSnapshotChangeEventSource.RelationalSnapshotContext<PostgresPartition, PostgresOffsetContext> snapshotContext) protected voiddetermineSnapshotOffset(RelationalSnapshotChangeEventSource.RelationalSnapshotContext<PostgresPartition, PostgresOffsetContext> ctx, PostgresOffsetContext previousOffset) getAllTableIds(RelationalSnapshotChangeEventSource.RelationalSnapshotContext<PostgresPartition, PostgresOffsetContext> ctx) protected SchemaChangeEventgetCreateTableEvent(RelationalSnapshotChangeEventSource.RelationalSnapshotContext<PostgresPartition, PostgresOffsetContext> snapshotContext, Table table) getSnapshotSelect(RelationalSnapshotChangeEventSource.RelationalSnapshotContext<PostgresPartition, PostgresOffsetContext> snapshotContext, TableId tableId, List<String> columns) Generate a valid Postgres query string for the specified table and columnsgetSnapshottingTask(PostgresPartition partition, PostgresOffsetContext previousOffset) private Lsnprotected voidlockTablesForSchemaSnapshot(ChangeEventSource.ChangeEventSourceContext sourceContext, RelationalSnapshotChangeEventSource.RelationalSnapshotContext<PostgresPartition, PostgresOffsetContext> snapshotContext) protected AbstractSnapshotChangeEventSource.SnapshotContext<PostgresPartition,PostgresOffsetContext> prepare(PostgresPartition partition) protected voidreadTableStructure(ChangeEventSource.ChangeEventSourceContext sourceContext, RelationalSnapshotChangeEventSource.RelationalSnapshotContext<PostgresPartition, PostgresOffsetContext> snapshotContext, PostgresOffsetContext offsetContext) protected voidreleaseSchemaSnapshotLocks(RelationalSnapshotChangeEventSource.RelationalSnapshotContext<PostgresPartition, PostgresOffsetContext> snapshotContext) protected voidprotected voidprivate voidMethods inherited from class io.debezium.relational.RelationalSnapshotChangeEventSource
additionalColumnFilter, createSchemaChangeEventsForTables, createSnapshotConnection, doExecute, enhanceOverriddenSelect, 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 -
connectorConfig
-
jdbcConnection
-
schema
-
snapshotter
-
slotCreatedInfo
-
startingSlotInfo
-
-
Constructor Details
-
PostgresSnapshotChangeEventSource
public PostgresSnapshotChangeEventSource(PostgresConnectorConfig connectorConfig, Snapshotter snapshotter, PostgresConnection jdbcConnection, PostgresSchema schema, EventDispatcher<PostgresPartition, TableId> dispatcher, Clock clock, SnapshotProgressListener<PostgresPartition> snapshotProgressListener, SlotCreationResult slotCreatedInfo, SlotState startingSlotInfo)
-
-
Method Details
-
getSnapshottingTask
protected AbstractSnapshotChangeEventSource.SnapshottingTask getSnapshottingTask(PostgresPartition partition, PostgresOffsetContext previousOffset) - Specified by:
getSnapshottingTaskin classAbstractSnapshotChangeEventSource<PostgresPartition,PostgresOffsetContext>
-
prepare
protected AbstractSnapshotChangeEventSource.SnapshotContext<PostgresPartition,PostgresOffsetContext> prepare(PostgresPartition partition) throws Exception - Specified by:
preparein classAbstractSnapshotChangeEventSource<PostgresPartition,PostgresOffsetContext> - Throws:
Exception
-
connectionCreated
protected void connectionCreated(RelationalSnapshotChangeEventSource.RelationalSnapshotContext<PostgresPartition, PostgresOffsetContext> snapshotContext) throws Exception- Overrides:
connectionCreatedin classRelationalSnapshotChangeEventSource<PostgresPartition,PostgresOffsetContext> - Throws:
Exception
-
getAllTableIds
protected Set<TableId> getAllTableIds(RelationalSnapshotChangeEventSource.RelationalSnapshotContext<PostgresPartition, PostgresOffsetContext> ctx) throws Exception- Specified by:
getAllTableIdsin classRelationalSnapshotChangeEventSource<PostgresPartition,PostgresOffsetContext> - Throws:
Exception
-
lockTablesForSchemaSnapshot
protected void lockTablesForSchemaSnapshot(ChangeEventSource.ChangeEventSourceContext sourceContext, RelationalSnapshotChangeEventSource.RelationalSnapshotContext<PostgresPartition, PostgresOffsetContext> snapshotContext) throws SQLException, InterruptedException- Specified by:
lockTablesForSchemaSnapshotin classRelationalSnapshotChangeEventSource<PostgresPartition,PostgresOffsetContext> - Throws:
SQLExceptionInterruptedException
-
releaseSchemaSnapshotLocks
protected void releaseSchemaSnapshotLocks(RelationalSnapshotChangeEventSource.RelationalSnapshotContext<PostgresPartition, PostgresOffsetContext> snapshotContext) throws SQLException- Specified by:
releaseSchemaSnapshotLocksin classRelationalSnapshotChangeEventSource<PostgresPartition,PostgresOffsetContext> - Throws:
SQLException
-
determineSnapshotOffset
protected void determineSnapshotOffset(RelationalSnapshotChangeEventSource.RelationalSnapshotContext<PostgresPartition, PostgresOffsetContext> ctx, PostgresOffsetContext previousOffset) throws Exception- Specified by:
determineSnapshotOffsetin classRelationalSnapshotChangeEventSource<PostgresPartition,PostgresOffsetContext> - Throws:
Exception
-
updateOffsetForSnapshot
- Throws:
SQLException
-
updateOffsetForPreSnapshotCatchUpStreaming
protected void updateOffsetForPreSnapshotCatchUpStreaming(PostgresOffsetContext offset) throws SQLException - Throws:
SQLException
-
getTransactionStartLsn
- Throws:
SQLException
-
readTableStructure
protected void readTableStructure(ChangeEventSource.ChangeEventSourceContext sourceContext, RelationalSnapshotChangeEventSource.RelationalSnapshotContext<PostgresPartition, PostgresOffsetContext> snapshotContext, PostgresOffsetContext offsetContext) throws SQLException, InterruptedException- Specified by:
readTableStructurein classRelationalSnapshotChangeEventSource<PostgresPartition,PostgresOffsetContext> - Throws:
SQLExceptionInterruptedException
-
getCreateTableEvent
protected SchemaChangeEvent getCreateTableEvent(RelationalSnapshotChangeEventSource.RelationalSnapshotContext<PostgresPartition, PostgresOffsetContext> snapshotContext, Table table) throws SQLException- Specified by:
getCreateTableEventin classRelationalSnapshotChangeEventSource<PostgresPartition,PostgresOffsetContext> - Throws:
SQLException
-
complete
protected void complete(AbstractSnapshotChangeEventSource.SnapshotContext<PostgresPartition, PostgresOffsetContext> snapshotContext) - Overrides:
completein classAbstractSnapshotChangeEventSource<PostgresPartition,PostgresOffsetContext>
-
getSnapshotSelect
protected Optional<String> getSnapshotSelect(RelationalSnapshotChangeEventSource.RelationalSnapshotContext<PostgresPartition, PostgresOffsetContext> snapshotContext, TableId tableId, List<String> columns) Generate a valid Postgres query string for the specified table and columns- Specified by:
getSnapshotSelectin classRelationalSnapshotChangeEventSource<PostgresPartition,PostgresOffsetContext> - Parameters:
tableId- the table to generate a query for- Returns:
- a valid query string
-
setSnapshotTransactionIsolationLevel
- Throws:
SQLException
-