Demogorgon314 commented on code in PR #20822:
URL: https://github.com/apache/pulsar/pull/20822#discussion_r1267722291


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/impl/ModularLoadManagerImpl.java:
##########
@@ -659,12 +660,25 @@ public synchronized void doLoadShedding() {
                     if (!shouldAntiAffinityNamespaceUnload(namespaceName, 
bundleRange, broker)) {
                         return;
                     }
+                    NamespaceBundle bundleToUnload = 
LoadManagerShared.getNamespaceBundle(pulsar, bundle);
+                    Optional<String> destBroker = 
this.selectBroker(bundleToUnload);
+                    if (!destBroker.isPresent()) {
+                        log.warn("No broker available to unload bundle {} from 
broker {}", bundle, broker);
+                        return;
+                    }
+                    if (destBroker.get().equals(broker)) {
+                        log.warn("Bundle {} destination broker {} is the same 
as the source broker {}",
+                                bundle, destBroker.get(), broker);
+                        return;
+                    }
 
-                    log.info("[{}] Unloading bundle: {} from broker {}",
-                            strategy.getClass().getSimpleName(), bundle, 
broker);
+                    log.info("[{}] Unloading bundle: {} from broker {} to dest 
broker {}",
+                            strategy.getClass().getSimpleName(), bundle, 
broker, destBroker.get());
                     try {
-                        
pulsar.getAdminClient().namespaces().unloadNamespaceBundle(namespaceName, 
bundleRange);
+                        pulsar.getAdminClient().namespaces()
+                                .unloadNamespaceBundle(namespaceName, 
bundleRange, destBroker.get());

Review Comment:
   When we have many brokers, it still has a chance to select the same broker 
if we don't pass the `destBroker ` parameter. I wonder if this is acceptable.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to