Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagebash
titleholmesrule
collapsetrue
{

"rulename": "VoLTE",

"loopcontrolname": "ControlLoop-VOLTE-2179b738-fd36-4843-a71a-a8c24c70c55b",

"description": "This rule is designed for the correlation analysis for the VoLTE use case.",

"content": "package org.onap.holmes.droolsRule;\n\nimport org.onap.holmes.common.dmaap.DmaapService;\nimport org.onap.holmes.common.api.stat.VesAlarm;\nimport org.onap.holmes.common.aai.CorrelationUtil;\nimport org.onap.holmes.common.dmaap.entity.PolicyMsg;\nimport org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder;\nimport org.onap.holmes.common.utils.DroolsLog;\n \n\nrule \"Relation_analysis_Rule\"\nsalience 200\nno-loop true\n    when\n        $root : VesAlarm(alarmIsCleared == 0,\n            $sourceId: sourceId, sourceId != null && !sourceId.equals(\"\"),\n\t\t\t$sourceName: sourceName, sourceName != null && !sourceName.equals(\"\"),\n\t\t\t$startEpochMicrosec: startEpochMicrosec,\n            specificProblem in (\"Fault_MultiCloud_VMFailure\"),\n            $eventId: eventId)\n        $child : VesAlarm( eventId != $eventId, parentId == null,\n            CorrelationUtil.getInstance().isTopologicallyRelated(sourceId, $sourceId, $sourceName),\n            specificProblem in (\"Slave MPU is offline\"),\n            startEpochMicrosec < $startEpochMicrosec + 60000 && startEpochMicrosec > $startEpochMicrosec - 60000 )\n    then\n\t\t$child.setParentId($root.getEventId());\n\t\tupdate($child);\n\t\t\nend\n\nrule \"root_has_child_handle_Rule\"\nsalience 150\nno-loop true\n\twhen\n\t\t$root : VesAlarm(alarmIsCleared == 0, rootFlag == 0, $eventId: eventId)\n\t\t$child : VesAlarm(eventId != $eventId, parentId == $eventId)\n\tthen\n\t\tDmaapService dmaapService = ServiceLocatorHolder.getLocator().getService(DmaapService.class);\n\t\tPolicyMsg policyMsg = dmaapService.getPolicyMsg($root, $child, \"org.onap.holmes.droolsRule\");\n        dmaapService.publishPolicyMsg(policyMsg, \"unauthenticated.DCAE_CL_OUTPUT\");\n\t\t$root.setRootFlag(1);\n\t\tupdate($root);\nend\n\nrule \"root_no_child_handle_Rule\"\nsalience 100\nno-loop true\n    when\n        $root : VesAlarm(alarmIsCleared == 0, rootFlag == 0,\n            sourceId != null && !sourceId.equals(\"\"),\n\t\t\tsourceName != null && !sourceName.equals(\"\"),\n            specificProblem in (\"Fault_MultiCloud_VMFailure\"))\n    then\n\t\tDmaapService dmaapService = ServiceLocatorHolder.getLocator().getService(DmaapService.class);\n\t\tPolicyMsg policyMsg = dmaapService.getPolicyMsg($root, null, \"org.onap.holmes.droolsRule\");\n        dmaapService.publishPolicyMsg(policyMsg, \"unauthenticated.DCAE_CL_OUTPUT\");\n\t\t$root.setRootFlag(1);\n\t\tupdate($root);\nend\n\nrule \"root_cleared_handle_Rule\"\nsalience 100\nno-loop true\n    when\n        $root : VesAlarm(alarmIsCleared == 1, rootFlag == 1)\n    then\n\t\tDmaapService dmaapService = ServiceLocatorHolder.getLocator().getService(DmaapService.class);\n\t\tPolicyMsg policyMsg = dmaapService.getPolicyMsg($root, null, \"org.onap.holmes.droolsRule\");\n        dmaapService.publishPolicyMsg(policyMsg, \"unauthenticated.DCAE_CL_OUTPUT\");\n\t\tretract($root);\nend\n\nrule \"child_handle_Rule\"\nsalience 100\nno-loop true\n    when\n        $child : VesAlarm(alarmIsCleared == 1, rootFlag == 0)\n    then\n\t\tretract($child);\nend",

"enabled": 1

}


