2

I am trying to create a kafka topic via AdminCommand using below code Source

 ZkClient zkClient = new ZkClient(kafkaHost, 10000, 10000, ZKStringSerializer$.MODULE$);
    AdminUtils.createTopic(zkClient, "pa_reliancepoc_telecom_usageevent", 10, 1, new Properties());

But getting the below exception

Exception in thread "main" org.I0Itec.zkclient.exception.ZkNoNodeException: org.apache.zookeeper.KeeperException$NoNodeException: KeeperErrorCode = NoNode for /brokers/ids
at org.I0Itec.zkclient.exception.ZkException.create(ZkException.java:47)
at org.I0Itec.zkclient.ZkClient.retryUntilConnected(ZkClient.java:685)
Community
  • 1
  • 1
Count
  • 1,395
  • 2
  • 19
  • 40

1 Answers1

1

From your exception, It says it could not able to connect zookeeper. In your code,

ZkClient zkClient = new ZkClient(kafkaHost, 10000, 10000, ZKStringSerializer$.MODULE$); 

The first argument is the zookeeper host, I don't know what you are having in the kafkaHost variable, As the name implies I think you have stored kafka host in that variable. Change the first argument by giving the zookeeper host. For example,

String zkHosts = "xxx.xxx.xx.xx:2181";
ZkClient zkClient = new ZkClient(zkHosts, 10000, 10000, ZKStringSerializer$.MODULE$); 

If you are having more then one zookeeper then give as comma separated string. For example,

String zkHosts = "xxx.xxx.xx.xx:2181,yyy.yyy.yy.yy:2181";

Jaya Ananthram
  • 3,433
  • 1
  • 22
  • 37