congbobo184 opened a new pull request #8111:
URL: https://github.com/apache/pulsar/pull/8111


   this PR also solve #8071 , we don't add the incorrect bundle data int the 
server own cache
   
   ### Motivation
   modify the get ownership logic to support getOwnerAsync twice can get the 
same result.
   
   
   ### Modifications
   
   ```
   org.apache.pulsar.broker.namespace.OwnershipCache;
   
       private CompletableFuture<Optional<Map.Entry<NamespaceEphemeralData, 
Stat>>> resolveOwnership(String path) {
           return 
ownershipReadOnlyCache.getWithStatAsync(path).thenApply(optionalOwnerDataWithStat
 -> {
               if (optionalOwnerDataWithStat.isPresent()) {
                   Map.Entry<NamespaceEphemeralData, Stat> ownerDataWithStat = 
optionalOwnerDataWithStat.get();
                   Stat stat = ownerDataWithStat.getValue();
                   if (stat.getEphemeralOwner() == 
localZkCache.getZooKeeper().getSessionId()) {
                       LOG.info("Successfully reestablish ownership of {}", 
path);
                       OwnedBundle ownedBundle = new 
OwnedBundle(ServiceUnitZkUtils.suBundleFromPath(path, bundleFactory));
                       if 
(selfOwnerInfo.getNativeUrl().equals(ownerDataWithStat.getKey().getNativeUrl()))
 {
                           ownedBundlesCache.put(path, 
CompletableFuture.completedFuture(ownedBundle));
                       }
                       ownershipReadOnlyCache.invalidate(path);
                       
namespaceService.onNamespaceBundleOwned(ownedBundle.getNamespaceBundle());
                   }
               }
               return optionalOwnerDataWithStat;
           });
       }
   
   ```
   
   ### Verifying this change
   
   add the test for it.
   
   ### Does this pull request potentially affect one of the following parts:
   
   *If `yes` was chosen, please highlight the changes*
   
     - Dependencies (does it add or upgrade a dependency): (no)
     - The public API: (no)
     - The schema: (no)
     - The default values of configurations: (no)
     - The wire protocol: (no)
     - The rest endpoints: (no)
     - The admin cli options: (no)
     - Anything that affects deployment: (no)
   
   ### Documentation
   
     - Does this pull request introduce a new feature? (no)
     - If yes, how is the feature documented? (not applicable / docs / JavaDocs 
/ not documented)
     - If a feature is not applicable for documentation, explain why?
     - If a feature is not documented yet in this PR, please create a followup 
issue for adding the documentation
   


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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to