Jason918 commented on code in PR #17922:
URL: https://github.com/apache/pulsar/pull/17922#discussion_r994447189
##########
pulsar-metadata/src/main/java/org/apache/pulsar/metadata/bookkeeper/PulsarRegistrationClient.java:
##########
@@ -153,4 +212,56 @@ private static Set<BookieId>
convertToBookieAddresses(List<String> children) {
}
return newBookieAddrs;
}
+
+ @Override
+ public CompletableFuture<Versioned<BookieServiceInfo>>
getBookieServiceInfo(BookieId bookieId) {
+ // this method cannot perform blocking calls to the MetadataStore
+ // or return a CompletableFuture that is completed on the
MetadataStore main thread
+ // this is because there are a few cases in which some operations on
the main thread
+ // wait for the result. This is due to the fact that resolving the
address of a bookie
+ // is needed in many code paths.
+ Versioned<BookieServiceInfo> resultFromCache =
bookieServiceInfoCache.get(bookieId);
+ if (log.isDebugEnabled()) {
+ log.debug("getBookieServiceInfo {} -> {}", bookieId,
resultFromCache);
+ }
+ if (resultFromCache != null) {
+ return CompletableFuture.completedFuture(resultFromCache);
+ } else {
+ return FutureUtils.exception(new
BKException.BKBookieHandleNotAvailableException());
+ }
+ }
+
+ public CompletableFuture<Versioned<BookieServiceInfo>>
readBookieServiceInfoAsync(BookieId bookieId) {
+ String asWritable = bookieRegistrationPath + "/" + bookieId;
+ return bookieServiceInfoMetadataCache.get(asWritable)
Review Comment:
You refer to this `get` could be a blocking call.
My best guess is when the key is loading for the first time.
But the key call path should be like :
- org.apache.pulsar.metadata.cache.impl.MetadataCacheImpl#get
- com.github.benmanes.caffeine.cache.AsyncLoadingCache#get
- org.apache.pulsar.metadata.cache.impl.MetadataCacheImpl#readValueFromStore
and all of these should not contains any blocking operations.
##########
pulsar-metadata/src/main/java/org/apache/pulsar/metadata/bookkeeper/PulsarRegistrationClient.java:
##########
@@ -153,4 +212,56 @@ private static Set<BookieId>
convertToBookieAddresses(List<String> children) {
}
return newBookieAddrs;
}
+
+ @Override
+ public CompletableFuture<Versioned<BookieServiceInfo>>
getBookieServiceInfo(BookieId bookieId) {
Review Comment:
I am trying to get more sense from this issue, but I don't see this method
in the stack of https://github.com/apache/pulsar/issues/17913. Call you point
out the call path from metadata main thread?
--
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]