我正在尝试连接到风暴中的远程kafka群集。我正在使用以下代码:
Broker brokerForPartition0 = new Broker("208.113.164.114:9091");
Broker brokerForPartition1 = new Broker("208.113.164.115:9092");
Broker brokerForPartition2 = new Broker("208.113.164.117:9093");
GlobalPartitionInformation partitionInfo = new GlobalPartitionInformation();
partitionInfo.addPartition(0, brokerForPartition2);//mapping from partition 0 to brokerForPartition0
partitionInfo.addPartition(1, brokerForPartition0);//mapping from partition 1 to brokerForPartition1
partitionInfo.addPartition(2, brokerForPartition1);//mapping from partition 2 to brokerForPartition2
StaticHosts hosts = new StaticHosts(partitionInfo);
SpoutConfig spoutConfig = new SpoutConfig(hosts, "newImageTest","/brokers","console-consumer-61818");
spoutConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
KafkaSpout kafkaSpout = new KafkaSpout(spoutConfig);
在spoutConfig的实例化中,我必须将zkroot和clientid作为参数。
java public SpoutConfig(BrokerHosts hosts, String topic, String zkRoot, String id);
我在哪里可以找到这两个信息?或者我应该创建它们吗?
谢谢!
答案 0 :(得分:0)
Spoutconfig是KafkaConfig的扩展,支持其他功能 具有ZooKeeper连接信息的字段以及用于控制行为的字段 特定于KafkaSpout。 Zkroot将用作root来存储你的 消费者的抵消。 id应该唯一标识您的鲸鱼嘴。
Zkroot
因此应该是某些ZNode路径,例如/some/path
,它将用于存储您提供的消费者偏移量。
id
是一些字符串,(例如一个UUID),可用于唯一标识您提到的喷口。