Interface LoadManager

  • All Known Implementing Classes:
    ModularLoadManagerWrapper, NoopLoadManager, SimpleLoadManagerImpl

    public interface LoadManager
    LoadManager runs through set of load reports collected from different brokers and generates a recommendation of namespace/ServiceUnit placement on machines/ResourceUnit. Each Concrete Load Manager will use different algorithms to generate this mapping. Concrete Load Manager is also return the least loaded broker that should own the new namespace.
    • Field Detail

      • LOG

        static final org.slf4j.Logger LOG
      • LOADBALANCE_BROKERS_ROOT

        static final java.lang.String LOADBALANCE_BROKERS_ROOT
        See Also:
        Constant Field Values
    • Method Detail

      • start

        void start()
            throws org.apache.pulsar.broker.PulsarServerException
        Throws:
        org.apache.pulsar.broker.PulsarServerException
      • isCentralized

        boolean isCentralized()
        Is centralized decision making to assign a new bundle.
      • getLeastLoaded

        java.util.Optional<ResourceUnit> getLeastLoaded​(org.apache.pulsar.common.naming.ServiceUnitId su)
                                                 throws java.lang.Exception
        Returns the Least Loaded Resource Unit decided by some algorithm or criteria which is implementation specific.
        Throws:
        java.lang.Exception
      • generateLoadReport

        org.apache.pulsar.policies.data.loadbalancer.LoadManagerReport generateLoadReport()
                                                                                   throws java.lang.Exception
        Generate the load report.
        Throws:
        java.lang.Exception
      • setLoadReportForceUpdateFlag

        void setLoadReportForceUpdateFlag()
        Set flag to force load report update.
      • writeLoadReportOnZookeeper

        void writeLoadReportOnZookeeper()
                                 throws java.lang.Exception
        Publish the current load report on ZK.
        Throws:
        java.lang.Exception
      • writeLoadReportOnZookeeper

        default void writeLoadReportOnZookeeper​(boolean force)
                                         throws java.lang.Exception
        Publish the current load report on ZK, forced or not. By default rely on method writeLoadReportOnZookeeper().
        Throws:
        java.lang.Exception
      • writeResourceQuotasToZooKeeper

        void writeResourceQuotasToZooKeeper()
                                     throws java.lang.Exception
        Update namespace bundle resource quota on ZK.
        Throws:
        java.lang.Exception
      • getLoadBalancingMetrics

        java.util.List<org.apache.pulsar.common.stats.Metrics> getLoadBalancingMetrics()
        Generate load balancing stats metrics.
      • doLoadShedding

        void doLoadShedding()
        Unload a candidate service unit to balance the load.
      • doNamespaceBundleSplit

        void doNamespaceBundleSplit()
                             throws java.lang.Exception
        Namespace bundle split.
        Throws:
        java.lang.Exception
      • disableBroker

        void disableBroker()
                    throws java.lang.Exception
        Removes visibility of current broker from loadbalancer list so, other brokers can't redirect any request to this broker and this broker won't accept new connection requests.
        Throws:
        java.lang.Exception
      • getAvailableBrokers

        java.util.Set<java.lang.String> getAvailableBrokers()
                                                     throws java.lang.Exception
        Get list of available brokers in cluster.
        Returns:
        Throws:
        java.lang.Exception
      • stop

        void stop()
           throws org.apache.pulsar.broker.PulsarServerException
        Throws:
        org.apache.pulsar.broker.PulsarServerException
      • initialize

        void initialize​(PulsarService pulsar)
        Initialize this LoadManager.
        Parameters:
        pulsar - The service to initialize this with.