Class LeaderElectionService

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class LeaderElectionService
    extends java.lang.Object
    implements java.lang.AutoCloseable
    A class that provides way to elect the leader among brokers.
    • Constructor Summary

      Constructors 
      Constructor Description
      LeaderElectionService​(org.apache.pulsar.metadata.api.coordination.CoordinationService cs, java.lang.String localWebServiceAddress, java.util.function.Consumer<org.apache.pulsar.metadata.api.coordination.LeaderElectionState> listener)  
    • Constructor Detail

      • LeaderElectionService

        public LeaderElectionService​(org.apache.pulsar.metadata.api.coordination.CoordinationService cs,
                                     java.lang.String localWebServiceAddress,
                                     java.util.function.Consumer<org.apache.pulsar.metadata.api.coordination.LeaderElectionState> listener)
    • Method Detail

      • start

        public void start()
      • close

        public void close()
                   throws java.lang.Exception
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        java.lang.Exception
      • readCurrentLeader

        public java.util.concurrent.CompletableFuture<java.util.Optional<LeaderBroker>> readCurrentLeader()
      • getCurrentLeader

        public java.util.Optional<LeaderBroker> getCurrentLeader()
      • isLeader

        public boolean isLeader()