use of com.alipay.sofa.healthcheck.startup.SofaBootApplicationAfterHealthCheckCallback in project sofa-boot by alipay.
the class AfterHealthCheckCallbackProcessor method doApplicationAfterHealthCheckCallback.
/**
* process application afterHealthCheckCallback
* @return
*/
private boolean doApplicationAfterHealthCheckCallback() {
boolean result = true;
logger.info("Begin ApplicationAfterHealthCheckCallback startup health check");
List<SofaBootApplicationAfterHealthCheckCallback> afterHealthCheckCallbacks = HealthCheckManager.getApplicationAfterHealthCheckCallbacks();
for (SofaBootApplicationAfterHealthCheckCallback afterHealthCheckCallback : afterHealthCheckCallbacks) {
try {
Health health = afterHealthCheckCallback.onHealthy(HealthCheckManager.getApplicationContext());
Status status = health.getStatus();
if (!status.equals(Status.UP)) {
result = false;
logger.error("sofaboot application afterHealthCheck callback(" + afterHealthCheckCallback.getClass() + ") failed, the details is: " + JSON.toJSONString(health.getDetails()));
} else {
logger.info("sofaboot application afterHealthCheck callback(" + afterHealthCheckCallback.getClass() + ") ]success.");
}
StartUpHealthCheckStatus.putAfterHealthCheckCallbackDetail(getKey(afterHealthCheckCallback.getClass().getName()), health);
} catch (Throwable t) {
result = false;
logger.error("Invoking ApplicationAfterHealthCheckCallback " + afterHealthCheckCallback.getClass().getName() + " got an exception.", t);
}
}
if (result) {
logger.info("ApplicationAfterHealthCheckCallback startup health check result: success.");
} else {
logger.error("ApplicationAfterHealthCheckCallback startup health check result: failed.");
}
return result;
}
Aggregations