Testing for global variable
by Chris Selwyn
Is there a way to test for the existence of a global variable in a StatelessKnowledgeSession before inserting a SetGlobal command into a BatchExecutionCommand?
I am trying to write a rules executor class that may execute some rulesets that need a particular global variable and some that don't.
So I would like to be able to automatically test whether the rules that I am about to execute have the global variable and if they do not then not to insert the SetGlobal into the batch.
I am using DRools 5.1
Chris Selwyn
14 years, 2 months
5.3.0 NoClassDefFound due to nested property access
by Wolfgang Laun
Is this already known and fixed in 5.4.0? The problem occurs when you
have, e.g.,
Fact( foo.bar == "baz" )
Stack dump:
Exception in thread "main" java.lang.NoClassDefFoundError: monitor/Monitor
at ASMAccessorImpl_114212541328697624590.getValue(Unknown Source)
at org.mvel2.optimizers.dynamic.DynamicGetAccessor.getValue(DynamicGetAccessor.java:73)
at org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:106)
at org.mvel2.compiler.ExecutableAccessor.getValue(ExecutableAccessor.java:42)
at org.mvel2.MVEL.executeExpression(MVEL.java:954)
at org.drools.base.extractors.MVELClassFieldReader.getValue(MVELClassFieldReader.java:100)
at org.drools.base.extractors.BaseObjectClassFieldReader.isNullValue(BaseObjectClassFieldReader.java:179)
at org.drools.rule.VariableRestriction$ObjectVariableContextEntry.updateFromFactHandle(VariableRestriction.java:338)
at org.drools.common.SingleBetaConstraints.updateFromFactHandle(SingleBetaConstraints.java:118)
at org.drools.reteoo.NotNode.modifyRightTuple(NotNode.java:339)
at org.drools.reteoo.BetaNode.modifyObject(BetaNode.java:431)
at org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateModifyObject(CompositeObjectSinkAdapter.java:468)
at org.drools.reteoo.CompositeObjectSinkAdapter.propagateModifyObject(CompositeObjectSinkAdapter.java:436)
at org.drools.reteoo.ObjectTypeNode.modifyObject(ObjectTypeNode.java:288)
at org.drools.reteoo.EntryPointNode.modifyObject(EntryPointNode.java:271)
at org.drools.common.NamedEntryPoint.update(NamedEntryPoint.java:459)
at org.drools.common.NamedEntryPoint.update(NamedEntryPoint.java:363)
at org.drools.base.DefaultKnowledgeHelper.update(DefaultKnowledgeHelper.java:298)
at monitor.Rule_stop_monitoring.defaultConsequence(Rule_stop_monitoring.java:8)
at monitor.Rule_stop_monitoringDefaultConsequenceInvoker.evaluate(Unknown
Source)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1091)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1029)
at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1251)
at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:708)
at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:672)
at org.drools.common.Scheduler$ActivationTimerJob.execute(Scheduler.java:90)
at org.drools.time.impl.DefaultTimerJobInstance.call(DefaultTimerJobInstance.java:46)
at org.drools.time.impl.DefaultTimerJobInstance.call(DefaultTimerJobInstance.java:13)
at org.drools.time.impl.PseudoClockScheduler.runCallBacks(PseudoClockScheduler.java:203)
at org.drools.time.impl.PseudoClockScheduler.advanceTime(PseudoClockScheduler.java:156)
14 years, 2 months
Multiple threading
by Apache
Hey,
I am trying to get multiple threads to insert events and run rules against the union of events inserted ( an as soon as they are inserted, a timer drools thread kicking of fireallrules() is not an option because that would introduce a delay ) and wanted some opinion on the following:
1. Stateless session is basically a wrapper around statefulsession and since per doc statefulsession is not threadsafe is it safe to assume 2 threads cannot insert and run fireallrules to compare against a union of objects inserted by multiple threads without some synchronication on event insertion and ESP fireallrulesrules ? ( would the answer still hold despite a drools-camel endpoint reading and storing exchanges from multiple threads ? )
2. If in the above point we simplify the case where the rule uses the "from" keyword and reads from a cache or a Db ( is reading from
A cache supported out of the box ? ) then will drools bhaviour will be bound by the thread which invokes fireallrules() ?
14 years, 2 months
MVEL strict-mode vs. performance
by womuji
Hi,
We are upgrading from Drools 5.1 to 5.3 to improve the performance, but we
are hoping to keep our drl files intact. We were trying to use the old drl
files by setting "drools.dialect.mvel.strict=false", but somehow with this
setting we still got " unable to resolve method using strict-mode .." error
from time to time.
I'm wondering if there is any correlation between this strict-mode and the
performance gain, if in order to achieve the performance gain, we have to
set the strict-mode to true, then we will make changes to our drl files,
instead of spending time to figure out why the effect of
"drools.dialect.mvel.strict=false" is sporadic.
Thanks.
--
View this message in context: http://drools.46999.n3.nabble.com/MVEL-strict-mode-vs-performance-tp37418...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 2 months
Re: [rules-users] rules-users Digest, Vol 63, Issue 60
by Shur, Bob
I don't understand either of these answers. All of the facts are in a list of facts passed into ksession.execute, like this:
final StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession();
List<Object> facts = createPosts();
if (facts.size() == 0) break;
long t0 = System.currentTimeMillis()/100;
ksession.execute(facts);
long t1 = System.currentTimeMillis()/100;
System.out.println("Elapsed time: " + (t1 - t0));
There are no more facts getting created during rules processing. The whole drl file is:
rule "collect"
when
$a : ArrayList(size > 0) from collect(Post());
then
System.out.println("Number of posts: " + $a.size());
System.out.println("DONE");
end
Why is the collect happening more than once? Actually I don't think it is, else I would be seeing more than one printout.
I agree that I could probably find a way to do without the list, but I would still like to understand why this is n-squared. I was actually planning to explore the performance of various ways to compute the minimum of a large number of objects. I was surprised to find that I was already up to n-squared just creating the list.
> ------------------------------
>
> Message: 3
> Date: Mon, 13 Feb 2012 20:59:20 +0100
> From: Wolfgang Laun <wolfgang.laun(a)gmail.com>
> Subject: Re: [rules-users] Performance of collect seems to be
> n-squared
> To: Rules Users List <rules-users(a)lists.jboss.org>
> Message-ID:
> <CANaj1LeAnD-
> kYngQqTzo1XoOh4V8tnqo5A+9CkVR6xPmK4gxMA(a)mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Repeatedly creating this ArrayList is bound to be O(n2).
>
> Why do you want the Post facts as a List? There may be better ways for
> achieving your goal.
>
> -W
>
>
> On 13 February 2012 20:49, Shur, Bob <robert.shur(a)hp.com> wrote:
>
> > I have a simple class Post { int id; ... }. I insert some number of
> them
> > as facts and then call ksession.execute(facts);
> >
> > The whole drl file (except for package and import statements) is:
> >
> > rule "collect"
> > when
> > $a : ArrayList(size > 0) from collect(Post());
> > then
> > System.out.println("Number of posts: " + $a.size());
> > System.out.println("DONE");
> > end
> >
> > The time it takes to run is n-squared in the number of posts. For
> 4000,
> > 8000, 16000, 32000, 64000 posts the time is (in 1/10 seconds):
> >
> > 4, 14, 56, 220, 852
> >
> > Is this expected? Is there a better way for me to do the collect?
> >
> >
> > _______________________________________________
> > rules-users mailing list
> > rules-users(a)lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
>
14 years, 2 months
Performance of collect seems to be n-squared
by Shur, Bob
I have a simple class Post { int id; ... }. I insert some number of them as facts and then call ksession.execute(facts);
The whole drl file (except for package and import statements) is:
rule "collect"
when
$a : ArrayList(size > 0) from collect(Post());
then
System.out.println("Number of posts: " + $a.size());
System.out.println("DONE");
end
The time it takes to run is n-squared in the number of posts. For 4000, 8000, 16000, 32000, 64000 posts the time is (in 1/10 seconds):
4, 14, 56, 220, 852
Is this expected? Is there a better way for me to do the collect?
14 years, 2 months
Re: [rules-users] Error running Drools 5.0 HelloWorldExample on WebSphere 6.1
by Blythe, Marshall
A quick follow-up: this error occurs only when I have rules using the MVEL dialect. I rewrote the MVEL rule in the HelloWorld.drl to use the Java dialect, and now the problem is gone. I may need to raise this issue on the MVEL mailing list instead.
----------------------------------------- This e-mail and any attachments may contain CONFIDENTIAL information, including PROTECTED HEALTH INFORMATION. If you are not the intended recipient, any use or disclosure of this information is STRICTLY PROHIBITED; you are requested to delete this e-mail and any attachments, notify the sender immediately, and notify the LabCorp Privacy Officer at privacyofficer(a)labcorp.com or call (877) 23-HIPAA.
14 years, 2 months