Just curious to know whether there is any API to know the a particular node is leader using CuratorFramework class in Curator Framework. I am using LeaderLatch but not working even the Node is leader (Elected by Zookeeper framework).
NOTE: 3 nodes are configured in cluster set up.
Zookeeper framework will take care of electing a node. I need to know the selected Curator client is pointing to leader or not.
String zkConnString = "172.18.54.211:2181";
RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
CuratorFramework client1 = CuratorFrameworkFactory.newClient(zkConnString, retryPolicy);
client1.start();
LeaderLatch leaderLatch = new LeaderLatch(client1, "/FirstNode");
try {
leaderLatch.start();
} catch (Exception e1) {
e1.printStackTrace();
}
System.out.println("has leader ship ? "+leaderLatch.hasLeadership());
The output is
has leader ship ? false
The Use case is as follows. Micro Services are involved in the use case.

If the LEADER corresponding Micro Service went down then need to select another leader. Each Micro service can be treated as a Z-NODE. If a Z-NODE is deleted a NODEREMOVED event will be triggered and listened.
The LEADER should not be Micro Service down node.