Commit 22c7eed5 authored by Ali Saeed's avatar Ali Saeed

Update onElectedToBeLeader function to register as coordinator and store it's IP address

parent 60a0d960
...@@ -18,10 +18,17 @@ public class OnElectionAction implements OnElectionCallback { ...@@ -18,10 +18,17 @@ public class OnElectionAction implements OnElectionCallback {
} }
@Override @Override
public void onElectedToBeLeader() { public void onElectedToBeLeader() {
serviceRegistry.unregisterFromCluster(); try {
serviceRegistry.registerForUpdates(); String ipAddress = InetAddress.getLocalHost().getHostAddress();
serviceRegistry.unregisterFromCluster();
GrpcServerLauncher.start(); serviceRegistry.registerToClusterAsCoordinator(ipAddress);
serviceRegistry.registerForUpdates();
GrpcServerLauncher.start();
} catch (UnknownHostException e) {
throw new RuntimeException(e);
} catch (KeeperException | InterruptedException e) {
throw new RuntimeException(e);
}
} }
@Override @Override
public void onWorker() { public void onWorker() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment