forked from debezium/debezium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DBZ-4272 Trigger schema refresh before snapshot; only for PostgreSQL
- Loading branch information
1 parent
652f41f
commit 0a10d5b
Showing
5 changed files
with
65 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...ebezium/connector/postgresql/PostgresSignalBasedIncrementalSnapshotChangeEventSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright Debezium Authors. | ||
* | ||
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
package io.debezium.connector.postgresql; | ||
|
||
import java.sql.SQLException; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import io.debezium.connector.postgresql.connection.PostgresConnection; | ||
import io.debezium.jdbc.JdbcConnection; | ||
import io.debezium.pipeline.EventDispatcher; | ||
import io.debezium.pipeline.source.snapshot.incremental.SignalBasedIncrementalSnapshotChangeEventSource; | ||
import io.debezium.pipeline.source.spi.DataChangeEventListener; | ||
import io.debezium.pipeline.source.spi.SnapshotProgressListener; | ||
import io.debezium.relational.RelationalDatabaseConnectorConfig; | ||
import io.debezium.relational.Table; | ||
import io.debezium.relational.TableId; | ||
import io.debezium.schema.DatabaseSchema; | ||
import io.debezium.util.Clock; | ||
|
||
/** | ||
* @author Chris Cranford | ||
*/ | ||
public class PostgresSignalBasedIncrementalSnapshotChangeEventSource extends SignalBasedIncrementalSnapshotChangeEventSource<TableId> { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(PostgresSignalBasedIncrementalSnapshotChangeEventSource.class); | ||
|
||
private final PostgresConnection jdbcConnection; | ||
private final PostgresSchema schema; | ||
|
||
public PostgresSignalBasedIncrementalSnapshotChangeEventSource(RelationalDatabaseConnectorConfig config, | ||
JdbcConnection jdbcConnection, | ||
EventDispatcher<TableId> dispatcher, | ||
DatabaseSchema<?> databaseSchema, | ||
Clock clock, | ||
SnapshotProgressListener progressListener, | ||
DataChangeEventListener dataChangeEventListener) { | ||
super(config, jdbcConnection, dispatcher, databaseSchema, clock, progressListener, dataChangeEventListener); | ||
this.jdbcConnection = (PostgresConnection) jdbcConnection; | ||
this.schema = (PostgresSchema) databaseSchema; | ||
} | ||
|
||
@Override | ||
protected Table refreshTableSchema(Table table) throws SQLException { | ||
LOGGER.debug("Refreshing table '{}' schema for incremental snapshot.", table.id()); | ||
schema.refresh(jdbcConnection, table.id(), true); | ||
return schema.tableFor(table.id()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters