@@ -119,7 +119,7 @@ public synchronized Multimap<String, String> findBundlesForUnloading(final LoadD
119119 }
120120 });
121121 if (selectedBundlesCache .isEmpty () && conf .isLowerBoundarySheddingEnabled ()) {
122- tryLowerBoundaryShedding (loadData , conf );
122+ tryLowerBoundaryShedding (loadData , threshold , conf );
123123 }
124124 return selectedBundlesCache ;
125125 }
@@ -182,25 +182,24 @@ private double updateAvgResourceUsage(String broker, LocalBrokerData localBroker
182182 return historyUsage ;
183183 }
184184
185- private void tryLowerBoundaryShedding (LoadData loadData , ServiceConfiguration conf ) {
185+ private void tryLowerBoundaryShedding (LoadData loadData , double threshold , ServiceConfiguration conf ) {
186186 // Select the broker with the most resource usage.
187- final double threshold = conf .getLoadBalancerBrokerThresholdShedderPercentage () / 100.0 ;
188187 final double avgUsage = getBrokerAvgUsage (loadData , conf .getLoadBalancerHistoryResourcePercentage (), conf );
189188 Pair <Boolean , String > result = getMaxUsageBroker (loadData , threshold , avgUsage );
190189 boolean hasBrokerBelowLowerBound = result .getLeft ();
191190 String maxUsageBroker = result .getRight ();
192- BrokerData brokerData = loadData .getBrokerData ().get (maxUsageBroker );
193- if (brokerData == null ) {
194- log .info ("Load data is null or bundle <=1, skipping bundle unload." );
195- return ;
196- }
197191 if (!hasBrokerBelowLowerBound ) {
198192 log .info ("No broker is below the lower bound, threshold is {}, "
199193 + "avgUsage usage is {}, max usage of Broker {} is {}" ,
200194 threshold , avgUsage , maxUsageBroker ,
201195 brokerAvgResourceUsage .getOrDefault (maxUsageBroker , 0.0 ));
202196 return ;
203197 }
198+ BrokerData brokerData = loadData .getBrokerData ().get (maxUsageBroker );
199+ if (brokerData == null ) {
200+ log .info ("Load data is null or bundle <=1, skipping bundle unload." );
201+ return ;
202+ }
204203 LocalBrokerData localData = brokerData .getLocalData ();
205204 double brokerCurrentThroughput = localData .getMsgThroughputIn () + localData .getMsgThroughputOut ();
206205 double minimumThroughputToOffload = brokerCurrentThroughput * threshold * LOWER_BOUNDARY_THRESHOLD_MARGIN ;
0 commit comments