Class NodeJoinController


  • public class NodeJoinController
    extends java.lang.Object
    This class processes incoming join request (passed zia ZenDiscovery). Incoming nodes are directly added to the cluster state or are accumulated during master election.
    • Field Detail

      • BECOME_MASTER_TASK

        public static final DiscoveryNode BECOME_MASTER_TASK
        a task indicated that the current node should become master, if no current master is known
      • FINISH_ELECTION_TASK

        public static final DiscoveryNode FINISH_ELECTION_TASK
        a task that is used to signal the election is stopped and we should process pending joins. it may be use in combination with BECOME_MASTER_TASK
    • Method Detail

      • waitToBeElectedAsMaster

        public void waitToBeElectedAsMaster​(int requiredMasterJoins,
                                            TimeValue timeValue,
                                            NodeJoinController.ElectionCallback callback)
        waits for enough incoming joins from master eligible nodes to complete the master election

        You must start accumulating joins before calling this method. See startElectionContext()

        The method will return once the local node has been elected as master or some failure/timeout has happened. The exact outcome is communicated via the callback parameter, which is guaranteed to be called.

        Parameters:
        requiredMasterJoins - the number of joins from master eligible needed to complete the election
        timeValue - how long to wait before failing. a timeout is communicated via the callback's onFailure method.
        callback - the result of the election (success or failure) will be communicated by calling methods on this object
      • startElectionContext

        public void startElectionContext()
        Accumulates any future incoming join request. Pending join requests will be processed in the final steps of becoming a master or when stopElectionContext(String) is called.
      • stopElectionContext

        public void stopElectionContext​(java.lang.String reason)
        Stopped accumulating joins. All pending joins will be processed. Future joins will be processed immediately
      • handleJoinRequest

        public void handleJoinRequest​(DiscoveryNode node,
                                      MembershipAction.JoinCallback callback)
        processes or queues an incoming join request.

        Note: doesn't do any validation. This should have been done before.