use of org.springframework.boot.actuate.health.Health.Builder in project sofa-boot by alipay.
the class SpringContextStartUpHealthCheckStatusCheckInfo method invoke.
@Override
public Health invoke() {
// spring
boolean springContextStatus = StartUpHealthCheckStatus.getSpringContextStatus();
// component
boolean componentStatus = StartUpHealthCheckStatus.getComponentStatus();
Map<String, Health> componentDetail = StartUpHealthCheckStatus.getComponentDetail();
// HealthIndicator
boolean healthIndicatorStatus = StartUpHealthCheckStatus.getHealthIndicatorStatus();
List<HealthIndicatorDetail> healthIndicatorDetails = StartUpHealthCheckStatus.getHealthIndicatorDetails();
// AfterHealthCheckCallback
boolean afterHealthCheckCallbackStatus = StartUpHealthCheckStatus.getAfterHealthCheckCallbackStatus();
Map<String, Health> afterHealthCheckCallbackDetails = StartUpHealthCheckStatus.getAfterHealthCheckCallbackDetails();
Map<String, Health> healths = new HashMap<String, Health>();
// spring
if (springContextStatus) {
healths.put("springContextHealthCheckInfo", Health.up().build());
} else {
healths.put("springContextHealthCheckInfo", Health.down().build());
}
// component and callback
Builder builder = null;
if (componentStatus && healthIndicatorStatus && afterHealthCheckCallbackStatus) {
builder = Health.up();
} else {
builder = Health.down();
}
if (!CollectionUtils.isEmpty(componentDetail)) {
builder = builder.withDetail("Middleware-start-period", componentDetail);
}
if (!CollectionUtils.isEmpty(afterHealthCheckCallbackDetails)) {
builder = builder.withDetail("Middleware-operation-period", afterHealthCheckCallbackDetails);
}
healths.put("sofaBootComponentHealthCheckInfo", builder.build());
// HealthIndicator
for (HealthIndicatorDetail healthIndicatorDetail : healthIndicatorDetails) {
String name = healthIndicatorDetail.getName();
Health health = healthIndicatorDetail.getHealth();
healths.put(name, health);
}
return this.healthAggregator.aggregate(healths);
}
use of org.springframework.boot.actuate.health.Health.Builder in project spring-boot by spring-projects.
the class AbstractHealthIndicator method health.
@Override
public final Health health() {
Health.Builder builder = new Health.Builder();
try {
doHealthCheck(builder);
} catch (Exception ex) {
builder.down(ex);
}
logExceptionIfPresent(builder.getException());
return builder.build();
}
use of org.springframework.boot.actuate.health.Health.Builder in project spring-cloud-netflix by spring-cloud.
the class EurekaHealthIndicator method health.
@Override
public Health health() {
Builder builder = Health.unknown();
Status status = getStatus(builder);
return builder.status(status).withDetail("applications", getApplications()).build();
}
Aggregations