java - 定义 SpoutConfig 参数

标签 java apache-kafka apache-storm apache-zookeeper

我有一个 Storm 拓扑,其中使用 KafkaSpout

BrokerHosts zk = new ZkHosts("localhost:2181");
SpoutConfig spoutConf = new SpoutConfig(zk, "topic", "/topic", "discovery");

我想知道在 SpoutConfig 中传递的第三个和第四个参数。

  • 第三个参数是安装Zookeeper的Zookeeper根路径还是dataDir路径?

  • 第四个参数是一个ID,但我不知道为什么使用它以及我应该提供什么?

最佳答案

zkRoot和id用于构造zookeeper路径,storm在该路径下存储kafka偏移量。您可以阅读here .

The spout stores the state of the offsets its consumed in Zookeeper. The spout is parameterized with the root path to store the offsets and an id for this particular spout. So offsets for partitions will be stored in these paths, where "0", "1" are ids for the partitions:

{root path}/{id}/0
{root path}/{id}/1
{root path}/{id}/2
{root path}/{id}/3
...

关于java - 定义 SpoutConfig 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31403890/

相关文章:

Java路径zeromq设置

java - 用storm替换java库中的包

java - apache Zookeeper kafka 路径

java - Spring Boot 通过 Id 请求数据

java - 有条件地继承类

apache-kafka - Spring for Apache Kafka 中的监听器容器是什么?

java - Kafka 最佳实践 + 如何为 JVM 设置推荐设置

java - 无法从 SD 卡读取保存的对象

java - 在 java 的多线程服务器中使用 try with 资源

apache-kafka - 卡夫卡流 : "TopicAuthorizationException: Not authorized to access topics" for an internal state store