简体   繁体   English

Kafka Streams 内部主题命名

[英]Kafka Streams Internal Topic Naming

According to the documentation ( https://docs.confluent.io/current/streams/developer-guide/manage-topics.html#internal-topics ), internal topics follow the naming convention <application.id>-<operatorName>-<suffix> .根据文档( https://docs.confluent.io/current/streams/developer-guide/manage-topics.html#internal-topics ),内部主题遵循命名约定<application.id>-<operatorName>-<suffix>

Some examples we have are:我们的一些例子是:

testapplication-KSTREAM-REDUCE-STATE-STORE-0000000008-repartition  
testapplication-KSTREAM-REDUCE-STATE-STORE-0000000027-repartition  

Does anyone know how the integer are determined?有谁知道整数是如何确定的?

Unfortunately our security requirements do not allow for us to create topics with our applications and need to be setup ahead of time.不幸的是,我们的安全要求不允许我们使用我们的应用程序创建主题,需要提前设置。 I am trying to determine if these topic names will be consistent.我正在尝试确定这些主题名称是否一致。

Usually the intermediate topic names are constructed with following convention:通常,中间主题名称按照以下约定构造:

<ApplicationId>-<operator name>-<suffix>

Suffix value can be either "changelog" or "repartition"后缀值可以是“changelog”或“repartition”

Based on the operator, it uses one of the suffix.根据运算符,它使用后缀之一。 Here is an example:下面是一个例子:

testapplication-aggregate-repartition测试应用程序聚合重新分区

testapplication-aggregate-changelog testapplication-aggregate-changelog

Have you seen these commands to set ACL for Streams internal topics.您是否看到过这些用于为 Streams 内部主题设置 ACL 的命令。 I believe they are introduced as part of Kafka v2.xx ( confluent doc )我相信它们是作为 Kafka v2.xx ( confluent doc ) 的一部分引入的

   # Allow Streams to manage its own internal topics and consumer groups:
   bin/kafka-acls ... --add --allow-principal User:team1 --operation All --resource- 
   pattern-type prefixed --topic team1-streams-app1 --group team1-streams-app1

So you just need to know the steams application.id, which is the prefix of all internal topics.所以你只需要知道steams application.id,它是所有内部主题的前缀。

I believe as you will give permission ALL, that would allow their creation as well.我相信,当你允许 ALL 时,这也将允许他们的创造。

为了回答您关于主题名称一致的问题,根据我的经验,它们在应用程序的执行之间是一致的,但是,如果您在逻辑中修改、添加或删除任何连接或减少的顺序,主题名称可能会更改.

To answer your main question about the integer, that's what I found in docs:要回答有关整数的主要问题,这就是我在文档中找到的内容:

The number is a globally incrementing number that represents the operator's order in the topology.数字是一个全局递增的数字,表示操作符在拓扑中的顺序。 The generated number is prefixed with a varying number of “0”s to create a string that is consistently 10 characters long.生成的数字以不同数量的“0”为前缀,以创建一个长度始终为 10 个字符的字符串。

This is quite important aspect of kafka streams DSL and can lead to some problems if you change a topology.这是 kafka 流 DSL 的一个非常重要的方面,如果您更改拓扑,可能会导致一些问题。 It's a good practice to name your stateful operator.命名您的有状态运算符是一个好习惯。

More information you can find in dsl-topology-naming article您可以在dsl-topology-naming文章中找到更多信息

Integers are internally generated.整数是内部生成的。

You can find it documented here:您可以在此处找到它的文档:

https://docs.confluent.io/current/streams/javadocs/index.html https://docs.confluent.io/current/streams/javadocs/index.html

Under groupBy method descriptions it says:在 groupBy 方法描述下,它说:

Because a new key is selected, an internal repartitioning topic will be created in Kafka.因为选择了一个新的key,Kafka内部会创建一个重新分区的topic。 This topic will be named "${applicationId}- XXX -repartition", where "applicationId" is user-specified in StreamsConfig via parameter APPLICATION_ID_CONFIG, "XXX" is an internally generated name , and "-repartition" is a fixed suffix.本主题将命名为“${applicationId}- XXX -repartition”,其中“applicationId”是用户通过参数APPLICATION_ID_CONFIG在StreamsConfig中指定的, “XXX”是内部生成的名称,“-repartition”是固定后缀。 You can retrieve all generated internal topic names via Topology.describe().您可以通过 Topology.describe() 检索所有生成的内部主题名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM