I am working on a model of the ZooKeeper software for academic purposes.
Since it is only a model, I don't want to replicate every detail of the
system. However, I also want to write the model in such a way that it
can be extended to show lower-level detail without a major rewrite (that
is, I want to have the details in mind, even if I don't make use of them
In particular, right now I am working on modelling client session
management, and I was hoping someone could fill in the gaps in my
understanding. The standalone case seems straightforward: the
ZooKeeperServer creates a SessionTrackerImpl which invokes the
ZooKeeperServer's expire method to end sessions when the session has
timed out. However, I can't seem to put all the pieces together for the
distributed case. From my reading, if a client is connected directly to
the leader, his session management is handled as in the standalone case.
However, if the client is connected to a Follower, it is different. The
Followers report all of their session data to the leader, who actually
manages session expiration. Since the Leader has a SessionTrackerImpl,
eventually, the Leader's expire() method will be called to initiate
ending the session.
But the two things I can't seem to figure out are:
1) How does the Follower get notified of that session expiration so that
it can remove the client from its SessionTracker?
2) Similarly, how does the Follower know to terminate its ServerCnxn
with the client?
And a related question, which I just thought to ask:
3) Can a client's session persist indefinitely if leader election keeps
flip-flopping (its unlikely to happen I know, but I'm just curious)?
Any insight would be awesome!