简体   繁体   English

我们如何使用Apache Kafka API获取主题的复制因子和保留时间

[英]How can we get Replication Factor and Retention Hours of the Topic using Apache Kafka API

How can we get Replication Factor and Retention Hours of the Topic using Apache Kafka API? 我们如何使用Apache Kafka API获取主题的复制因子和保留时间?

I am using version 0.9 and figured how to use AdminUtils to get number of paritiions. 我使用的是0.9版本,并计算了如何使用AdminUtils来获取数量。

If you are already familiar with the the AdminUtils it's not that far to go. 如果你已经熟悉了AdminUtils,那就没那么远了。 Get the config of the topic you are interest in. You'll get a map with all configuration items of this topic. 获取您感兴趣的主题的配置。您将获得包含此主题的所有配置项的地图。 At least in kafka 0.8.x the key for the retention configuration was "retention.ms". 至少在kafka 0.8.x中,保留配置的关键是“retention.ms”。 So let's try this one (Disclaimer - This is unchecked code): 所以让我们试试这个(免责声明 - 这是未经检查的代码):

val zkUtils = ZkUtils(zkConnectionString,
                      30000,
                      30000,
                      JaasUtils.isZkSecurityEnabled())
val configs = AdminUtils.fetchEntityConfig(zkUtils, ConfigType.Topic, topicName)
val retention = configs("retention.ms")

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

相关问题 有没有办法使用 Confluent.Kafka.Net 客户端查询主题的复制因子和保留时间? - Is there a way to query the replication factor and retention time for a topic using the Confluent.Kafka .Net client? 如何从 Java 代码中获取 Kafka Topic 的复制因子 - How to get Replication Factor of Kafka Topic from Java code Kafka-python 获取主题的复制因子 - Kafka-python Get replication factor for a topic 如何使用 Java API 找到主题的复制因子? - How to find replication factor of a topic using Java API? 我们如何使用 API 从 IDE 在 Kafka 中创建主题 - How Can we create a topic in Kafka from the IDE using API 在 Kafka 中,我们如何获取主题的元数据? - In Kafka, How can we get the metadata of a topic? 如果我有一个运行的 kafka 服务器,我可以拥有多少个主题的复制因子? - If I have one kafka server running How many replication factor for a Topic I can have? kafka + 如何使用 kafka cli 作为 kafka-configs 更改主题保留时间 - kafka + how to change the topic retention hours with kafka cli as kafka-configs Kafka 流:PolicyViolationException:主题复制因子必须为 3 - Kafka stream: PolicyViolationException: Topic replication factor must be 3 kafka主题分区的最大复制因子是多少 - What is the maximum replication factor for a partition of kafka topic
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM