Re: [rules-users] Fire rule only when all the fact objects sent during a specific period match the WHEN part

2008-08-22 Thread ganesh.p

Thanks Edson

But there are certain issues. I have attached the diagram which shows the
fact flow.
Here is my requirement

I have a application which has a Fact Queue and RuleBase and there are
multiple clients. Each client has a agent which captures System idle
information continuously in that system with approximately 10 sec delay and
sends the SystemInfo fact to the FactQueue. Now when a new fact is added to
the FactQueue that fact is sent to RuleBase. This process happens
continuously without halt.  The FactQueue contains new SystemInfo objects,
there won't be single common SystemInfo object. Although each client sends
fact with 10seconds delay, since there are lots of clients, the FactQueue
will get added with facts with less than 1 second delay because all the
clients are simultaneously sending facts. The systeminfo also contains name
of the system from which the idle information is captured. This name is
checked in the WHEN clause of the rule.


Suppose we use Statefulsession(only one instance) and have a single common
SystemInfo object and update the value in this common object from new
SystemInfo fact(as and when new fact is added to the FactQueue), and notify
the update to drools, we have to synchronize each update operation. I think
this may cause performance issue.

Suppose we add all these new fact objects to single cached Statefulsession,
the session will endup with millions of fact
objects("session.insert(systeminfo)"). We don't know when to dispose the
objects and session, and session will hold the references to all the facts
causing out of memory.

If we use Stateless session then we will lose previous facts when a new fact
is sent to session. session.execute(systeminfo). So we lose the previous
state.  So can't check a condition is true for a duration. 


Please help me in finding solution to this.

Thanks a lot
-Ganesh



Edson Tirelli-3 wrote:
> 
>Ok, your case seems clearly a case where you need either a
> StatefulSession or your application needs to send previous readings to
> drools.
>If you are using a StatefulSession AND you always use the same
> SystemInfo
> object (just use update on it), you could use "duration" on your rule:
> 
> rule "Start_New_Process_If_System_is_70%_Idle_Continuously_for_60_Seconds"
>duration 6
> when
> SystemInfo (idle >= 70)  //Idle continuously for 60 seconds
> then
> // start new process
> end
> 
>Using StatelessSession, you must have an update rule for your object
> 
> rule "System_is_70%_Idle"
> salience 10
> when
> $si : SystemInfo (idle >= 70)
> then
> $si.setIdleCounter( $si.getIdleCounter() + 1 );
> end
> 
> rule "Start_New_Process_If_System_is_70%_Idle_Continuously_for_60_Seconds"
> when
> SystemInfo( idleCounter >= 12)
> then
> // start new process
> end
> 
>[]s
>Edson
> 
> 2008/8/19 ganesh.p <[EMAIL PROTECTED]>
> 
>>
>> I need to create a rule with following requirements:
>>
>> There is a fact class called SystemInfo which contains idle information
>> of
>> a
>> sytem
>>
>> public class SystemInfo {
>>private double idle; //System idle percentage
>>
>>public void setIdle(double idle) {
>>this.idle = idle;
>>}
>>
>>public double getIdle() {
>>return this.idle;
>>}
>> }
>>
>>
>> The SystemInfo objects are continuously sent to DROOLS (StatelessSession)
>> with 5 second delay.
>>
>> I need to create a rule
>>
>>
>> rule
>> "Start_New_Process_If_System_is_70%_Idle_Continuously_for_60_Seconds"
>>
>> when SystemInfo (idle >= 70)  //Idle continuously for 60 seconds
>> then
>>  // start new process
>>
>> end
>>
>>
>> I need to fire this rule only if all the 12 SystemInfo objects which are
>> sent with 5 seconds delay for 60 seconds, match the condition "idle >=
>> 70".
>> Even if a single SystemInfo doesn't match this condition then this rule
>> shouldn't be fired.
>>
>> I am using DROOLS 4.0. Please help me in implementing the WHEN condition.
>>
>> Thanks
>> -Ganesh
>> --
>> View this message in context:
>> http://www.nabble.com/Fire-rule-only-when-all-the-fact-objects-sent-during-a-specific-period-match-the-WHEN-part-tp19029247p19029247.html
>> Sent from the drools - user mailing list archive at Nabble.com.
>>
>> ___
>> rules-users mailing list
>> rules-users@lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
> 
> 
> 
> -- 
> Edson Tirelli
> JBoss Drools Core Development
> JBoss, a division of Red Hat @ www.jboss.com
> 
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> 
> 
http://www.nabble.com/file/p19105531/Facts.jpeg 
-- 
View this message in context: 
http://www.nabble.com/Fire-rule-only-when-all-the-fact-objects-sent-during-a-specific-period-match-the-WHEN-part-tp19029247p19105531.html
Sent from the drools - user mailing list archive at Nabb

