Hi,
I am using zookeeper 3.4.6.
I have created A records "test-zookeeper.domain.name" with 2 ips behinds.
One has the zookeeper running, the other not.
21 Jul 2016 01:12:24,616 [WARN] (main-SendThread)
org.apache.zookeeper.ClientCnxn: Session 0x0 for server null, unexpected
error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at
org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1141)
21 Jul 2016 01:12:24,724 [ERROR] (main) KafkaProducerConfig: Failed to get
data from zookeeper, as KeeperErrorCode = ConnectionLoss for /brokers/ids
My code:
ZooKeeper zk = new ZooKeeper("test-zookeeper.domain.name:2181", 60000,
null); //zookeeper will close the session after 60s
List<String> ids = zk.getChildren("/brokers/ids", false);
=====Some debug I have already done===
ConnectStringParser connectStringParser = new ConnectStringParser("
test-zookeeper.domain.name:2181");
Collection<InetSocketAddress> serverAddresses =
connectStringParser.getServerAddresses();
StaticHostProvider test = new StaticHostProvider(serverAddresses);
LOG.info(test.size()); //the result is 2
--
Thanks,
Lishi