summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuangrongFu <fu.guangrong@zte.com.cn>2018-07-14 10:42:32 +0800
committerGuangrongFu <fu.guangrong@zte.com.cn>2018-07-14 10:42:32 +0800
commita475aac49b3b029acf28174117a6423f6dd5eed7 (patch)
tree110fa93d65fe188372a3c82d0b8e1cd39d202ca9
parent8490a957d5200419a0b8e60c35d8b2c7ecb1ba6e (diff)
Remove alarms from DB when they are cleared
Change-Id: I56fe8356a10b25ccf2d9d3d4f73db8715701693f Issue-ID: HOLMES-143 Signed-off-by: GuangrongFu <fu.guangrong@zte.com.cn>
-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;
+ }
+
}