joseluisll commented on code in PR #8688:
URL: https://github.com/apache/hadoop/pull/8688#discussion_r4288047632
##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/ZKDelegationTokenSecretManager.java:
##########
@@ -386,6 +433,24 @@ private void loadFromZKCache(final boolean isTokenCache) {
LOG.info("Loaded {} cache.", cacheName);
}
+ private void awaitCacheInitialized(CountDownLatch initialized,
+ String cacheName) throws IOException {
+ try {
+ if (cacheInitTimeoutMs > 0) {
+ if (!initialized.await(cacheInitTimeoutMs, TimeUnit.MILLISECONDS)) {
+ throw new IOException("Timed out after " + cacheInitTimeoutMs
+ + " ms waiting for " + cacheName + " cache initialization");
+ }
+ } else {
+ initialized.await();
Review Comment:
**Ask:** log a WARN periodically while waiting here, for example by calling
`await(timeout)` in a loop and logging on each pass.
**Why:** if ZooKeeper becomes unreachable, startup now hangs here with
nothing in the logs.
**Optional:** add a code comment noting that in Curator 5.2.0 a failed read
during the first load still counts as done, so the latch can release with the
cache only partly loaded.
##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/ZKDelegationTokenSecretManager.java:
##########
@@ -301,9 +334,11 @@ public void startThreads() throws IOException {
}
})
.forDeletes(childData -> processKeyRemoved(childData.getPath()))
+ .forInitialized(keyCacheInitialized::countDown)
Review Comment:
**Ask (nit, optional):** add `.afterInitialized()` to both listener builders.
**Why:** without it, these listeners also process every existing node during
the first load, and `loadFromZKCache` then decodes them all again. The latch
still works with `.afterInitialized()`.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]