Class ThresholdShedder

java.lang.Object
org.apache.pulsar.broker.loadbalance.impl.ThresholdShedder
All Implemented Interfaces:
LoadSheddingStrategy

public class ThresholdShedder extends Object implements LoadSheddingStrategy
Load shedding strategy that unloads any broker that exceeds the average resource utilization of all brokers by a configured threshold. As a consequence, this strategy tends to distribute load among all brokers. It does this by first computing the average resource usage per broker for the whole cluster. The resource usage for each broker is calculated using the following method: LocalBrokerData.getMaxResourceUsageWithWeight(double, double, double, double, double). The weights for each resource are configurable. Historical observations are included in the running average based on the broker's setting for loadBalancerHistoryResourcePercentage. Once the average resource usage is calculated, a broker's current/historical usage is compared to the average broker usage. If a broker's usage is greater than the average usage per broker plus the loadBalancerBrokerThresholdShedderPercentage, this load shedder proposes removing enough bundles to bring the unloaded broker 5% below the current average broker usage. Note that recently unloaded bundles are not unloaded again.
  • Constructor Details

    • ThresholdShedder

      public ThresholdShedder()
  • Method Details

    • findBundlesForUnloading

      public com.google.common.collect.Multimap<String,String> findBundlesForUnloading(LoadData loadData, org.apache.pulsar.broker.ServiceConfiguration conf)
      Description copied from interface: LoadSheddingStrategy
      Recommend that all of the returned bundles be unloaded.
      Specified by:
      findBundlesForUnloading in interface LoadSheddingStrategy
      Parameters:
      loadData - The load data to used to make the unloading decision.
      conf - The service configuration.
      Returns:
      A map from all selected bundles to the brokers on which they reside.
    • onActiveBrokersChange

      public void onActiveBrokersChange(Set<String> newBrokers)
      Description copied from interface: LoadSheddingStrategy
      Triggered when active broker changes.
      Specified by:
      onActiveBrokersChange in interface LoadSheddingStrategy
      Parameters:
      newBrokers - active Brokers