Chris,

   I am glad you asked these questions, because I am looking for feedback on the approaches we are using.
  
   So, first thing to understand is: sliding windows AND memory management are only active when the processing mode is set to STREAM. There is no memory management or support to sliding windows in CLOUD mode as this would not make sense.

   Assuming the engine is set to STREAM mode, it will use 2 sources of information to calculate the expiration time for each event type: the @expiration policy and temporal constraints. @expiration is explicit and obvious. For temporal constraints, the calculation is quite complex, so let me show the simplest possible example: imagine a rule:

when
   $a : A()
   $b : B( this after[1s,30s] $a )
then
end

    In the above example, it is obvious that any A() must wait at least 30s for eventual B()s. B()s on the other hand will either match immediately or will never match. So, the expiration offset for A will be 30s and for B will be 0 (zero). Now the engine will calculate the offset based on all temporal constraints from all rules and (simplistically speaking) take the max between the value calculated and the @expiration policy if it exists as long as the max is not infinite. Any object type for which there are no explicit expiration policy, nor temporal constraints from which to derive the expiration offset will have an infinite expiration offset, i.e., will never be automatically retracted.

   So, length sliding windows, that was what you asked about, as it is today, will not hold the object beyond its expiration offset. Maybe we should, maybe not... I am open to arguments on that field.

    Feedback and arguments welcome.

    []s
    Edson

  

2009/6/12 Chris Richmond <crichmond@referentia.com>

Hello,

 

I wanted to ask this question in a separate email so as to keep each email to one topic for easier thread following.  Let me know if you prefer multiple questions per email next time.

 


I am using Drools fusion basically with some success where I am at this point only running some aggregates and calling some java functions when a running average over the last 1 minute or so drops below a certain value.   

 

The sources for those values come from objects I am injecting into memory space, but I am not specifically calling retraction code since it is my understanding that I can set the policy in the rule file for how long to hold objects in memory.  So for example I have this rule which simpoly outputs to out when the average goes above 100 for the last 10 items(you can tell I created mine based on the stock ticker).  It seems to be working, but I have some questions to ensure I understand before moving forward.

 

 

So below the “declare MyObject” with assigning it role event with a default expiration of 2 minutes.  Is my undertanding correct that fusion will disregard thos objects that are injected without me having to take any other action? 

 

Also, in my “show averages” rule below, if I did ont have the “declare MyObject” delcaration with expiration policy set, would fusion automatially throw away MyObjects older than the last 10  based on my rule no longer needing them?    If it would, then which takes priority, the expires declaration for MyObject or the no longer needed by my aggregate rule below.  I am assuming that the rule would keep them beyond 2 minutes it it was necessary, but is this correct?  If the rule as written would not automatically remove objects from memory space, then is there something I could do to tell the rule to do so when it is no longer needed by my aggregate?

 

Thanks,


Chris

 

 

 

 

 

 

<imports removed>

 

 

# default dialect for the semantic code will be MVEL

dialect "mvel"

 

# tells the engine that a object instance will assume the

# role (semantics) of events and that the default retention

# policy will be 2 minutes

declare MyObject

    @role( event )

    @expires( 2m )

end

 

 

rule "show averages"

when

 

      $n : Number( doubleValue > 100 ) from accumulate (

 

           

     

            $stat:MyObject($bc: byteCount, srcIPAddress == "10.5.0.4") over window:length(10) from entry-point "MyObject stream",

 

            average( $bc )

           

        )

       

       

then

 

    System.err.println("average: " + $n)

end


_______________________________________________
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