Reputation: 346
I am trying to understand basics of Apache zookeeper. Zookeeper server(standalone/quorum) runs on a host(s)/port(s) and like below the zookeeper client would mention the details.
The constructor that creates a ZooKeeper handle usually looks like:
ZooKeeper( String connectString, int sessionTimeout, Watcher watcher)
where: connectString Contains the hostnames and ports of the ZooKeeper servers.
The zookeeper server notifies the clients of status changes in cluster. My question is that I am not being able to figure out from tutorials that how the zookeeper server knows of IP address and port number of zookeeper client. If somebody could please provide a java snippet of zookeeper API, where this information is specified, that would be great.
Upvotes: 0
Views: 640
Reputation: 262534
zookeeper server notifies the clients of status changes in cluster.
This happens within an existing connection that the client has to the server. The server does not "reach out" to currently unconnected (potential at this point) clients. Meaning the client needs to be seeded with at least one server address that is still accurate in order to connect at all. It will then be informed about where all the others are.
Upvotes: 1