heesung-sn commented on code in PR #20552:
URL: https://github.com/apache/pulsar/pull/20552#discussion_r1224999529


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/ExtensibleLoadManagerImpl.java:
##########
@@ -180,6 +183,23 @@ public class ExtensibleLoadManagerImpl implements 
ExtensibleLoadManager {
             .build();
     private final CountDownLatch initWaiter = new CountDownLatch(1);
 
+    /**
+     * Get all the bundles that are owned by this broker.
+     */
+    public Set<NamespaceBundle> getOwnedServiceUnits() {
+        var entrySet = serviceUnitStateChannel.getOwnershipEntrySet();
+        return entrySet.stream()
+                .filter(entry -> {
+                    var stateData = entry.getValue();
+                    return stateData.state() == ServiceUnitState.Owned
+                            && StringUtils.isNotBlank(stateData.dstBroker())
+                            && 
stateData.dstBroker().equals(brokerRegistry.getBrokerId());

Review Comment:
   I think so. Afaik, the local variables will be likely in the CPU registers, 
which can be faster. `brokerRegistry.getBrokerId()` will need to deference, 
which could cause page hit/miss and stack getBrokerId() and deference again. 
   
   I am not sure if the modern java compiler optimizes this code with local var 
or not.



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