From 5e490d4394fd35f4b1a20e12af53a92f77e49a00 Mon Sep 17 00:00:00 2001 From: Gunnar Morling Date: Tue, 10 Dec 2019 07:22:19 +0100 Subject: [PATCH] DBZ-585 Renaming 'initial_schema_only' snapshot mode for Oracle into 'schema_only' --- .../oracle/OracleConnectorConfig.java | 35 +++++++++++++++++-- .../connector/oracle/OracleConnectorIT.java | 4 +-- .../oracle/StreamingDatatypesIT.java | 2 +- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/debezium-connector-oracle/src/main/java/io/debezium/connector/oracle/OracleConnectorConfig.java b/debezium-connector-oracle/src/main/java/io/debezium/connector/oracle/OracleConnectorConfig.java index 86e605dfc..059dbfbf7 100644 --- a/debezium-connector-oracle/src/main/java/io/debezium/connector/oracle/OracleConnectorConfig.java +++ b/debezium-connector-oracle/src/main/java/io/debezium/connector/oracle/OracleConnectorConfig.java @@ -14,6 +14,7 @@ import io.debezium.config.Configuration; import io.debezium.config.EnumeratedValue; import io.debezium.config.Field; +import io.debezium.config.Field.ValidationOutput; import io.debezium.connector.AbstractSourceInfo; import io.debezium.connector.SourceInfoStructMaker; import io.debezium.document.Document; @@ -66,12 +67,13 @@ public class OracleConnectorConfig extends HistorizedRelationalDatabaseConnector public static final Field SNAPSHOT_MODE = Field.create("snapshot.mode") .withDisplayName("Snapshot mode") .withEnum(SnapshotMode.class, SnapshotMode.INITIAL) + .withValidation(OracleConnectorConfig::validateSnapshotMode) .withWidth(Width.SHORT) .withImportance(Importance.LOW) .withDescription("The criteria for running a snapshot upon startup of the connector. " + "Options include: " + "'initial' (the default) to specify the connector should run a snapshot only when no offsets are available for the logical server name; " - + "'initial_schema_only' to specify the connector should run a snapshot of the schema when no offsets are available for the logical server name. "); + + "'schema_only' to specify the connector should run a snapshot of the schema when no offsets are available for the logical server name. "); public static final Field TABLENAME_CASE_INSENSITIVE = Field.create("database.tablename.case.insensitive") .withDisplayName("Case insensitive table names") @@ -255,8 +257,16 @@ public static enum SnapshotMode implements EnumeratedValue { /** * Perform a snapshot of the schema but no data upon initial startup of a connector. + * + * @deprecated to be removed in 1.1; use {@link #INITIAL_SCHEMA} instead. */ - INITIAL_SCHEMA_ONLY("initial_schema_only", false); + @Deprecated + INITIAL_SCHEMA_ONLY("initial_schema_only", false), + + /** + * Perform a snapshot of the schema but no data upon initial startup of a connector. + */ + SCHEMA_ONLY("schema_only", false); private final String value; private final boolean includeData; @@ -357,4 +367,25 @@ protected SourceInfoStructMaker getSourceInfoStruc public String getContextName() { return Module.contextName(); } + + /** + * Validate the time.precision.mode configuration. + * + * If {@code adaptive} is specified, this option has the potential to cause overflow which is why the + * option was deprecated and no longer supported for this connector. + */ + private static int validateSnapshotMode(Configuration config, Field field, ValidationOutput problems) { + if (config.hasKey(SNAPSHOT_MODE.name())) { + final String snapshotMode = config.getString(SNAPSHOT_MODE.name()); + if (SnapshotMode.INITIAL_SCHEMA_ONLY.value.equals(snapshotMode)) { + // this will be logged as ERROR, but returning 0 doesn't prevent start-up + problems.accept(SNAPSHOT_MODE, snapshotMode, + "The 'initial_schema_only' snapshot.mode is no longer supported and will be removed in a future revision. Use 'schema_only' instead."); + return 0; + } + } + + // Everything checks out ok. + return 0; + } } diff --git a/debezium-connector-oracle/src/test/java/io/debezium/connector/oracle/OracleConnectorIT.java b/debezium-connector-oracle/src/test/java/io/debezium/connector/oracle/OracleConnectorIT.java index 16cf50a3c..c34e510a6 100644 --- a/debezium-connector-oracle/src/test/java/io/debezium/connector/oracle/OracleConnectorIT.java +++ b/debezium-connector-oracle/src/test/java/io/debezium/connector/oracle/OracleConnectorIT.java @@ -370,7 +370,7 @@ public void shouldStreamAfterRestartAfterSnapshot() throws Exception { public void shouldReadChangeStreamForExistingTable() throws Exception { Configuration config = TestHelper.defaultConfig() .with(RelationalDatabaseConnectorConfig.TABLE_WHITELIST, "ORCLPDB1\\.DEBEZIUM\\.CUSTOMER") - .with(OracleConnectorConfig.SNAPSHOT_MODE, SnapshotMode.INITIAL_SCHEMA_ONLY) + .with(OracleConnectorConfig.SNAPSHOT_MODE, SnapshotMode.SCHEMA_ONLY) .build(); start(OracleConnector.class, config); @@ -460,7 +460,7 @@ public void shouldReadChangeStreamForExistingTable() throws Exception { public void deleteWithoutTombstone() throws Exception { Configuration config = TestHelper.defaultConfig() .with(RelationalDatabaseConnectorConfig.TABLE_WHITELIST, "ORCLPDB1\\.DEBEZIUM\\.CUSTOMER") - .with(OracleConnectorConfig.SNAPSHOT_MODE, SnapshotMode.INITIAL_SCHEMA_ONLY) + .with(OracleConnectorConfig.SNAPSHOT_MODE, SnapshotMode.SCHEMA_ONLY) .with(OracleConnectorConfig.TOMBSTONES_ON_DELETE, false) .build(); diff --git a/debezium-connector-oracle/src/test/java/io/debezium/connector/oracle/StreamingDatatypesIT.java b/debezium-connector-oracle/src/test/java/io/debezium/connector/oracle/StreamingDatatypesIT.java index b5f372055..694121d32 100644 --- a/debezium-connector-oracle/src/test/java/io/debezium/connector/oracle/StreamingDatatypesIT.java +++ b/debezium-connector-oracle/src/test/java/io/debezium/connector/oracle/StreamingDatatypesIT.java @@ -36,7 +36,7 @@ public void before() throws Exception { Configuration config = TestHelper.defaultConfig() .with(OracleConnectorConfig.TABLE_WHITELIST, whitelistedTables) - .with(OracleConnectorConfig.SNAPSHOT_MODE, SnapshotMode.INITIAL_SCHEMA_ONLY) + .with(OracleConnectorConfig.SNAPSHOT_MODE, SnapshotMode.SCHEMA_ONLY) .build(); start(OracleConnector.class, config);