[rules-users] Storing temp results in eval block
cfili
cfilippelli at cerner.com
Mon Aug 27 17:16:44 EDT 2007
Thanks, I had not thought of it this way. The one thing that worries me
about making the Resource object modifiable and not "read-only" is that
multiple rules may be using that object. I would not want one rule to
override a value in the attributes map. To avoid this I would have to make
the keys in the attributes map unique for the rule.
Again thanks for the feedback.
Edson Tirelli-3 wrote:
>
> What I would do in your case is to have 2+ rules. One rule calculates
> the value, and the other(s) rule(s) will reason over the calculated value.
> Example:
>
> rule "Calculates Memory Usage"
> when
> $mpw: Resource( type=="MemoryInfo", attributes.Percent == null,
> $phys:
> attributes.PhysicalUsed, $tot: attributes.TotalPhysical )
> then
> $mpw.setAttribute( "Percent", ((Double)$phys).doubleValue() /
> ((Double)$tot).doubleValue());
> update( $mpw );
> end
>
> rule "High Average Usage"
> when
> Resource( type=="MemoryInfo", attributes.Percent > .95 )
> then
> // do something
> end
>
> rule "Medium Average Usage"
> when
> Resource( type=="MemoryInfo", attributes.Percent > .50 && <= .95 )
> then
> // do something
> end
>
> Hope it helps...
>
> []s
> Edson
>
>
>
> 2007/8/27, cfili <cfilippelli at cerner.com>:
>>
>>
>> Sure... basically using a map called "attributes" to retrieve specific
>> attributes on a resource. Currently I am simply printing the value from
>> the
>> eval, but I would like to be able to store it.
>>
>> rule "High Memory 95%"
>>
>> when
>> $mpw : Resource(type == "MemoryInfo", $physUsed :
>> attributes["PhysicalUsed"], $totalPhys : attributes["TotalPhysical"])
>> eval((((Double)$physUsed).doubleValue() /
>> ((Double)$totalPhys).doubleValue()) > 0.95)
>> then
>> System.out.println(" Percent Used: " +
>> ((Double)$physUsed).doubleValue() /
>> ((Double)$totalPhys).doubleValue());
>> end
>> --
>> View this message in context:
>> http://www.nabble.com/Storing-temp-results-in-eval-block-tf4225783.html#a12354084
>> Sent from the drools - user mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>
>
>
> --
> Edson Tirelli
> Software Engineer - JBoss Rules Core Developer
> Office: +55 11 3529-6000
> Mobile: +55 11 9287-5646
> JBoss, a division of Red Hat @ www.jboss.com
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
--
View this message in context: http://www.nabble.com/Storing-temp-results-in-eval-block-tf4225783.html#a12357945
Sent from the drools - user mailing list archive at Nabble.com.
More information about the rules-users
mailing list