1 package org.openecomp.sdc.common.util;
3 import org.apache.commons.collections.CollectionUtils;
4 import org.openecomp.sdc.common.api.HealthCheckInfo;
5 import org.slf4j.Logger;
6 import org.slf4j.LoggerFactory;
8 import java.util.ArrayList;
9 import java.util.Collection;
10 import java.util.List;
12 import static org.openecomp.sdc.common.api.HealthCheckInfo.HealthCheckStatus.DOWN;
14 public class HealthCheckUtil {
16 private static Logger log = LoggerFactory.getLogger(HealthCheckUtil.class.getName());
17 public boolean getAggregateStatus(List<HealthCheckInfo> healthCheckInfos, Collection<String> excludes) {
18 boolean status = true;
19 excludes = CollectionUtils.isEmpty(excludes) ? new ArrayList<>() : excludes;
20 for (HealthCheckInfo healthCheckInfo : healthCheckInfos) {
21 if (!excludes.contains(healthCheckInfo.getHealthCheckComponent()) && healthCheckInfo.getHealthCheckStatus().equals(DOWN)) {
22 log.debug("Component {} is reported as DOWN - Aggregated HC will be DOWN", healthCheckInfo.getHealthCheckComponent());
31 public String getAggregateDescription(List<HealthCheckInfo> healthCheckInfos, String parentDescription) {
33 StringBuilder sb = new StringBuilder();
34 healthCheckInfos.forEach(x -> {
35 if (x.getHealthCheckStatus() == DOWN) {
36 sb.append("Component ").append(x.getHealthCheckComponent()).append(" is Down, ");
40 return sb.length() > 0 ? sb.substring(0, sb.length() - 1) : "";