Bully algorithm in Java
The bully algorithm is a type of Election algorithm which is mainly used for choosing a coordinate. In a distributed system, we need some election algorithms such as bully and ring to get a coordinator that performs functions needed by other processes.
Election algorithms select a single process from the processes that act as coordinator. A new process is selected when the selected coordinator process crashes due to some reasons. In order to determine the position where the new copy of coordinator should be restarted, the election algorithms are used.
It assumes that each process has a unique priority number in the system, so the highest priority process will be chosen first as a new coordinator. When the current use coordinator process crashes, it elects a new process having the highest priority number. We note that priority number and pass it to each active process in the distributed system.
The Bully election algorithm is as follows:
Let's assume that P is a process that sends a message to the coordinator.
Next TopicConvert JSON File to String in Java