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.openecomp.sdc.common.log.wrappers.Logger;
7 import java.util.ArrayList;
8 import java.util.Collection;
11 import static org.openecomp.sdc.common.api.HealthCheckInfo.HealthCheckStatus.DOWN;
13 public class HealthCheckUtil {
15 private static Logger log = Logger.getLogger(HealthCheckUtil.class.getName());
16 public boolean getAggregateStatus(List<HealthCheckInfo> healthCheckInfos, Collection<String> excludes) {
17 boolean status = true;
18 excludes = CollectionUtils.isEmpty(excludes) ? new ArrayList<>() : excludes;
19 for (HealthCheckInfo healthCheckInfo : healthCheckInfos) {
20 if (!excludes.contains(healthCheckInfo.getHealthCheckComponent()) && healthCheckInfo.getHealthCheckStatus().equals(DOWN)) {
21 log.debug("Component {} is reported as DOWN - Aggregated HC will be DOWN", healthCheckInfo.getHealthCheckComponent());
30 public String getAggregateDescription(List<HealthCheckInfo> healthCheckInfos, String parentDescription) {
32 StringBuilder sb = new StringBuilder();
33 healthCheckInfos.forEach(x -> {
34 if (x.getHealthCheckStatus() == DOWN) {
35 sb.append("Component ").append(x.getHealthCheckComponent()).append(" is Down, ");
39 return sb.length() > 0 ? sb.substring(0, sb.length() - 1) : "";