StatefulKnowledgeSession: thread-safe
by Wolfgang Laun
(I don't want to confuse things by adding to the recent thread on the
user list. And I do hope that I got this right. Please read carefully
and correct me. Thanks.)
The statement "StatefulKnowledgeSession is thread-safe" must be
annotated with caveats so that users don't overload this basically
simple statement with meaning that isn't logically implied by it.
StatefulKnowledgeSession is thread-safe means that any two threads
cannot interact in such a way that it would corrupt data protected by
the implementing object. It does not mean that all code executed on
behalf of the data maintained by a Stateful Knowledge Session object
is thread-safe. In particular, the execution of a consequence is not a
critical section from the session's point of view.
The existence of an activation implies that the LHS conditions are
true for the objects playing a part. As soon as one thread begins
actions based on these preconditions and is on its way to modifying
one or more facts, any other thread doing likewise with any of the
participating objects in this or another RHS is running into a race
condition.
If a consequence execution is a critical section for some application
object, it is the user's responsibility to achieve proper
synchronisation, either for entire consequences or for individual fact
objects.
-W
12 years, 8 months
Drools Grid - Request for Feedback/Comments
by Mauricio Salatino
Hi All,
I'm writing this email to request some comments/feedback about Drools Grid.
The project is highly experimental and I was playing with it for some
time now. We are using it in a project where its doing its job and
it's quite decent. There are some aspects of the project that can be
improved and that's the main reason why I'm writing this email.
Because this project is experimental I would like to know the future
direction of it. If there are other alternative to the features
proposed by grid I'm OK with working on the new approaches to achieve
the same results.
For the ones that doesn't know what is inside grid let me list some of
its features:
* It provides an API based on GridNodes that allows us to represent
a box that can host our knowledge sessions and a set of services
* It provides all the Session Virtualization APIs and internal
mechanisms that allows us to instantiate remote sessions in remote
machines/jvms
* It provides some experimental components like: WhitePages and Schedulers
I'm OK with changing the APIs and how the components are linked
together, but in this occasion I'm worried about the Session
Virtualization features. The session virtualization layer right now is
tied to Mina and the code that is used to make everything works
remotely is getting bigger and bigger. Most of the code inside these
features can be improved and it's not perfect but it's getting
complete, at least for the use case where I'm working for, that it's
quite extensive.
Can we reuse this code or at least some bit of it for the simulation
framework remoting stuff? If we can't I would like to be sure that at
least with the simulation framework we will be able to achieve the
same results in some way or another.
I can also spend some time to provide different transports for the
ones that are afraid of Mina, that's not a problem. What I would like
to see is that we are working on all the components that we need to
compose a knowledge grid and then write the APIs that fits to the
practical use cases.
I'm right now cleaning some improvements and fixes that will make grid
compile again inside the master. I can keep that code updated and be
responsible for it or I can start working in a different alternative
that has more probabilities of survive.
Any comments/feedback?
--
- CTO @ http://www.plugtree.com
- MyJourney @ http://salaboy.wordpress.com
- Co-Founder @ http://www.jugargentina.org
- Co-Founder @ http://www.jbug.com.ar
- Salatino "Salaboy" Mauricio -
12 years, 8 months
Order of retraction matters
by Wolfgang Laun
5.3.0 Final.
KnowledgeBase using STREAM, running a stateful session in one thread,
inserting events from another fact.
class Event{ String name; }
class Monitor{ Event event; String name; }
rule "start monitoring"
when
$e: Event($name: name)
not Monitor( name == $name )
then
insert( new Monitor( $e, $name ) );
end
rule "timeout"
timer( int: 10s )
when
$m: Monitor( name == $name )
$e: Event($name: name)
then
retract( $m ); // =======================
retract( $m.getEvent() ); // ========================
end
This order of retracts results in a NPE, see the dump below.
Reversing these two works correctly.
Exception in thread "main" Exception executing consequence for rule "start
monitoring" in hashcode: java.lang.NullPointerException
at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1101)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1029)
at org.drools.common.DefaultAgenda.fireUntilHalt(DefaultAgenda.java:1229)
at
org.drools.common.AbstractWorkingMemory.fireUntilHalt(AbstractWorkingMemory.java:753)
at
org.drools.common.AbstractWorkingMemory.fireUntilHalt(AbstractWorkingMemory.java:729)
at
org.drools.impl.StatefulKnowledgeSessionImpl.fireUntilHalt(StatefulKnowledgeSessionImpl.java:234)
at hashcode.Main.execute(Main.java:148)
at hashcode.Main.main(Main.java:206)
Caused by: java.lang.NullPointerException
at org.drools.base.hashcode.StateEvent42211789$getItemName.getValue(Unknown
Source)
at org.drools.base.ClassFieldReader.getValue(ClassFieldReader.java:87)
at org.drools.rule.Declaration.getValue(Declaration.java:219)
at hashcode.Rule_start_monitoringDefaultConsequenceInvoker.evaluate(Unknown
Source)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1091)
... 7 more
12 years, 8 months
Re: [rules-dev] 5.3.0 NoClassDefFound due to nested property access
by Wolfgang Laun
Yes? No? Don't know? None of the previous?
On 8 February 2012 11:43, Wolfgang Laun <wolfgang.laun(a)gmail.com> wrote:
> 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)
>
12 years, 8 months
Project Idea - pure HTML5 Audit log
by Mark Proctor
I was just making a swing app, for Wumpups, and thought it would be
really nice if I could embed the audit log that would render in the
example as it was executing. I can't re-use the existing stuff, as it's
SWT based.
So I thought a nice project for someone would be to make an
HTML5/Javascript version of the Eclipse graphical audit log. It should
be able to take json document and render an audit log correctly. This
component can then be re-used by people anywhere, we can even move the
SWT version over to the HTML5 version in eclipse, so that we only have a
single version to maintain.
In theory it's not too difficult, we don't need any fancy canvas stuff.
Just indent lines and use background coloured spans for highlighting.
The hardest part of the project is probably getting the current xstream
document dumped to a sane json format. Luckily xstream already has json
capabilities, so maybe not too hard.
Any takers?
Mark
12 years, 8 months
Re: [rules-dev] [rules-users] Need Camel + drools (OSGI) integration help
by Mark Proctor
neither spring or camel have been OSGi-ified. only api, core, compiler,
templates, decision-tables and flow have.
If someone wants to OSGi-ify those and contribute back they are very
welcome:
1) update the pom.xml to use the osgi bundle plugin, see other existing
poms.
https://github.com/droolsjbpm/drools/blob/master/drools-decisiontables/po...
2) create an Activator to register the module, again see Activator's for
core, compiler etc.
https://github.com/droolsjbpm/drools/blob/master/drools-decisiontables/sr...
3) update the osgi bundle's pom with new dependencies, make sure to pull
in the spring ones, unless the actual project provides osgi ready jars.
https://github.com/droolsjbpm/droolsjbpm-build-distribution/tree/master/d...
4) Update the boot-bundles.properties so that Spring DM loads the OSGi
dependencies
https://github.com/droolsjbpm/droolsjbpm-build-distribution/blob/master/d...
5) write unit tests for spring and camel.
Mark
On 03/02/2012 03:47, Alexander Filipchik wrote:
> Hello all!
>
> Don't know if it is right list to ask, but I'm trying to make drools +
> camel running on Fuse (ServiceMix container).
> I couldn't even install OSGI drools artifacts for 5.3.1 version
> (because of weird dependency on drools.core Snapshot),
> but did it with v5.2.1. I used:
>
> mvel2/2.1.0,
> org.drools/drools-core/5.2.1.Final, org.drools/drools-compiler/5.2.1.Final,
> org.drools/knowledge-api/5.2.1.Final
> and org.drools/drools-camel/5.2.1.Final.
>
> All are installed and active. Part of log:
>
> [ 162] [Active ] [ ] [ ] [ 60] Drools ::
> Compiler (5.2.1.Final)
>
> [ 163] [Active ] [ ] [ ] [ 60] mvel2
> (2.1.0.drools4)
>
> [ 164] [Active ] [ ] [ ] [ 60] Drools :: Core
> (5.2.1.Final)
>
> [ 165] [Active ] [ ] [ ] [ 60] Knowledge API
> (5.2.1.Final)
>
> [ 172] [Active ] [ ] [ ] [ 60]
> mvn:org.drools/drools-camel/5.2.1.Final
>
> Then I tried to add my own camel-drools router (I created OSGI bundle
> for it). It depends on:
>
> Import-Package:
> org.apache.activemq,org.apache.activemq.camel.component,org.apache.activemq.pool,org.apache.camel;version="[2.8,3)",org.apache.camel.builder;version="[2.8,3)",org.apache.camel.component.jms;version="[2.8,3)",org.apache.camel.model;version="[2.8,3)",org.drools.camel.component,org.osgi.service.blueprint;version="[1.0.0,2.0.0)",org.springframework.transaction;version="[3,4)"
>
> It tried to install it to a container but all I got -
>
> Error executing command: Unresolved constraint in bundle
> com.betfair.drools [170]: Unable to resolve 170.0: missing requirement
> [170.0] package; (package=org.drools.camel.component)
>
> I even tried to put drools-camel.jar with org.drools.camel.component
> in a lib folder and add package to
> org.osgi.framework.system.packages.extra, but got same result.
>
> Do you have any idea, blog posts, samples which could help me?
> I'm completely stuck.
>
> Thanks,
> Alex
>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
12 years, 8 months