merlimat commented on code in PR #22846: URL: https://github.com/apache/pulsar/pull/22846#discussion_r1628064192
########## pulsar-broker-common/src/main/java/org/apache/pulsar/bookie/rackawareness/BookieRackAffinityMapping.java: ########## @@ -116,25 +115,32 @@ public synchronized void setConf(Configuration conf) { super.setConf(conf); MetadataStore store; try { - store = createMetadataStore(conf); - bookieMappingCache = store.getMetadataCache(BookiesRackConfiguration.class); - store.registerListener(this::handleUpdates); - racksWithHost = bookieMappingCache.get(BOOKIE_INFO_ROOT_PATH).get() - .orElseGet(BookiesRackConfiguration::new); - for (Map<String, BookieInfo> bookieMapping : racksWithHost.values()) { - for (String address : bookieMapping.keySet()) { - bookieAddressListLastTime.add(BookieId.parse(address)); - } - if (LOG.isDebugEnabled()) { - LOG.debug("BookieRackAffinityMapping init, bookieAddressListLastTime {}", - bookieAddressListLastTime); - } - } - updateRacksWithHost(racksWithHost); - watchAvailableBookies(); - } catch (InterruptedException | ExecutionException | MetadataException e) { + store = getMetadataStore(conf); + } catch (MetadataException e) { throw new RuntimeException(METADATA_STORE_INSTANCE + " failed to init BookieId list"); } + + bookieMappingCache = store.getMetadataCache(BookiesRackConfiguration.class); + store.registerListener(this::handleUpdates); + bookieMappingCache.get(BOOKIE_INFO_ROOT_PATH) Review Comment: Ok, makes sense. I think we should still change the sync call in the watcher event. It's unlikely to have a cache miss there, though it's technically possible. Without changing BK client constructor to reflect the blocking operation that happens, I think we could change the BK provider class to do the creation in background. -- 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: commits-unsubscr...@pulsar.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org