This code example (Github)演示了如何获取Kafka主题的元数据,其中包括有关当前偏移量的信息。
这是一个用Rust rdkafka编写的示例,它在后台使用了C++实现RDKafka。
我已经在我工作的系统上试验过这个程序。
以下是我可以访问的有关元数据的一些信息。
Topics:
Topic: [HIDDEN] Err: None
Partition: 0 Leader: 123806 Replicas: [123806, 115260, 7075] ISR: [123806, 115260, 7075] Err: None
Low watermark: 0 High watermark: 0 (difference: 0)
Partition: 1 Leader: 7075 Replicas: [7075, 123806, 123244] ISR: [7075, 123806, 123244] Err: None
Low watermark: 0 High watermark: 0 (difference: 0)
Partition: 2 Leader: 123244 Replicas: [123244, 7075, 115250] ISR: [123244, 7075, 115250] Err: None
Low watermark: 0 High watermark: 0 (difference: 0)
Partition: 3 Leader: 115250 Replicas: [115250, 123244, 123790] ISR: [115250, 123244, 123790] Err: None
Low watermark: 0 High watermark: 0 (difference: 0)
Partition: 4 Leader: 123790 Replicas: [123790, 115250, 115260] ISR: [123790, 115250, 115260] Err: None
Low watermark: 0 High watermark: 0 (difference: 0)
Partition: 5 Leader: 115260 Replicas: [115260, 123790, 123806] ISR: [115260, 123790, 123806] Err: None
Low watermark: 0 High watermark: 0 (difference: 0)
Partition: 6 Leader: 123806 Replicas: [123806, 7075, 123244] ISR: [123806, 7075, 123244] Err: None
Low watermark: 0 High watermark: 0 (difference: 0)
Partition: 7 Leader: 7075 Replicas: [7075, 123244, 115250] ISR: [7075, 123244, 115250] Err: None
Low watermark: 0 High watermark: 0 (difference: 0)
Partition: 8 Leader: 123244 Replicas: [123244, 115250, 123790] ISR: [123244, 115250, 123790] Err: None
Low watermark: 0 High watermark: 0 (difference: 0)
Partition: 9 Leader: 115250 Replicas: [115250, 123790, 115260] ISR: [115250, 123790, 115260] Err: None
Low watermark: 0 High watermark: 7 (difference: 7)
Partition: 10 Leader: 123790 Replicas: [123790, 115260, 123806] ISR: [123790, 115260, 123806] Err: None
Low watermark: 0 High watermark: 0 (difference: 0)
Partition: 11 Leader: 115260 Replicas: [115260, 123806, 7075] ISR: [115260, 123806, 7075] Err: None
Low watermark: 0 High watermark: 0 (difference: 0)
Partition: 12 Leader: 123806 Replicas: [123806, 115250, 123790] ISR: [123806, 115250, 123790] Err: None
Low watermark: 0 High watermark: 0 (difference: 0)
Partition: 13 Leader: 7075 Replicas: [7075, 123790, 115260] ISR: [7075, 123790, 115260] Err: None
Low watermark: 0 High watermark: 0 (difference: 0)
Total message count: 7
此特定主题的复制因子配置为3。
但是,上表中的所有“高水位线”值均为零,但值为7的1除外。
为什么会这样呢?如果复制因子为3,并且总共有14个分区,如此处所示,我希望看到所有分区都同步,因此它们都具有高水位线值7,或3个分区同步(复制数量),因此3个分区具有高水位线值7。
1条答案
按热度按时间slhcrj9b1#
在问这个问题的时候,我想出了答案,这让我想到了一个与上面的问题略有不同的问题。
这可能是有用的参考信息,为某人在未来。
要回答上述问题,我们必须了解这些数字的含义。为了理解这一点,一些术语:
所以,上面的数据表是有意义的。只有一个键在使用,因此只有一个分区包含所有消息,所有消息都具有相同的键。