Scott: the right answer in this case is for the leader to watch for the "disconnected" event and shut down. If the connection re-establishes, the leader should still be the leader (their ephemeral sequential node should still be there), in which case it can go back to work. If the connection doesn't re-establish, one of two things may happen…
1) Your leader stays in the disconnected state (because it's unable to reconnect), meanwhile the zookeeper server expires the session (because it hasn't seen a heartbeat), deletes the ephemeral sequential node and a new worker is promoted to leader. 2) Your leader quickly transitions to the expired state, the ephemeral node is lost and a new worker is promoted to leader. In both cases, your initial leader should see a disconnected event first. If it shuts down when it sees that event, you should be relatively safe in thinking that you only have one worker going at a time. Once your initial leader sees the expiration event, it can try to reconnect to the ensemble, create the new ephemeral sequential node and get back into the queue for being a leader. Ryan
