summaryrefslogtreecommitdiffstats
path: root/engine-d/src/main/java/org/onap
diff options
context:
space:
mode:
authorVenkata Molluru <venkatamuralimohanreddy.molluru@techmahindra.com>2021-10-30 08:51:05 +0000
committerGuangrong Fu <fu.guangrong@zte.com.cn>2021-11-08 18:04:23 +0800
commit97afdabeb7d1f2095f3fa170f0f78fb366c91644 (patch)
tree8111cce85b33f877663acc5e8b7ab2b0dee6b576 /engine-d/src/main/java/org/onap
parent553c09f2e8691b6d1301470538c3a00571894356 (diff)
Add support to 7.1 VES data-stream in-parallel to 5.4
Issue-ID: HOLMES-308 Signed-off-by: Venkata Molluru <venkatamuralimohanreddy.molluru@techmahindra.com> Change-Id: I2a45548659e63171d80fdaab85318f0890b94345
Diffstat (limited to 'engine-d/src/main/java/org/onap')
-rw-r--r--engine-d/src/main/java/org/onap/holmes/dsa/dmaappolling/DMaaPResponseUtil.java38
-rw-r--r--engine-d/src/main/java/org/onap/holmes/engine/db/AlarmInfoDao.java2
2 files changed, 34 insertions, 6 deletions
diff --git a/engine-d/src/main/java/org/onap/holmes/dsa/dmaappolling/DMaaPResponseUtil.java b/engine-d/src/main/java/org/onap/holmes/dsa/dmaappolling/DMaaPResponseUtil.java
index e7d6669..394dc08 100644
--- a/engine-d/src/main/java/org/onap/holmes/dsa/dmaappolling/DMaaPResponseUtil.java
+++ b/engine-d/src/main/java/org/onap/holmes/dsa/dmaappolling/DMaaPResponseUtil.java
@@ -18,10 +18,14 @@ package org.onap.holmes.dsa.dmaappolling;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.jvnet.hk2.annotations.Service;
-import org.onap.holmes.common.api.stat.AlarmAdditionalField;
import org.onap.holmes.common.api.stat.VesAlarm;
+import org.onap.holmes.common.api.stat.AlarmAdditionalField;
+import com.google.gson.Gson;
+import java.util.Map;
+import java.util.TimeZone;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import static org.onap.holmes.common.utils.GsonUtil.*;
@@ -52,7 +56,9 @@ public class DMaaPResponseUtil {
vesAlarm.setEventName(getAsString(commonEventHeaderJson, "eventName"));
vesAlarm.setAlarmIsCleared(vesAlarm.getEventName().endsWith("Cleared") ? 1 : 0);
vesAlarm.setEventType(getAsString(commonEventHeaderJson, "eventType"));
- vesAlarm.setInternalHeaderFields(getAsString(commonEventHeaderJson, "internalHeaderFields"));
+ if (commonEventHeaderJson.has("internalHeaderFields")) {
+ vesAlarm.setInternalHeaderFields(commonEventHeaderJson.getAsJsonObject("internalHeaderFields").toString());
+ }
vesAlarm.setLastEpochMicrosec(getAsLong(commonEventHeaderJson, "lastEpochMicrosec"));
vesAlarm.setNfcNamingCode(getAsString(commonEventHeaderJson, "nfcNamingCode"));
vesAlarm.setNfNamingCode(getAsString(commonEventHeaderJson, "nfNamingCode"));
@@ -63,19 +69,41 @@ public class DMaaPResponseUtil {
vesAlarm.setSourceId(getAsString(commonEventHeaderJson, "sourceId"));
vesAlarm.setSourceName(getAsString(commonEventHeaderJson, "sourceName"));
vesAlarm.setStartEpochMicrosec(getAsLong(commonEventHeaderJson, "startEpochMicrosec"));
- vesAlarm.setVersion(getAsLong(commonEventHeaderJson, "version"));
+ vesAlarm.setVersion(getAsString(commonEventHeaderJson, "version"));
+ vesAlarm.setNfVendorName(getAsString(commonEventHeaderJson, "nfVendorName"));
+ if (commonEventHeaderJson.has("timeZoneOffset")) {
+ TimeZone timeZone = TimeZone.getTimeZone(getAsString(commonEventHeaderJson, "timeZoneOffset"));
+ vesAlarm.setTimeZoneOffset(timeZone);
+ }
+ if (commonEventHeaderJson.has("vesEventListenerVersion")) {
+ vesAlarm.setVesEventListenerVersion(getAsString(commonEventHeaderJson, "vesEventListenerVersion"));
+ }
}
private void convertFaultFieldsJsonToEvent(JsonObject faultFieldsJson, VesAlarm vesAlarm) {
- vesAlarm.setAlarmAdditionalInformation(getListElementByNode(faultFieldsJson, "alarmAdditionalInformation"));
vesAlarm.setAlarmCondition(getAsString(faultFieldsJson, "alarmCondition"));
vesAlarm.setAlarmInterfaceA(getAsString(faultFieldsJson, "alarmInterfaceA"));
vesAlarm.setEventCategory(getAsString(faultFieldsJson, "eventCategory"));
vesAlarm.setEventSeverity(getAsString(faultFieldsJson, "eventSeverity"));
vesAlarm.setEventSourceType(getAsString(faultFieldsJson, "eventSourceType"));
- vesAlarm.setFaultFieldsVersion(getAsLong(faultFieldsJson, "faultFieldsVersion"));
+ vesAlarm.setFaultFieldsVersion(getAsString(faultFieldsJson, "faultFieldsVersion"));
vesAlarm.setSpecificProblem(getAsString(faultFieldsJson, "specificProblem"));
vesAlarm.setVfStatus(getAsString(faultFieldsJson, "vfStatus"));
+ //Support VES Specificatin 5.4
+ if ("2.0".equals(vesAlarm.getFaultFieldsVersion())) {
+ List<AlarmAdditionalField> alarmAdditionalFieldList = getListElementByNode(faultFieldsJson, "alarmAdditionalInformation");
+ Map<String, String> alarmAdditionalInformation = new HashMap<String, String>();
+ for (AlarmAdditionalField field : alarmAdditionalFieldList) {
+ alarmAdditionalInformation.put(field.getName(), field.getValue());
+ }
+ vesAlarm.setAlarmAdditionalInformation(alarmAdditionalInformation);
+ } //Support VES Specification 7.1
+ else if (faultFieldsJson.has("alarmAdditionalInformation")) {
+ JsonObject alarmAddInfo = JsonParser.parseString(faultFieldsJson.get("alarmAdditionalInformation").toString()).getAsJsonObject();
+ Gson gson = new Gson();
+ Map map = gson.fromJson(alarmAddInfo, Map.class);
+ vesAlarm.setAlarmAdditionalInformation(map);
+ }
}
private List<AlarmAdditionalField> getListElementByNode(JsonObject jsonNode, String name) {
diff --git a/engine-d/src/main/java/org/onap/holmes/engine/db/AlarmInfoDao.java b/engine-d/src/main/java/org/onap/holmes/engine/db/AlarmInfoDao.java
index bab3084..83fa3f6 100644
--- a/engine-d/src/main/java/org/onap/holmes/engine/db/AlarmInfoDao.java
+++ b/engine-d/src/main/java/org/onap/holmes/engine/db/AlarmInfoDao.java
@@ -27,7 +27,7 @@ import java.util.List;
public abstract class AlarmInfoDao {
@GetGeneratedKeys
- @SqlUpdate("INSERT INTO ALARM_INFO (EVENTID,EVENTNAME,STARTEPOCHMICROSEC,SOURCEID,SOURCENAME,ALARMISCLEARED,ROOTFLAG,LASTEPOCHMICROSEC) VALUES (:eventId,:eventName,:startEpochMicroSec,:sourceId,:sourceName,:alarmIsCleared,:rootFlag,:lastEpochMicroSec)")
+ @SqlUpdate("INSERT INTO ALARM_INFO (EVENTID,EVENTNAME,STARTEPOCHMICROSEC,SOURCEID,SOURCENAME,SEQUENCE,ALARMISCLEARED,ROOTFLAG,LASTEPOCHMICROSEC) VALUES (:eventId,:eventName,:startEpochMicroSec,:sourceId,:sourceName,:sequence,:alarmIsCleared,:rootFlag,:lastEpochMicroSec)")
protected abstract String addAlarm(@BindBean AlarmInfo alarmInfo);
@SqlQuery("SELECT * FROM ALARM_INFO")