From e2c4bb80397fc6b0b5fbb39262ee1af7840f2d06 Mon Sep 17 00:00:00 2001 From: mfvitale Date: Mon, 18 Mar 2024 16:47:53 +0100 Subject: [PATCH] DBZ-7308 tableLockingStatement from SnapshotLock interface now takes just one table in input --- .../debezium/connector/db2/Db2SnapshotChangeEventSource.java | 4 +--- .../connector/db2/snapshot/lock/ExclusiveSnapshotLock.java | 5 +---- .../debezium/connector/db2/snapshot/lock/NoSnapshotLock.java | 3 +-- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/main/java/io/debezium/connector/db2/Db2SnapshotChangeEventSource.java b/src/main/java/io/debezium/connector/db2/Db2SnapshotChangeEventSource.java index b0edb3b..7ca4ff4 100644 --- a/src/main/java/io/debezium/connector/db2/Db2SnapshotChangeEventSource.java +++ b/src/main/java/io/debezium/connector/db2/Db2SnapshotChangeEventSource.java @@ -11,7 +11,6 @@ import java.sql.Savepoint; import java.sql.Statement; import java.util.List; -import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; @@ -32,7 +31,6 @@ import io.debezium.relational.Tables; import io.debezium.schema.SchemaChangeEvent; import io.debezium.snapshot.SnapshotterService; -import io.debezium.spi.snapshot.Snapshotter; import io.debezium.util.Clock; public class Db2SnapshotChangeEventSource extends RelationalSnapshotChangeEventSource { @@ -90,7 +88,7 @@ else if (connectorConfig.getSnapshotIsolationMode() == SnapshotIsolationMode.EXC } Optional lockingStatement = snapshotterService.getSnapshotLock().tableLockingStatement(connectorConfig.snapshotLockTimeout(), - Set.of(quoteTableName(tableId))); + quoteTableName(tableId)); if (lockingStatement.isPresent()) { LOGGER.info("Locking table {}", tableId); diff --git a/src/main/java/io/debezium/connector/db2/snapshot/lock/ExclusiveSnapshotLock.java b/src/main/java/io/debezium/connector/db2/snapshot/lock/ExclusiveSnapshotLock.java index dbd08a0..2f58272 100644 --- a/src/main/java/io/debezium/connector/db2/snapshot/lock/ExclusiveSnapshotLock.java +++ b/src/main/java/io/debezium/connector/db2/snapshot/lock/ExclusiveSnapshotLock.java @@ -8,7 +8,6 @@ import java.time.Duration; import java.util.Map; import java.util.Optional; -import java.util.Set; import io.debezium.connector.db2.Db2ConnectorConfig; import io.debezium.snapshot.spi.SnapshotLock; @@ -26,9 +25,7 @@ public void configure(Map properties) { } @Override - public Optional tableLockingStatement(Duration lockTimeout, Set tableIds) { - - String tableId = tableIds.iterator().next(); // For Db2 we expect just one table at time. + public Optional tableLockingStatement(Duration lockTimeout, String tableId) { return Optional.of("SELECT * FROM " + tableId + " WHERE 0=1 WITH CS"); } diff --git a/src/main/java/io/debezium/connector/db2/snapshot/lock/NoSnapshotLock.java b/src/main/java/io/debezium/connector/db2/snapshot/lock/NoSnapshotLock.java index 2a1d1a1..ab4294d 100644 --- a/src/main/java/io/debezium/connector/db2/snapshot/lock/NoSnapshotLock.java +++ b/src/main/java/io/debezium/connector/db2/snapshot/lock/NoSnapshotLock.java @@ -8,7 +8,6 @@ import java.time.Duration; import java.util.Map; import java.util.Optional; -import java.util.Set; import io.debezium.connector.db2.Db2ConnectorConfig; import io.debezium.snapshot.spi.SnapshotLock; @@ -26,7 +25,7 @@ public void configure(Map properties) { } @Override - public Optional tableLockingStatement(Duration lockTimeout, Set tableIds) { + public Optional tableLockingStatement(Duration lockTimeout, String tableId) { return Optional.empty(); }