Re: [rules-users] Fire rule only when all the fact objects sent during a specific period match the WHEN part

2008-08-19 Thread Edson Tirelli
   Ok, your case seems clearly a case where you need either a
StatefulSession or your application needs to send previous readings to
drools.
   If you are using a StatefulSession AND you always use the same SystemInfo
object (just use update on it), you could use "duration" on your rule:

rule "Start_New_Process_If_System_is_70%_Idle_Continuously_for_60_Seconds"
   duration 6
when
SystemInfo (idle >= 70)  //Idle continuously for 60 seconds
then
// start new process
end

   Using StatelessSession, you must have an update rule for your object

rule "System_is_70%_Idle"
salience 10
when
$si : SystemInfo (idle >= 70)
then
$si.setIdleCounter( $si.getIdleCounter() + 1 );
end

rule "Start_New_Process_If_System_is_70%_Idle_Continuously_for_60_Seconds"
when
SystemInfo( idleCounter >= 12)
then
// start new process
end

   []s
   Edson

2008/8/19 ganesh.p <[EMAIL PROTECTED]>

>
> I need to create a rule with following requirements:
>
> There is a fact class called SystemInfo which contains idle information of
> a
> sytem
>
> public class SystemInfo {
>private double idle; //System idle percentage
>
>public void setIdle(double idle) {
>this.idle = idle;
>}
>
>public double getIdle() {
>return this.idle;
>}
> }
>
>
> The SystemInfo objects are continuously sent to DROOLS (StatelessSession)
> with 5 second delay.
>
> I need to create a rule
>
>
> rule "Start_New_Process_If_System_is_70%_Idle_Continuously_for_60_Seconds"
>
> when SystemInfo (idle >= 70)  //Idle continuously for 60 seconds
> then
>  // start new process
>
> end
>
>
> I need to fire this rule only if all the 12 SystemInfo objects which are
> sent with 5 seconds delay for 60 seconds, match the condition "idle >= 70".
> Even if a single SystemInfo doesn't match this condition then this rule
> shouldn't be fired.
>
> I am using DROOLS 4.0. Please help me in implementing the WHEN condition.
>
> Thanks
> -Ganesh
> --
> View this message in context:
> http://www.nabble.com/Fire-rule-only-when-all-the-fact-objects-sent-during-a-specific-period-match-the-WHEN-part-tp19029247p19029247.html
> Sent from the drools - user mailing list archive at Nabble.com.
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
Edson Tirelli
JBoss Drools Core Development
JBoss, a division of Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Fire rule only when all the fact objects sent during a specific period match the WHEN part

2008-08-18 Thread ganesh.p

I need to create a rule with following requirements:

There is a fact class called SystemInfo which contains idle information of a
sytem

public class SystemInfo {
private double idle; //System idle percentage

public void setIdle(double idle) {
this.idle = idle;
}

public double getIdle() {
return this.idle;
}
}


The SystemInfo objects are continuously sent to DROOLS (StatelessSession)
with 5 second delay.

I need to create a rule


rule "Start_New_Process_If_System_is_70%_Idle_Continuously_for_60_Seconds"

when SystemInfo (idle >= 70)  //Idle continuously for 60 seconds
then
  // start new process

end


I need to fire this rule only if all the 12 SystemInfo objects which are
sent with 5 seconds delay for 60 seconds, match the condition "idle >= 70". 
Even if a single SystemInfo doesn't match this condition then this rule
shouldn't be fired.

I am using DROOLS 4.0. Please help me in implementing the WHEN condition. 

Thanks
-Ganesh
-- 
View this message in context: 
http://www.nabble.com/Fire-rule-only-when-all-the-fact-objects-sent-during-a-specific-period-match-the-WHEN-part-tp19029247p19029247.html
Sent from the drools - user mailing list archive at Nabble.com.

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users