blob: 494333c2a8687671e19ea7fb77729abcb88a9c85 [file] [log] [blame]
Guangrong Fub189f5f2022-01-24 15:07:08 +08001package org.onap.holmes.droolsRule;
2
3import org.onap.holmes.common.dmaap.DmaapService;
4import org.onap.holmes.common.api.stat.VesAlarm;
5import org.onap.holmes.common.aai.CorrelationUtil;
6import org.onap.holmes.common.dmaap.entity.PolicyMsg;
7import org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder;
8import org.onap.holmes.common.utils.DroolsLog;
9
10rule "Relation_analysis_Rule"
11salience 200
12no-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"),
23 startEpochMicrosec < $startEpochMicrosec + 60000 && startEpochMicrosec > $startEpochMicrosec - 60000 )
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);
29end
30
31rule "root_has_child_handle_Rule"
32salience 150
33no-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());
40 DmaapService dmaapService = ServiceLocatorHolder.getLocator().getService(DmaapService.class);
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);
45end
46
47rule "root_no_child_handle_Rule"
48salience 100
49no-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());
58 DmaapService dmaapService = ServiceLocatorHolder.getLocator().getService(DmaapService.class);
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);
63end
64
65rule "root_cleared_handle_Rule"
66salience 100
67no-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());
73 DmaapService dmaapService = ServiceLocatorHolder.getLocator().getService(DmaapService.class);
74 PolicyMsg policyMsg = dmaapService.getPolicyMsg($root, null, "org.onap.holmes.droolsRule");
75 dmaapService.publishPolicyMsg(policyMsg, "dcae_cl_out");
76 retract($root);
77end
78
79rule "child_handle_Rule"
80salience 100
81no-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);
88end