Re: [rules-users] Question about collect and sliding windows

2010-12-02 Thread Anais Martinez

Well, I have tested it during 10 hours this night, by sending the readings
each 15 minutes and it works, because the interval of sending is exactly
what  was needed. Therefore, you are right: the problem is in the delayed
readings, and if the server changes the frequency of sending or sends all
readings at a single time, that rule will not work 0_o.

Actually, we don't have a problem with unsucessfull fire, because the real
system will activate the alarm once a day, if it appears. I have started
with a simple system but I will include more restrictions and intermediate
rules to active differents events. 

Thank you very much. Regards
-- 
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/Question-about-collect-and-sliding-windows-tp1999562p2004702.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


[rules-users] Question about collect and sliding windows

2010-12-01 Thread Anais Martinez

Hello. I have two questions about collect and sliding windows. I have created
this rule:

rule Active risk
when
 $n:Node()
 $readings: ArrayList(size==80)  from collect(
   Reading( nodeID == $n.nodeID, 
(signalType == SignalType.PLUVIOSITY  value = 10)||
(signalType == SignalType.AIR_TEMPERATURE  value=12)
   ) over window:time(10h))
then
  System.out.println(Active risk in node + $n.getNodeID());
end

And the declarations are the following (Reading and Node are java classes):

declare Reading
@role(event)
@timestamp (timestamp)
end

declare Node
@role(fact)
end


Well, I have probe the rule. I have inserted 100 readings which satisfy the
conditions, in a single time but with different timestamp (I have simulated
that there are a pluviosity reading and a air_temperature reading each 15
minutes), that is, in main:

long init= 129072960L; 
long interval = 1000*60*15;
for (int i=0; i100; i++){
long fecha = init+i*interval;
Reading r1 = new Reading(SignalType.PLUVIOSITY, value1, node);
session.insert(r1);

Reading r2 = new Reading(SignalType.AIR_TEMPERATURE, value1, node);
session.insert(r2);
}

The message is not written (I have fired rules after insertions). 

My questions: 
Has drools any problem if I inserted all readings at same time? (Do I have
to use the pseudo-clock?)
My problem is that the readings will be sent from a server in real system,
and it's possible that the server will send all readings belonging to an
interval of one/two hour/s at same time. 

Thanks.

-- 
View this message in context: 
http://drools-java-rules-engine.46999.n3.nabble.com/Question-about-collect-and-sliding-windows-tp1999562p1999562.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


Re: [rules-users] Question about collect and sliding windows

2010-12-01 Thread Wolfgang Laun
A sliding window requires the use of STREAM mode, and you must use a
session clock, pseudo or real-time.

I'm also a worried about size==80; shouldn't you use size = 80?
But this depends on the way you run the session; are you doing this
with fireUntilHalt in a separate thread?

It shouldn't be a problem if the session is run with a real-time clock and
delayed events (with the timestamp in the data, as you apparently have)
arrive and are inserted. Docs say that that this is OK, as long as events
are inserted in each entry-point in chronological order. If there are
different streams, each with individual delays, you may have to use
multiple entry-points.


On 1 December 2010 16:10, Anais Martinez amarti...@iti.upv.es wrote:


 Hello. I have two questions about collect and sliding windows. I have
 created
 this rule:

 rule Active risk
 when
  $n:Node()
  $readings: ArrayList(size==80)  from collect(
   Reading( nodeID == $n.nodeID,
(signalType == SignalType.PLUVIOSITY  value = 10)||
(signalType == SignalType.AIR_TEMPERATURE  value=12)
   ) over window:time(10h))
 then
  System.out.println(Active risk in node + $n.getNodeID());
 end

 And the declarations are the following (Reading and Node are java classes):

 declare Reading
@role(event)
@timestamp (timestamp)
 end

 declare Node
@role(fact)
 end


 Well, I have probe the rule. I have inserted 100 readings which satisfy the
 conditions, in a single time but with different timestamp (I have simulated
 that there are a pluviosity reading and a air_temperature reading each 15
 minutes), that is, in main:

 long init= 129072960L;
 long interval = 1000*60*15;
 for (int i=0; i100; i++){
long fecha = init+i*interval;
Reading r1 = new Reading(SignalType.PLUVIOSITY, value1, node);
session.insert(r1);

Reading r2 = new Reading(SignalType.AIR_TEMPERATURE, value1, node);
session.insert(r2);
 }

 The message is not written (I have fired rules after insertions).

 My questions:
 Has drools any problem if I inserted all readings at same time? (Do I have
 to use the pseudo-clock?)
 My problem is that the readings will be sent from a server in real system,
 and it's possible that the server will send all readings belonging to an
 interval of one/two hour/s at same time.

 Thanks.

 --
 View this message in context:
 http://drools-java-rules-engine.46999.n3.nabble.com/Question-about-collect-and-sliding-windows-tp1999562p1999562.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

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


Re: [rules-users] Question about collect and sliding windows

2010-12-01 Thread Wolfgang Laun
On 1 December 2010 17:19, Anais Martinez amarti...@iti.upv.es wrote:


  What does your thread do after it returns from fireAllRules?

 My thread sleeps five minutes and then it fires again: (intervalLength =
 5*60*1000):


You might as well let the Engine sleep, waiting for news.

If you turn it on, every now and then, you'll get all sorts of delays. Say,
an event arrives 1ms after you've returned from an unsuccessful
fireAllRules()
(there's no fireRules() method, is there?), then you won't get any
reaction
until next time round, i.e., 5 minutes later. This may not be as expected.

Regards
-W



 @Override
public void run(){

while(!end){
try {
Thread.sleep(intervalLength);
int nRules = ksession.fireRules();
if(nRules  0){
logger.debug(nRules +  reglas disparadas.);
}
}
catch (InterruptedException e) {
logger.error(e);
}

}

}

 Well, if the events arrive on schedule it should be OK, but what about the
 delayed arrivals?

 Ah, ok...

 Thank you, again.


 --
 View this message in context:
 http://drools-java-rules-engine.46999.n3.nabble.com/Question-about-collect-and-sliding-windows-tp1999562p277.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

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