I have a question regarding implementation two-phase-commit protocol in zookeeper cluster to coordinate certain transaction among multiple client connections. Right now I have the following idea:
- Coordinator
C
register transaction node/app/tx
- register processing node for each involved party
/app/tx/%d (Ni)
- set watchers on each involved party node
Ni
- notify each
Ni
about new transactiontx
Ni
checks that its node is createdNi
sets transaction to prepare()/abort()C
recieves the result from all the parties and decides abort/continue- if continue, each
Ni
executes query N
i notifiesC
with ok/failC
decides abort|commitC
notifies everybody about the result.tx
is commited
But I am not sure is it a right direction ? And I am not sure how to implement this in python kazoo or any other language (Java)? It would be nice if you can help me by providing snippet or correcting my algorithm ? In addition, how to extend this protocol for inter-zookeeper communication? Say, we maintain multiple different zookeeper clusters that are wrapped into zones or any other abstract entity and we would like to perform such explicit transactions on particular zone using two-phase commit ?
C
to do). I think that the nodes can decide for themselves if the transaction should be committed or not, since they are watching all ZK locations – Christopher Swenson