nodece commented on code in PR #23253:
URL: https://github.com/apache/pulsar/pull/23253#discussion_r1753213550


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/ClustersBase.java:
##########
@@ -802,46 +803,44 @@ private CompletableFuture<Void> 
filterAndUnloadMatchedNamespaceAsync(String clus
                             .map(CompletableFuture::join)
                             .flatMap(List::stream)
                             .collect(Collectors.toList()));
-        }).thenCompose(shouldUnloadNamespaces -> {
-            if (CollectionUtils.isEmpty(shouldUnloadNamespaces)) {
+        }).thenCompose(clusterLocalNamespaces -> {
+            if (CollectionUtils.isEmpty(clusterLocalNamespaces)) {
                 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.
-                if (CollectionUtils.isEqualCollection(oldPolicy.getPrimary(), 
policyData.getPrimary())) {
-                    // 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());
+            boolean unloadAllNamespaces = false;
+            // We also compare that the previous primary broker list is same 
as current, in case all namespaces need
+            // to be placed again anyway.
+            if 
(NamespaceIsolationPolicyUnloadScope.all_matching.equals(policyData.getUnloadScope())
+                    || (oldPolicy != null
+                    && 
!CollectionUtils.isEqualCollection(oldPolicy.getPrimary(), 
policyData.getPrimary()))) {
+                unloadAllNamespaces = true;
+            }
+            // list is same, so we continue finding the changed namespaces.
 
-                    log.debug("combined regexes: {}; common regexes:{}", 
combinedNamespaces, combinedNamespaces);
+            // We create a intersection of the old and new regexes. These 
won't need to be unloaded.
+            Set<String> commonNamespaces = new 
HashSet<>(policyData.getNamespaces());
+            commonNamespaces.retainAll(oldNamespaces);
 
-                    // Find the changed regexes (new - new ∩ old). TODO for 
4.x, make this (new U old - new ∩ old)
-                    combinedNamespaces.removeAll(commonNamespaces);
+            log.debug("combined regexes: {}; common regexes:{}", 
combinedNamespaces, combinedNamespaces);

Review Comment:
   ```suggestion
               log.debug("combined regexes: {}; common regexes:{}", 
combinedNamespaces, commonNamespaces);
   ```



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