Guangrong Fu | b189f5f | 2022-01-24 15:07:08 +0800 | [diff] [blame] | 1 | package org.onap.holmes.droolsRule; |
| 2 | |
| 3 | import org.onap.holmes.common.dmaap.DmaapService; |
| 4 | import org.onap.holmes.common.api.stat.VesAlarm; |
| 5 | import org.onap.holmes.common.aai.CorrelationUtil; |
| 6 | import org.onap.holmes.common.dmaap.entity.PolicyMsg; |
Guangrong Fu | 0bbe5b0 | 2022-09-15 19:52:40 +0800 | [diff] [blame] | 7 | import org.onap.holmes.common.utils.SpringContextUtil; |
Guangrong Fu | b189f5f | 2022-01-24 15:07:08 +0800 | [diff] [blame] | 8 | import org.onap.holmes.common.utils.DroolsLog; |
| 9 | |
| 10 | rule "Relation_analysis_Rule" |
| 11 | salience 200 |
| 12 | no-loop true |
| 13 | when |
| 14 | $root : VesAlarm(alarmIsCleared == 0, |
| 15 | $sourceId: sourceId, sourceId != null && !sourceId.equals(""), |
| 16 | $sourceName: sourceName, sourceName != null && !sourceName.equals(""), |
| 17 | $startEpochMicrosec: startEpochMicrosec, |
| 18 | eventName in ("Fault_MultiCloud_VMFailure"), |
| 19 | $eventId: eventId) |
| 20 | $child : VesAlarm( eventId != $eventId, parentId == null, |
| 21 | CorrelationUtil.getInstance().isTopologicallyRelated(sourceId, $sourceId, $sourceName), |
| 22 | eventName in ("Fault_MME_eNodeB out of service alarm"), |
Guangrong Fu | 0bbe5b0 | 2022-09-15 19:52:40 +0800 | [diff] [blame] | 23 | startEpochMicrosec < $startEpochMicrosec + 60000 && startEpochMicrosec > $startEpochMicrosec - 60000) |
Guangrong Fu | b189f5f | 2022-01-24 15:07:08 +0800 | [diff] [blame] | 24 | then |
| 25 | DroolsLog.printInfo("==========================================================="); |
| 26 | DroolsLog.printInfo("Relation_analysis_Rule: rootId=" + $root.getEventId() + ", childId=" + $child.getEventId()); |
| 27 | $child.setParentId($root.getEventId()); |
| 28 | update($child); |
| 29 | end |
| 30 | |
| 31 | rule "root_has_child_handle_Rule" |
| 32 | salience 150 |
| 33 | no-loop true |
| 34 | when |
| 35 | $root : VesAlarm(alarmIsCleared == 0, rootFlag == 0, $eventId: eventId) |
| 36 | $child : VesAlarm(eventId != $eventId, parentId == $eventId) |
| 37 | then |
| 38 | DroolsLog.printInfo("==========================================================="); |
| 39 | DroolsLog.printInfo("root_has_child_handle_Rule: rootId=" + $root.getEventId() + ", childId=" + $child.getEventId()); |
Guangrong Fu | 0bbe5b0 | 2022-09-15 19:52:40 +0800 | [diff] [blame] | 40 | DmaapService dmaapService = SpringContextUtil.getBean(DmaapService.class); |
Guangrong Fu | b189f5f | 2022-01-24 15:07:08 +0800 | [diff] [blame] | 41 | PolicyMsg policyMsg = dmaapService.getPolicyMsg($root, $child, "org.onap.holmes.droolsRule"); |
| 42 | dmaapService.publishPolicyMsg(policyMsg, "dcae_cl_out"); |
| 43 | $root.setRootFlag(1); |
| 44 | update($root); |
| 45 | end |
| 46 | |
| 47 | rule "root_no_child_handle_Rule" |
| 48 | salience 100 |
| 49 | no-loop true |
| 50 | when |
| 51 | $root : VesAlarm(alarmIsCleared == 0, rootFlag == 0, |
| 52 | sourceId != null && !sourceId.equals(""), |
| 53 | sourceName != null && !sourceName.equals(""), |
| 54 | eventName in ("Fault_MultiCloud_VMFailure")) |
| 55 | then |
| 56 | DroolsLog.printInfo("==========================================================="); |
| 57 | DroolsLog.printInfo("root_no_child_handle_Rule: rootId=" + $root.getEventId()); |
Guangrong Fu | 0bbe5b0 | 2022-09-15 19:52:40 +0800 | [diff] [blame] | 58 | DmaapService dmaapService = SpringContextUtil.getBean(DmaapService.class); |
Guangrong Fu | b189f5f | 2022-01-24 15:07:08 +0800 | [diff] [blame] | 59 | PolicyMsg policyMsg = dmaapService.getPolicyMsg($root, null, "org.onap.holmes.droolsRule"); |
| 60 | dmaapService.publishPolicyMsg(policyMsg, "dcae_cl_out"); |
| 61 | $root.setRootFlag(1); |
| 62 | update($root); |
| 63 | end |
| 64 | |
| 65 | rule "root_cleared_handle_Rule" |
| 66 | salience 100 |
| 67 | no-loop true |
| 68 | when |
| 69 | $root : VesAlarm(alarmIsCleared == 1, rootFlag == 1) |
| 70 | then |
| 71 | DroolsLog.printInfo("==========================================================="); |
| 72 | DroolsLog.printInfo("root_cleared_handle_Rule: rootId=" + $root.getEventId()); |
Guangrong Fu | 0bbe5b0 | 2022-09-15 19:52:40 +0800 | [diff] [blame] | 73 | DmaapService dmaapService = SpringContextUtil.getBean(DmaapService.class); |
Guangrong Fu | b189f5f | 2022-01-24 15:07:08 +0800 | [diff] [blame] | 74 | PolicyMsg policyMsg = dmaapService.getPolicyMsg($root, null, "org.onap.holmes.droolsRule"); |
| 75 | dmaapService.publishPolicyMsg(policyMsg, "dcae_cl_out"); |
| 76 | retract($root); |
| 77 | end |
| 78 | |
| 79 | rule "child_handle_Rule" |
| 80 | salience 100 |
| 81 | no-loop true |
| 82 | when |
| 83 | $child : VesAlarm(alarmIsCleared == 1, rootFlag == 0) |
| 84 | then |
| 85 | DroolsLog.printInfo("==========================================================="); |
| 86 | DroolsLog.printInfo("child_handle_Rule: childId=" + $child.getEventId()); |
| 87 | retract($child); |
Guangrong Fu | 0bbe5b0 | 2022-09-15 19:52:40 +0800 | [diff] [blame] | 88 | end |