use of io.vertigo.commons.daemon.DaemonStat in project vertigo by KleeGroup.
the class DaemonManagerImpl method checkDaemonsExecs.
@HealthChecked(name = "lastExecs", feature = "daemons")
public HealthMeasure checkDaemonsExecs() {
final List<DaemonStat> daemonStats = getStats();
final long failureCount = daemonStats.stream().filter(// to have a real indicator we use only daemon that have been executed at least once
daemonStat -> daemonStat.getCount() > 0).filter(daemonStat -> !daemonStat.isLastExecSuccess()).count();
// ---
final HealthMeasureBuilder healthMeasure = HealthMeasure.builder();
if (failureCount == 0) {
return healthMeasure.withGreenStatus().build();
} else if (failureCount < daemonStats.size()) {
return healthMeasure.withYellowStatus("At least one daemon failed", null).build();
}
return healthMeasure.withRedStatus("All daemons failed", null).build();
}
Aggregations