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: [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]