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 Classes Modifier and Type Class Description private static classPostgresSnapshotChangeEventSource.PostgresSnapshotContextMutable 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
Fields Modifier and Type Field Description private PostgresConnectorConfigconnectorConfigprivate PostgresConnectionjdbcConnectionprivate static org.slf4j.LoggerLOGGERprivate PostgresSchemaschemaprivate SlotCreationResultslotCreatedInfoprivate Snapshottersnapshotterprivate SlotStatestartingSlotInfo-
Fields inherited from class io.debezium.relational.RelationalSnapshotChangeEventSource
clock, dispatcher, LOG_INTERVAL, SELECT_ALL_PATTERN
-
-
Constructor Summary
Constructors Constructor Description PostgresSnapshotChangeEventSource(PostgresConnectorConfig connectorConfig, Snapshotter snapshotter, PostgresConnection jdbcConnection, PostgresSchema schema, EventDispatcher<TableId> dispatcher, Clock clock, SnapshotProgressListener snapshotProgressListener, SlotCreationResult slotCreatedInfo, SlotState startingSlotInfo)
-
Method Summary
-
Methods inherited from class io.debezium.relational.RelationalSnapshotChangeEventSource
additionalColumnFilter, createSchemaChangeEventsForTables, createSnapshotConnection, doExecute, enhanceOverriddenSelect, getChangeRecordEmitter, getClock, getColumnValue, getPreparedColumnNames, lastSnapshotRecord, postSnapshot, readTableStatement, releaseDataSnapshotLocks, rowCountForTable, schema, tryStartingSnapshot
-
Methods inherited from class io.debezium.pipeline.source.AbstractSnapshotChangeEventSource
delaySnapshotIfNeeded, determineDataCollectionsToBeSnapshotted, execute
-
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
connectorConfig
private final PostgresConnectorConfig connectorConfig
-
jdbcConnection
private final PostgresConnection jdbcConnection
-
schema
private final PostgresSchema schema
-
snapshotter
private final Snapshotter snapshotter
-
slotCreatedInfo
private final SlotCreationResult slotCreatedInfo
-
startingSlotInfo
private final SlotState startingSlotInfo
-
-
Constructor Detail
-
PostgresSnapshotChangeEventSource
public PostgresSnapshotChangeEventSource(PostgresConnectorConfig connectorConfig, Snapshotter snapshotter, PostgresConnection jdbcConnection, PostgresSchema schema, EventDispatcher<TableId> dispatcher, Clock clock, SnapshotProgressListener snapshotProgressListener, SlotCreationResult slotCreatedInfo, SlotState startingSlotInfo)
-
-
Method Detail
-
getSnapshottingTask
protected AbstractSnapshotChangeEventSource.SnapshottingTask getSnapshottingTask(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
private void updateOffsetForSnapshot(PostgresOffsetContext offset) throws SQLException
- Throws:
SQLException
-
updateOffsetForPreSnapshotCatchUpStreaming
protected void updateOffsetForPreSnapshotCatchUpStreaming(PostgresOffsetContext offset) throws SQLException
- Throws:
SQLException
-
getTransactionStartLsn
private Lsn getTransactionStartLsn() throws SQLException
- 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
protected void setSnapshotTransactionIsolationLevel() throws SQLException- Throws:
SQLException
-
-