70 likes | 217 Views
JADE: The Bully Algorithm. Problem. Context of distributed computing Problem of leader election: leader election is the process of designating a single process as the organizer of some task distributed among several computers (nodes).
E N D
Problem • Context of distributedcomputing • Problem of leader election: • leader election is the process of designating a single process as the organizer of some task distributed among several computers (nodes). • Before the task is begun, all network nodes are unaware which node will serve as the "leader," or coordinator, of the task. • After a leader election algorithm has been run, each node recognizes a particular, unique node as the task leader. • The network nodes communicate among themselves in order to decide which of them will get into the "leader" state • Nodes can crash and resume
The Bully Algorithm • The bully algorithm is a method indistributed computing for dynamicallyselecting a coordinator by process ID number. • When a process P determines that the current coordinator is down because of message timeouts, it performs the following: • P broadcasts an election message to all other processes with higher process IDs. • If P hears from no process with a higher process ID, it wins the election and broadcasts victory. • If P hears from a process with a higher ID, P waits a certain amount of time for that process to broadcast itself as the leader. If it does not receive this message in time, it re-broadcasts the election message.
Implementation • Each node is an agent. • Each node is assigned a PID number. • Actions that each node has to perform during the evolution of the algorithm are mapped into behaviours. • Wait for messages (with a certain template) • Start election • Reply no to agents with lower PID • Query if coordinator is alive • Answer I’m alive • Behaviours interact each other putting other behaviours (even themselves) in the queue.