kfaraz commented on code in PR #16528: URL: https://github.com/apache/druid/pull/16528#discussion_r1623499307
########## server/src/main/java/org/apache/druid/curator/discovery/CuratorDruidLeaderSelector.java: ########## @@ -215,4 +219,45 @@ public void unregisterListener() CloseableUtils.closeAndSuppressExceptions(leaderLatch.get(), e -> log.warn(e, "Failed to close LeaderLatch.")); listenerExecutor.shutdownNow(); } + + /** + * Handles connection state changes. Recreates the leader latch if connection to zookeeper is lost. + */ + private void handleConnectionStateChanged(CuratorFramework client, ConnectionState newState) + { + switch (newState) { + case SUSPENDED: + case LOST: + recreateLeaderLatch(); + break; + case RECONNECTED: + // Connection reestablished, no action needed here + break; + default: + // Do nothing for other states + break; + } + } + + private void recreateLeaderLatch() Review Comment: Please use this method in line 107 as well instead of duplicating the code there. ########## server/src/main/java/org/apache/druid/curator/discovery/CuratorDruidLeaderSelector.java: ########## @@ -215,4 +219,45 @@ public void unregisterListener() CloseableUtils.closeAndSuppressExceptions(leaderLatch.get(), e -> log.warn(e, "Failed to close LeaderLatch.")); listenerExecutor.shutdownNow(); } + + /** + * Handles connection state changes. Recreates the leader latch if connection to zookeeper is lost. + */ + private void handleConnectionStateChanged(CuratorFramework client, ConnectionState newState) + { + switch (newState) { + case SUSPENDED: + case LOST: + recreateLeaderLatch(); + break; + case RECONNECTED: + // Connection reestablished, no action needed here + break; + default: + // Do nothing for other states + break; + } + } + + private void recreateLeaderLatch() Review Comment: Please call this method from line 107 as well instead of duplicating the code there. -- 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