finalServiceManager.stopAsync().awaitStopped();
}
});
// Register this node.
final NodeService nodeService = injector.getInstance(NodeService.class);
nodeService.registerServer(serverStatus.getNodeId().toString(), configuration.isMaster(), configuration.getRestTransportUri());
if (configuration.isMaster() && !nodeService.isOnlyMaster(serverStatus.getNodeId())) {
LOG.warn("Detected another master in the cluster. Retrying in {} seconds to make sure it is not "
+ "an old stale instance.", configuration.getStaleMasterTimeout());
try {
Thread.sleep(configuration.getStaleMasterTimeout());
} catch (InterruptedException e) { /* nope */ }
if (!nodeService.isOnlyMaster(serverStatus.getNodeId())) {
// All devils here.
String what = "Detected other master node in the cluster! Starting as non-master! "
+ "This is a mis-configuration you should fix.";
LOG.warn(what);
activityWriter.write(new Activity(what, Main.class));