[英]Kafka describe topic command lists multiple topics description
Running following command on topic my.topic.test
gives description on both my.topic.test
and my.topic_test
(notice the dot and underscore difference in the names) topics.在主题
my.topic.test
上运行以下命令my.topic.test
给出关于my.topic.test
和my.topic_test
(注意名称中的点和下划线差异)主题的描述。
Is that desired behavior or a bug (I would lean towards a bug)?这是期望的行为还是错误(我倾向于错误)?
kafka-topics --describe --zookeeper my_zookeeper_ip:2181 --topic my.topic.test
Topic:my.topic.test PartitionCount:4 ReplicationFactor:1 Configs:
Topic: my.topic.test Partition: 0 Leader: 2 Replicas: 2 Isr: 2
Topic: my.topic.test Partition: 1 Leader: 3 Replicas: 3 Isr: 3
Topic: my.topic.test Partition: 2 Leader: 4 Replicas: 4 Isr: 4
Topic: my.topic.test Partition: 3 Leader: 0 Replicas: 0 Isr: 0
Topic:my.topic_test PartitionCount:5 ReplicationFactor:4 Configs:
Topic: my.topic_test Partition: 0 Leader: 4 Replicas: 3,4,5,1 Isr: 4,1,3
Topic: my.topic_test Partition: 1 Leader: 4 Replicas: 1,3,4 Isr: 4,1,3
Topic: my.topic_test Partition: 2 Leader: 4 Replicas: 4,2,5,3 Isr: 4,3,2
Topic: my.topic_test Partition: 3 Leader: 4 Replicas: 5,1,4 Isr: 4,1
Topic: my.topic_test Partition: 4 Leader: 1 Replicas: 5,1,3,0 Isr: 1,0,3
When run with --describe
, kafka-topics
accepts a regex for the --topic
argument.当使用
--describe
运行时, kafka-topics
接受--topic
参数的正则表达式。 In a regex, .
在正则表达式中,
.
matches any characters so you see the expected behaviour.匹配任何字符,以便您看到预期的行为。
That said, kafka-topics prints a warning when creating a topic with dots or underscores and should have prevented creating 2 topics with such names as metrics would collide:也就是说,kafka-topics 在创建带有点或下划线的主题时会打印警告,并且应该阻止创建 2 个具有诸如指标冲突的名称的主题:
WARNING: Due to limitations in metric names, topics with a period ('.') or underscore ('_') could collide. To avoid issues it is best to use either, but not both.
How did you create the topics ?你是如何创建主题的?
first of all ,it's not bug.首先,这不是错误。 according to source-code of kafka-10.2 in topic part Kafka-source ,
根据主题部分Kafka-source中 kafka-10.2 的源代码,
val legalChars = "[a-zA-Z0-9\\._\\-]"
private val maxNameLength = 249
private val rgx = new Regex(legalChars + "+")
max length of your topic-name can be 249 words,and its treats dot(.) and underscore( _ ) are treated equal.That is your topic name您的主题名称的最大长度可以是 249 个单词,并且它对待点(。)和下划线( _ )是平等的。那就是您的主题名称
my.topic.test, my.topic_test, my_topic.test are same .
my.topic.test, my.topic_test, my_topic.test 是一样的。 you should either use ( _ )underscore or dot ( . ) but not both.
您应该使用( _ )下划线或点( . ),但不能同时使用。
for best practice i'll recommend you to use hyphen ( - ) like i prefer to use.为了获得最佳实践,我建议您像我喜欢使用的那样使用连字符 ( - )。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.