Class SimpleLoadManagerImpl

  • All Implemented Interfaces:
    java.util.function.Consumer<org.apache.pulsar.metadata.api.Notification>, LoadManager

    public class SimpleLoadManagerImpl
    extends java.lang.Object
    implements LoadManager, java.util.function.Consumer<org.apache.pulsar.metadata.api.Notification>
    • Field Detail

      • RESOURCE_QUOTA_GO_UP_TIMEWINDOW

        public static final long RESOURCE_QUOTA_GO_UP_TIMEWINDOW
      • RESOURCE_QUOTA_GO_DOWN_TIMEWINDOW

        public static final long RESOURCE_QUOTA_GO_DOWN_TIMEWINDOW
      • LOADBALANCER_DYNAMIC_SETTING_STRATEGY_ZPATH

        public static final java.lang.String LOADBALANCER_DYNAMIC_SETTING_STRATEGY_ZPATH
        See Also:
        Constant Field Values
      • SETTING_NAME_STRATEGY

        public static final java.lang.String SETTING_NAME_STRATEGY
        See Also:
        Constant Field Values
      • LOADBALANCER_STRATEGY_LLS

        public static final java.lang.String LOADBALANCER_STRATEGY_LLS
        See Also:
        Constant Field Values
      • LOADBALANCER_STRATEGY_RAND

        public static final java.lang.String LOADBALANCER_STRATEGY_RAND
        See Also:
        Constant Field Values
      • LOADBALANCER_STRATEGY_LEAST_MSG

        public static final java.lang.String LOADBALANCER_STRATEGY_LEAST_MSG
        See Also:
        Constant Field Values
    • Constructor Detail

      • SimpleLoadManagerImpl

        public SimpleLoadManagerImpl()
      • SimpleLoadManagerImpl

        public SimpleLoadManagerImpl​(PulsarService pulsar)
    • Method Detail

      • initialize

        public void initialize​(PulsarService pulsar)
        Description copied from interface: LoadManager
        Initialize this LoadManager.
        Specified by:
        initialize in interface LoadManager
        Parameters:
        pulsar - The service to initialize this with.
      • start

        public void start()
                   throws org.apache.pulsar.broker.PulsarServerException
        Specified by:
        start in interface LoadManager
        Throws:
        org.apache.pulsar.broker.PulsarServerException
      • disableBroker

        public void disableBroker()
                           throws java.lang.Exception
        Description copied from interface: LoadManager
        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.
        Specified by:
        disableBroker in interface LoadManager
        Throws:
        java.lang.Exception
      • getAvailableBrokers

        public java.util.Set<java.lang.String> getAvailableBrokers()
                                                            throws java.lang.Exception
        Description copied from interface: LoadManager
        Get list of available brokers in cluster.
        Specified by:
        getAvailableBrokers in interface LoadManager
        Returns:
        Throws:
        java.lang.Exception
      • isCentralized

        public boolean isCentralized()
        Description copied from interface: LoadManager
        Is centralized decision making to assign a new bundle.
        Specified by:
        isCentralized in interface LoadManager
      • writeResourceQuotasToZooKeeper

        public void writeResourceQuotasToZooKeeper()
                                            throws java.lang.Exception
        Description copied from interface: LoadManager
        Update namespace bundle resource quota on ZK.
        Specified by:
        writeResourceQuotasToZooKeeper in interface LoadManager
        Throws:
        java.lang.Exception
      • getLoadBalancingMetrics

        public java.util.List<org.apache.pulsar.common.stats.Metrics> getLoadBalancingMetrics()
        Description copied from interface: LoadManager
        Generate load balancing stats metrics.
        Specified by:
        getLoadBalancingMetrics in interface LoadManager
      • getLeastLoaded

        public java.util.Optional<ResourceUnit> getLeastLoaded​(org.apache.pulsar.common.naming.ServiceUnitId serviceUnit)
                                                        throws java.lang.Exception
        Description copied from interface: LoadManager
        Returns the Least Loaded Resource Unit decided by some algorithm or criteria which is implementation specific.
        Specified by:
        getLeastLoaded in interface LoadManager
        Throws:
        java.lang.Exception
      • getResourceAvailabilityFor

        public com.google.common.collect.Multimap<java.lang.Long,​ResourceUnit> getResourceAvailabilityFor​(org.apache.pulsar.common.naming.ServiceUnitId serviceUnitId)
                                                                                                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • accept

        public void accept​(org.apache.pulsar.metadata.api.Notification n)
        Specified by:
        accept in interface java.util.function.Consumer<org.apache.pulsar.metadata.api.Notification>
      • getUpdateRankingHandle

        public java.util.concurrent.Future<?> getUpdateRankingHandle()
      • isAboveLoadLevel

        public static boolean isAboveLoadLevel​(org.apache.pulsar.policies.data.loadbalancer.SystemResourceUsage usage,
                                               float thresholdPercentage)
      • isBelowLoadLevel

        public static boolean isBelowLoadLevel​(org.apache.pulsar.policies.data.loadbalancer.SystemResourceUsage usage,
                                               float thresholdPercentage)
      • getSystemResourceUsage

        public org.apache.pulsar.policies.data.loadbalancer.SystemResourceUsage getSystemResourceUsage()
                                                                                                throws java.io.IOException
        Throws:
        java.io.IOException
      • generateLoadReport

        public org.apache.pulsar.policies.data.loadbalancer.LoadReport generateLoadReport()
                                                                                   throws java.lang.Exception
        Description copied from interface: LoadManager
        Generate the load report.
        Specified by:
        generateLoadReport in interface LoadManager
        Throws:
        java.lang.Exception
      • writeLoadReportOnZookeeper

        public void writeLoadReportOnZookeeper()
                                        throws java.lang.Exception
        Description copied from interface: LoadManager
        Publish the current load report on ZK.
        Specified by:
        writeLoadReportOnZookeeper in interface LoadManager
        Throws:
        java.lang.Exception
      • doLoadShedding

        public void doLoadShedding()
        Description copied from interface: LoadManager
        Unload a candidate service unit to balance the load.
        Specified by:
        doLoadShedding in interface LoadManager
      • doNamespaceBundleSplit

        public void doNamespaceBundleSplit()
                                    throws java.lang.Exception
        Detect and split hot namespace bundles.
        Specified by:
        doNamespaceBundleSplit in interface LoadManager
        Throws:
        java.lang.Exception
      • stop

        public void stop()
                  throws org.apache.pulsar.broker.PulsarServerException
        Specified by:
        stop in interface LoadManager
        Throws:
        org.apache.pulsar.broker.PulsarServerException