lordcheng10 commented on code in PR #17797:
URL: https://github.com/apache/pulsar/pull/17797#discussion_r990748495


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceService.java:
##########
@@ -959,6 +970,34 @@ void splitAndOwnBundleOnceAndRetry(NamespaceBundle bundle,
         });
     }
 
+    /**
+     * Update new bundle-range to admin/policies/namespace.
+     * Update may fail because of concurrent write to Zookeeper.
+     *
+     * @param nsname
+     * @param nsBundles
+     * @throws Exception
+     */
+    private CompletableFuture<Void> 
updateNamespaceBundlesForPolicies(NamespaceName nsname,
+                                                                      
NamespaceBundles nsBundles) {
+        Objects.requireNonNull(nsname);
+        Objects.requireNonNull(nsBundles);
+
+        return 
pulsar.getPulsarResources().getNamespaceResources().getPoliciesAsync(nsname).thenCompose(policies
 -> {
+            if (policies.isPresent()) {
+                return 
pulsar.getPulsarResources().getNamespaceResources().setPoliciesAsync(nsname, 
oldPolicies -> {
+                    oldPolicies.bundles = nsBundles.getBundlesData();
+                    return oldPolicies;
+                });
+            } else {
+                Policies newPolicies = new Policies();

Review Comment:
   1. Policies are created when the namespace is created.
   2. Under normal circumstances, after the bundle is split, the case where the 
policies do not exist will not appear.
   <img width="1007" alt="image" 
src="https://user-images.githubusercontent.com/19296967/194743893-7315b131-3bf0-44e1-a11c-d1cef8dfe252.png";>
   



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