-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-20430 Add configuration to control internal topic creation in Kafka Connect #20384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a60d5c0
98670aa
1fceb32
b539b5b
bad21aa
2fb8b98
f2f1369
157001b
efcdac5
32471f8
3ae0db0
f4cbbd5
daa516f
3e147ec
62d5e3b
368aebb
2e6af81
72924c6
5270a7a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| #!/bin/bash | ||
| # Licensed to the Apache Software Foundation (ASF) under one or more | ||
| # contributor license agreements. See the NOTICE file distributed with | ||
| # this work for additional information regarding copyright ownership. | ||
| # The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| # (the "License"); you may not use this file except in compliance with | ||
| # the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| if [ "x$KAFKA_HEAP_OPTS" = "x" ]; then | ||
| export KAFKA_HEAP_OPTS="-Xms256M -Xmx2G" | ||
| fi | ||
|
|
||
| exec $(dirname $0)/kafka-run-class.sh org.apache.kafka.tools.ConnectInternalTopics "$@" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| @echo off | ||
| rem Licensed to the Apache Software Foundation (ASF) under one or more | ||
| rem contributor license agreements. See the NOTICE file distributed with | ||
| rem this work for additional information regarding copyright ownership. | ||
| rem The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| rem (the "License"); you may not use this file except in compliance with | ||
| rem the License. You may obtain a copy of the License at | ||
| rem | ||
| rem http://www.apache.org/licenses/LICENSE-2.0 | ||
| rem | ||
| rem Unless required by applicable law or agreed to in writing, software | ||
| rem distributed under the License is distributed on an "AS IS" BASIS, | ||
| rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| rem See the License for the specific language governing permissions and | ||
| rem limitations under the License. | ||
|
|
||
| IF ["%KAFKA_HEAP_OPTS%"] EQU [""] ( | ||
| set KAFKA_HEAP_OPTS=-Xms256M -Xmx2G | ||
| ) | ||
|
|
||
| "%~dp0kafka-run-class.bat" org.apache.kafka.tools.ConnectInternalTopics %* |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,10 +18,13 @@ | |
|
|
||
| import org.apache.kafka.clients.admin.AdminClientConfig; | ||
| import org.apache.kafka.clients.admin.NewTopic; | ||
| import org.apache.kafka.clients.admin.TopicDescription; | ||
| import org.apache.kafka.clients.consumer.ConsumerRecord; | ||
| import org.apache.kafka.common.config.TopicConfig; | ||
| import org.apache.kafka.common.utils.Time; | ||
| import org.apache.kafka.connect.errors.ConnectException; | ||
| import org.apache.kafka.connect.runtime.WorkerConfig; | ||
| import org.apache.kafka.connect.runtime.distributed.DistributedConfig; | ||
| import org.apache.kafka.connect.util.Callback; | ||
| import org.apache.kafka.connect.util.KafkaBasedLog; | ||
| import org.apache.kafka.connect.util.TopicAdmin; | ||
|
|
@@ -39,17 +42,35 @@ public abstract class KafkaTopicBasedBackingStore { | |
|
|
||
| Consumer<TopicAdmin> topicInitializer(String topic, NewTopic topicDescription, WorkerConfig config, Time time) { | ||
| return admin -> { | ||
| log.debug("Creating Connect internal topic for {}", getTopicPurpose()); | ||
| // Create the topic if it doesn't exist | ||
| Set<String> newTopics = createTopics(topicDescription, admin, config, time); | ||
| if (!newTopics.contains(topic)) { | ||
| // It already existed, so check that the topic cleanup policy is compact only and not delete | ||
| log.debug("Using admin client to check cleanup policy of '{}' topic is '{}'", topic, TopicConfig.CLEANUP_POLICY_COMPACT); | ||
| admin.verifyTopicCleanupPolicyOnlyCompact(topic, getTopicConfig(), getTopicPurpose()); | ||
| if (config.internalTopicsCreationEnabled()) { | ||
| log.debug("Creating Connect internal topic for {}", getTopicPurpose()); | ||
| // Create the topic if it doesn't exist | ||
| Set<String> newTopics = createTopics(topicDescription, admin, config, time); | ||
| if (!newTopics.contains(topic)) { | ||
| verifyTopicConfig(topic, admin); | ||
| } | ||
| } else { | ||
| log.debug("Skipping creation of Connect internal topic for {} because automatic topic creation is disabled", getTopicPurpose()); | ||
|
anton-liauchuk marked this conversation as resolved.
|
||
| Map<String, TopicDescription> existing = admin.describeTopics(topic); | ||
| if (existing.isEmpty()) { | ||
| String msg = String.format("Topic '%s' specified via the '%s' property is missing." + | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this error message correct if it's a connector-specific offset topic? Also, what |
||
| " The config '%s' is set to '%s', so automatic creation of internal topics is disabled." + | ||
| " Either enable automatic creation or create the topics manually before starting the worker.", | ||
| topic, getTopicConfig(), DistributedConfig.INTERNAL_TOPICS_AUTOMATIC_CREATION_ENABLE_CONFIG, config.internalTopicsCreationEnabled()); | ||
| throw new ConnectException(msg); | ||
| } | ||
|
|
||
| verifyTopicConfig(topic, admin); | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| private void verifyTopicConfig(String topic, TopicAdmin admin) { | ||
| // It already existed, so check that the topic cleanup policy is compact only and not delete | ||
| log.debug("Using admin client to check cleanup policy of '{}' topic is '{}'", topic, TopicConfig.CLEANUP_POLICY_COMPACT); | ||
| admin.verifyTopicCleanupPolicyOnlyCompact(topic, getTopicConfig(), getTopicPurpose()); | ||
| } | ||
|
|
||
| private Set<String> createTopics(NewTopic topicDescription, TopicAdmin admin, WorkerConfig config, Time time) { | ||
| // get the prefixless default api timeout and retry backoff for topic creation retry configs | ||
| AdminClientConfig adminClientConfig = new AdminClientConfig(config.originals()); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,7 @@ type: docs | |
| * Brokers can now record a human-readable description of each streams group's processing topology via a pluggable backend, retrievable through `Admin#describeStreamsGroups` and `kafka-streams-groups.sh --describe --topology`. The feature is disabled unless the new broker configuration `group.streams.topology.description.plugin.class` is set to a `StreamsGroupTopologyDescriptionPlugin` implementation; on the client side, the new Kafka Streams configuration `topology.description.push.enabled` (default `true`) controls whether the client pushes topology descriptions when requested. This adds a new RPC, `StreamsGroupTopologyDescriptionUpdate`, bumps `StreamsGroupDescribe` and `StreamsGroupHeartbeat` to version 1, and introduces the error codes `GROUP_DELETION_FAILED` (134) and `STREAMS_TOPOLOGY_DESCRIPTION_UPDATE_FAILED` (135). `DeleteGroups` is bumped to version 3, adding a per-group `ErrorMessage` field so brokers can report why a group deletion failed (for example, when the plugin fails to delete its stored topology description, the group is not deleted and `GROUP_DELETION_FAILED` is returned; retrying the deletion is safe). For further details, please refer to [KIP-1331](https://cwiki.apache.org/confluence/display/KAFKA/KIP-1331%3A+Streams+Group+Topology+Description+Plugin) and the [Topology Description Plugin](/{version}/streams/developer-guide/topology-description-plugin/) documentation. | ||
| * The `kafka-producer-perf-test.sh` tool now supports `--record-key-range`, `--key-distribution`, and `--random-seed` options to control the distribution of record keys. Use `--key-distribution range` for sequential key assignment (round-robin over the key range) or `--key-distribution random` for random key selection. The `--random-seed` option allows reproducible benchmark runs when using random key distribution. For further details, please refer to [KIP-1299](https://cwiki.apache.org/confluence/x/XpQ8G). | ||
| * Share groups now support dead-letter queue functionality as outlined in [KIP-1191](https://cwiki.apache.org/confluence/x/fApJFg). Any records which are released (beyond max delivery count) or rejected by the share consumer become eligible for DLQ. Share group DLQ gets enabled when the Kafka feature `share.version` is upgraded to 2. The user can configure a DLQ topic on a share group by setting the dynamic config `errors.deadletterqueue.topic.name` (default `""`) to the name of the DLQ topic. The cluster can be configured to auto create the DLQ topics by setting the dynamic cluster config `errors.deadletterqueue.auto.create.topics.enable` to `true` (default `false`). If auto create is not enabled, the user must create the DLQ topic like a standard Kafka topic and set the dynamic config `errors.deadletterqueue.group.enable` to `true` on the DLQ topic. The DLQ topic name must be prefixed by the value set in the dynamic cluster config `errors.deadletterqueue.topic.name.prefix` (default `dlq.`). The records sent to the DLQ topic by default only contain source record metadata like group, topic name, partition id, offset and delivery count. If original record data is also required, the user must set the dynamic config `errors.deadletterqueue.copy.record.enable` to `true` on the share group. | ||
| * Kafka Connect distributed workers now support the `internal.topics.automatic.creation.enable` configuration (default: `true`). When set to `false`, Connect will not automatically create internal topics (offset, config, status, and connector-specific offset topics) and will instead fail at startup if any of these topics are missing. A new `connect-internal-topics.sh` tool is also available for manually creating these topics. For further details, please refer to [KIP-1209](https://cwiki.apache.org/confluence/display/KAFKA/KIP-1209:+Add+configuration+to+control+internal+topic+creation+in+Kafka+Connect). | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should use immutable KIP link https://cwiki.apache.org/confluence/x/GAq2Fg |
||
|
|
||
| ## Upgrading to 4.3.0 | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.