On Jun 6, 2008, at 17:42 , Benjamin Reed wrote: > No. Internally we use an atomic broadcast protocol (which is what > Paxos would provide us) to keep the replicas in sync, but the > protocol is much simpler than Paxos.
After reading QuorumPeer, I think it is safe to say that Zookeeper implements Paxos. The mapping between your code and Lamport's terminology: Zookeeper -> Lamport (Paxos) Notification (FastLeaderElection.java) -> Prepare request NEWLEADER (Leader.java) -> Accept message (zxid, leader id) -> "proposal number" It seems more or less equivalent to me, and there are no obvious problems with it that I can find. Unrelated observations from browsing the source: 1. syncLimit has slightly different comments in the class header, and inline with the variable. 2. ResponderThread: It reads "state" from the enclosing class. This variable is not volatile. My weak understanding of the Java memory model is that without doing a "synchronizing operation," the JVM would be free to optimize away the access of this "state" variable. That is, the ResponderThread could get "stuck" in an old state. I could be wrong because this stuff is ridiculously hard. See the FAQ: http://www.cs.umd.edu/~pugh/java/memoryModel/jsr-133-faq.html#volatile The accesses to the currentVote volatile variable probably gives you the memory barrier guarantees you need, except when LEADING. In that case, the ResponderThread never touches another volatile, so in theory the JVM could read state once and by happy with it forever after. Will it ever actually do that? I would be surprised. However, I think you would be safer making state volatile, so ResponderThread would *definitely* see a change immediately. FastLeaderElection.java line 224: The part of the condition after && is not needed: This is the else branch of an if statement, where the condition is exactly the first part. Hence, the part after && *must* be true. FastLeaderElection.java: I think it also has accesses of a set of variables between threads with no synchronization or volatiles, such as logicalclock. Evan -- Evan Jones http://evanjones.ca/ ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Zookeeper-user mailing list Zookeeper-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/zookeeper-user