Class LeaderChecker


  • public class LeaderChecker
    extends java.lang.Object
    The LeaderChecker is responsible for allowing followers to check that the currently elected leader is still connected and healthy. We are fairly lenient, possibly allowing multiple checks to fail before considering the leader to be faulty, to allow for the leader to temporarily stand down on occasion, e.g. if it needs to move to a higher term. On deciding that the leader has failed a follower will become a candidate and attempt to become a leader itself.
    • Field Detail

      • LEADER_CHECK_ACTION_NAME

        public static final java.lang.String LEADER_CHECK_ACTION_NAME
        See Also:
        Constant Field Values
      • LEADER_CHECK_INTERVAL_SETTING

        public static final Setting<TimeValue> LEADER_CHECK_INTERVAL_SETTING
      • LEADER_CHECK_TIMEOUT_SETTING

        public static final Setting<TimeValue> LEADER_CHECK_TIMEOUT_SETTING
      • LEADER_CHECK_RETRY_COUNT_SETTING

        public static final Setting<java.lang.Integer> LEADER_CHECK_RETRY_COUNT_SETTING
    • Constructor Detail

      • LeaderChecker

        public LeaderChecker​(Settings settings,
                             TransportService transportService,
                             java.lang.Runnable onLeaderFailure)
    • Method Detail

      • updateLeader

        public void updateLeader​(@Nullable
                                 DiscoveryNode leader)
        Starts and / or stops a leader checker for the given leader. Should only be called after successfully joining this leader.
        Parameters:
        leader - the node to be checked as leader, or null if checks should be disabled
      • setCurrentNodes

        public void setCurrentNodes​(DiscoveryNodes discoveryNodes)
        Update the "known" discovery nodes. Should be called on the leader before a new cluster state is published to reflect the new publication targets, and also called if a leader becomes a non-leader. TODO if heartbeats can make nodes become followers then this needs to be called before a heartbeat is sent to a new node too.

        isLocalNodeElectedMaster() should reflect whether this node is a leader, and nodeExists() should indicate whether nodes are known publication targets or not.