zk1931 / jzab

ZooKeeper Atomic Broadcast in Java
http://zk1931.github.io/jzab/master/
Apache License 2.0
54 stars 23 forks source link

Add sync operation. #142

Closed EasonLiao closed 10 years ago

EasonLiao commented 10 years ago

Sync is like a normal request, it will be forwarded to leader.

The leader will attach last proposed zxid of the peer who sends SYNC request and send it back to the sender. The sender of SYNC request will give it to CommitProcessor. CommitProcessor will deliver it at correct time (after the zxid attached to the SYNC message has been delivered).

EasonLiao commented 10 years ago

There're some changes to user interface.

For QuorumZab, it has one more operation :

void sync(ByteBuffer message);

For StateMachine, it has one more callback :

void deliverSync(ByteBuffer syncRequest);
fpj commented 10 years ago

Hi there! I'm sorry for being silent. It is an interesting design choice to add the sync call. This is not a typical call for the implementation of broadcast protocols like Zab, but if you have made the design choice that any of the replicas can deliver updates, then I believe you need something like sync. There is no question here, it is just an observation. :-)

EasonLiao commented 10 years ago

Hi Flavio,

We're planing to build a distributed embedded library(like distributed map, queue, lock without server process) on top of our zab implementation, it seems like "sync"(we renamed it to "flush") is needed since if we do a read after write, we want to see the result of write. It seems this requirement is common for many applications.