org.zodiac.actuate.health.checker.LivenessHealthCheckerProcessor Maven / Gradle / Ivy
package org.zodiac.actuate.health.checker;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthAggregator;
import org.springframework.boot.actuate.health.OrderedHealthAggregator;
import java.util.List;
import java.util.Map;
public class LivenessHealthCheckerProcessor extends AbstractHealthCheckerProcessor {
@SuppressWarnings("deprecation")
private HealthAggregator healthAggregator;
private List livenessHealthCheckers;
public LivenessHealthCheckerProcessor(HealthCheckerInfo healthCheckerInfo, List livenessHealthCheckers) {
super(healthCheckerInfo);
this.livenessHealthCheckers = livenessHealthCheckers;
this.healthAggregator = new OrderedHealthAggregator();
}
// @Override
// protected Health dohealthCheck() {
// Map healths = null;
// if (livenessHealthCheckers != null) {
// /*使用(key1, key2) -> key2)是避免key冲突,冲突时将前面的value 和后面的value拼接起来。*/
// healths = livenessHealthCheckers.stream().collect(Collectors.toMap(LivenessHealthChecker::getName,
// LivenessHealthChecker::isHealthy, (key1, key2) -> key2, LinkedHashMap::new));
// }
// return null != healths && healths.size() > 0 ? healthAggregator.aggregate(healths) : Health.up().build();
// }
@Override
protected Health afterHealthCheck(Map healths, boolean checkResult) {
return null != healths && healths.size() > 0 ? healthAggregator.aggregate(healths) : Health.up().build();
}
@Override
protected List getCheckers() {
return livenessHealthCheckers;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy