Caused by: org.I0Itec.zkclient.exception.ZkTimeoutException: Unable to connect to zookeeper server within timeout: 6000
源代码
public class TestConsumer {
public static void main(String[] args) {
Properties prop = new Properties();
prop.setProperty("zookeeper.connect", "s101:2181");
prop.setProperty("group.id", "xxx");
ConsumerConfig consumerProp = new ConsumerConfig(prop);
ConsumerConnector conn = Consumer.createJavaConsumerConnector(consumerProp);
//得到连接后,开始抓取数据
HashMap<String, Integer> map = new HashMap<String, Integer>();
map.put("t1", 1);
Map<String, List<KafkaStream<byte[], byte[]>>> streams = conn.createMessageStreams(map);
List<KafkaStream<byte[], byte[]>> streamList = streams.get("t1");
for ( KafkaStream<byte[], byte[]&