election algorithm Who wins? God knows
what is leader election problem? coordinator node/process goes down or crashes in distributed system. all process are in contention for leadership. Who wins? Election algorithm at rescue.
what is election algorithm? [static networks] Eventually there is a leader. There should be no more than one leader.
Types of election algorithm [static networks] bully algorithm ring algorithm
assumptions one process per node each process has unique id. each process has process number.
bully algorithm devised by Garcia-Molina in 1982. process P initiates election. sends ‘election’ message to all the process with higher process number. if no answer – P is ‘leader’ if answer - P work’s over and waits. sender takes over and continues till victor found.
example 2 2 1 1 2 1 e 4 5 5 a 4 5 e a 6 6 e e 6 7 7 3 3 7 3 crashed 2 1 2 1 4 5 4 5 e e L a e 6 6 7 3 7 3
ring algorithm 5 6 2 1 2 3 2 5 3 6 7 4 crashed 6 5 5
other proposed ring algo P sends election message to next neighbor Q in clockwise direction. Whichever loses becomes relay node. And the winner continues until it finds itself as its neighbor.
example 2 1 3 3 7 4 crashed 6 5 Relay processors
tree algorithm It is divided into 3 stages 1st - growing. 2nd- shrinking 3rd - leader
Example growing 10 5 e B D B D e e A A 3 e C F C F e e 2 7 B D A e e C
Continued… shrinking & leader B A(D,10) D A C F A(F,7) B D B D L(D,10) A(D,10) A A A(F,7) C F C F L(D,10)
Mobile adhoc network why different algorithm needed? constantly changing number and position of nodes. partitioning as well as merging of clusters. most valued node must be selected as leader.
Modified tree algorithm 2 new message probe – to determine if the child node is active. reply – response to probe msg.
Variables maintained at nodes Binary variable to indicate if the node is currently in election or not. Id of the parent node Binary variable to indicate whether the node has sent its parent acknowledge message. Leader of cluster. List of current neighbors List of nodes from which acknowledge message is being awaited. Computation index
Computation index present in election message it is used to identify an election. syntax: (num, id) num – number of times the node has initiated a election. id – identification number of node.
example Z B A G C H Z B A G C H <3,D> <2,B> <2,B>
example of algorithm B B C C A A G G Z H Z H
continued… B B Ldr(C) C C Ldr(C) Ldr(H) G G Z H Z H
continued… B Ldr(H) C G Z H
partitioning and merging