DBZ-6892 Removing all code related to previously deprecated MongoDB conenctor configuration

This commit is contained in:
Jakub Cechacek 2023-09-12 10:41:14 +02:00 committed by Jiri Pechanec
parent 1bc62872fd
commit 9aadc38414
8 changed files with 7 additions and 73 deletions

View File

@ -209,13 +209,11 @@ public Config validate(Map<String, String> connectorConfigs) {
// Get the config values for each of the connection-related fields ...
ConfigValue connectionStringValue = results.get(MongoDbConnectorConfig.CONNECTION_STRING.name());
ConfigValue hostsValue = results.get(MongoDbConnectorConfig.HOSTS.name());
ConfigValue userValue = results.get(MongoDbConnectorConfig.USER.name());
ConfigValue passwordValue = results.get(MongoDbConnectorConfig.PASSWORD.name());
// If there are no errors on any of these ...
if (hostsValue.errorMessages().isEmpty()
&& userValue.errorMessages().isEmpty()
if (userValue.errorMessages().isEmpty()
&& passwordValue.errorMessages().isEmpty()
&& connectionStringValue.errorMessages().isEmpty()) {
@ -225,7 +223,7 @@ public Config validate(Map<String, String> connectorConfigs) {
client.listDatabaseNames();
}
catch (MongoException e) {
hostsValue.addErrorMessage("Unable to connect: " + e.getMessage());
connectionStringValue.addErrorMessage("Unable to connect: " + e.getMessage());
}
}

View File

@ -832,35 +832,6 @@ public static OversizeHandlingMode parse(String value, String defaultValue) {
"for data change, schema change, transaction, heartbeat event etc.")
.withDefault(DefaultTopicNamingStrategy.class.getName());
/**
* The comma-separated list of hostname and port pairs (in the form 'host' or 'host:port') of the MongoDB servers in the
* replica set.
*/
@Deprecated
public static final Field HOSTS = Field.create("mongodb.hosts")
.withDisplayName("Hosts")
.withType(Type.LIST)
.withGroup(Field.createGroupEntry(Field.Group.CONNECTION, 6))
.withWidth(Width.LONG)
.withImportance(Importance.HIGH)
.withValidation(MongoDbConnectorConfig::validateHosts)
.withDescription("The hostname and port pairs (in the form 'host' or 'host:port') "
+ "of the MongoDB server(s) in the replica set.");
@Deprecated
public static final Field AUTO_DISCOVER_MEMBERS = Field.create("mongodb.members.auto.discover")
.withDisplayName("Auto-discovery")
.withType(Type.BOOLEAN)
.withGroup(Field.createGroupEntry(Field.Group.CONNECTION, 7))
.withWidth(Width.SHORT)
.withImportance(Importance.LOW)
.withDefault(true)
.withValidation(Field::isBoolean)
.withDescription("Specifies whether the addresses in 'hosts' are seeds that should be "
+ "used to discover all members of the cluster or replica set ('true'), "
+ "or whether the address(es) in 'hosts' should be used as is ('false'). "
+ "The default is 'true'.");
public static final Field SOURCE_INFO_STRUCT_MAKER = CommonConnectorConfig.SOURCE_INFO_STRUCT_MAKER
.withDefault(MongoDbSourceInfoStructMaker.class.getName());
@ -870,7 +841,6 @@ public static OversizeHandlingMode parse(String value, String defaultValue) {
TOPIC_PREFIX,
CONNECTION_STRING,
CONNECTION_MODE,
HOSTS,
USER,
PASSWORD,
AUTH_SOURCE,
@ -879,7 +849,6 @@ public static OversizeHandlingMode parse(String value, String defaultValue) {
SOCKET_TIMEOUT_MS,
SERVER_SELECTION_TIMEOUT_MS,
MONGODB_POLL_INTERVAL_MS,
AUTO_DISCOVER_MEMBERS,
SSL_ENABLED,
SSL_ALLOW_INVALID_HOSTNAMES,
CURSOR_MAX_AWAIT_TIME_MS)
@ -1001,14 +970,10 @@ private static int validateOversizeSkipThreshold(Configuration config, Field fie
private static int validateConnectionString(Configuration config, Field field, ValidationOutput problems) {
String connectionStringValue = config.getString(field);
String hostValue = config.getString(HOSTS);
if (connectionStringValue == null) {
if (hostValue == null) {
problems.accept(field, null, "Missing connection string");
return 1;
}
return 0;
problems.accept(field, null, "Missing connection string");
return 1;
}
try {

View File

@ -82,12 +82,7 @@ public MongoDbConnectorConfig getConnectorConfig() {
* @return hosts or connection string
*/
public String connectionSeed() {
String seed = config.getString(MongoDbConnectorConfig.CONNECTION_STRING);
if (seed == null) {
String hosts = config.getString(MongoDbConnectorConfig.HOSTS);
seed = ConnectionStrings.buildFromHosts(hosts);
}
return seed;
return config.getString(MongoDbConnectorConfig.CONNECTION_STRING);
}
public ConnectionString connectionString() {

View File

@ -13,7 +13,6 @@
import com.mongodb.ConnectionString;
import io.debezium.DebeziumException;
import io.debezium.util.Strings;
/**
@ -35,10 +34,6 @@ public static Optional<String> parseFromHosts(String hosts) {
return matcher(hosts).map(m -> connectionString(m.group(2), m.group(3)));
}
public static String buildFromHosts(String hosts) {
return parseFromHosts(hosts).orElseThrow(() -> new DebeziumException("Unable to build connection string"));
}
/**
* Appends new parameter to connection string
*

View File

@ -38,10 +38,6 @@ public Configurator serverName(String serverName) {
return with(CommonConnectorConfig.TOPIC_PREFIX, serverName);
}
public Configurator hosts(String hosts) {
return with(MongoDbConnectorConfig.HOSTS, hosts);
}
public Configurator maxBatchSize(int maxBatchSize) {
return with(MongoDbConnectorConfig.MAX_BATCH_SIZE, maxBatchSize);
}

View File

@ -214,7 +214,7 @@ public void shouldValidateAcceptableConfiguration() {
MongoDbConnector connector = new MongoDbConnector();
Config result = connector.validate(config.asMap());
assertNoConfigurationErrors(result, MongoDbConnectorConfig.HOSTS);
assertNoConfigurationErrors(result, MongoDbConnectorConfig.CONNECTION_STRING);
assertNoConfigurationErrors(result, CommonConnectorConfig.TOPIC_PREFIX);
assertNoConfigurationErrors(result, MongoDbConnectorConfig.USER);
assertNoConfigurationErrors(result, MongoDbConnectorConfig.PASSWORD);

View File

@ -21,7 +21,6 @@ public class MongoDbConnectorWithConnectionStringIT extends AbstractMongoConnect
private Configuration getConfig(String connectionString, boolean ssl) {
var properties = TestHelper.getConfiguration(mongo).asProperties();
properties.remove(MongoDbConnectorConfig.HOSTS.name());
return Configuration.from(properties).edit()
.with(MongoDbConnectorConfig.POLL_INTERVAL_MS, 10)

View File

@ -176,11 +176,6 @@ To use the MongoDB connector with a replica set, you must set the value of the `
When the connector is ready to begin capturing changes from a MongoDB change stream, it starts a connection task.
The connection task then uses the specified connection string to establish a connection to an available replica set member.
[WARNING]
====
Due to changes in the way that the connector manages database connections, this release of {prodname} no longer supports use of the `mongodb.members.auto.discover` property to prevent the connector from performing membership discovery.
====
[[mongodb-sharded-cluster]]
MongoDB sharded cluster::
A https://docs.mongodb.com/manual/sharding/[MongoDB sharded cluster] consists of:
@ -192,7 +187,7 @@ To use the MongoDB connector with a sharded cluster, in the connector configurat
[WARNING]
====
The `mongodb.connection.string` property replaces the deprecated `mongodb.hosts` property that was used to provide earlier versions of the connector with the host address of the _configuration server_ replica.
The `mongodb.connection.string` property replaces the removed `mongodb.hosts` property that was used to provide earlier versions of the connector with the host address of the _configuration server_ replica.
In the current release, use `mongodb.connection.string` to provide the connector with the addresses of MongoDB routers, also known as `mongos`.
====
@ -1693,15 +1688,6 @@ After a source record is deleted, emitting a tombstone event (the default behavi
* `avro_unicode` replaces the underscore or characters that cannot be used in the Avro type name with corresponding unicode like _uxxxx. Note: _ is an escape sequence like backslash in Java +
See {link-prefix}:{link-avro-serialization}#avro-naming[Avro naming] for more details.
|[[mongodb-property-mongodb-hosts]]<<mongodb-property-mongodb-hosts, `+mongodb.hosts+`>>
|No default
|The comma-separated list of hostname and port pairs (in the form 'host' or 'host:port') of the MongoDB servers in the replica set. The list can contain a single hostname and port pair. +
+
[NOTE]
====
This property is deprecated and should be replaced by xref:mongodb-property-mongodb-connection-string[`+mongodb.connection.string`].
====
|===
The following _advanced_ configuration properties have good defaults that will work in most situations and therefore rarely need to be specified in the connector's configuration.