Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.kafka.connect.runtime;

import org.apache.kafka.clients.admin.AdminClientConfig;
import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.kafka.clients.producer.KafkaProducer;
Expand Down Expand Up @@ -607,8 +608,18 @@ static Map<String, Object> adminConfigs(ConnectorTaskId id,
Class<? extends Connector> connectorClass,
ConnectorClientConfigOverridePolicy connectorClientConfigOverridePolicy) {
Map<String, Object> adminProps = new HashMap<>();
adminProps.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, Utils.join(config.getList(WorkerConfig.BOOTSTRAP_SERVERS_CONFIG), ","));
// User-specified overrides
// Use the top-level worker configs to retain backwards compatibility with older releases which
// did not require a prefix for connector admin client configs in the worker configuration file
// Only include configs that do not begin with "admin." since those will be added next, but with
// the prefix stripped
Map<String, Object> nonPrefixedWorkerConfigs = config.originals().entrySet().stream()
.filter(e -> !e.getKey().startsWith("admin."))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
adminProps.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG,
Utils.join(config.getList(WorkerConfig.BOOTSTRAP_SERVERS_CONFIG), ","));
adminProps.putAll(nonPrefixedWorkerConfigs);

// Admin client-specific overrides in the worker config
Comment thread
C0urante marked this conversation as resolved.
adminProps.putAll(config.originalsWithPrefix("admin."));

// Connector-specified overrides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,8 @@ public void testAdminConfigsClientOverridesWithAllPolicy() {
Map<String, Object> connConfig = new HashMap<String, Object>();
connConfig.put("metadata.max.age.ms", "10000");

Map<String, String> expectedConfigs = new HashMap<>();
Map<String, String> expectedConfigs = new HashMap<>(workerProps);

expectedConfigs.put("bootstrap.servers", "localhost:9092");
expectedConfigs.put("client.id", "testid");
expectedConfigs.put("metadata.max.age.ms", "10000");
Expand All @@ -1153,7 +1154,6 @@ public void testAdminConfigsClientOverridesWithAllPolicy() {
PowerMock.replayAll();
assertEquals(expectedConfigs, Worker.adminConfigs(new ConnectorTaskId("test", 1), configWithOverrides, connectorConfig,
null, allConnectorClientConfigOverridePolicy));

}

@Test(expected = ConnectException.class)
Expand All @@ -1171,7 +1171,6 @@ public void testAdminConfigsClientOverridesWithNonePolicy() {
PowerMock.replayAll();
Worker.adminConfigs(new ConnectorTaskId("test", 1), configWithOverrides, connectorConfig,
null, noneConnectorClientConfigOverridePolicy);

}

private void assertStatusMetrics(long expected, String metricName) {
Expand Down