Class ELECTION

java.lang.Object
org.jgroups.stack.Protocol
org.jgroups.protocols.raft.election.BaseElection
org.jgroups.protocols.raft.ELECTION
All Implemented Interfaces:
org.jgroups.Lifecycle

public class ELECTION extends BaseElection
The default leader election algorithm.

Performs leader election. This implementation takes full advantage of JGroup's membership events with View. When the current node is the view coordinator, it starts a voting thread to ask all members to send their information. The voting thread stops when a new leader is elected.

The process that starts the voting thread is not trying to elect itself. The process running the voting process increases its term and asks all nodes about their term and log index information to select the new leader, in the form of VoteResponse. For safety reasons, only the nodes with the most up-to-date log can be elected a leader. With a response from the majority processes, the leader with the higher term and log index is elected. The oldest process (view coordinator) in the system has a priority. Once decided, the process sends a message reliably to everyone identifying the new leader, with the LeaderElected message.

After a leader is elected, a new election round starts on view changes only if the leader left the cluster. In case of losing a majority, the leader steps down.

This implementation is more robust than building with heartbeats, leading to fewer disruptions in the cluster with unnecessary (competing) election rounds. This also means the leader is capable of stepping down. Referred to in ยง6.2 of Ongaro's dissertation to prevent stale leadership information.

More information is available in the design docs.

Since:
0.1
Author:
Bela Ban
See Also:
  • Field Details

  • Constructor Details

    • ELECTION

      public ELECTION()
  • Method Details

    • handleView

      protected void handleView(org.jgroups.View v)
      Specified by:
      handleView in class BaseElection