Class LeaderElectorImp

    • Constructor Detail

      • LeaderElectorImp

        public LeaderElectorImp​(org.apache.storm.shade.org.apache.curator.framework.CuratorFramework zk,
                                String id,
                                LeaderListenerCallbackFactory leaderListenerCallbackFactory)
    • Method Detail

      • prepare

        public void prepare​(Map<String,​Object> conf)
        Description copied from interface: ILeaderElector
        Method guaranteed to be called as part of initialization of leader elector instance.
        Specified by:
        prepare in interface ILeaderElector
        Parameters:
        conf - configuration
      • addToLeaderLockQueue

        public void addToLeaderLockQueue()
                                  throws Exception
        Description copied from interface: ILeaderElector
        queue up for leadership lock. The call returns immediately and the caller must check isLeader() to perform any leadership action. This method can be called multiple times so it needs to be idempotent.
        Specified by:
        addToLeaderLockQueue in interface ILeaderElector
        Throws:
        Exception
      • quitElectionFor

        public void quitElectionFor​(int delayMs)
                             throws Exception
        Description copied from interface: ILeaderElector
        Removes the caller from leadership election, relinquishing leadership if acquired, then requeues for leadership after the specified delay.
        Specified by:
        quitElectionFor in interface ILeaderElector
        Parameters:
        delayMs - The delay to wait before re-entering the election
        Throws:
        Exception
      • isLeader

        public boolean isLeader()
                         throws Exception
        Description copied from interface: ILeaderElector
        Decide if the caller currently has the leader lock.
        Specified by:
        isLeader in interface ILeaderElector
        Returns:
        true if the caller currently has the leader lock.
        Throws:
        Exception
      • awaitLeadership

        public boolean awaitLeadership​(long timeout,
                                       TimeUnit timeUnit)
                                throws InterruptedException
        Description copied from interface: ILeaderElector
        Wait for the caller to gain leadership. This should only be used in single-Nimbus clusters, and is only useful to allow testing code to wait for a LocalCluster's Nimbus to gain leadership before trying to submit topologies.
        Specified by:
        awaitLeadership in interface ILeaderElector
        Returns:
        true is leadership was acquired, false otherwise
        Throws:
        InterruptedException
      • getLeader

        public NimbusInfo getLeader()
        Description copied from interface: ILeaderElector
        Get the current leader's address.
        Specified by:
        getLeader in interface ILeaderElector
        Returns:
        the current leader's address, may return null if no one has the lock.