summaryrefslogtreecommitdiffstats
path: root/engine-d/src
diff options
context:
space:
mode:
authortang peng <tang.peng5@zte.com.cn>2018-07-16 00:45:31 +0000
committerGerrit Code Review <gerrit@onap.org>2018-07-16 00:45:31 +0000
commit95ed68877f81768b474849641322a5861b4ecb05 (patch)
tree69976346a2903a9afe54a04f5995211aab5ee1c6 /engine-d/src
parent0420b71eb8b07a2e32b2055305ec9c764a4ca8dc (diff)
parenta475aac49b3b029acf28174117a6423f6dd5eed7 (diff)
Merge "Remove alarms from DB when they are cleared"
Diffstat (limited to 'engine-d/src')
-rw-r--r--engine-d/src/main/java/org/onap/holmes/engine/manager/DroolsEngine.java28
1 files changed, 24 insertions, 4 deletions
diff --git a/engine-d/src/main/java/org/onap/holmes/engine/manager/DroolsEngine.java b/engine-d/src/main/java/org/onap/holmes/engine/manager/DroolsEngine.java
index 3740f18..dcc40fd 100644
--- a/engine-d/src/main/java/org/onap/holmes/engine/manager/DroolsEngine.java
+++ b/engine-d/src/main/java/org/onap/holmes/engine/manager/DroolsEngine.java
@@ -223,16 +223,22 @@ public class DroolsEngine {
}
}
- public void putRaisedIntoStream(VesAlarm raiseAlarm) {
- FactHandle factHandle = this.kieSession.getFactHandle(raiseAlarm);
+ public void putRaisedIntoStream(VesAlarm alarm) {
+ FactHandle factHandle = this.kieSession.getFactHandle(alarm);
if (factHandle != null) {
Object obj = this.kieSession.getObject(factHandle);
if (obj != null && obj instanceof VesAlarm) {
- raiseAlarm.setRootFlag(((VesAlarm) obj).getRootFlag());
+ alarm.setRootFlag(((VesAlarm) obj).getRootFlag());
}
this.kieSession.delete(factHandle);
+
+ if (alarm.getAlarmIsCleared() == 1) {
+ alarmInfoDao.deleteClearedAlarm(convertVesAlarm2AlarmInfo(alarm));
+ }
+ } else {
+ this.kieSession.insert(alarm);
}
- this.kieSession.insert(raiseAlarm);
+
this.kieSession.fireAllRules();
}
@@ -294,4 +300,18 @@ public class DroolsEngine {
return vesAlarm;
}
+ private AlarmInfo convertVesAlarm2AlarmInfo(VesAlarm vesAlarm){
+ AlarmInfo alarmInfo = new AlarmInfo();
+ alarmInfo.setEventId(vesAlarm.getEventId());
+ alarmInfo.setEventName(vesAlarm.getEventName());
+ alarmInfo.setStartEpochMicroSec(vesAlarm.getStartEpochMicrosec());
+ alarmInfo.setLastEpochMicroSec(vesAlarm.getLastEpochMicrosec());
+ alarmInfo.setSourceId(vesAlarm.getSourceId());
+ alarmInfo.setSourceName(vesAlarm.getSourceName());
+ alarmInfo.setAlarmIsCleared(vesAlarm.getAlarmIsCleared());
+ alarmInfo.setRootFlag(vesAlarm.getRootFlag());
+
+ return alarmInfo;
+ }
+
}