Reputation: 65
I'm trying to connect a KafkaSpout belonging to a storm topology running on a LocalCluster
object. I wrote this code according to the documentation I found on https://github.com/apache/storm/tree/master/external/storm-kafka.
private static final String brokerZkStr = "localhost:2181";
private static final String topic = "/test-topic-multi";
public void startTopology()
{
BrokerHosts hosts = new ZkHosts(brokerZkStr);
SpoutConfig conf = new SpoutConfig(hosts, topic, "localhost:2181", UUID
.randomUUID().toString());
KafkaSpout kafkaSput = new KafkaSpout(conf);
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("kafka-spout", kafkaSput);
Config topConfig = new Config();
topConfig.setDebug(true);
LocalCluster cluster = new LocalCluster();
cluster.submitTopology("HelloStorm", topConfig , builder.createTopology());
}
I want to use a zookeeper instance running at localhost:2181
but when a try to run the code I get the following error:
java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Invalid path string "/brokers/topics//test-topic-multi/partitions" caused by empty node name specified @16
at storm.kafka.DynamicBrokersReader.getBrokerInfo(DynamicBrokersReader.java:81)
at storm.kafka.trident.ZkBrokerReader.<init>(ZkBrokerReader.java:42)
at storm.kafka.KafkaUtils.makeBrokerReader(KafkaUtils.java:57)
at storm.kafka.KafkaSpout.open(KafkaSpout.java:87)
It seems to be just a problem of wrong settings but I can't solve it
PS Kafka configuration is the following: 1 instance of Zookeeper and 2 brokers running on localhost:9092
and localhost:9093
Upvotes: 1
Views: 2213
Reputation: 65
I think I solve it. I just messed up with the configuration code. The correct one is:
private static final String topic = "test-topic-multi";
....
SpoutConfig conf = new SpoutConfig(hosts, topic, "/" + topic, UUID
.randomUUID().toString());
Upvotes: 1
Reputation: 2647
Your kafka topic name is not valid. Why are you attempting to connect to a topic which does not exist?
sql@injection:~$ kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic /test-topic
Error while executing topic command topic name /test-topic is illegal, contains a character other than ASCII alphanumerics, '.', '_' and '-'
kafka.common.InvalidTopicException: topic name /test-topic is illegal, contains a character other than ASCII alphanumerics, '.', '_' and '-'
at kafka.common.Topic$.validate(Topic.scala:42)
at kafka.admin.AdminUtils$.createOrUpdateTopicPartitionAssignmentPathInZK(AdminUtils.scala:181)
at kafka.admin.AdminUtils$.createTopic(AdminUtils.scala:172)
at kafka.admin.TopicCommand$.createTopic(TopicCommand.scala:93)
at kafka.admin.TopicCommand$.main(TopicCommand.scala:55)
at kafka.admin.TopicCommand.main(TopicCommand.scala)
Are you really sure the front-slash belongs to the topic name?
Upvotes: 0