How work the sliding windows?
by linolia83
Hi all, I’m trying to build the example 2.14 in Drools Fusion at follow
link:
http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-fusion/ht...
two notes:
• Important: Sliding Windows are only available when running the engine in
STREAM mod (paragraph 2.6 – Sliding window )
• Drools generalized the concept of a stream as an "entry point" into the
engine. An entry point is for drools a gate from which facts come. The facts
may be regular facts or special facts like events. (paragraph 2.3 - Stream
support )
1) Presupposing that the SensorReading object is an event, why in order to
develop the example 2.14 the SensorReading object it didn’t use a
entrypoint? I have developed it in this way:
my regoleStream.drl file rule:
declare SensorReading
@role( event )
@timestamp ( timestamp )
@duration ( timeduration )
end
rule "Alarm"
when
TemperatureThreshold( $max : max )
$lettore: SensorReading( ) from entry-point "entry"
$media: Number( doubleValue >= $max ) from accumulate(
SensorReading( $temp : temperature )
over window:time( 5s ) from entry-point "entry" ,
average( $temp ) )
then
System.err.println("Temp media: " + $media);
end
I have defined my class SensorReading.java and Sensor.java
public class SensorReading {
private double temperature;
private long timestamp;
private long timeduration;
// constructor, getters, setters...
}
public class Sensor {
private Random random = new Random();
public double nextReading() {
return (20.5 + random.nextGaussian());
}
}
my class: DroolsTest is defined in STREAM MODE and PSEUDO CLOCK SESSION
configuration
(see the file DroolsTest.java)
http://www.nabble.com/file/p24406682/exampleSensorReading.zip
exampleSensorReading.zip
I have another question: using the accumulated function in order to
calculate the average, I must use update or an insert for a new reading? in
other words:
entrypoint.update( eventhandle, reading ); or
entrypoint.insert(reading);
Using the statement insert my output it is:
Tempo: 0s T: 21.799588922737122
Temp media: 21.799588922737122
Tempo: 1s T: 22.88313013240042
Temp media: 22.88313013240042
Temp media: 22.34135952756877
Tempo: 2s T: 21.421353538299165
Temp media: 21.42135353829916
Temp media: 22.395871267700002
Temp media: 22.034690864478904
Tempo: 3s T: 19.458193737965093
Temp media: 20.930563588215644
Temp media: 21.661451885266274
Temp media: 21.39056658285045
Tempo: 4s T: 20.8832973982136
Temp media: 20.8832973982136
Temp media: 20.921110350215237
Temp media: 21.50582098785574
Temp media: 21.28911274592308
Tempo: 5s T: 19.97430560962051
Tempo: 6s T: 20.518826117217664
Temp media: 20.518826117217664
Temp media: 20.518826117217664
Temp media: 20.518826117217664
Temp media: 20.51882611721767
Temp media: 20.51882611721765
Temp media: 20.51882611721766
Temp media: 20.518826117217674
Tempo: 7s T: 19.189461637685618
Tempo: 8s T: 19.187724324701474
Tempo: 9s T: 18.158118482083236
Tempo: 10s T: 20.587196329519568
Using the statement update my output it is:
Tempo: 0s T: 20.688079808657893
Temp media: 20.688079808657893
Tempo: 1s T: 21.369835728163952
Temp media: 21.369835728163952
Tempo: 2s T: 21.975416358939214
Temp media: 21.975416358939214
Tempo: 3s T: 21.6785090963422
Temp media: 21.6785090963422
Tempo: 4s T: 19.93979461762877
Tempo: 5s T: 20.355758074646886
Temp media: 20.355758074646886
Tempo: 6s T: 21.76122923383071
Temp media: 21.76122923383071
The output that I would wish to obtain (after 5 sec) is the following one:
Tempo: 0s T: 21.799588922737122
Tempo: 1s T: 22.88313013240042
Tempo: 2s T: 21.421353538299165
Tempo: 3s T: 19.458193737965093
Tempo: 4s T: 20.8832973982136
Tempo: 5s T: 19.97430560962051
Temp media: 21.xxxxxxx (fire only if avg is > 20)
You thoughts that my error has had:
A) I use in wrong way the API, in phase of configuration of rule the engine
B) is an logical error of my rule
C) I mistake me and the sliding windows they can’t be used as I would wish
--
View this message in context: http://www.nabble.com/How-work-the-sliding-windows--tp24406682p24406682.html
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 8 months
Re: Unable to load dialect 'org.drools.rule.builder.dialect.java.JavaDialectConfiguration: (Pradeep Ruhil)
by Pardeep.Ruhil@lntinfotech.com
Hi,
Thanks Mark for answering my query.
Now I have set all the jars file in the classpath, but still m getting the
same exception.
The exception is caused by : Null pointer exception.
I am not able to understand why it is giving me this exception, while in
the mailing list I didn't found anybody having this
problem.
This is my code snippet :
KnowledgeBuilderConfiguration config = KnowledgeBuilderFactory.
newKnowledgeBuilderConfiguration();
config.setProperty("drools.dialect.java.compiler", "ECLIPSE");
KnowledgeBuilder kbuilder =KnowledgeBuilderFactory.newKnowledgeBuilder(
config );
//KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource(
"shopingdiscount.drl"), ResourceType.DRL);
Am I missing anything that is to initialized , so that I can get through
this Null Pointer Exception.
Please help me to through of this situation. I am stuck in this.
Thanks & Regards
Pardeep Ruhil
______________________________________________________________________
16 years, 8 months
Re: Unable to load dialect 'org.drools.rule.builder.dialect.java.JavaDialectConfiguration:
by Pardeep.Ruhil@lntinfotech.com
Thanks Mark for answering my query.
Now I have set all the jars file in the classpath, but still m getting the
same exception.
The exception is caused by : Null pointer exception.
I am not able to understand why it is giving me this exception, while in
the mailing list I didn't found anybody having this
problem.
This is my code snippet :
KnowledgeBuilderConfiguration config = KnowledgeBuilderFactory.
newKnowledgeBuilderConfiguration();
config.setProperty("drools.dialect.java.compiler", "ECLIPSE");
KnowledgeBuilder kbuilder =KnowledgeBuilderFactory.newKnowledgeBuilder(
config );
//KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource(
"shopingdiscount.drl"), ResourceType.DRL);
Am I missing anything that is to initialized , so that I can get through
this Null Pointer Exception.
Please help me to through of this situation. I am stuck in this.
Thanks & Regards
Pardeep Ruhil
______________________________________________________________________
16 years, 8 months
How to call a another drl file from one drl file
by Amila Silva
hi,
I have requirement to execute a chain of rules. One rule after another
and they are reusable.I need to know how to call another drl file from a drl
file. or in a then part of the
a rule.
thanks
Amila Silva
16 years, 8 months
Persistence and mina human task handling
by Balázs Molnár
Hello,
I tried to setup a sample standalone "hello" application that attempts to
run a process involving human tasks.
Main components were:
- mina task server (as documentation hinted, based on a sample),
- standalone "hello sort of" application running a ruleflow with some
workitems including a human task too,
- eclipse human task view.
I setup the persistence - following the documentation, asked for a jta
datasource and used bitronix transaction manager.
The application:
- begins a new user transaction
- creates a new process instance in a stateful session
- calls fireallrules
- waits on the console with System.in.read() (this was already a workaround
to avoid completing the user transaction before the human task is handled in
the HT view, this otherwise caused a nullpointer assigment at line 83 in
JPAWorkItemManager which tried to refer to variable "em" which when set
returned null for the following assignment if usertransaction were
committed:
EntityManager em = (EntityManager) this.workingMemory.getEnvironment().get(
EnvironmentName.ENTITY_MANAGER );)
... following the above the message reaches the human task server, and then
the task appears in the human task view - so far so good.
Then when the task is started and completed in the view, the
"GetCompletedTaskResponseHandler.execute()" begins handling the completed
message. Unfortunately this call fails with :
" no transaction started on this thread"
I have then checked the threads in the debug view and looked like the
message response is actually running in the "NioProcessor" thread. At this
point I got stuck. If there is some guideance on how to correctly setup
transaction management and Mina task client/human task work item handler it
would be very much appreciated.
thank you.
16 years, 8 months
Unable to load dialect 'org.drools.rule.builder.dialect.java.JavaDialectConfiguration:
by Pardeep.Ruhil@lntinfotech.com
Hi,
I am newbie to drools. I am facing the below exception when I m trying to
run my code through
Command Prompt.
I have set the all the jars in the xbootclasspath of my application , but
still I am getting the same exception.
I am able to run my application in eclipse , but the same when i run from
Command Prompt give me this exception.
Please help to get through the situation.
My exception is :
org.drools.RuntimeDroolsException: Unable to load dialect
'org.drools.rule.builder.dialect.java.JavaDialectConfiguration:java
:org.drools.rule.builder.dialect.java.JavaDialectConfiguration'
at
org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:274)
at
org.drools.compiler.PackageBuilderConfiguration.buildDialectConfigurationMap(PackageBuilderConfiguration.java:259)
at
org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConfiguration.java:176)
at
org.drools.compiler.PackageBuilderConfiguration.<init>(PackageBuilderConfiguration.java:153)
at
org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:242)
.
.
.
Caused by: java.lang.NullPointerException
at
org.drools.rule.builder.dialect.java.JavaDialectConfiguration.setCompiler(JavaDialectConfiguration.java:92)
at
org.drools.rule.builder.dialect.java.JavaDialectConfiguration.init(JavaDialectConfiguration.java:55)
at
org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:270)
Thanks & Regards
Pardeep Ruhil
L&T Infotech Ltd
Mumbai
Ph: +919820283884
Larsen & Toubro Infotech Ltd.
www.Lntinfotech.com
This Document is classified as:
L&T Infotech Proprietary L&T Infotech Confidential L&T Infotech
Internal Use Only L&T Infotech General Business
This Email may contain confidential or privileged information for the
intended recipient (s) If you are not the intended recipient, please do
not use or disseminate the information, notify the sender and delete it
from your system.
______________________________________________________________________
16 years, 8 months