in myriad-scheduler/src/main/java/org/apache/myriad/health/MesosMasterHealthCheck.java [47:87]
protected Result check() throws Exception {
String mesosMaster = cfg.getMesosMaster();
int zkIndex = mesosMaster.indexOf("zk://", 0);
Result result = Result.unhealthy("Unable to connect to: " + mesosMaster);
if (zkIndex >= 0) {
final int fromIndex = 5;
String zkHostPorts = mesosMaster.substring(fromIndex, mesosMaster.indexOf("/", fromIndex));
String[] hostPorts = zkHostPorts.split(",");
for (String hostPort : hostPorts) {
final int maxRetries = 3;
final int baseSleepTimeMs = 1000;
CuratorFramework client = CuratorFrameworkFactory.newClient(hostPort, new ExponentialBackoffRetry(baseSleepTimeMs,
maxRetries));
client.start();
final int blockTime = 5;
client.blockUntilConnected(blockTime, TimeUnit.SECONDS);
switch (client.getState()) {
case STARTED:
result = Result.healthy();
break;
case STOPPED:
LOGGER.info("Unable to reach: ", hostPort);
break;
case LATENT:
LOGGER.info("Unable to reach: ", hostPort);
break;
default:
LOGGER.info("Unable to reach: ", hostPort);
}
}
} else {
if (HealthCheckUtils.checkHostPort(mesosMaster)) {
result = Result.healthy();
}
}
return result;
}