razinbouzar commented on code in PR #16528:
URL: https://github.com/apache/druid/pull/16528#discussion_r1623327565


##########
server/src/main/java/org/apache/druid/curator/discovery/CuratorDruidLeaderSelector.java:
##########
@@ -215,4 +208,37 @@ public void unregisterListener()
     CloseableUtils.closeAndSuppressExceptions(leaderLatch.get(), e -> 
log.warn(e, "Failed to close LeaderLatch."));
     listenerExecutor.shutdownNow();
   }
+
+  // Method to handle connection state changes
+  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()
+  {
+    // Close existing leader latch
+    CloseableUtils.closeAndSuppressExceptions(leaderLatch.get(), e -> 
log.warn(e, "Failed to close LeaderLatch."));
+
+    // Create and start a new leader latch
+    LeaderLatch newLeaderLatch = createNewLeaderLatchWithListener();

Review Comment:
   Re-wrote the method per feedback 
[here](https://github.com/apache/druid/pull/16528#discussion_r1622747033)



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

Reply via email to