AmatyaAvadhanula commented on code in PR #15726: URL: https://github.com/apache/druid/pull/15726#discussion_r1512566055
########## server/src/main/java/org/apache/druid/discovery/BaseNodeRoleWatcher.java: ########## @@ -209,13 +221,59 @@ private void removeNode(DiscoveryDruidNode druidNode) } } + public void cacheInitializedTimedOut() + { + synchronized (lock) { + LOGGER.warn("Cache for node role [%s] could not be initialized before timeout.", nodeRole.getJsonName()); Review Comment: Fixed ########## server/src/main/java/org/apache/druid/discovery/BaseNodeRoleWatcher.java: ########## @@ -209,13 +221,59 @@ private void removeNode(DiscoveryDruidNode druidNode) } } + public void cacheInitializedTimedOut() + { + synchronized (lock) { + LOGGER.warn("Cache for node role [%s] could not be initialized before timeout.", nodeRole.getJsonName()); + // No need to wait on CountDownLatch, because we are holding the lock under which it could only be + // counted down. + if (cacheInitialized.getCount() == 0) { + LOGGER.warn("Cache for node watcher of role[%s] is already initialized. ignoring timeout.", nodeRole.getJsonName()); + return; + } + + // It is important to take a snapshot here as list of nodes might change by the time listeners process + // the changes. + List<DiscoveryDruidNode> currNodes = Lists.newArrayList(nodes.values()); + LOGGER.info( + "Node watcher of role [%s] is now initialized with %d nodes.", + nodeRole.getJsonName(), + currNodes.size()); + + for (DruidNodeDiscovery.Listener listener : nodeListeners) { + safeSchedule( + () -> { + listener.nodesAdded(currNodes); Review Comment: Done -- 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...@druid.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org For additional commands, e-mail: commits-h...@druid.apache.org