Dear Stephen,

Its very interesting:)
I hope the following tips will give more idea about the client session 
management....

>>>>>1) How does the Follower get notified of that session expiration so that
it can remove the client from its SessionTracker?

As you know, Leader.SessionTrackerImpl will do the expiration ticks and once it 
reaches the expiry time will create 'closeSession' request and add to the 
RequestProcessor chain. Simulateneously this request will go to the Follower 
and will be same as normal 'request' processing lifecycle.

>>>>2) Similarly, how does the Follower know to terminate its ServerCnxn
with the client?
Once the 'closesession' request is ready for committing Leader will pass the 
command to the Follower and corresponding FinalRequestProcessor in the Follower 
will do the session closure.

>>>>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)?
Only Leader is having the logic to evaluate session expiry and raise 
'closesession' request. He will do the countdown after successfully becoming as 
Leader. In ZK, there is nothing like elapsed time for a client session and 
after every Leader re-election, will begin the countdown freshly. Yeah, 
unstability in the zk leadership would delay the client session expiry as no 
record of elapsed time in the system.

Example: Say client session timeout is 30secs, assume timeout has elapsed 
20secs, now there is a fluctuation and again new Leader has re-elcted. Here 
once more the countdown starts from 30secs and the client will be getting 
additional grace period to rejoin.

-Rakesh
________________________________________
From: Stephen Skeirik [skeir...@illinois.edu]
Sent: Saturday, August 04, 2012 12:40 AM
To: user@zookeeper.apache.org
Subject: ZooKeeper Client Session Management

Dear All,

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
now).

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!
Thanks,

Stephen Skeirik

Reply via email to