[英]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.