gaoran10 commented on code in PR #20315:
URL: https://github.com/apache/pulsar/pull/20315#discussion_r1197391067


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannelImpl.java:
##########
@@ -1140,26 +1152,69 @@ private void overrideOwnership(String serviceUnit, 
ServiceUnitStateData orphanDa
         }
     }
 
+    protected void waitForCleanups(boolean excludeSystemTopics, int 
timeoutInMillis) {
+        long started = System.currentTimeMillis();
+        while (System.currentTimeMillis() - started < timeoutInMillis) {
+            boolean cleaned = true;
+            for (var etr : tableview.entrySet()) {
+                var serviceUnit = etr.getKey();
+                var data = etr.getValue();
+
+                if (excludeSystemTopics && 
serviceUnit.startsWith(SYSTEM_NAMESPACE.toString())) {
+                    continue;
+                }
+
+                if (data.state() == Owned && 
data.dstBroker().equals(lookupServiceAddress)) {
+                    cleaned = false;
+                    break;
+                }
+            }
+            if (cleaned) {
+                try {
+                    
MILLISECONDS.sleep(OWNERSHIP_CLEAN_UP_CONVERGENCE_DELAY_IN_MILLIS);

Review Comment:
   Sorry, I'm not sure why need to sleep while all service units are all 
cleaned.



-- 
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