Hi All,
I am in the process of creating some rules for a POC I am doing using drools,
having some issues understanding why I have an infinite loop in a rule.
Rule in question:
rule "Check Parameter Threshold Update Breach"
no-loop true
when
ParameterUpdateEvent($name : name)
from entry-point "ParamUpdateStream"
$param : Parameter(name == $name)
Number($averageUpdateValue : doubleValue)
from accumulate(ParameterUpdateEvent(name == $param.name,
$value : value)
over window:time(15m)
from entry-point "ParamUpdateStream", average($value))
$tholdBreach : Parameter.Threshold(windowSize == 15,
threshold >= $averageUpdateValue) from $param.thresholds
$firedAlert : AlertInformation(name == $param.name,
severity != $tholdBreach.severity)
then
System.out.println("Updating alert from '" +
$firedAlert.getSeverity() +
"' to '" + $tholdBreach.getSeverity() +
"' alarm: Average update value for " +
$param.getName() + " = " + $averageUpdateValue);
$firedAlert.setSeverity($tholdBreach.getSeverity());
update($firedAlert);
//insert(new AlertInformation($param.getName(),
$tholdBreach.getSeverity()));
//modify($firedAlert);
end
I understand what is happening up to the $tholdBreach : Parameter.Threshold
line. Each Parameter can have a list of thresholds and what I want this line to
do is pick the correct threshold if any are breached. For instance Param1 has 2
thresholds: MINOR and CRITICAL, the MINOR threshold should fire if
averageUpdateValue is >= 50, the CRITICAL threshold should fire if
averageUpdateValue is >= 40. The first problem I need to solve (in a better
way) is getting the correct threshold out of this, the way I do it now is but
putting the MINOR threshold in the list before the CRITICAL one. This means
that it will be checked first from the line in question. This, to me, is not a
good solution. Is there a more deterministic way to do this, I was thinking of
somehow using the difference between the threshold and the averageUpdateValue
to get the right now but I don't see how that can work from a rule stand point.
The other question I have is this rule loops infinitely when the
averageUpdateValue is below 40 (CRITICAL threshold) between a MINOR alarm and
a CRITICAL alarm and I don't see why or how because tholdBreach should always
be the CRITICAL alarm and the rule would stop on the next line, but it is
alernatly returning CRITICAL then MINOR which is confusing. To confuse this
even more when I comment out the update($firedAlert) and replace that with a
retract($firedAlert) and insert(new ...) it does not loop.
Any ideas would be great.
Thanks
Glenn
_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users