I play with the leaderboards using LeaderLatch. With a local ZooKeeper installed, I have ~ 30 seconds to select a leader when there is only one instance and almost the same time to select a new leader when the leaders decline (when I complete the process). Should this work like that, and can I speed it up?
I am using the following code:
CuratorFramework curator = CuratorFrameworkFactory.newClient("127.0.0.1", new ExponentialBackoffRetry(100, 3)); curator.start(); LeaderLatch leaderLatch = new LeaderLatch(curator, "/test/t"); leaderLatch.addListener(new LeaderLatchListener() { @Override public void isLeader() { System.out.println("Leader"); } @Override public void notLeader() { } }); leaderLatch.start();
source share