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 {
}
@Override
public void onElectedToBeLeader() {
try {
String ipAddress = InetAddress.getLocalHost().getHostAddress();
serviceRegistry.unregisterFromCluster();
serviceRegistry.registerToClusterAsCoordinator(ipAddress);
serviceRegistry.registerForUpdates();
GrpcServerLauncher.start();
} catch (UnknownHostException e) {
throw new RuntimeException(e);
} catch (KeeperException | InterruptedException e) {
throw new RuntimeException(e);
}
}
@Override
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