grssam commented on code in PR #23120:
URL: https://github.com/apache/pulsar/pull/23120#discussion_r1735846636


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/ClustersBase.java:
##########
@@ -793,6 +806,44 @@ private CompletableFuture<Void> 
filterAndUnloadMatchedNamespaceAsync(String clus
             if (CollectionUtils.isEmpty(shouldUnloadNamespaces)) {
                 return CompletableFuture.completedFuture(null);
             }
+            // If unload type is 'changed', we need to figure out a further 
subset of namespaces whose placement might
+            // actually have been changed.
+
+            log.debug("Old policy: {} ; new policy: {}", oldPolicy, 
policyData);
+            if (oldPolicy != null && 
NamespaceIsolationPolicyUnloadScope.changed.equals(policyData.getUnloadScope()))
 {
+                // We also compare that the previous primary broker list is 
same as current, in case all namespaces need
+                // to be placed again anyway.
+                List<String> oldBrokers = new 
ArrayList<>(policyData.getPrimary());
+                oldBrokers.removeAll(policyData.getPrimary());
+
+                if (oldBrokers.isEmpty()) {
+                    // list is same, so we continue finding the changed 
namespaces.
+
+                    // We create a union regex list contains old + new regexes
+                    Set<String> combinedNamespaces = new 
HashSet<>(oldPolicy.getNamespaces());
+                    combinedNamespaces.addAll(policyData.getNamespaces());
+                    // We create a intersection of the old and new regexes. 
These won't need to be unloaded
+                    Set<String> commonNamespaces = new 
HashSet<>(oldPolicy.getNamespaces());
+                    commonNamespaces.retainAll(policyData.getNamespaces());
+
+                    log.debug("combined: regexes{}; common regexes:{}", 
combinedNamespaces, combinedNamespaces);

Review Comment:
   Good catch! I've updated it.



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