Pull request in reference to issue #23
Here is the original issue text:
I've run into a somewhat nasty issue with zkclient while running Kafka.
During a reconnect, the org.apache.zookeeper.ZooKeeper constructor threw an UknownHostException(https://issues.apache.org/jira/browse/ZOOKEEPER-1576). This caused Kafka(as it would any ZkClient consumer) to loose all Zookeeper connectivity silently.
As far as I can see, the zkclient consumer has no recourse in this situation. Meaning, no state change event is fired after stateChangedEvent(Expired). There does not seem to be a way for the client to tell that something has gone wrong, short of kicking off some sort of timed reconnect check on session expiration.
Would it make sense to add something to the interface that would report session re-connection errors to the consumer? Is there some way to handle this situation that I am not seeing?
a state change event for failed session establishment
If i interpret the commit correctly then in case there is a session establishment error then the client will now push a notification to all state listeners. But what happens afterwards ? Is there some re-attempt to connect or is it a dead client then ?
Also is it possible for you to add a test case!?
added a basic test for state change functionality
ZkStateChangeTest: complete state asserts. Removing stray printlns
We're seeing a problem that looks like it is related to this as well, so I would like to get this resolved one way or another asap.
Does the proposed approach work for you? The alternative would I guess be to have reconnect() itself go into a retry loop.
Hey Anatoly + Sam, sorry i somehow missed the notification for the testcase.
I've merged your pull request few minutes ago!
Could you also release a new version of zkClient so it can be packaged with the 0.8 release of Kafka?
it uploaded the 0.4 release to sonatype. Within a few hours it should be merget to public maven repos.
Let me know if everything works for you!