Class SimpleLoadManagerImpl

java.lang.Object
org.apache.pulsar.broker.loadbalance.impl.SimpleLoadManagerImpl
All Implemented Interfaces:
Consumer<org.apache.pulsar.metadata.api.Notification>, LoadManager

public class SimpleLoadManagerImpl extends Object implements LoadManager, Consumer<org.apache.pulsar.metadata.api.Notification>
  • Field Details

    • 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 String LOADBALANCER_DYNAMIC_SETTING_STRATEGY_ZPATH
      See Also:
    • SETTING_NAME_STRATEGY

      public static final String SETTING_NAME_STRATEGY
      See Also:
    • LOADBALANCER_STRATEGY_LLS

      public static final String LOADBALANCER_STRATEGY_LLS
      See Also:
    • LOADBALANCER_STRATEGY_RAND

      public static final String LOADBALANCER_STRATEGY_RAND
      See Also:
    • LOADBALANCER_STRATEGY_LEAST_MSG

      public static final String LOADBALANCER_STRATEGY_LEAST_MSG
      See Also:
  • Constructor Details

    • SimpleLoadManagerImpl

      public SimpleLoadManagerImpl()
    • SimpleLoadManagerImpl

      public SimpleLoadManagerImpl(PulsarService pulsar)
  • Method Details

    • 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 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:
      Exception
    • getAvailableBrokers

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

      public CompletableFuture<Set<String>> getAvailableBrokersAsync()
      Specified by:
      getAvailableBrokersAsync in interface LoadManager
    • 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 Exception
      Description copied from interface: LoadManager
      Update namespace bundle resource quota on ZK.
      Specified by:
      writeResourceQuotasToZooKeeper in interface LoadManager
      Throws:
      Exception
    • getLoadBalancingMetrics

      public 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 Optional<ResourceUnit> getLeastLoaded(org.apache.pulsar.common.naming.ServiceUnitId serviceUnit) throws 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:
      Exception
    • getResourceAvailabilityFor

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

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

      public 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()
    • generateLoadReport

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

      public void setLoadReportForceUpdateFlag()
      Description copied from interface: LoadManager
      Set flag to force load report update.
      Specified by:
      setLoadReportForceUpdateFlag in interface LoadManager
    • writeLoadReportOnZookeeper

      public void writeLoadReportOnZookeeper() throws Exception
      Description copied from interface: LoadManager
      Publish the current load report on ZK.
      Specified by:
      writeLoadReportOnZookeeper in interface LoadManager
      Throws:
      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 Exception
      Detect and split hot namespace bundles.
      Specified by:
      doNamespaceBundleSplit in interface LoadManager
      Throws:
      Exception
    • stop

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