AnonHxy commented on code in PR #17797:
URL: https://github.com/apache/pulsar/pull/17797#discussion_r990745899
##########
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:
I wonder if we will remove the existed Policies in a race condition.
--
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]