zhaijack commented on a change in pull request #1488: Load manager should 
offload multiple bundles when overloaded
URL: https://github.com/apache/incubator-pulsar/pull/1488#discussion_r179025858
 
 

 ##########
 File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/OverloadShedder.java
 ##########
 @@ -40,73 +44,89 @@
  * rate that has not been recently unloaded.
  */
 public class OverloadShedder implements LoadSheddingStrategy {
+
     private static final Logger log = 
LoggerFactory.getLogger(OverloadShedder.class);
-    private Map<String, String> selectedBundlesCache;
 
-    /**
-     * Create an OverloadShedder with the service configuration.
-     *
-     * @param conf
-     *            Service configuration to create from.
-     */
-    public OverloadShedder(final ServiceConfiguration conf) {
-        selectedBundlesCache = new HashMap<>();
-    }
+    private final Multimap<String, String> selectedBundlesCache = 
ArrayListMultimap.create();
+
+    private final static double ADDITIONAL_THRESHOLD_PERCENT_MARGIN = 0.05;
 
     /**
-     * Attempt to shed one bundle off every broker which is overloaded.
+     * Attempt to shed some bundles off every broker which is overloaded.
      *
      * @param loadData
      *            The load data to used to make the unloading decision.
      * @param conf
      *            The service configuration.
      * @return A map from bundles to unload to the brokers on which they are 
loaded.
      */
-    public Map<String, String> findBundlesForUnloading(final LoadData 
loadData, final ServiceConfiguration conf) {
+    public Multimap<String, String> findBundlesForUnloading(final LoadData 
loadData, final ServiceConfiguration conf) {
         selectedBundlesCache.clear();
         final double overloadThreshold = 
conf.getLoadBalancerBrokerOverloadedThresholdPercentage() / 100.0;
         final Map<String, Long> recentlyUnloadedBundles = 
loadData.getRecentlyUnloadedBundles();
 
 Review comment:
   Is it OK to avoid shed bundle, if all brokers are overload here?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to