codelipenghui commented on a change in pull request #14283:
URL: https://github.com/apache/pulsar/pull/14283#discussion_r806616715
##########
File path:
pulsar-metadata/src/main/java/org/apache/pulsar/metadata/cache/impl/MetadataCacheImpl.java
##########
@@ -261,12 +261,17 @@ public void invalidate(String path) {
}
@Override
- public void refresh(String path) {
+ public CompletableFuture<Void> refresh(String path) {
// Refresh object of path if only it is cached before.
- if (objCache.getIfPresent(path) != null) {
- objCache.synchronous().invalidate(path);
- objCache.synchronous().refresh(path);
- }
+ CompletableFuture<Void> promise = new CompletableFuture<>();
+ this.store.getMetadataCacheScheduler().executeOrdered(path, () -> {
+ if (objCache.getIfPresent(path) != null) {
+ objCache.synchronous().invalidate(path);
+ objCache.synchronous().refresh(path);
+ }
+ promise.complete(null);
+ });
+ return promise;
Review comment:
Good point! I have run the test with this approach, it works. Thanks,
@ben-manes for the great approach.
--
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]