use of de.codecentric.boot.admin.server.domain.values.StatusInfo.STATUS_UNKNOWN in project spring-boot-admin by codecentric.
the class ApplicationRegistry method getStatus.
protected Tuple2<String, Instant> getStatus(List<Instance> instances) {
// TODO: Correct is just a second readmodel for groups
Map<String, Instant> statusWithTime = instances.stream().collect(toMap((instance) -> instance.getStatusInfo().getStatus(), Instance::getStatusTimestamp, this::getMax));
if (statusWithTime.size() == 1) {
Map.Entry<String, Instant> e = statusWithTime.entrySet().iterator().next();
return Tuples.of(e.getKey(), e.getValue());
}
if (statusWithTime.containsKey(StatusInfo.STATUS_UP)) {
Instant oldestNonUp = statusWithTime.entrySet().stream().filter((e) -> !StatusInfo.STATUS_UP.equals(e.getKey())).map(Map.Entry::getValue).min(naturalOrder()).orElse(Instant.EPOCH);
Instant latest = getMax(oldestNonUp, statusWithTime.getOrDefault(StatusInfo.STATUS_UP, Instant.EPOCH));
return Tuples.of(StatusInfo.STATUS_RESTRICTED, latest);
}
return statusWithTime.entrySet().stream().min(Map.Entry.comparingByKey(StatusInfo.severity())).map((e) -> Tuples.of(e.getKey(), e.getValue())).orElse(Tuples.of(STATUS_UNKNOWN, Instant.EPOCH));
}
Aggregations