From 35297a85ee4a0d9af8a3277b5ea79ed7c67496c2 Mon Sep 17 00:00:00 2001 From: Zhiqiang He Date: Sat, 18 Apr 2015 08:49:01 -0700 Subject: [PATCH] kafka-2088; kafka-console-consumer.sh should not create zookeeper path when no brokers found and chroot was set in zookeeper.connect; patched by Zhiqiang He; reviewed by Gwen Shapira and Jun Rao --- core/src/main/scala/kafka/tools/ConsoleConsumer.scala | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/src/main/scala/kafka/tools/ConsoleConsumer.scala b/core/src/main/scala/kafka/tools/ConsoleConsumer.scala index 9d9b781986f..80b26744a79 100755 --- a/core/src/main/scala/kafka/tools/ConsoleConsumer.scala +++ b/core/src/main/scala/kafka/tools/ConsoleConsumer.scala @@ -126,6 +126,11 @@ object ConsoleConsumer extends Logging { consumerProps.put("auto.offset.reset", if(options.has(resetBeginningOpt)) "smallest" else "largest") consumerProps.put("zookeeper.connect", options.valueOf(zkConnectOpt)) + if (!checkZkPathExists(options.valueOf(zkConnectOpt),"/brokers/ids")) { + System.err.println("No brokers found.") + System.exit(1) + } + if (!options.has(deleteConsumerOffsetsOpt) && options.has(resetBeginningOpt) && checkZkPathExists(options.valueOf(zkConnectOpt),"/consumers/" + consumerProps.getProperty("group.id")+ "/offsets")) { System.err.println("Found previous offset information for this group "+consumerProps.getProperty("group.id")