To illustrate, the rule is like this in clean format:

Code Block
titleRule content
linenumberstrue
collapsetrue
package org.onap.holmes.droolsRule;


import org.onap.holmes.common.dmaap.DmaapService;
import org.onap.holmes.common.api.stat.VesAlarm;
import org.onap.holmes.common.aai.CorrelationUtil;
import org.onap.holmes.common.dmaap.entity.PolicyMsg;
import org.onap.holmes.common.dropwizard.ioc.utils.ServiceLocatorHolder;
import org.onap.holmes.common.utils.DroolsLog;


rule "Relation_analysis_Rule"
salience 200
no-loop true
    when
        $root : VesAlarm(alarmIsCleared == 0,
            $sourceId: sourceId, sourceId != null && !sourceId.equals(\"\"),
			$sourceName: sourceName, sourceName != null && !sourceName.equals(\"\"),
			$startEpochMicrosec: startEpochMicrosec,
            specificProblem in (\"Fault_MultiCloud_VMFailure\"),
            $eventId: eventId)
        $child : VesAlarm( eventId != $eventId, parentId == null,
            CorrelationUtil.getInstance().isTopologicallyRelated(sourceId, $sourceId, $sourceName),
            specificProblem in (\"Slave MPU is offline\"),
            startEpochMicrosec < $startEpochMicrosec + 60000 && startEpochMicrosec > $startEpochMicrosec - 60000 )
    then
		$child.setParentId($root.getEventId());
		update($child);
end


rule "root_has_child_handle_Rule"
salience 150
no-loop true
	when
		$root : VesAlarm(alarmIsCleared == 0, rootFlag == 0, $eventId: eventId)
		$child : VesAlarm(eventId != $eventId, parentId == $eventId)
	then
		DmaapService dmaapService = ServiceLocatorHolder.getLocator().getService(DmaapService.class);
		PolicyMsg policyMsg = dmaapService.getPolicyMsg($root, $child, \"org.onap.holmes.droolsRule\");
        dmaapService.publishPolicyMsg(policyMsg, \"unauthenticated.DCAE_CL_OUTPUT\");
		$root.setRootFlag(1);
		update($root);
end


rule "root_no_child_handle_Rule\"
salience 100
no-loop true
    when
        $root : VesAlarm(alarmIsCleared == 0, rootFlag == 0,
            sourceId != null && !sourceId.equals(\"\"),
    		sourceName != null && !sourceName.equals(\"\"),
            specificProblem in (\"Fault_MultiCloud_VMFailure\"))
    then
		DmaapService dmaapService = ServiceLocatorHolder.getLocator().getService(DmaapService.class);
		PolicyMsg policyMsg = dmaapService.getPolicyMsg($root, null, \"org.onap.holmes.droolsRule\");
        dmaapService.publishPolicyMsg(policyMsg, \"unauthenticated.DCAE_CL_OUTPUT\");
		$root.setRootFlag(1);
		update($root);
nend


rule "root_cleared_handle_Rule"
salience 100
no-loop true
    when\n        $root : VesAlarm(alarmIsCleared == 1, rootFlag == 1)\n    then\n\t\tDmaapService dmaapService = ServiceLocatorHolder.getLocator().getService(DmaapService.class);\n\t\tPolicyMsg policyMsg = dmaapService.getPolicyMsg($root, null, \"org.onap.holmes.droolsRule\");\n        dmaapService.publishPolicyMsg(policyMsg, \"unauthenticated.DCAE_CL_OUTPUT\");\n\t\tretract($root);\nend\n\nrule \"child_handle_Rule\"\nsalience 100\nno-loop true\n    when\n        $child : VesAlarm(alarmIsCleared == 1, rootFlag == 0)\n    then\n\t\tretract($child);\nend",



Before install Holmes dockers, you need to install postgres

...