diff options
Diffstat (limited to 'common-app-api/src/main/java/org/openecomp/sdc/common')
8 files changed, 83 insertions, 17 deletions
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/Constants.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/Constants.java index fcde7f13ac..8e15b96e0c 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/api/Constants.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/Constants.java @@ -109,6 +109,8 @@ public interface Constants { public static final String ARTIFACT_NAME = "artifactName"; public static final String ARTIFACT_ID = "uniqueId"; public static final String REQUIRED_ARTIFACTS = "requiredArtifacts"; + public static final String ARTIFACT_HEAT_PARAMS = "heatParameters"; + public static final String ARTIFACT_ES_ID = "esId"; public static final String ABSTRACT = "abstract"; public static final String GLOBAL_SUBSTITUTION_TYPES_SERVICE_TEMPLATE = "Definitions/GlobalSubstitutionTypesServiceTemplate.yaml"; @@ -127,4 +129,15 @@ public interface Constants { public static final String SERVICE_TEMPLATE_FILE_POSTFIX = "ServiceTemplate.yaml"; public static final String SERVICE_TEMPLATES_CONTAINING_FOLDER = "Definitions/"; public static final String UNBOUNDED = "unbounded"; + + //SDC HealthCheck components + public static final String HC_COMPONENT_FE = "FE"; + public static final String HC_COMPONENT_BE = "BE"; + public static final String HC_COMPONENT_TITAN = "TITAN"; + public static final String HC_COMPONENT_CASSANDRA = "CASSANDRA"; + public static final String HC_COMPONENT_DISTRIBUTION_ENGINE = "DE"; + + //external HealthCheck components + public static final String HC_COMPONENT_ON_BOARDING = "ON_BOARDING"; + public static final String HC_COMPONENT_DCAE = "DCAE"; } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/api/HealthCheckInfo.java b/common-app-api/src/main/java/org/openecomp/sdc/common/api/HealthCheckInfo.java index 2e4f54f153..8afd2fb4c9 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/api/HealthCheckInfo.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/api/HealthCheckInfo.java @@ -27,14 +27,14 @@ import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; public class HealthCheckInfo { - - private HealthCheckComponent healthCheckComponent; + + private String healthCheckComponent; private HealthCheckStatus healthCheckStatus; private String version; private String description; private List<HealthCheckInfo> componentsInfo; - public HealthCheckInfo(HealthCheckComponent healthCheckComponent, HealthCheckStatus healthCheckStatus, + public HealthCheckInfo(String healthCheckComponent, HealthCheckStatus healthCheckStatus, String version, String description) { super(); this.healthCheckComponent = healthCheckComponent; @@ -43,7 +43,7 @@ public class HealthCheckInfo { this.description = description; } - public HealthCheckInfo(HealthCheckComponent healthCheckComponent, HealthCheckStatus healthCheckStatus, + public HealthCheckInfo(String healthCheckComponent, HealthCheckStatus healthCheckStatus, String version, String description, List<HealthCheckInfo> componentsInfo) { super(); this.healthCheckComponent = healthCheckComponent; @@ -57,7 +57,7 @@ public class HealthCheckInfo { super(); } - public HealthCheckComponent getHealthCheckComponent() { + public String getHealthCheckComponent() { return healthCheckComponent; } @@ -65,6 +65,10 @@ public class HealthCheckInfo { return healthCheckStatus; } + public void setHealthCheckStatus(HealthCheckStatus healthCheckStatus) { + this.healthCheckStatus = healthCheckStatus; + } + public List<HealthCheckInfo> getComponentsInfo() { return componentsInfo; } @@ -85,11 +89,15 @@ public class HealthCheckInfo { return description; } - public enum HealthCheckComponent { - FE, BE, TITAN, DE, ON_BOARDING, CASSANDRA, - CAS, ZU;//Amdocs components + public void setDescription(String description) { + this.description = description; } + /*public enum HealthCheckComponent { + FE, BE, TITAN, DE, ON_BOARDING, CASSANDRA, DCAE, + CAS, ZU;//Amdocs components + }*/ + public enum HealthCheckStatus { UP, DOWN, UNKNOWN; } diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorLogUtil.java b/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorLogUtil.java index 5051d8e645..950af691da 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorLogUtil.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/config/EcompErrorLogUtil.java @@ -25,9 +25,7 @@ import java.util.IllegalFormatException; import java.util.Locale; import org.apache.commons.lang3.StringUtils; -import org.openecomp.sdc.common.config.EcompErrorConfiguration.EcompAlarmSeverity; import org.openecomp.sdc.common.config.EcompErrorConfiguration.EcompErrorSeverity; -import org.openecomp.sdc.common.config.EcompErrorConfiguration.EcompErrorType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/config/generation/GenerateEcompErrorsCsv.java b/common-app-api/src/main/java/org/openecomp/sdc/common/config/generation/GenerateEcompErrorsCsv.java index 584a1d8ad1..87453dedc4 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/config/generation/GenerateEcompErrorsCsv.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/config/generation/GenerateEcompErrorsCsv.java @@ -30,9 +30,9 @@ import java.util.Date; import java.util.List; import org.openecomp.sdc.common.config.EcompErrorEnum; -import org.openecomp.sdc.common.config.EcompErrorLogUtil; import org.openecomp.sdc.common.config.EcompErrorEnum.AlarmSeverity; import org.openecomp.sdc.common.config.EcompErrorEnum.ErrorType; +import org.openecomp.sdc.common.config.EcompErrorLogUtil; public class GenerateEcompErrorsCsv { diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/listener/AppContextListener.java b/common-app-api/src/main/java/org/openecomp/sdc/common/listener/AppContextListener.java index 45976c42d1..a6965a75ac 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/listener/AppContextListener.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/listener/AppContextListener.java @@ -38,7 +38,6 @@ import org.openecomp.sdc.common.impl.ExternalConfiguration; import org.openecomp.sdc.common.impl.FSConfigurationSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.slf4j.MDC; public class AppContextListener implements ServletContextListener { diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/HealthCheckUtil.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/HealthCheckUtil.java new file mode 100644 index 0000000000..e0d5206066 --- /dev/null +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/HealthCheckUtil.java @@ -0,0 +1,42 @@ +package org.openecomp.sdc.common.util; + +import java.util.List; + +import org.openecomp.sdc.common.api.HealthCheckInfo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class HealthCheckUtil { + + private static Logger log = LoggerFactory.getLogger(HealthCheckUtil.class.getName()); + + public static boolean getAggregateStatus(List<HealthCheckInfo> healthCheckInfos) { + + boolean status = true; + + for (HealthCheckInfo healthCheckInfo : healthCheckInfos) { + if (healthCheckInfo.getHealthCheckStatus().equals(HealthCheckInfo.HealthCheckStatus.DOWN)) { + log.debug("Component {} is reported as DOWN - Aggregated HC will be DOWN", healthCheckInfo.getHealthCheckComponent()); + status = false; + break; + } + } + + return status; + } + + public static String getAggregateDescription(List<HealthCheckInfo> healthCheckInfos, String parentDescription) { + + StringBuilder sb = new StringBuilder(); + healthCheckInfos.forEach(x -> { + if (x.getHealthCheckStatus() == HealthCheckInfo.HealthCheckStatus.DOWN) { + sb.append("Component ").append(x.getHealthCheckComponent()).append(" is Down, "); + } + }); + + return sb.length() > 0 ? sb.substring(0, sb.length() - 1) : ""; + +// return description; + } + +} diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/PairUtils.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/PairUtils.java index eb6c29ce4a..d58b9a970d 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/PairUtils.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/PairUtils.java @@ -20,12 +20,12 @@ package org.openecomp.sdc.common.util; -import org.apache.commons.lang3.tuple.ImmutablePair; -import org.apache.commons.lang3.tuple.Pair; - import java.util.List; import java.util.stream.Collectors; +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.commons.lang3.tuple.Pair; + public class PairUtils { public static <L, R> List<L> leftSequence(List<ImmutablePair<L, R>> pairs) { diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/util/YamlToObjectConverter.java b/common-app-api/src/main/java/org/openecomp/sdc/common/util/YamlToObjectConverter.java index 242d74a9ca..322725b032 100644 --- a/common-app-api/src/main/java/org/openecomp/sdc/common/util/YamlToObjectConverter.java +++ b/common-app-api/src/main/java/org/openecomp/sdc/common/util/YamlToObjectConverter.java @@ -267,8 +267,14 @@ public class YamlToObjectConverter { public boolean isValidYaml(byte[] fileContents) { try { - Map<String, Object> mappedToscaTemplate = (Map<String, Object>) defaultYaml - .load(new ByteArrayInputStream(fileContents)); + + Iterable<Object> mappedToscaTemplateIt = defaultYaml.loadAll(new ByteArrayInputStream(fileContents)); + + for (Object o : mappedToscaTemplateIt) { + System.out.println("Loaded object type:" + o.getClass()); + Map<String, Object> map = (Map<String, Object>) o; + } + } catch (Exception e) { log.error("Failed to convert yaml file to object - yaml is invalid", e); return false; |