From 492d32e83d4e08642fa2d7de2ac522a006f8ca13 Mon Sep 17 00:00:00 2001 From: twthorn Date: Tue, 22 Oct 2024 13:06:04 -0400 Subject: [PATCH] DBZ-8325 Remove unused variable & update java doc --- .../vitess/TableTopicNamingStrategy.java | 18 +++++++++++++----- .../jdbc/VitessBinlogValueConverter.java | 3 +++ .../vitess/jdbc/VitessConnection.java | 4 +++- .../jdbc/VitessDefaultValueConverter.java | 2 ++ .../connector/vitess/VitessTestCleanup.java | 3 +++ .../vitess/connection/DdlMessageTest.java | 2 ++ 6 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/debezium/connector/vitess/TableTopicNamingStrategy.java b/src/main/java/io/debezium/connector/vitess/TableTopicNamingStrategy.java index f65e6d3f..f535ecab 100644 --- a/src/main/java/io/debezium/connector/vitess/TableTopicNamingStrategy.java +++ b/src/main/java/io/debezium/connector/vitess/TableTopicNamingStrategy.java @@ -22,13 +22,13 @@ public class TableTopicNamingStrategy extends AbstractTopicNamingStrategy { private final String overrideDataChangeTopicPrefix; - private final String overrideSchemaChangeTopicName; + private final String overrideSchemaChangeTopic; public TableTopicNamingStrategy(Properties props) { super(props); Configuration config = Configuration.from(props); this.overrideDataChangeTopicPrefix = config.getString(VitessConnectorConfig.OVERRIDE_DATA_CHANGE_TOPIC_PREFIX); - this.overrideSchemaChangeTopicName = config.getString(VitessConnectorConfig.OVERRIDE_SCHEMA_CHANGE_TOPIC); + this.overrideSchemaChangeTopic = config.getString(VitessConnectorConfig.OVERRIDE_SCHEMA_CHANGE_TOPIC); } public static TableTopicNamingStrategy create(CommonConnectorConfig config) { @@ -47,11 +47,19 @@ public String dataChangeTopic(TableId id) { return topicNames.computeIfAbsent(id, t -> sanitizedTopicName(topicName)); } + /** + * Return the schema change topic. There are two cases: + * 1. If override schema change topic is specified - use this as the topic name + * 2. If override schema change topic is not specified - return the `topic.prefix` specified by the + * {@link CommonConnectorConfig.TOPIC_PREFIX} config (unique to + * each connector, so it doesn't risk name conflicts) + * + * @return String representing the schema change topic name. + */ @Override public String schemaChangeTopic() { - String topicName; - if (!Strings.isNullOrBlank(overrideSchemaChangeTopicName)) { - return overrideSchemaChangeTopicName; + if (!Strings.isNullOrBlank(overrideSchemaChangeTopic)) { + return overrideSchemaChangeTopic; } else { return prefix; diff --git a/src/main/java/io/debezium/connector/vitess/jdbc/VitessBinlogValueConverter.java b/src/main/java/io/debezium/connector/vitess/jdbc/VitessBinlogValueConverter.java index 3a8691f2..26cd39cb 100644 --- a/src/main/java/io/debezium/connector/vitess/jdbc/VitessBinlogValueConverter.java +++ b/src/main/java/io/debezium/connector/vitess/jdbc/VitessBinlogValueConverter.java @@ -14,12 +14,15 @@ import io.debezium.connector.binlog.jdbc.BinlogValueConverters; import io.debezium.connector.mysql.antlr.MySqlAntlrDdlParser; import io.debezium.connector.vitess.VitessConnectorConfig; +import io.debezium.connector.vitess.VitessDatabaseSchema; import io.debezium.jdbc.JdbcValueConverters; import io.debezium.jdbc.TemporalPrecisionMode; import io.debezium.relational.Column; import io.debezium.service.spi.ServiceRegistry; /** + * Create a binlog value converter class to be passed into the + * {@link VitessDefaultValueConverter} in the {@link VitessDatabaseSchema} * @author Thomas Thornton */ public class VitessBinlogValueConverter extends BinlogValueConverters { diff --git a/src/main/java/io/debezium/connector/vitess/jdbc/VitessConnection.java b/src/main/java/io/debezium/connector/vitess/jdbc/VitessConnection.java index f73a1483..67a2a1b9 100644 --- a/src/main/java/io/debezium/connector/vitess/jdbc/VitessConnection.java +++ b/src/main/java/io/debezium/connector/vitess/jdbc/VitessConnection.java @@ -10,7 +10,9 @@ import io.debezium.jdbc.JdbcConnection; /** - * Needed to maintain compatibility with RelationalSnapshotChangeEventSource + * A connection with Vitess that is JDBC compatible. + * + * Needed to maintain compatibility with {@link io.debezium.relational.RelationalSnapshotChangeEventSource} * * TODO: Move all query-based interactions with Vitess onto this class. * Currently we do these with VitessReplicationConnection instead diff --git a/src/main/java/io/debezium/connector/vitess/jdbc/VitessDefaultValueConverter.java b/src/main/java/io/debezium/connector/vitess/jdbc/VitessDefaultValueConverter.java index 022152eb..a275e21c 100644 --- a/src/main/java/io/debezium/connector/vitess/jdbc/VitessDefaultValueConverter.java +++ b/src/main/java/io/debezium/connector/vitess/jdbc/VitessDefaultValueConverter.java @@ -10,6 +10,8 @@ import io.debezium.connector.binlog.jdbc.BinlogValueConverters; /** + * Create a binlog default value converter to be passed into the {@link io.debezium.relational.TableSchemaBuilder} + * in {@link io.debezium.connector.vitess.VitessDatabaseSchema} * @author Thomas Thornton */ public class VitessDefaultValueConverter extends BinlogDefaultValueConverter { diff --git a/src/test/java/io/debezium/connector/vitess/VitessTestCleanup.java b/src/test/java/io/debezium/connector/vitess/VitessTestCleanup.java index ff12bc96..006647b2 100644 --- a/src/test/java/io/debezium/connector/vitess/VitessTestCleanup.java +++ b/src/test/java/io/debezium/connector/vitess/VitessTestCleanup.java @@ -9,6 +9,9 @@ import org.junit.After; /** + * Used to tear down the {@link VitessDatabaseSchema} and {@link VitessConnectorTask} after each + * test to avoid resource conflicts. + * * @author Thomas Thornton */ public class VitessTestCleanup { diff --git a/src/test/java/io/debezium/connector/vitess/connection/DdlMessageTest.java b/src/test/java/io/debezium/connector/vitess/connection/DdlMessageTest.java index 86a05180..3dab66de 100644 --- a/src/test/java/io/debezium/connector/vitess/connection/DdlMessageTest.java +++ b/src/test/java/io/debezium/connector/vitess/connection/DdlMessageTest.java @@ -13,6 +13,8 @@ import org.junit.Test; /** + * Verify the behavior of {@link DdlMessage} + * * @author Thomas Thornton */ public class DdlMessageTest {