Wanted to see if zookeeper or curator has any api that can return the host that it was connected to. This is mainly for debugging incase the connection was lost or session was expired we will know which host had the issue. I see CuratorZookeeperClient has a method getConnectionString() but seems like thats just returning the all the hosts in the ensemble.
The ZooKeeper
object has the protected method testableRemoteSocketAddress()
. It's meant for testing only however. You can create a subclass that adds a method to return the value. Again, for testing only.