in distributed system, 5 processes, using zookeeper coordinate. need these processes run 1 one in every round. run order dynamic, known every round.
any zookeeper recipe can this? thanks
for example: round 1: 1 2 3 4 5 round 2: 3 2 4 1 5
your problem not defined:
in situation when given process fails start have kind of timeout or system halt?
do processes terminate between rounds, started external mechanism every round?
do care process termination status? if process started failed in middle of execution, should next process start?
in simplest case, when
- accept halting
- don't differentiate between successful termination , failure
- assume every process somehow started every round , knows position in current round
we use following approach (probably can simplified):
- for given round either pre-setup or make first process in round create path
/round. - the first process
- checks
getchildren('/round')returns empty list - creates ephemeral znode
/round/exec_1 - creates permanent znode
/round/start_1
- checks
- every other process number
n- gets list of
/round's children - checks if
/round/start_{n-1}exists - if yes, checks
/round/exec_{n-1}, waits deleted (using watcher) - if not, wait appear (using watcher), act if node there.
- gets list of
if answers questions above different, protocol can adjusted.
but general idea here define how indicate process go: register fact previous process has started , wait terminate.
Comments
Post a Comment