Re: [rules-users] Is protobuf cache actually used?

2014-07-08 Thread Edson Tirelli
   It is a bit convoluted, indeed, but AFAIK, it is using the cache
and working fine. The cache is populated here:

https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/main/java/org/drools/compiler/kie/builder/impl/AbstractKieModule.java#L301

   It is set here:

https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/main/java/org/drools/compiler/kie/builder/impl/AbstractKieModule.java#L180

   And we have some tests here:

https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/compiler/integrationtests/KieCompilationCacheTest.java


   Edson

On Mon, Jul 7, 2014 at 7:01 PM, Federico Bertola
federico.bertol...@gmail.com wrote:
 Hi Edson,
 yes I saw that the JavaDialect class retrieve the compilation cache from
 the conf, but after a quick search it seems no one use the
 setCompilationCache method of KnowledgeBuilderConfigurationImpl, not
 even in the tests. So I was wondering what was the best way to use it...

 Maybe I get something wrong, in that case, I apologize :)

 Federico.

 On 07/07/2014 21:04, Edson Tirelli wrote:
 Federico,

 Not sure why you say it is not used?

 Drools tries to use any pre-compiled resource bytecode if it is
 available in the cache. If it is not available, it falls back to JIT
 compilation:

 https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/main/java/org/drools/compiler/rule/builder/dialect/java/JavaDialect.java#L627

 Edson

 On Sat, Jul 5, 2014 at 11:34 AM, Federico Bertola
 federico.bertol...@gmail.com wrote:
 Hi,
 from what I see, the protobuf cache that the KnowledgeBuilder produce
 and saves as *.cache, is not currently used anywhere, right? If so, what
 would it be required to reload the compilation data inside the
 KnowledgeBuilder? There's something I'm missing or there is some piece
 of code demonstrating this capability?

 Best regards,
 Federico.
 ___
 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



-- 
  Edson Tirelli
  Principal Software Engineer
  Red Hat Business Systems and Intelligence Group
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Is protobuf cache actually used?

2014-07-07 Thread Edson Tirelli
Federico,

Not sure why you say it is not used?

Drools tries to use any pre-compiled resource bytecode if it is
available in the cache. If it is not available, it falls back to JIT
compilation:

https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/main/java/org/drools/compiler/rule/builder/dialect/java/JavaDialect.java#L627

Edson

On Sat, Jul 5, 2014 at 11:34 AM, Federico Bertola
federico.bertol...@gmail.com wrote:
 Hi,
 from what I see, the protobuf cache that the KnowledgeBuilder produce
 and saves as *.cache, is not currently used anywhere, right? If so, what
 would it be required to reload the compilation data inside the
 KnowledgeBuilder? There's something I'm missing or there is some piece
 of code demonstrating this capability?

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



-- 
  Edson Tirelli
  Principal Software Engineer
  Red Hat Business Systems and Intelligence Group
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] how to create kbases with useful names for JMX

2014-05-28 Thread Edson Tirelli
   Christopher,

   Thanks for reporting this. The public API does not currently allows
users to set the ID of the KieBase unfortunately. I will fix this for
6.1. With 6.0, it is only possible to do it using the internal APIs.

   Edson



On Tue, May 27, 2014 at 4:37 PM, cjohns13
christopher.johns...@netboss.com wrote:
 How can I create new container / knowledgebases so that the names as shown in
 JMX are not random UUID() strings?

 Something like this currently:
 KieContainer container =
 KieServices.Factory.get().newKieContainer(releaseId);
 container.newKieSession(myName);

 When you enable mbeans via Kie.mbeans.enabled=true

 Yields, in JMX:

 objectName: org.drools.kbases:type=2d4ffdab-2aca-4d5d-8c44-a5031c4d4094

 but, would rather have it be
 org.drools.kbases:type=myName

 How can I create the container/kbase/session so it gets a good name, as it
 stands now?  I can see in KnowledgeBaseFactoryServiceImpl.java that there is
 a way to set this kbaseId, but can't figure out a way to actually set this
 at the high level.




 --
 View this message in context: 
 http://drools.46999.n3.nabble.com/how-to-create-kbases-with-useful-names-for-JMX-tp4029719.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users



-- 
  Edson Tirelli
  Principal Software Engineer
  Red Hat Business Systems and Intelligence Group
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Drools spawning a lot of JIT threads

2014-04-28 Thread Edson Tirelli
Frank,

Can I ask you please to open a ticket for this? Feel free to submit a
pull request if you have a solution already, or we will do it
ourselves. I think we should set a reasonable limit for the thread
pool size and optionally allow the user to configure it.

Thanks,
Edson

On Mon, Apr 28, 2014 at 9:49 AM, Frank Pavageau
frank.pavag...@gmail.com wrote:
 Hi.

 I'm using Drools 5.5 in a web application, upgraded a few months ago from
 5.1. When starting multiple instances of the application on a server *at the
 same time*, I recently noticed some problems with the JVMs complaining of
 not being able to create native threads.

 The stack trace led to Drools, and more specifically MvelConstraint
 submitting JIT tasks to an Executor through its jitEvaluator() method. The
 Executor is created by ExecutorProviderImpl and is a basic CachedThreadPool,
 which means it can create an unbounded number of threads (which then die
 after idling for a minute). In my case, it apparently meant around 900
 threads per JVM, which multiplied by the number of running JVMs saturated
 the OS for a short while.

 Has anyone else been bitten by this? Should there be a more reasonable
 default implementation and should I create an issue for this?

 I then have a question related to how I fixed this: I created my own
 implementation of ExecutorProvider by extending ExecutorProviderImpl and
 creating a ThreadPoolExecutor with an upper bound on the number of threads
 and a LinkedBlockingQueue to queue the tasks when all the threads are
 already busy. That works fine, the only problem is telling Drools to use my
 implementation: the only way I've found is by calling
 ServiceRegistryImpl.getInstance().registerLocator(). ServiceRegistryImpl
 implements ServiceRegistry, but the interface doesn't seem to be exposed
 through Drools' more public API; it seems a bit wrong to call the
 implementing class directly to get its instance, especially given the
 Javadoc which states This is an internal class, not for public
 consumption. Am I missing something?

 Regards,
 Frank

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



-- 
  Edson Tirelli
  Principal Software Engineer
  Red Hat Business Systems and Intelligence Group
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Drools 6.x and Custom Operators(Evaluators) and Accumulators - Using them as regular functions?

2014-03-05 Thread Edson Tirelli
   Matt,

   Accumulate functions can now be imported as described in the
documentation:

http://docs.jboss.org/drools/release/6.0.1.Final/drools-docs/html_single/index.html(search
for import accumulate)

   AFAIK, there are no changes on how evaluators are used in Drools 6.0,
but we do want to make them simpler to use, so we might also add an
import-like statement as we did for accumulate functions in the future.

   Edson




On Wed, Mar 5, 2014 at 12:04 PM, mattmadhavan mmadha...@facs.org wrote:

 Hello,
 Recently I read/cam across couple of posts regarding Custom operators and
 Accumulators in Drools 6.x.

 I seems that I can import them as functions and use them directly without
 having to declare them in the configurationBuilder etc.

 Can some on Elaborate on this one please?

 Do I still extend the Evaluator class? Is there any syntax changes?

 Thanks in advance!

 Matt'M




 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Drools-6-x-and-Custom-Operators-Evaluators-and-Accumulators-Using-them-as-regular-functions-tp4028543.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  Principal Software Engineer
  Red Hat Business Systems and Intelligence Group
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Re: [rules-users] @key declarations for a type - What's under the hood?

2014-02-27 Thread Edson Tirelli
There are no fancy hidden things in this bean generator, so your Door
would have an empty constructor and a constructor with two Room parameters:

Door door = new Door( fromRoom, toRoom );

   Edson


On Thu, Feb 27, 2014 at 11:24 AM, Matthew Versaggi
profversa...@gmail.comwrote:

 But what if you now have 2 declare statements in which one defines itself
 in terms of the other ...

 // A room is also a thing
 declare Room extends Thing
 name : String @key
 end

 One would instantiate an object like this:
 Room room = new Room(office);


 // A door is a pathway between two rooms
 declare Door extends Thing
fromRoom : Room @key
toRoom   : Room @key
 end

 How would one instantiate an object of 'Door' ?



 On Wed, Feb 26, 2014 at 5:11 PM, Edson Tirelli ed.tire...@gmail.comwrote:


Drools bytecode generates these beans without generating java source
 code (if you are using the declare, not the data modeller). Having said
 that, it is very simple:

 declare Here
 location: String @key
 end

Generates a java class roughly equivalent to:

 public class Here implements Serializable {
private String location;

public Here() {}

public Here( String location ) {
   this.location = location;
}

public String getLocation() { return location; }
public void setLocation(String location) { this.location = location; }

// generates a toString()

// generates a hashCode()/equals() method that use the location's
 hashcode()/equals()
 }

I did this from memory, but it is pretty much all it does. Nothing
 complex there, just a javabean really.

The difference to not using @key is that the hashCode()/equals()
 methods would not take location in consideration, and in this case, since
 there are no other attributes, would then rely on system identity.

Edson





 On Wed, Feb 26, 2014 at 2:23 PM, profversaggi profversa...@gmail.comwrote:

 I was looking for something along the lines of a method of inspecting the
 resulting code of any arbitrary @key declarations I might want to
 deploy. Is
 there such a way?



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/key-declarations-for-a-type-What-s-under-the-hood-tp4028343p4028346.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




 --
   Edson Tirelli
   Principal Software Engineer
   Red Hat Business Systems and Intelligence Group


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




 --
 #
 Matthew R. Versaggi, President  CEO
 Versaggi Information Systems, Inc.
 Adjunct Professor of eBusiness DePaul University
 Email: mailto:m...@versaggi.com, profversa...@gmail.com
 M: 630-292-8422
 LinkedIn:  http://www.linkedin.com/in/versaggi
 #

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




-- 
  Edson Tirelli
  Principal Software Engineer
  Red Hat Business Systems and Intelligence Group
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Re: [rules-users] @key declarations for a type - What's under the hood?

2014-02-26 Thread Edson Tirelli
   Drools bytecode generates these beans without generating java source
code (if you are using the declare, not the data modeller). Having said
that, it is very simple:

declare Here
location: String @key
end

   Generates a java class roughly equivalent to:

public class Here implements Serializable {
   private String location;

   public Here() {}

   public Here( String location ) {
  this.location = location;
   }

   public String getLocation() { return location; }
   public void setLocation(String location) { this.location = location; }

   // generates a toString()

   // generates a hashCode()/equals() method that use the location's
hashcode()/equals()
}

   I did this from memory, but it is pretty much all it does. Nothing
complex there, just a javabean really.

   The difference to not using @key is that the hashCode()/equals() methods
would not take location in consideration, and in this case, since there
are no other attributes, would then rely on system identity.

   Edson





On Wed, Feb 26, 2014 at 2:23 PM, profversaggi profversa...@gmail.comwrote:

 I was looking for something along the lines of a method of inspecting the
 resulting code of any arbitrary @key declarations I might want to deploy.
 Is
 there such a way?



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/key-declarations-for-a-type-What-s-under-the-hood-tp4028343p4028346.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  Principal Software Engineer
  Red Hat Business Systems and Intelligence Group
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Re: [rules-users] How to declare custom accumulators in kmodule.xml?

2013-12-03 Thread Edson Tirelli
   Alexis,

   This was not exposed in the kmodule and we are discussing the best way
to do it. Ideally, we want to reduce in 6 the complexities of configuration
we had in 5, and for accumulate functions, we are thinking the best would
be to simply support them in imports in the DRL file. So, for instance, to
use a function foo() in a rule, one would do (pseudo code for now):

import function org.bar.FooFunction.foo;

Or a similar construct. Happy to hear your thoughts about this compared
to a module/system wide configuration like we had in 5. We will do this
over the next few days.

Having said that, for those already using accumulate functions and
migrating to Drools 6, the work around until we get this in place is to use
the old way, adding a configuration file to the META-INF directory:

META-INF/drools.packagebuilder.conf

And setting the custom functions in there as properties (e.g.):

drools.accumulate.function.foo = org.bar.FooFunction
..

We will get this sorted out in the next few days, if anyone wants to
contribute their thoughts, it is welcomed.

Edson



On Tue, Dec 3, 2013 at 11:52 AM, abr alexis.brou...@haulogy.net wrote:

 Hello everyone,

 I tried to move from Drools 5.5.0.Final to 6.0.0.Final and I've some issues
 with moving from declaring kbase in Spring to the new kmodule.xml.

 My main concern for the moment is about custom accumulators.
 In the 5.5.0.Final Spring config, I had something like :

 bean id=myAcc
 class=my.namespace.rules.accumulators.MyCustomAccumulator
 /

 drools:kbase id=kb1
   drools:resources
  [...]
   /drools:resources

   drools:configuration
 drools:accumulate-functions
   drools:accumulate-function name=myAcc ref=myAcc /
 [...]
 /drools:accumulate-functions
   /drools:configuration
 /drools:kbase


 I've thoroughly read the 6.0.0.Final documentation and the
 kie-spring-6.0.0.xsd (found here:

 https://github.com/droolsjbpm/droolsjbpm-integration/blob/master/kie-spring/src/main/resources/org/kie/spring/kie-spring-6.0.0.xsd
 )
 but I haven't find a way to declare custom accumulators.

 I also tested my luck by changing all drools: by kie: but with no
 success.

 Would you point me to a working example of declaring custom accumulators in
 6.0.0.Final?

 Thanks in advance.




 --
 View this message in context:
 http://drools.46999.n3.nabble.com/How-to-declare-custom-accumulators-in-kmodule-xml-tp4027073.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  Principal Software Engineer
  Red Hat Business Systems and Intelligence Group
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Re: [rules-users] drools 6 equivalent of addKnowledgePackages

2013-12-03 Thread Edson Tirelli
   There are several different ways of doing it, but here is a snippet to
help creating an in-memory kjar with default kbases and ksessions:


public static byte[] createKJar(KieServices ks,
ReleaseId releaseId,
String pom,
String... drls) {
KieFileSystem kfs = ks.newKieFileSystem();
if( pom != null ) {
kfs.write(pom.xml, pom);
} else {
kfs.generateAndWritePomXML(releaseId);
}
KieResources kr = KieServices.getResources();
for (int i = 0; i  drls.length; i++) {
if (drls[i] != null) {
kfs.write( kr.newByteArrayResource( drls[i].getBytes()
).setSourcePath(my/pkg/drl+i+.drl) );
}
}
KieBuilder kb = ks.newKieBuilder(kfs).buildAll();
if( kb.getResults().hasMessages(
org.kie.api.builder.Message.Level.ERROR ) ) {
for( org.kie.api.builder.Message result :
kb.getResults().getMessages() ) {
System.out.println(result.getText());
}
return null;
}
InternalKieModule kieModule = (InternalKieModule) ks.getRepository()
.getKieModule(releaseId);
byte[] jar = kieModule.getBytes();
return jar;
}

   Please note that you usually don't need the byte[] back, so you can
ignore everything after the last 3 lines of the code. Also, the error check
in the snippet is just printing to sysout. You should handle this
accordingly in your application.

   Hope it helps.

   Edson




On Tue, Dec 3, 2013 at 3:25 AM, pmander paul.s.man...@gmail.com wrote:

 I head previously read that but didn't spot the bit that mentions creating
 from a drl defined as a String. I take it this can be done from
 KieFileSystem.

 String rules = ...
 KieFileSystem kfs = kieServices.newKieFileSystem();
 kfs.write(kieServices.getResources().newReaderResource(new
 StringReader(rules)));

 This throws an exception complaining that the resource doesn't have a
 source
 or target path set.

 Is there a way to push a dynamically created drl into this without writing
 it to disk first?



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/drools-6-equivalent-of-addKnowledgePackages-tp4027044p4027059.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  Principal Software Engineer
  Red Hat Business Systems and Intelligence Group
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Re: [rules-users] replace session clock at runtime

2013-09-30 Thread Edson Tirelli
   Alexander,

   Regarding the clock, to be honest, I think you found a loophole... :)
the original design does not allow switching out clocks on an existing
session as it is impossible for the engine to guarantee consistency in such
case. Additionally, in my experience, real time clocks are usually not the
best choice for production applications. They require less code, but in the
end, the application has no control over the time flow and can create
several situations that will make it impossible for you to obtain the
desired results.

   My suggestion is always to use a pseudo clock and have your application
control it based on your desired behaviour. This can be as simple as a
thread syncing the clock with the machine clock at predefined intervals, or
based on a clock heartbeat event, or based on the streams of events, etc.

   Thanks for pointing out the docs errors. We will update them for the
next release (6.0.0). Also, if you can submit a PR with the update, always
happy to apply.

   Edson


On Mon, Sep 30, 2013 at 9:21 AM, Alexander Wolf m...@alexander-wolf.netwrote:

 [SOLUTION]

 I found a solution/workaround to this problem:
 I create the session with
 JPAKnowledgeService.newStatefulKnowledgeSession() and pseudo clock in
 configuration, feed in my old events - and store the session it a database.
 When retrieving the session, I  can set realtime clock in the
 configuration with JPAKnowledgeService.loadStatefulKnowledgeSession().

 As I am not really interested in storing the sessions, I use an in-memory
 db like in the documentation (3.3.10. Persistence and Transactions)

 @Project Team:
 The documentation (Chapter 3.3.10 / Drools 5.5.0) is really outdated, e.g.
  the package references in persistence.xml are not correct any more .
 Also it seems to be a full example, but missing location of files (where
 to put persistence.xml) and information about general configuration of
 hibernate and bitronix. (I can see why you omitted it, but it would be
 helpful)

 I also don't get why it is impossible to do the same with the
 SerializeMarshallingStrategy - I am pretty sure that the UnMarshaller also
 internally sets a new clock configuration and it would be a great feature,
 if this could be exposed to let developers set their own clock as required.

 Cheers, Alex

 On 25.09.2013, at 06:59, Wolfgang Laun wolfgang.l...@gmail.com wrote:

  Setting the clock is a session configuration option, which means that
  it has to be set at session instantiation time.
 
  You might try to continue to use the pseudo-clock until you have finished
  the replay and mimick the realtime clock with it, although it might need
  some experimenting to learn when and how to advance the pseudo-clock:
  before and/or after insertions, every n ms,...
 
  -W
 
  On 24/09/2013, amarok m...@alexander-wolf.net wrote:
  I am still stuck with this. Is there any way to replay events into a
  session
  and then getting into realtime mode?
 
 
  amarok wrote
  Drools 5.5
 
  Hey guys,
 
  Is it possible to replace the session clock of an existing stateful
  knowledge session (STREAM mode) while it is running or at least by
  pausing
  and restarting it?
  I need to feed old events into the session to restore a certain session
  state before switching the sessions to realtime mode and continue
 with
  new incoming events...
 
  A code snippet would make me very happy ;)
 
  - Alex
  ___
  rules-users mailing list
 
  rules-users@.jboss
 
  https://lists.jboss.org/mailman/listinfo/rules-users
 
 
 
 
 
  --
  View this message in context:
 
 http://drools.46999.n3.nabble.com/rules-users-replace-session-clock-at-runtime-tp4026090p4026112.html
  Sent from the Drools: User forum 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


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




-- 
  Edson Tirelli
  Principal Software Engineer
  Red Hat Business Systems and Intelligence Group
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

[rules-users] Tracking documentation changes

2013-07-25 Thread Edson Tirelli
 As we approach final release, many of us will be working on
documentation. I would like to ask anyone committing changes to docs to use
the BZ-916448 on your commit message to make it easier to track these
commits.

   Thank you

-- 
  Edson Tirelli
  Principal Software Engineer
  Red Hat Business Systems and Intelligence Group
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Re: [rules-users] Benefits of pluggable operators

2013-05-24 Thread Edson Tirelli
   Thomas,

   Pluggable operators were developed much before we supported free form
expressions, but nowadays they can be used for the same purpose. It is then
a matter of preference basically. You can still develop and use pluggable
operators if that makes your rule more readable by hiding complexity
related to parameter passing or something that would be required in a
method call, but I can't think of any advantage or disadvantage in either
approach in terms of performance or cost.

   If I remember correctly, pluggable operators were developed for Drools
4.0, while free form expressions were only fully functional in 5.3+
(limited functionality in 5.2).

   Edson


On Fri, May 24, 2013 at 10:54 AM, Thomas Grayson tgray...@bluemetal.comwrote:

  What are the benefits of using pluggable operators (implementations of
 org.drools.base.evaluators.EvaluatorDefinition such str, matches, or
 before) versus simply making an equivalent function call?  I’ve read the 
 Creating
 pluggable 
 operatorshttp://blog.athico.com/2010/06/creating-pluggable-oprators.htmlblog
  post.  Apart from saying that the Eclipse plugin can recognize these
 operators, it doesn’t really make a case for why I’d want to create my own
 implementation.  One might argue that operators enhance reusability, but a
 static method offers much the same benefit.  Does a pluggable operator have
 any optimization, caching, or other advantage?

 ** **

 For example, here are two ways to match the start of a string in a
 property of a fact, one using  the “str[startsWith]” operator and another
 with Java’s String.startsWith method:

 ** **

 *declare* Fact

 key : String @key

 *end*

 ** **

 *rule* Use operator

 *when*

 Fact(key str[startsWith] abc)

 *then*

 // do something

 *end*

 ** **

 *rule* Use method

 *when*

 Fact(key.startsWith(abc))

 *then*

 // do something

 *end*

 ** **

 Does one of these perform better than the other?

 ** **

 Best wishes,

 Tom

 ** **

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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Re: [rules-users] ArrayIndexOutOfBoundsException in MVELCompilationUnit

2012-11-21 Thread Edson Tirelli
   In any case, the bug you mention was fixed in both 5.3.x and 5.4.x
branches.

   Edson


On Wed, Nov 21, 2012 at 7:37 AM, Stephen Masters stephen.mast...@me.comwrote:

 Actually please ignore. I temporarily upgraded to 5.4 which identified a
 bug in a DSL. With that fixed, I was able to downgraded again.

 Thanks anyway!

 Steve

 Stephen Masters stephen.mast...@me.com wrote:

 Hi folks,
 
 I seem to have come across an issue with hitting an
 ArrayIndexOutOfBoundsException:3 during an insert. It seems to depend on
 how many other facts have already been inserted.
 
 This is on 5.3 Final.
 
 Can anybody give me any pointers on how to diagnose such an issue?
 
 Many thanks
 
 Steve
 ___
 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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Guvnor Declarative Model

2012-09-07 Thread Edson Tirelli
   Ouch, more than 255 fields? As of 5.4.x there is no workaround, the
engine always tries to generate the constructor.

   Can you please open a JIRA and we will fix this for the next release?

   Thank you,
   Edson

On Fri, Sep 7, 2012 at 9:05 AM, JP Chemali jshem...@hotmail.com wrote:

 Hi guys,

 I just stumbled into the same issue in 5.4.0.Final, I think this is caused
 by https://issues.jboss.org/browse/JBRULES-2652
 When declaring a type, a constructor with all fields as parameters is
 generated automatically, but this causes in our case to hit a barrier of
 the
 Java language because the generated constructor has more than 255
 parameters

 Anyone knows if this generation can be skipped (annotation or something
 else), maybe a safeguard not to generate the constructor when the limit is
 reached would be nice too?



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Guvnor-Declarative-Model-tp4019419p4019637.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Job Opportunity - Jboss, Drools, Java Architecht/Consultant

2012-08-30 Thread Edson Tirelli
   Please all, one of the goals of this e-mail list is to connect people
and job offers are a good thing for the community as a whole. Lets not make
an issue out of it.

   Thank you,
   Edson

On Thu, Aug 30, 2012 at 7:08 AM, Vincent LEGENDRE 
vincent.legen...@eurodecision.com wrote:

 But it may be a horse anyway ...
 Let's say Anatolia is this list, and the horse the initial post.
 According to all the jobs available for that kind of profile around the
 world, it can be the first of a very long bunch of junk mails proposing a
 job that anyone here can find within a week ...



-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Job Opportunity - Jboss, Drools, Java Architecht/Consultant

2012-08-30 Thread Edson Tirelli
   Hi Pamela,

   Posting to the list is fine, but you may also want to post it here:

http://jobs.athico.com/post-direct

   It shows up on the Drools blog:

http://blog.athico.com/

   Edson

On Thu, Aug 30, 2012 at 9:39 AM, Pamela McGrath
pam...@ttechsolutions.netwrote:

 I assure you I am not going to start sending a lot of Junk mail proposing
 job opportunities, this is the first Jboss/Java/ Drools job opening I have
 come across and I was having a hard time finding someone who had all of the
 qualifications needed for the job.

 ** **

 *From:* rules-users-boun...@lists.jboss.org [mailto:
 rules-users-boun...@lists.jboss.org] *On Behalf Of *Vincent LEGENDRE
 *Sent:* Thursday, August 30, 2012 7:08 AM
 *To:* Rules Users List
 *Subject:* Re: [rules-users] Job Opportunity - Jboss, Drools, Java
 Architecht/Consultant

 ** **

 But it may be a horse anyway ...
 Let's say Anatolia is this list, and the horse the initial post.
 According to all the jobs available for that kind of profile around the
 world, it can be the first of a very long bunch of junk mails proposing a
 job that anyone here can find within a week ... 
 --

 *De: *Tom Eugelink t...@tbee.org
 *À: *rules-users@lists.jboss.org
 *Envoyé: *Jeudi 30 Août 2012 11:59:07
 *Objet: *Re: [rules-users] Job Opportunity - Jboss, Drools,Java
 Architecht/Consultant

 Hey, I'm already impressed with myself that I knew MI is Michigan (I did
 use google to find out how that is spelled though, initially had a T in
 there). :-)

 Tom


 On 2012-08-30 11:53, Wolfgang Laun wrote:
  Well, it's certainly not Troy in Anatolia ;-)
 
 
  On 30/08/2012, Tom Eugelink t...@tbee.org wrote:
  I assume this is somewhere in the US? MI is Michigan, right? (There are
 non
  Americans on this list as well ;-)
 
  Tom
 
 

 ___
 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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Matching consecutive events

2012-08-06 Thread Edson Tirelli
   Hi Jaro,

   This might be a side effect of the temporal reasoning algorithm when
using unbounded intervals like you are doing (i.e., using before and after
operators without an interval parameter). Assuming this is what is
happening, the activation is probably scheduled, but it only happens when
the next activity is about to happen inside the session.

   With the current version, I can only suggest two workarounds. Either:

* Use straight relational operators in your rule (, ). E.g.:

$ev2 : LocalizationEvent( ..., timestamp  $ev1.timestamp ) ...

* Or, try to use bounded temporal operators. E.g.:

$ev2 : LocalizationEvent( ... this after[0,60s] $ev1 ) ...

We know it is not ideal, and for the next Drools release we are
implementing explicit sequence operators where you will be able to just
define [strict] sequencing. E.g.:

when
 $ev1 : LocalizationEvent( ... ) =
 $ev2 : LocalizationEvent( ... )
then
...

 Details here:

https://community.jboss.org/wiki/EventSequencing#4_Definition_Sequence_Conditional_Elements

 Edson
On Wed, Aug 1, 2012 at 5:52 AM, jpullmann 
jaroslav.pullm...@fit.fraunhofer.de wrote:

 Dear contributors,

   this rule is expected to match a sequence of 2 consecutive events:

 rule test
 when
 // a)
 $ev1 : LocalizationEvent( type == TYPE.HINT,  $target : target  )
 from entry-point events/localization
 $ev2 : LocalizationEvent( type == TYPE.HINT, target == $target,
 this
 after $ev1 ) from entry-point events/localization
 // b)
 // Ev1 directly followed by ev2: no other HINT in between
 not( LocalizationEvent( type == TYPE.HINT, target == $target, this
 after $ev1, this before $ev2 )  from entry-point events/localization )
 then
   do()
 end

  The second event is interpreted as a confirmation of the first event
 (a).
  No other (deviating) event is allowed between them (b). With this
 restriction
  in place, the rule requires a sequence of 3 input events for activation,
 otherwise
  2 events are sufficient (as expected). The events are ordered correctly
 and
 it is
  not obvious, why a third event is needed since the interval between ev1
 and
 ev2 is
  closed ? This leads to an unnecessary delay in rule activation.. How could
 this be
  avoided and are there other approaches to match a concrete event sequence
 pattern ?

  Many thanks
Jaro



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Matching-consecutive-events-tp4018980.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Apply role to whole class hierarchy

2012-07-27 Thread Edson Tirelli
   Looks like a bug. :( The code to inherit @role event is there, but
apparently there is something else going on:

https://github.com/droolsjbpm/drools/blob/master/drools-core/src/main/java/org/drools/rule/Package.java#L485

   Please open a JIRA with the information bellow.

   Edson

On Fri, Jul 27, 2012 at 3:01 AM, Joerg Henne
hennejg+nab...@googlemail.comwrote:

 Thanks for your help, Edson!

 We are using drools 5.4.0.Final via maven.

 Maybe I am missing something, so here's a quick overview of what we do. We
 have a model class ButtonEvent which is derived like this:
 ButtonEvent - ZonedEvent - VSCPEvent

 Then there's a rulebase with something like this:

 import test.vscp.VSCPEvent;
 import test.vscp.information.ButtonEvent;

 declare VSCPEvent
 @role( event )
 @timestamp( timestamp )
 @expires( 1h )
 end
 declare ButtonEvent
 @role( event )
 @timestamp( timestamp )
 @expires( 1h )
 end

 rule Button long pressed
 when
 b : ButtonEvent( action == Action.PRESSED )
 not( ButtonEvent( action == Action.RELEASED, this after[0s,1s] b )
 )
 then
 ...
 end

 What I would have expected is that the second 'declare' statement to be
 unnecessary. However, if I take it away, this is what I get:

 java.lang.ClassCastException: org.drools.common.DefaultFactHandle
 at

 org.drools.base.evaluators.AfterEvaluatorDefinition$AfterEvaluator.evaluateCachedRight(AfterEvaluatorDefinition.java:316)
 at

 org.drools.rule.constraint.EvaluatorConstraint.isAllowedCachedRight(EvaluatorConstraint.java:80)
 at

 org.drools.common.SingleBetaConstraints.isAllowedCachedRight(SingleBetaConstraints.java:139)
 at org.drools.reteoo.NotNode.assertObject(NotNode.java:133)
 at

 org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
 at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:141)
 at

 org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:497)
 at

 org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:382)
 at
 org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:235)
 at
 org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:240)
 at
 org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:337)
 at
 org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:298)
 at

 org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:888)
 at

 org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:847)
 at

 org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:269)
 ...

 Thanks
 Joerg





 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Apply-role-to-whole-class-hierarchy-tp4018930p4018942.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Apply role to whole class hierarchy

2012-07-26 Thread Edson Tirelli
   Derived classes should inherit the @role of parent classes... which
version of Drools are you using?

   Edson

On Thu, Jul 26, 2012 at 12:48 PM, Joerg Henne hennejg+nab...@googlemail.com
 wrote:

 Hi all,

 we are processing events through a Fusion rule base. To be recognized as
 such, model classes must be declared as @role(event). We are using a rather
 extensive hierarchy of events, all derived from a single abstract class.
 Unfortunately, it doesn't seem to be possible to declare just this base
 class as an event and have the 'event' role for the others derived from
 that.
 Is there a way around having to declare each and every single event class
 separately?

 Thanks
 Joerg



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Apply-role-to-whole-class-hierarchy-tp4018930.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Slow compilation (4h) for a single rule

2012-07-25 Thread Edson Tirelli
   Listen to what others are saying in this thread... it is very good
advice, specially what wolfgang suggests bellow regarding collapsing evals.

   Also, I just read the example in your link where you have multiple
accumulates in a single rule... that is *bad*

   For those that attended or saw my presentation on best practices, an
easy way to estimate the performance of accumulates is to remember that the
performance of accumulates in a single rule is polinomial: O(n^a), where
n is the number of matching facts and a is the number of accumulates
you have in the same rule.

   So, if you have 1 rule with 5 accumulates, the performance will be n^5.
If instead you break the accumulates into 5 rules with one accumulate each,
you get a performance of O(5n) that is much better.

   Edson

On Wed, Jul 25, 2012 at 7:42 AM, Wolfgang Laun wolfgang.l...@gmail.comwrote:

 A last effort from my side.

 Given any number of bound variables a, b, c: to determine whether an
 arbitrary boolean expression involving arithmetic and comparison
 operators, a single eval() is sufficient and preferable to a CE
 combination involving the CE operators and, or, not combining
 many evals.

 Instead of
not( eval( a == 1 ) )
 use
eval( ! (a == 1) )  // or better
eval( a != 0 )

 Instead of
 eval( a == 1 ) or eval( b == 1 )
 use
eval( a == 1 || b == 1 )

 Instead of
 eval( a == 1 ) and eval( b == 1 )
 use
eval( a == 1  b == 1 )

 -W

 On 25/07/2012, fx242 dro...@fx242.com wrote:
  Thanks for your explanation Edson, it makes sense now I think!
  Basically what you are saying is that there is a limit, beyond which is
 no
  longer feasible to use more ORs on a rule.
 
 
  Edson Tirelli-4 wrote
 
  You are trying to avoid the issue. As reported by others, your
  conditions should be inside the patterns, not in or'd evals in the
 end,
  and yes, it is possible to generate rules like that in an automated
  program.
 
 
  Sadly I don't see how, as some of my rules have arbitrary arithmetic
  involving more than one variable inside the Number(), for more context
 see
  the example I've put on
 
 http://drools.46999.n3.nabble.com/drools-arithmetics-without-eval-td3823232.html
 .
 
  For this case I think I will try to invert the logic and get rid of the
  ORs:
  not(A or B) = not(A) and not(B).
 
  Best regards,
  TL
 
 
 
 
  --
  View this message in context:
 
 http://drools.46999.n3.nabble.com/Slow-compilation-4h-for-a-single-rule-tp4018855p4018894.html
  Sent from the Drools: User forum 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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Slow compilation (4h) for a single rule

2012-07-24 Thread Edson Tirelli
   You are trying to avoid the issue. As reported by others, your
conditions should be inside the patterns, not in or'd evals in the end,
and yes, it is possible to generate rules like that in an automated program.

   Now, the reason it is taking so long is because of the ors. I don't
think there is any bug there. Just for you to understand, an OR is just
syntax sugar for multiple rules. So if you have a rule that says:

A() or B()

   The engine is actually creating 2 rules:

rule 1 when
   A()
...

rule 2 when
   B()
...

I.e., it generates all possible combinations of rules, one for each of
your logical branches.

Now, I quickly counted 26 ors in your rule. It is quite possible that
the engine is generating all possible combinations of rules for all your
ORs, and that is roughly (there are some factors that influence the number
of rules): 2^26 == 67108864 rules. To compile 67 million rules, it can
indeed take some time.

I don't know for sure if that is the case without looking at your
application, but to solve your problem you should fix your rule generation,
not look for a problem elsewhere.

Edson

On Tue, Jul 24, 2012 at 9:29 AM, fx242 dro...@fx242.com wrote:

 I understand that the rule looks pointless and under-optimized, but it's
 the
 only way I could represent this kind of rule in an automated way (I didn't
 write the rule by hand). Basically with these rules I try to pre-compute
 the
 amount of some products on the WM (using count() inside a accumulate
 function) resulting in a Number(), and then on the last condition I
 evaluate
 some arbitrary arithmetic operation using the variables inside the Number()
 object.
 For more details for examples see my previous post where I've tried to
 address this issue:

 http://drools.46999.n3.nabble.com/drools-arithmetics-without-eval-td3823232.html

 So, considerations apart of the way the rule is written, I still think
 there
 is a bug or something similar on the RETE compiler, that causes this rule
 to
 be processed in a very expensive way. Can someone confirm this, and try to
 sugest an alternative? Maybe It's something that is already fixed on newer
 versions as sugested by Esteban?

 Regards,
 Tiago Lopes



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Slow-compilation-4h-for-a-single-rule-tp4018855p4018870.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Why does it seem like salience is being ignored?

2012-07-16 Thread Edson Tirelli
   Sorry, just saw your message. fireUntilHalt() will work in your use
case, as Mark mentioned. With fireUntilHalt(), as soon as a rule is
activated, it will fire if the agenda is idle. Because the topology of the
discrimination network is affected by the order of the rules in the file,
you end up having this different firing order depending on the order of the
rules in the file.

   The only way to work around this with the current version of Drools is
to call fireAllRules() after each insertion of an object into the working
memory and the current implementation of the Drools-Camel component does
not support that. If you want to do it yourself, it is quite easy:

1. Add support to a new parameter to tell the component to fireAllRules()
after inserting the object into the working memory:

https://github.com/droolsjbpm/droolsjbpm-integration/blob/master/drools-camel/src/main/java/org/drools/camel/component/DroolsEndpoint.java

2. Add the call to fireAllRules() after inserting the object in here:

https://github.com/droolsjbpm/droolsjbpm-integration/blob/master/drools-camel/src/main/java/org/drools/camel/component/DroolsInsertProducer.java


   Meanwhile, for the next version, we will need to add a staging area to
the agenda where the activations of a given propagation are added to the
agenda only when the whole propagation completes. This will fix the issue
for the general case.

   Edson

On Sat, Jul 14, 2012 at 2:18 PM, Ladd l...@codemettle.com wrote:

 I just tried the same test using 5.3.0 and got the same results.  Rule1b
 fires first.

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Why-does-it-seem-like-salience-is-being-ignored-tp4018669p4018687.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Why does it seem like salience is being ignored? - SOLVED!

2012-07-16 Thread Edson Tirelli
   Glad to hear!

   If you can contribute your changes to drools-camel back, we can add it
to the codebase and maintain from now on. The whole drools community will
benefit.

   Thanks,
   Edson

On Mon, Jul 16, 2012 at 1:37 PM, Ladd l...@codemettle.com wrote:

 Many thanks to Edson, Wolfgang, and Mark.  Edson, your solution of
 modifying
 the drools-camel component to call fireAllRules() after each insert did the
 trick.  My salience values are now being honored.

 Thanks guys!!

 - Ladd

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Why-does-it-seem-like-salience-is-being-ignored-tp4018669p4018716.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] [Solved] Concurrency bug in 5.4.0.Final

2012-07-11 Thread Edson Tirelli
  Hi all,

  Just a heads up, in case you are using the community release 5.4.0.Final
in a multi-threaded application, be aware that we found a quite serious
racing condition bug:

https://issues.jboss.org/browse/JBRULES-3573

  The bug is now fixed in 5.4.x branch, so I strongly recommend that you
build from source and use that instead. The bug was also fixed in the
up-stream branch and will be released in 5.5.0.

  IMPORTANT: if you are a Red Hat subscriber, you don't need to do anything
as the problem did not exist in the product release.

  Edson

-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] [Solved] Concurrency bug in 5.4.0.Final

2012-07-11 Thread Edson Tirelli
   Unfortunately, we have limited resources to maintain older branches in
the community. While backporting fixes like this is usually quick (a few
minutes of work if the source code did no diverge too much), making a full
release involves usually more than a week of work by multiple members of
the team. We feel that it is much more productive to use that time towards
the new release putting it out sooner rather than later.

   In any case, users can always build from source themselves if they need
the fix sooner and this kind of bug is typically found during the
productization and does not usually affect the product. In the rare
instances that it does, customers receive patches created by the Red Hat
product team.

   The source is available in github:
https://github.com/droolsjbpmhttps://github.com/organizations/droolsjbpm
and
building it is just a few maven commands. You can check the documentation
for instructions.

   Edson

On Wed, Jul 11, 2012 at 2:13 PM, Caillard, Quentin 
quentin.caill...@ariadnext.com wrote:

 Hi.
 Thanks for the fix.

 I have read in Mark Proctor's blog that the 5.5 will be released within
 the next 4-5 months. Is there any release date for the next release in the
 branch 5.4.x?

 2012/7/11 Edson Tirelli ed.tire...@gmail.com


   Hi all,

   Just a heads up, in case you are using the community release
 5.4.0.Final in a multi-threaded application, be aware that we found a quite
 serious racing condition bug:

 https://issues.jboss.org/browse/JBRULES-3573

   The bug is now fixed in 5.4.x branch, so I strongly recommend that you
 build from source and use that instead. The bug was also fixed in the
 up-stream branch and will be released in 5.5.0.

   IMPORTANT: if you are a Red Hat subscriber, you don't need to do
 anything as the problem did not exist in the product release.

   Edson

 --
   Edson Tirelli
   JBoss Drools Core Development
   JBoss by Red Hat @ www.jboss.com

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




 --

 Quentin CAILLARD

 *Software Engineering*

 quentin.caill...@ariadnext.com


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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] FireUntilHalt

2012-07-11 Thread Edson Tirelli
   Which Drools version are you using?

   There are no secrets, but you have to be aware that in this mode rules
will fire right away if they can. Also, if you are using 5.4.0.Final,
please read another e-mail I sent to the list today, as there was a
concurrency bug that was fixed in the 5.4.x branch that could cause NPE.

   Edson

On Wed, Jul 11, 2012 at 10:16 PM, crajor crjo...@sandia.gov wrote:

 I have a fairly complicated drools program and I want to introduce temporal
 reasoning to it.  I spent a bit of time writing some proof-of-concept
 programs to get the feel of fusion and then tried to slowly introduce
 things
 into my original drools program.  When I changed my program from using
 fireAllRules() to using fireUntilHalt() on a separate thread, I suddenly
 get
 failures in my unit tests.  (My first thought was that there was a race
 condition between my unit tests and the thread calling fireUntilHalt() so I
 introduced a delay before my unit tests but no luck)

 Here are some of the behaviors I am seeing.

 1) I occasionally get nullpointerexception from the thread running
 fireUntilHalt()
 2) My lock-on-active rules aren't firing

 I have banged my head on this a while with no success.  (I even tried
 putting fireAllRules() in a loop because of suggestions I saw but no luck
 and same behavior).  My questions are, Is there a secret to using
 fireUntilHalt() that I am not aware of?  Can anybody point me to where I
 can
 educate myself on its proper use?

 BTW no persistence and no spring in the code at this point.

 Thanks, in advance, for any help you can provide.

 Craig

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/FireUntilHalt-tp4018610.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Issues without response

2012-06-26 Thread Edson Tirelli
   Wolfgang,

   Yes, I agree. We've been careful with that we expose on the
knowledge-api, but this is clearly an interface that should be there.

   Will take care of it.

Edson

On Tue, Jun 26, 2012 at 5:48 AM, Wolfgang Laun wolfgang.l...@gmail.comwrote:

 @Edson: There is, of course, the fundamental problem of the
 pseudo-clock feature being full-bodiedly announced in Drools Fusion
 but
 SessionPseudoClock remaining absent from the stable API. While the
 Fusion manual emphasizes (correctly) that a pseudo-clock is useful in
 unit test it's important to note that there are good use cases for
 using it in certain production scenarios, both of which warrants that
 this feature should not be kept under-the-counter.

 -W


 On 26/06/2012, Edson Tirelli ed.tire...@gmail.com wrote:
 Cyril,
 
 Thank you for reporting and providing a well written test case. It
  really helps.
 
 We've all been involved with a number of other tasks, including the
  workshops from last week and JBW this week, that prevented me and others
  from working on tickets. Having said that, because the test case in
  JBRULES-3528 was well written, it allowed me to see the problem and
  identify a solution really quickly (literally between meetings). It is
  committed now to both 5.4.x branch and master branch.
 
 To other community members that don't know how to report bugs, take a
  look at Cyril's test case (https://issues.jboss.org/browse/JBRULES-3528
 ).
  It is a good example of how to help us help you. You can attach test
 cases
  to the tickets or send us a pull request in git hub. There are other
  community users that also usually provide good test cases (Wolfgang, just
  to mention one more), but if you don't know how to do it, I really
  recommend you look at that.
 
 Edson
 
 
  On Mon, Jun 25, 2012 at 5:58 AM, Cyril Sochor
  cyril.soc...@gmail.comwrote:
 
   Hi,
 
  I created two issues in bugtracker, second one with pull request.
  JBRULES-3528 Deadlock when using pseudo session clock
  JBRULES-3529 JMS messenger for JBOSS AS 7.1
 
  Issues are 20 days without any response. What's wrong?
 
  Thank you,
  Cyril Sochor
 
 
  ___
  rules-users mailing list
  rules-users@lists.jboss.org
  https://lists.jboss.org/mailman/listinfo/rules-users
 
 
 
 
  --
Edson Tirelli
JBoss Drools Core Development
JBoss by Red Hat @ www.jboss.com
 
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] JBPM fails to resume a rehydrated active process instance

2012-06-04 Thread Edson Tirelli
   Alberto,

   Which versions of Drools and jBPM are you using?

   Edson

On Mon, Jun 4, 2012 at 3:55 AM, Alberto R. Galdo arga...@gmail.com wrote:

 Hi guys,

We are using JBPM 5 for long running processes in one of our products,
 both, the knowledge session and WorkItemInfo  ProcessInstanceInfo are
 persisted in a PostgreSQL database. Our processes involve a set of
 automated tasks along with UserTasks handled inside JBPM's HumanTask
 provided server  ( the one that uses mina  JPA ).

For maintenance purposes, our application needs to be restarted once in
 a while so we need our processes to keep running after a sucesful
 rehydratation of the knowledge  JBPM contexts . We've tested a persistent
 approach like this:

  - We started our application and started several instances of a
 process that involves at least one human task node.
  - We've completed several human tasks in the current session and
 things went ok, workitems got completed  processinstances desappeared as
 processes came to and end.
  - We left several human task in stateReady for our users to consume
 afterwards.
  - We restarted the application and let JBPM rehydrate it's context
 via   JPAKnowledgeService.loadStatefulKnowledgeSession()

Then we acquired and completed a Ready HumanTask, it got completed in
 JBPM HumanTask server's database backend but the process attached never got
 neither updater, nor its subsequent nodes were executed. This is weird.

 We first tought it was a rehydratation problem and that the process
 definition was not loaded properly, but what was our suprise when we've
 been able to execute several new process instances wich we could complete
 properly. So, seems that we are able to complete current ( as in the
 current session, not the rehydrated ones ) process instances, but not able
 to complete process instances that are not started in the current session
 ( the rehydrated ones ).

What's wrong here. Is it not possible to resume a process in a
 rehydrated session when human tasks  JBPM's HumanTask server are involved?


 Greets,

 Alberto R. Galdo
 arga...@gmail.com



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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] drools.packagebuilder.conf

2012-06-01 Thread Edson Tirelli
 Ok, it seems the problem is not the configuration file then, but the
operator itself. There were some changes on how MVEL analyzes and executes
expressions and this seems to be related to that...

 Can you provide an isolated test case with your operator so that we
can reproduce the problem?

 Thanks.

On Fri, Jun 1, 2012 at 11:51 AM, Matteo Cusmai cusmaimat...@gmail.comwrote:

 Hi Mario,
 i have tried to put it every where.

 The strange thing is that if i use 5.3 it is with file under
 /home/myhomefolder and if i use 5.4 i get this error:

 ERROR [2012-06-01 17:37:27,588] [VSensorLoader-Thread0]
 (ExpertSystemManager.java:63) - Unable to Analyse Expression
 $vehicle_type == type  geoIsWithinDistance0.evaluate( $location,
 source.getGeometry() ):
  [java] [Error: unable to resolve method using strict-mode:
 org.dfms.model.mapfeature.Route.geoIsWithinDistance0()]
  [java] [Near : {... cle_type == type 
 geoIsWithinDistance0.evaluate( }]
  [java]  ^ : [Rule
 name='VehicleAtRouteStart-event']
  [java] Unable to Analyse Expression $vehicle_type == type 
 geoIsWithinDistance0.evaluate( $location, source.getGeometry() ):T
  [java] [Error: unable to resolve method using strict-mode:
 org.dfms.model.mapfeature.Route.geoIsWithinDistance0()]
  [java] [Near : {... cle_type == type 
 geoIsWithinDistance0.evaluate( }]
  [java]  ^ : [Rule
 name='VehicleAtRouteStart-update']

 where geo are custom evaluator.

 What do you think?



 On Fri, Jun 1, 2012 at 5:29 PM, Mario Fusco mario.fu...@gmail.com wrote:

 Hi Matteo,

 Drools loads conf files from several places and merge them including home
 directory, meta-inf directory, etc. This is the class that does this job
 and
 as you can see it isn't changed in the last year:


 https://github.com/mariofusco/droolsjbpm-knowledge/blob/master/knowledge-api/src/main/java/org/drools/util/ChainedProperties.java

 In particular, as you can see at line 71, it should try to load the conf
 file also from your home folder. I don't know why it is not working in
 your
 case. Probably are you launching it with the wrong user? Alternatively you
 could also try to put that conf file in a folder named META_INF in your
 classpath.

 I hope this helps,
 Mario

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/rules-users-drools-packagebuilder-conf-tp4017706p4017723.html
 Sent from the Drools: User forum 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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] drools.packagebuilder.conf

2012-06-01 Thread Edson Tirelli
   It still looks like a bug... if you can submit the test case, we can fix
it.

   Edson

On Fri, Jun 1, 2012 at 2:07 PM, Matteo Cusmai cusmaimat...@gmail.comwrote:

 Hi all,
 it seems that i have solved.

 the problem was, as said by Edson, in mvel analyze.

 In following rule:

 rule VehicleAtRouteStart-event
 dialect mvel
 no-loop
 when
 $obs: VehicleMatchedObservation( $vehicle_id : vehicle_id,
 $location : location, $road_line : road_line, $vehicle_type : vehicle_type
 ) over window:time(15m) from entry-point lowLevelSensorStream
 $route: Route( $vehicle_type == type , $location
 geoIsWithinDistance[10m] source.getGeometry() , $routeid : id )
 not VehicleAtRouteStart( this before[ 0, 10m ] $obs, vehicleId ==
 $vehicle_id )
 then
 insert ( SituationManager.createVehicleAtRouteStart(Vehicle at
 the beginning of route  + $vehicle_type, Event.THREAT_NO, $location,
 $obs.getSensorId(), $routeid, $vehicle_id) );
 end

 the problem was in red.
 I have solved by inverting object of operator:

 $route: Route( $vehicle_type == type , source.getGeometry()
 geoIsWithinDistance[10m] $location , $routeid : id )

 Is this the update to mvel?




 On Fri, Jun 1, 2012 at 7:00 PM, Matteo Cusmai cusmaimat...@gmail.comwrote:

 Hi Mario,
 i am trying to extract an example from my project, creating a simple
 drools project under eclipse.
 But when i try to create project with version 5.4 of drools, eclipse is
 not able to use 5.4. I get a compilation error on sample classes.

 i have added drools 5.4 as runtime into eclipse, select it for new
 project, but i get a compilation error.
 Do you have an idea?


 On Fri, Jun 1, 2012 at 6:13 PM, Mario Fusco mario.fu...@gmail.comwrote:

 Matteo,

 I don't think the problem is in the resolution of the conf file. More
 likely
 the file is loaded and parsed correctly, but then, for some reason, the
 DRL
 compiler isn't able to find your custom evaluators.

 I'd need to reproduce your problem to better figure out what's going
 wrong.
 Can you send me the source code of one of your evaluators, the conf file
 defining it and a DRL with a rule using it? It will be even better if you
 could open a Jira ticket, assign it to me and attach the failing example
 I
 am asking there.

 Thanks a lot,
 Mario

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/rules-users-drools-packagebuilder-conf-tp4017706p4017726.html
 Sent from the Drools: User forum 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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Drools 5.0 to 5.4 upgrade

2012-05-27 Thread Edson Tirelli
   Did you upgrade your MVEL jar to the new version as well?

   Edson

On Sat, May 26, 2012 at 10:27 AM, Ben Cuthbert bencuthb...@ymail.comwrote:

 After upgrading the jars to the latest version I am getting this when
 starting my rules

 java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)

 Caused by: java.lang.NoSuchFieldError:
 COMPILER_OPT_ALLOW_RESOLVE_INNERCLASSES_WITH_DOTNOTATION
at
 org.drools.rule.builder.PatternBuilder.setInputs(PatternBuilder.java:969)
at
 org.drools.rule.builder.PatternBuilder.buildRelationalExpression(PatternBuilder.java:669)
at
 org.drools.rule.builder.PatternBuilder.buildExpression(PatternBuilder.java:634)
at
 org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:618)
at
 org.drools.rule.builder.PatternBuilder.processConstraintsAndBinds(PatternBuilder.java:449)
at
 org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:310)
at
 org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:118)
at
 org.drools.rule.builder.GroupElementBuilder.build(GroupElementBuilder.java:67)
at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:84)
at
 org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:2706)
at
 org.drools.compiler.PackageBuilder.compileRules(PackageBuilder.java:930)
at
 org.drools.compiler.PackageBuilder.compileAllRules(PackageBuilder.java:839)
at
 org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:831)
at
 org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:467)
at
 org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:673)
at
 org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:45)
at
 org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:34)


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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] java.lang.AbstractMethodError: org.jbpm.marshalling.impl.ProcessMarshallerImpl.init while unmarshalling statefulknowledgesession

2012-04-16 Thread Edson Tirelli
 list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Fusion: Insert passed events

2012-03-16 Thread Edson Tirelli
   Wolfgang's answer is spot on. Pretend that you are not using an
engine... imagine that you are implementing a java method in a java
application to handle this use case... how would you do it? Either you use
the timestamp at the source or the timestamp at the engine. Either you
execute your actions at 06:00 or you don't... if an event arrives at 06:30,
but was emitted at the source at 05:30, and you already executed the
actions in your java method at 06:00 as you wanted, what will your method
do?

   In other words, you can't selectively choose for this event to use the
timestamp at source, for that event I will use the timestamp at arrival,
or your application will be inconsistent. Wire delays are a common
situation in the real world, so you have to make a decision on how you will
handle then and do it. For the case in the previous paragraph, the usual
approach is to use compensating transactions if necessary.

   The engine allows you to do whatever your application would do. This is
a design decision on the use case that has to be taken.

   Edson

On Fri, Mar 16, 2012 at 4:17 AM, javadude s...@bighugesystems.com wrote:

 I guess the engine use the insert fact timestamp and not the annotated
 timestamp for the non-existence of a event. Think it would not be easy to
 implement the engine, because you need to take care of past and future
 events. And for past events, both the events where the trigger did not pass
 yet and events where the backdating of the event would make the trigger
 already happened...

 Would be interesting to hear the opinion of the core developers.

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Fusion-Insert-passed-events-tp3824630p3831195.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Using Character typed properties in Drool 5.3

2012-03-16 Thread Edson Tirelli
Try updating to MVEL 2.1.0.drools9.jar that Mario released a few days
ago. There are many fixes in there.

Edson

On Fri, Mar 16, 2012 at 7:53 PM, julia jozers...@yahoo.com wrote:

 Edson,
 any word from Mario on how to get around this problem?

 We are importing a lot of POJOs with Character setters/getters. I would
 hate
 to rewrite them all to Strings just to be able to work with Guvnor. Any
 advice would be appreciated.

 thanks!

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/rules-users-Using-Character-typed-properties-in-Drool-5-3-tp3741968p3833523.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Future events

2012-03-14 Thread Edson Tirelli
   An event represents something that already happened (past), so there is
no such thing as a future event. You can have a fact that represents
something that is scheduled to happen in the future, but that is not an
event, and it can change as it is just data. Events are immutable.

   For instance: airport. You can have a flight scheduled to leave tomorrow
at 08:00am, from gate B1. That schedule might change, because the flight
can be delayed, cancelled, change gates, etc. It is just a fact in your
system (e.g. ScheduledFlight). But when the flight actually departs the
gate, then the system can have an event like FlightDepartedFromGate() that
says the flight left the gate B1 at 08:02am. This is immutable, because it
registers something that happened.

   Edson

On Wed, Mar 14, 2012 at 1:44 PM, lexsoto lexs...@gmail.com wrote:

 Hello:

 I have this rule:



 An event is inserted that has a timestamp in the future, the rule is fired.
 This looks like a bug, because the sliding time window has not yet met the
 timestamp of the event.
 I expect the rule to fire not immediately but only when the time reaches
 the
 event time.

 Is my assumption/understanding correct?


 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Future-events-tp3826236p3826236.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Future events

2012-03-14 Thread Edson Tirelli
   The reason is because the engine will not queue up events and wait for
the correct time to deal with them. The engine assumes events always
represent past times. But for past events, I am sure the window is
respected. If you have a rule that counts the number of events in the last
5 hours, an event that happened 5 hours and 1 minute ago will not be in the
total count.

   Edson

On Wed, Mar 14, 2012 at 4:58 PM, lexsoto lexs...@gmail.com wrote:

 Thanks Edson for your reply, however I am still not clear about why the
 rule
 is firing if the time stamp of the event falls outside the time window.
 This can happen, for example, if the event originates in a machine with
 clock slightly ahead. I think the problem also occurs if the time is in the
 past; I would not want  to take action on a future or old event.

 I understand that events are immutable, and I am not changing the event in
 any way.  However, I expect the sliding time window to be changing along
 with the system clock until it reaches the timestamp of the event.
 My question still unanswered, why is the rule firing outside its time
 window? Is there a way to make this work?  Any advice about how to address
 this use case?

 Thanks

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Future-events-tp3826236p3826759.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Variable length sliding windows?

2012-03-01 Thread Edson Tirelli
   Nope, only constants.

   Edson

On Thu, Mar 1, 2012 at 11:25 AM, Lauer, Will C will.la...@ca.com wrote:

 I'm evaluating the use of Drools Fusion for a new project and have a
 question about sliding windows that wasn't clear from the documentation.
 Does the time specification in a sliding window need to be hardcoded in the
 rule, or can it be derived from something else? Basically, I'm wondering
 whether I can write a rule that looks something like

when
...
Window ($win : length)
Number (intValue  $someValue) from accumulate (
Sample($len: length, value  $someThreashold) over
 window:time ($win),
sum($len) )
then
...
end

 I know window:time() supports constant values like 10m, but can the
 window be driven from one of the other facts in the LHS picked up by the
 LHS of the rule?


 Will Lauer
 CA Technologies
 Sr Software Architect
 Tel:  +1-713-625-9410
 Cell: +1-979-820-2210
 will.la...@ca.com



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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Slinding window !

2012-02-28 Thread Edson Tirelli
   This is correct and works as designed. Please note that a direct event
expiration does NOT cause a rule to be cancelled. So using sliding windows
in isolation will be useless:

X() over window:time(...)

   Will activate and fire for every single X, and that is correct.

   Now, if you use sliding windows in combination with other CEs, then the
results will be affected by the sliding window. This is perfectly clear
with accumulate/collect, but also happens when you are using multiple
patterns. For instance:

X() over window:time( 1m )
Y() over window:time( 1m )

   This will create pairs of [X,Y] only for the X's and Y's that happened
in the last minute, as intended. An X that just happened will not match an
Y that happened 2 minutes ago.

   Edson



On Tue, Feb 28, 2012 at 7:18 AM, Wolfgang Laun wolfgang.l...@gmail.comwrote:

 I can confirm (using 5.3.0) that after
advance the clock to 1
insert an event with timestamp 1,
advance the clock to 3
insert another one with timestamp 3
advance the clock to 4
fire all rules
 a rule with
   Event() over window:time( 2s )
 will fire twice (2 times). There is no difference between STREAM and CLOUD
 mode.

 Indeed, the documentation (Fusion, 2.6.1, Sliding Time Windows)
 appears to tell another story:  Sliding Time Windows allow the user
 to write rules that will only match events occurring in the last X
 time units. This is quite explicit.

 Also, please note that firing all rules after each insertion produces
 the expected results; the rule firings at T=3 and T=4 show only one
 event in the window.

 Even more surprisingly, running a rule that collects over a sliding
 window works as intuitively expected:
   $l: List() from collect( Event() over window:time( 2s ) )
 Here the List will never contain more than one element, even when the
 simple pattern (shown above) fires twice.

 -W





 On 28/02/2012, Hassan azbak...@gmail.com wrote:
  Hi guys,
 
  While trying to understand how slinding window work, I realize that all
  exemples are given with accumulate or collect functions , I din't
 know
  why ??
 
  $a : List() from collect(Event1() over window:time(2s) from entry-point
  point)
// work
 
 
  Bur why
 
  $a : Event1() over window:time(2s) from entry-point point)
 
 
  doesn't work ??!
 
  Thanks,
  Youssef AZBAKH
 
  --
  View this message in context:
  http://drools.46999.n3.nabble.com/Slinding-window-tp3783772p3783772.html
  Sent from the Drools: User forum 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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Slinding window !

2012-02-28 Thread Edson Tirelli
   Yes, the misunderstanding is that an expiration is not a retract.
Expiration does not cancel an activation. Retract does. So if you received
an event dated T1, it match your pattern and the rule will activate. Then
you receive event dated T3 and your rule activates again for the new event.
Then when the clock advances to T4, the event at T1 expires and will not
create any **new** matches for the rule, but it respects the activation
that was **already created**. Then you fireAllRules() at time T4 and it
will fire the 2 existing activations.

   This happens because of the 2-phase execution of the engine and the need
to unify the semantics of event processing and rules processing. Imagine
that the engine was, because of forward chaining, executing a long sequence
of high priority activations that prevented the rule in discussion of being
fired at time T1...T3. Only at T4 the engine had CPU cycles to execute the
rule for event T1. If event expiration would cancel the activation, the
engine would completely miss the rule execution because of lack of
processing power. This is an extreme example, but perfectly illustrates
what happens with events that expire immediately or within a few
milliseconds.

   The application can also be designed to run in cycles, waiting as much
as it wants to fireAllRules(), because it is guaranteed that it will not
miss any events because of that.

   On the other hand, if you were running the engine with fireUntilHalt(),
after inserting event T1, the activation would be created and fired asap.

Key point: expiration != retraction

   Hope it helps,
 Edson

On Tue, Feb 28, 2012 at 11:05 AM, Wolfgang Laun wolfgang.l...@gmail.comwrote:

 I think there is a misunderstanding - expiry is not an issue.

 We have two events, dated (say) 1 and 3 and it is now 4 o'clock and
 the window looks back 2 units:
   Event() over window:time(2)
 This fires twice!

 -W




 On 28/02/2012, Edson Tirelli ed.tire...@gmail.com wrote:
 This is correct and works as designed. Please note that a direct event
  expiration does NOT cause a rule to be cancelled. So using sliding
 windows
  in isolation will be useless:
 
  X() over window:time(...)
 
 Will activate and fire for every single X, and that is correct.
 
 Now, if you use sliding windows in combination with other CEs, then
 the
  results will be affected by the sliding window. This is perfectly clear
  with accumulate/collect, but also happens when you are using multiple
  patterns. For instance:
 
  X() over window:time( 1m )
  Y() over window:time( 1m )
 
 This will create pairs of [X,Y] only for the X's and Y's that happened
  in the last minute, as intended. An X that just happened will not match
 an
  Y that happened 2 minutes ago.
 
 Edson
 
 
 
  On Tue, Feb 28, 2012 at 7:18 AM, Wolfgang Laun
  wolfgang.l...@gmail.comwrote:
 
  I can confirm (using 5.3.0) that after
 advance the clock to 1
 insert an event with timestamp 1,
 advance the clock to 3
 insert another one with timestamp 3
 advance the clock to 4
 fire all rules
  a rule with
Event() over window:time( 2s )
  will fire twice (2 times). There is no difference between STREAM and
 CLOUD
  mode.
 
  Indeed, the documentation (Fusion, 2.6.1, Sliding Time Windows)
  appears to tell another story:  Sliding Time Windows allow the user
  to write rules that will only match events occurring in the last X
  time units. This is quite explicit.
 
  Also, please note that firing all rules after each insertion produces
  the expected results; the rule firings at T=3 and T=4 show only one
  event in the window.
 
  Even more surprisingly, running a rule that collects over a sliding
  window works as intuitively expected:
$l: List() from collect( Event() over window:time( 2s ) )
  Here the List will never contain more than one element, even when the
  simple pattern (shown above) fires twice.
 
  -W
 
 
 
 
 
  On 28/02/2012, Hassan azbak...@gmail.com wrote:
   Hi guys,
  
   While trying to understand how slinding window work, I realize that
 all
   exemples are given with accumulate or collect functions , I din't
  know
   why ??
  
   $a : List() from collect(Event1() over window:time(2s) from
 entry-point
   point)
 // work
  
  
   Bur why
  
   $a : Event1() over window:time(2s) from entry-point point)
  
  
   doesn't work ??!
  
   Thanks,
   Youssef AZBAKH
  
   --
   View this message in context:
  
 http://drools.46999.n3.nabble.com/Slinding-window-tp3783772p3783772.html
   Sent from the Drools: User forum 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
 
 
 
 
  --
Edson Tirelli
JBoss Drools Core

Re: [rules-users] Slinding window !

2012-02-28 Thread Edson Tirelli
   This is tricky indeed and it is part of the design decisions we had to
make. When you have a rule:

when
   X()

   The rule cares about X. Whether X is an event or fact, whether X is in a
sliding window was simply expired by the expiration policy. Because the
rule cares about X, X has to be correct and the rule has to be fired for X
unless it is explicitly retracted.

When you have a rule that says:

when
   List() from collect(X() ...)

The rule does not care about the elements of the List individually, the
rule cares about the List of elements. Quoting the text above: Because the
rule cares about the List, the List has to be correct, i.e., reflect the
current content at the time it fires.

It is hard to see on paper, but as soon as you start applying it to use
cases, it makes sense. For instance, you want to fire a rule to call the
firefighters if the fire alarm is sounding. Even if it takes some time to
do it, you want to call the fire fighters. On the other hand, you want to
turn on the sprinklers if the average temperature is above X degrees... but
since the time it raised over X degrees, something happened and the
temperature lowered to under X degrees, so you don't want to turn on the
sprinklers anymore because the current temperature is under the threshold,
even if it was over in the past.

It is tricky and there is no single right or wrong answer on this. It
was a design decision.

Edson

2012/2/28 Wolfgang Laun wolfgang.l...@gmail.com

 OK, I suspected as much.

 But how do you explain that the List that's collected at T=4 by
List() from collect( Event() over window(2) )
 contains just one element? This means that the same pattern Event over
 window(2) produces two different sets of facts, at the same time!

 (I don't think that expiry is a good term for an event drifting out of
 a window, but that's not the point.)

 -W

 2012/2/28 Edson Tirelli ed.tire...@gmail.com


Yes, the misunderstanding is that an expiration is not a retract.
 Expiration does not cancel an activation. Retract does. So if you received
 an event dated T1, it match your pattern and the rule will activate. Then
 you receive event dated T3 and your rule activates again for the new event.
 Then when the clock advances to T4, the event at T1 expires and will not
 create any **new** matches for the rule, but it respects the activation
 that was **already created**. Then you fireAllRules() at time T4 and it
 will fire the 2 existing activations.

This happens because of the 2-phase execution of the engine and the
 need to unify the semantics of event processing and rules processing.
 Imagine that the engine was, because of forward chaining, executing a long
 sequence of high priority activations that prevented the rule in discussion
 of being fired at time T1...T3. Only at T4 the engine had CPU cycles to
 execute the rule for event T1. If event expiration would cancel the
 activation, the engine would completely miss the rule execution because of
 lack of processing power. This is an extreme example, but perfectly
 illustrates what happens with events that expire immediately or within a
 few milliseconds.

The application can also be designed to run in cycles, waiting as much
 as it wants to fireAllRules(), because it is guaranteed that it will not
 miss any events because of that.

On the other hand, if you were running the engine with
 fireUntilHalt(), after inserting event T1, the activation would be created
 and fired asap.

 Key point: expiration != retraction

Hope it helps,
  Edson


 On Tue, Feb 28, 2012 at 11:05 AM, Wolfgang Laun 
 wolfgang.l...@gmail.comwrote:

 I think there is a misunderstanding - expiry is not an issue.

 We have two events, dated (say) 1 and 3 and it is now 4 o'clock and
 the window looks back 2 units:
   Event() over window:time(2)
 This fires twice!

 -W




 On 28/02/2012, Edson Tirelli ed.tire...@gmail.com wrote:
 This is correct and works as designed. Please note that a direct
 event
  expiration does NOT cause a rule to be cancelled. So using sliding
 windows
  in isolation will be useless:
 
  X() over window:time(...)
 
 Will activate and fire for every single X, and that is correct.
 
 Now, if you use sliding windows in combination with other CEs, then
 the
  results will be affected by the sliding window. This is perfectly clear
  with accumulate/collect, but also happens when you are using multiple
  patterns. For instance:
 
  X() over window:time( 1m )
  Y() over window:time( 1m )
 
 This will create pairs of [X,Y] only for the X's and Y's that
 happened
  in the last minute, as intended. An X that just happened will not
 match an
  Y that happened 2 minutes ago.
 
 Edson
 
 
 
  On Tue, Feb 28, 2012 at 7:18 AM, Wolfgang Laun
  wolfgang.l...@gmail.comwrote:
 
  I can confirm (using 5.3.0) that after
 advance the clock to 1
 insert an event with timestamp 1,
 advance the clock to 3
 insert another one

Re: [rules-users] Slinding window !

2012-02-28 Thread Edson Tirelli
   :) That works... as it was the reason fireUntilHalt() was created.

   Edson

2012/2/28 Wolfgang Laun wolfgang.l...@gmail.com

 All right, I can condense the discussion into a single recommendation for
 CEP with Fusion:

 If you want consistent real-time results from your rules, make sure that
 the Engine doesn't remain idle - evaluate each new situation immediately,
 or do not run the Engine intermittently at all (i.e., call fireUntilHalt()).

 -W


 2012/2/28 Edson Tirelli ed.tire...@gmail.com


This is tricky indeed and it is part of the design decisions we had to
 make. When you have a rule:

 when
X()

The rule cares about X. Whether X is an event or fact, whether X is in
 a sliding window was simply expired by the expiration policy. Because the
 rule cares about X, X has to be correct and the rule has to be fired for X
 unless it is explicitly retracted.

 When you have a rule that says:

 when
List() from collect(X() ...)

 The rule does not care about the elements of the List individually,
 the rule cares about the List of elements. Quoting the text above: Because
 the rule cares about the List, the List has to be correct, i.e., reflect
 the current content at the time it fires.

 It is hard to see on paper, but as soon as you start applying it to
 use cases, it makes sense. For instance, you want to fire a rule to call
 the firefighters if the fire alarm is sounding. Even if it takes some time
 to do it, you want to call the fire fighters. On the other hand, you want
 to turn on the sprinklers if the average temperature is above X degrees...
 but since the time it raised over X degrees, something happened and the
 temperature lowered to under X degrees, so you don't want to turn on the
 sprinklers anymore because the current temperature is under the threshold,
 even if it was over in the past.

 It is tricky and there is no single right or wrong answer on this. It
 was a design decision.

 Edson


 2012/2/28 Wolfgang Laun wolfgang.l...@gmail.com

 OK, I suspected as much.

 But how do you explain that the List that's collected at T=4 by
List() from collect( Event() over window(2) )
 contains just one element? This means that the same pattern Event over
 window(2) produces two different sets of facts, at the same time!

 (I don't think that expiry is a good term for an event drifting out
 of a window, but that's not the point.)

 -W

 2012/2/28 Edson Tirelli ed.tire...@gmail.com


Yes, the misunderstanding is that an expiration is not a retract.
 Expiration does not cancel an activation. Retract does. So if you received
 an event dated T1, it match your pattern and the rule will activate. Then
 you receive event dated T3 and your rule activates again for the new event.
 Then when the clock advances to T4, the event at T1 expires and will not
 create any **new** matches for the rule, but it respects the activation
 that was **already created**. Then you fireAllRules() at time T4 and it
 will fire the 2 existing activations.

This happens because of the 2-phase execution of the engine and the
 need to unify the semantics of event processing and rules processing.
 Imagine that the engine was, because of forward chaining, executing a long
 sequence of high priority activations that prevented the rule in discussion
 of being fired at time T1...T3. Only at T4 the engine had CPU cycles to
 execute the rule for event T1. If event expiration would cancel the
 activation, the engine would completely miss the rule execution because of
 lack of processing power. This is an extreme example, but perfectly
 illustrates what happens with events that expire immediately or within a
 few milliseconds.

The application can also be designed to run in cycles, waiting as
 much as it wants to fireAllRules(), because it is guaranteed that it will
 not miss any events because of that.

On the other hand, if you were running the engine with
 fireUntilHalt(), after inserting event T1, the activation would be created
 and fired asap.

 Key point: expiration != retraction

Hope it helps,
  Edson


 On Tue, Feb 28, 2012 at 11:05 AM, Wolfgang Laun 
 wolfgang.l...@gmail.com wrote:

 I think there is a misunderstanding - expiry is not an issue.

 We have two events, dated (say) 1 and 3 and it is now 4 o'clock and
 the window looks back 2 units:
   Event() over window:time(2)
 This fires twice!

 -W




 On 28/02/2012, Edson Tirelli ed.tire...@gmail.com wrote:
 This is correct and works as designed. Please note that a direct
 event
  expiration does NOT cause a rule to be cancelled. So using sliding
 windows
  in isolation will be useless:
 
  X() over window:time(...)
 
 Will activate and fire for every single X, and that is correct.
 
 Now, if you use sliding windows in combination with other CEs,
 then the
  results will be affected by the sliding window. This is perfectly
 clear
  with accumulate/collect, but also happens when you are using multiple

Re: [rules-users] Drools Fusion: updating event duration

2012-02-24 Thread Edson Tirelli
   A couple comments:

* The temporal reasoning features/operators are available in both CLOUD and
STREAM mode. The biggest differences are that in CLOUD mode there is no
automatic garbage collection of old events and you can't use sliding
windows, but everything else works.

* You can insert events with old timestamps, but in that case it is the
rule's author responsibility to understand that sliding windows using that
event type might be affected and if running in STREAM mode, you should
define an expiration policy for that event type that will keep him in
memory for enough time to match any rules that require it. For instance, if
in your application events will have a maximum duration of 24hs and because
of that they can be inserted into the system with a delay of 24hs, you
should define an expiration policy for it that is at least 24hs.

   Edson

2012/2/24 Matteo Cusmai cusmaimat...@gmail.com

 Hi Wolfgang,
 thanks a lot for the explanation, but i am very sad now.
 I have to use STREAM mode, because i am implementing a spatio-temporal
 expert system, so, i need of temporal reasoning. I need to compare events
 on time too.
 From my understaning, i am limitated by:

- i cannot update timestamp and duration of an event;
- i cannot insert a new event with an old timestamp

 is it right?

 In a realtime sensor system, i don't receive the event with duration, but
 i need to correlate them to have an event with duration.

 Do you have any suggestions?

 Thanks a lot,

 Matteo.


 On Thu, Feb 23, 2012 at 7:39 AM, Wolfgang Laun wolfgang.l...@gmail.comwrote:

 On 22/02/2012, Edson Tirelli ed.tire...@gmail.com wrote:
 If your use case somehow has mutable events, you can retract,
 change
  the duration and reinsert.

 But mind the requirements of STREAM mode: Events in each stream must
 be time-ordered. I.e., inside a given stream, events that happened
 first must be inserted first into the engine. If reinsertions would
 violate this, you must run the session in CLOUD mode, which has
 certain consequences. This is all very well described in the Fusion
 manual, section on Event Processing Modes.

 -W


  The engine uses optimizations for the temporal
  reasoning that are based on the fact that events should be immutable.
 That
  is why the engine resolves the timestamp/duration attributes at insert
  time and make them immutable.
 
 Edson
 
  2012/2/22 Matteo Cusmai cusmaimat...@gmail.com
 
  Hi Edson,
  so, when i want modify an event, i could do as follow:
 
 - clone event;
 - change the duration
 - retract the previuos event
 - insert the new event
 
  Is it right?
 
  Bye bye,
 
  Matteo.
 
  2012/2/22 Edson Tirelli ed.tire...@gmail.com
 
 
 Unfortunately you can't update event durations or timestamp. Events
  are supposed to represent things that happened and as so, are
 immutable
  (other than data enrichment). If an event representation is no longer
  true,
  that event has to be retracted. Most common case is when you are
 dealing
  with atomic events (like start and end atomic events) that represent a
  complex event. Usually you will have a rule that correlates the start
 and
  end atomic events and creates a complex derived event, retracting the
  atomic ones.
 
 Edson
 
  2012/2/22 Matteo Cusmai cusmaimat...@gmail.com
 
 
  Hi all,
  i am using Drools Fusion in multi sensor data fusion system. I have
 some
  rules that generate a new event when some situations occur. But from
 the
  other hand, i would like to update the event, when i understand that
 new
  sensor observation is referring to the same event. I have my Event
 clazz
  with duration field, i try to update it in modify clause, but i have
  concern about it, because when i use temporal operator (such as
 before,
  meets, so on) it seems that Drools manage them as event with duration
  null.
  I could post the code too.
  Bye bye,
  Matteo.
  ___
  rules-users mailing list
  rules-users@lists.jboss.org
  https://lists.jboss.org/mailman/listinfo/rules-users
 
 
 
 
  --
Edson Tirelli
JBoss Drools Core Development
JBoss by Red Hat @ www.jboss.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
 
 
 
 
  --
Edson Tirelli
JBoss Drools Core Development
JBoss by Red Hat @ www.jboss.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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss

Re: [rules-users] How to create a drl file or decision table dynamically?

2012-02-24 Thread Edson Tirelli
 The reason it is not in the manual yet is because it was not promoted
to the public API yet. Nevertheless, you can use it, but be aware that
there might still be changes on it from version to version until it is
promoted to the public API. I am hoping Mark will give me the go ahead to
make it public soon.

 Examples are here:

https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/lang/api/DescrBuilderTest.java

 The javadoc is not complete, but what is there is correct. Classes are:

https://github.com/droolsjbpm/drools/tree/master/drools-compiler/src/main/java/org/drools/lang/api

 The API is completely typesafe, so you can trust the code completion
of you java editor... :)

 Edson


2012/2/24 Michael Anstis michael.ans...@gmail.com

 1) No you don't have to save it; just use one of the overloaded methods on
 KnowledgeBuilder that takes a StringReader, or String or something else
 similar.

 2) I understand there to be one for Drools Expert too, which I'd expect to
 be in one of the drools-xxx JARs however am having trouble finding it!

 Re#2, I've asked Edson Tirelli (the author of the Drools Expert Fluent
 API) to advise further...


 On 24 February 2012 17:35, shawn youngxiao...@hotmail.com wrote:

 Thank you~
 Does it mean I have to write a file in java and saved it as .drl?
 fluent API is in jbpm, right?

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/How-to-create-a-drl-file-or-decision-table-dynamically-tp3772708p3773187.html
 Sent from the Drools: User forum 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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Drools Fusion: updating event duration

2012-02-22 Thread Edson Tirelli
   Unfortunately you can't update event durations or timestamp. Events are
supposed to represent things that happened and as so, are immutable (other
than data enrichment). If an event representation is no longer true, that
event has to be retracted. Most common case is when you are dealing with
atomic events (like start and end atomic events) that represent a complex
event. Usually you will have a rule that correlates the start and end
atomic events and creates a complex derived event, retracting the atomic
ones.

   Edson

2012/2/22 Matteo Cusmai cusmaimat...@gmail.com


 Hi all,
 i am using Drools Fusion in multi sensor data fusion system. I have some
 rules that generate a new event when some situations occur. But from the
 other hand, i would like to update the event, when i understand that new
 sensor observation is referring to the same event. I have my Event clazz
 with duration field, i try to update it in modify clause, but i have
 concern about it, because when i use temporal operator (such as before,
 meets, so on) it seems that Drools manage them as event with duration null.
 I could post the code too.
 Bye bye,
 Matteo.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Drools Fusion: updating event duration

2012-02-22 Thread Edson Tirelli
   If your use case somehow has mutable events, you can retract, change
the duration and reinsert. The engine uses optimizations for the temporal
reasoning that are based on the fact that events should be immutable. That
is why the engine resolves the timestamp/duration attributes at insert
time and make them immutable.

   Edson

2012/2/22 Matteo Cusmai cusmaimat...@gmail.com

 Hi Edson,
 so, when i want modify an event, i could do as follow:

- clone event;
- change the duration
- retract the previuos event
- insert the new event

 Is it right?

 Bye bye,

 Matteo.

 2012/2/22 Edson Tirelli ed.tire...@gmail.com


Unfortunately you can't update event durations or timestamp. Events
 are supposed to represent things that happened and as so, are immutable
 (other than data enrichment). If an event representation is no longer true,
 that event has to be retracted. Most common case is when you are dealing
 with atomic events (like start and end atomic events) that represent a
 complex event. Usually you will have a rule that correlates the start and
 end atomic events and creates a complex derived event, retracting the
 atomic ones.

Edson

 2012/2/22 Matteo Cusmai cusmaimat...@gmail.com


 Hi all,
 i am using Drools Fusion in multi sensor data fusion system. I have some
 rules that generate a new event when some situations occur. But from the
 other hand, i would like to update the event, when i understand that new
 sensor observation is referring to the same event. I have my Event clazz
 with duration field, i try to update it in modify clause, but i have
 concern about it, because when i use temporal operator (such as before,
 meets, so on) it seems that Drools manage them as event with duration null.
 I could post the code too.
 Bye bye,
 Matteo.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




 --
   Edson Tirelli
   JBoss Drools Core Development
   JBoss by Red Hat @ www.jboss.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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Regex parsing of drl file versus Visitor pattern

2012-02-16 Thread Edson Tirelli
   First it is important to know that you are dealing with internal APIs
here and they can change from version to version, although they haven't
changed much in the latest few versions.

   If you use the DRLParser directly, it will give you an AST-like
descriptor model (root object is a PackageDescr). That model contains info
like line/column of each element in the source file, including the type
declarations. Of course, comments are discarded by the parser, but if you
want to inject/remove stuff you can simply use the position information to
do that in the original file and this way preserve comments and ordering,
etc.

   Edson

On Thu, Feb 16, 2012 at 1:50 PM, mikeg m...@thegoldners.com wrote:

 My project uses Drools type declarations with custom annotations that are
 used to assist in the dynamic mapping of underlying domain data to drools
 fact types.

 I need to provide a Swing user interface for rule creation that guides the
 user through the custom type declarations, rules, and functions.  Guvnor
 doesn't seem to be a good fit.

 I've looked at drools-verifier (and the older DrlDumper class) and its use
 of the Visitor pattern to traverse a rule package, but it is a lot of work
 to implement just for the type declaration enhancements.  Producing
 identical DRL to the imported file seems difficult.  Also, any inline
 comments and formatting is lost.

 Alternatively, I could parse (via regex patterns) the DRL to extract the
 type declarations, rules, and functions and then reconstruct the complete
 package file.  This seems simpler, though brittle. Also, the regex gets
 complicated when attempting to get extended information (metadata,
 annotations, etc.).

 Any thoughts on either approach?  Is there an easier way to process a rules
 file into a simple data model that doesn't lose the original DRL syntax?



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Regex-parsing-of-drl-file-versus-Visitor-pattern-tp3751402p3751402.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Performance of collect seems to be n-squared

2012-02-13 Thread Edson Tirelli
   Just FYI, the array list is created once and reused with incremental
addition/removal of elements.

   The problem is that the engine does not know when you are done inserting
all the Post facts, so each post inserted is propagated down the network
with the cancellation and reactivation of the rule.

   This is one of those situations where a use of a control fact might be
recommended, if you are inserting Post facts in batches. E.g.:

rule X
when
 exists( AllPostsInserted() )
 $a : ArrayList(size  0) from collect(Post());
then
...
end

   Edson


2012/2/13 Wolfgang Laun wolfgang.l...@gmail.com

 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.s...@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@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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Using Character typed properties in Drool 5.3

2012-02-13 Thread Edson Tirelli
   Which version of MVEL are you using? It looks like a regression. I will
ping Mario to take a look.

   Edson

On Mon, Feb 13, 2012 at 6:45 PM, Welsh, Armand awe...@statestreet.comwrote:

 Correction:

 Even using Character.valueOf('Y') does not work anymore in Drools 5.3.
  The validate works, but the compile steps fails because Drools is treating
 'Y' as a String.  However, in Drools 5.2 and prior, 'Y' was properly casted
 to a Character when the property it was being compared to was a property of
 type Character.

 If anyone has any insight on where the documentation address this change
 in behavior, I would appreciate some guidance.  I am trying to
 re-standardize how our rules are coded for evaluating Character typed
 properties.

 Armand

 -Original Message-
 From: rules-users-boun...@lists.jboss.org [mailto:
 rules-users-boun...@lists.jboss.org] On Behalf Of Welsh, Armand
 Sent: Monday, February 13, 2012 3:16 PM
 To: Rules Users List
 Subject: [rules-users] Using Character typed properties in Drool 5.3

 Community,

 In drools 5.2 I had the following LHS

 when
BloombergColumn (columnName == CRNCY, $cur : stringValue != null)
Country (currency == $cur, emergingMkt == 'Y' || countryCode in
 (BH,HR,CZ,EE,HK,HU,IL,KR,KW,MO,OM,QA,SA,SG,SK,SI,TT))


 I am switching to Drool 5.3, and Drools Guvnor reports the following error
 upon validate (or compile):

[bum_code_value.currency 01] Unable to Analyse Expression
 emergingMkt == 'Y' || countryCode == BH || countryCode == HR ||
 countryCode == CZ || countryCode == EE || countryCode == HK ||
 countryCode == HU || countryCode == IL || countryCode == KR ||
 countryCode == KW || countryCode == MO || countryCode == OM ||
 countryCode == QA || countryCode == SA || countryCode == SG ||
 countryCode == SK || countryCode == SI || countryCode == TT: [Error:
 Comparison operation requires compatible types. Found class
 java.lang.Character and class java.lang.String] [Near : {... == SK ||
 countryCode == SI || countryCode == TT }] ^ [Line: 7, Column: 28]

 Looking at the emergingMkt in my data model, I see that it is defined as a
 Character.  If I change my LHS to:

BloombergColumn (columnName == CRNCY, $cur : stringValue != null)
Country (currency == $cur, emergingMkt == Character.valueOf('Y') ||
 countryCode in
 (BH,HR,CZ,EE,HK,HU,IL,KR,KW,MO,OM,QA,SA,SG,SK,SI,TT))


 Then the validate passes.

 Was this change in behavior intentional?  I don't see a reference to this
 change in the Drools 5.3 documentation, and this makes for a harder to read
 rule for our Drools analysts.

 Thanks in advance,
 Armand

 ___
 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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] bytecode representation of rules

2012-01-28 Thread Edson Tirelli
   Take a look at the org.drools.rule.JavaDialectRuntimeData class in
drools-core. It contains a Map field called store. All bytecode generated
is stored in there, but there is no built-in way of dumping it. So either
your tool allows you to inspect it in memory, or you change the class to
dump it somewhere. Take a look at the writeExternal() method to understand
how we dump it during kbase serialization.

   Edson

2012/1/28 Mainul Raju mainul.r...@yahoo.com


 Thanks a lot. At least we are on the same track :).

 I already dumped it into a directory and It gives me all generated .java
 files. At this point, trying to figure out some ways around for static
 analysis on rules by using SOOT. No luck yet :( .

 Thanks again for your informative response.

 --
 Mainul

   --
 *From:* Edson Tirelli ed.tire...@gmail.com
 *To:* Rules Users List rules-users@lists.jboss.org
 *Sent:* Friday, 27 January 2012, 17:35
 *Subject:* Re: [rules-users] bytecode representation of rules


Tough question to answer as not everything in a DRL file becomes
 bytecode, and not all in the same place. For instance, rule consequences
 and other semantic code blocks, when using the java dialect, will become a
 class that is code generated and compiled in memory. You can see that code
 by setting the dump dir option in the KnowledgeBuilderConfiguration object
 (or -Ddrools.dump.dir=path on the command line).

Constraints on the other hand will become a mix of JIT bytecode and/or
 MVEL expressions and/or object accessors, depending on several factors.
 Since they are shared among multiple rules, they don't belong to a single
 rule in particular, but become part of the Rete network, that is basically
 an in-memory data structure.

Not exactly sure if this helps you...

Edson

 2012/1/26 Mainul Raju mainul.r...@yahoo.com



 Hello All:

 I have been trying to get the byte code representation of rules (.drl
 files). I would appreciate it if anyone could kindly provide me any way to
 do that.

 I have created a rule based application with 100 rules in 5 different .drl
 files. My intention is to analyze the application with some byte code
 analyzer (i.e. soot). For the purpose of hat static analysis, I need the
 byte-code representation of rules which I can't get from drools.

 Thanks in advance.
 //
 Mainul

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




 --
   Edson Tirelli
   JBoss Drools Core Development
   JBoss by Red Hat @ www.jboss.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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] bytecode representation of rules

2012-01-27 Thread Edson Tirelli
   Tough question to answer as not everything in a DRL file becomes
bytecode, and not all in the same place. For instance, rule consequences
and other semantic code blocks, when using the java dialect, will become a
class that is code generated and compiled in memory. You can see that code
by setting the dump dir option in the KnowledgeBuilderConfiguration object
(or -Ddrools.dump.dir=path on the command line).

   Constraints on the other hand will become a mix of JIT bytecode and/or
MVEL expressions and/or object accessors, depending on several factors.
Since they are shared among multiple rules, they don't belong to a single
rule in particular, but become part of the Rete network, that is basically
an in-memory data structure.

   Not exactly sure if this helps you...

   Edson

2012/1/26 Mainul Raju mainul.r...@yahoo.com



 Hello All:

 I have been trying to get the byte code representation of rules (.drl
 files). I would appreciate it if anyone could kindly provide me any way to
 do that.

 I have created a rule based application with 100 rules in 5 different .drl
 files. My intention is to analyze the application with some byte code
 analyzer (i.e. soot). For the purpose of hat static analysis, I need the
 byte-code representation of rules which I can't get from drools.

 Thanks in advance.
 //
 Mainul

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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] MVEL curly braces position - bug or feature?

2012-01-06 Thread Edson Tirelli
   Looks like a bug. MVEL does ; injection in order to make ; optional, so
my guess is that it is mistakenly injecting ; after your modify() call and
handling {} as a separate code block.

   Edson

On Fri, Jan 6, 2012 at 11:51 AM, nickS nsand...@msxi-euro.com wrote:

 Hi

 I've been learning drools ands I saw that there is a Fibonacci example, so
 I
 thought I'd write my own using mvel as the dialect and then compare it to
 the model solution.

 However, I couldn't get mine working. It parsed but the behaviour was very
 odd. It kept ignoring the modify block in my recurse rule and consequently
 it went into an infinite loop. I compared it to the 'approved' solution and
 the two were pretty much the same, except that it worked and mine didn't.

 After a lot of checking I noticed that I had started my curly brace on a
 new
 line after modify but the example had continued straight after the closing
 brace of the modify.

 Works //

 modify ( f ){
value = 1
   };

 or

  modify ( f ){value = 1 };


 Doesn't Work //

 modify ( f )
 {
  value = 1
  };


 Does anyone know if this is a bug or a feature?


 --
 View this message in context:
 http://drools.46999.n3.nabble.com/MVEL-curly-braces-position-bug-or-feature-tp3638341p3638341.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Two bugs(?) of drools 5.3

2011-12-30 Thread Edson Tirelli
   By your description, they look like problems, so please open a ticket
for them.

   Edson

2011/12/28 Miles Wen miles.w...@gmail.com

 Hi all,
 I'm using drools 5.3.0.Final.And I think I found two possibly bugs:

 1): drl compilation failed when encountering multiple continuous '!'
 (a.k.a 'not' operator)s.for example:

 rule out
 when
 Msg(!!!false)
 then
 end

 the code above won't compile, but 'Msg(!false)' compiles correctly. I
 remember there's no such problems when using drools 5.0, this caused some
 incompatibility issues in our system...

 2): Weird exception thrown:  java.lang.ClassCastException:
 org.drools.reteoo.InitialFactImpl cannot be cast to XXX..., for example:

 rule test
 when
 l1:Msg(str == 'test') and
 l2:Msg(!bool) or
 eval(!false)
 then
 end

 this code above throws exception at runtime:

 org.drools.RuntimeDroolsException: Unexpected exception executing action
 org.drools.reteoo.ReteooWorkingMemory$WorkingMemoryReteAssertAction@743fbbfc
 at
 org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:977)
 at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:315)
 at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:291)
 at
 org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:886)
 at
 org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:845)
 at
 org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:255)
 at com.sample.DroolsTest.main(DroolsTest.java:56)
 Caused by: org.drools.RuntimeDroolsException:
 com.sample.Rule_testEval0Invoker@3e1b05a2 : java.lang.ClassCastException:
 org.drools.reteoo.InitialFactImpl cannot be cast to com.sample.Msg
 at org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:119)
 at
 org.drools.reteoo.EvalConditionNode.assertLeftTuple(EvalConditionNode.java:178)
 at
 org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:197)
 at
 org.drools.reteoo.SingleLeftTupleSinkAdapter.createAndPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:146)
 at
 org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:158)
 at
 org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
 at
 org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:215)
 at
 org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:244)
 at org.drools.reteoo.Rete.assertObject(Rete.java:107)
 at
 org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:284)
 at
 org.drools.reteoo.ReteooWorkingMemory$WorkingMemoryReteAssertAction.execute(ReteooWorkingMemory.java:404)
 at
 org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:975)
 ... 6 more
 Caused by: java.lang.ClassCastException: org.drools.reteoo.InitialFactImpl
 cannot be cast to com.sample.Msg
 at com.sample.Rule_testEval0Invoker.evaluate(Unknown Source)
 at org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:114)
 ... 17 more

 Is there any workaround for those problems? especially the 2nd one...

 Any help would be appreciated,
 Thanks!

 --
 Regards.
 Miles. Wen


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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] 5.3.0.Final throws RuntimeDroolsException: Unable to merge resource attribute for type declaration

2011-12-13 Thread Edson Tirelli
   John,

   All you need to do is create an account for yourself in the JIRA home
page and you will be able to create the ticket and upload your project.
That is the best way as it provides tracking and avoids your code being
lost in someone's (or my) inbox.

https://issues.jboss.org/browse/JBRULES

   Edson

2011/12/13 Green, John M (HP Software) john.gr...@hp.com

  Edson,

 ** **

 Thanks for  your feedback.  I've have created an eclipse/maven project to
 duplicate this problem but I couldn't figure out how to open an issue in
 Jira (perhaps I don't have permission).

 ** **

 If I include all the dependent libraries in a zip file (for convenience)
 the zip will be 7MB (which might not be so convenient after all). 

 ** **

 Please let me know how I can open a new issue in Jira and/or how best to
 deliver this project to you. 

 ** **

 John 

 *From:* rules-users-boun...@lists.jboss.org [mailto:
 rules-users-boun...@lists.jboss.org] *On Behalf Of *Edson Tirelli
 *Sent:* Friday, December 09, 2011 5:34 PM
 *To:* Rules Users List
 *Subject:* Re: [rules-users] 5.3.0.Final throws RuntimeDroolsException:
 Unable to merge resource attribute for type declaration

 ** **

 ** **

Looks like a bug in the merging algorithm for types. Can any of you
 please open a JIRA with a small test case and/or instructions on how to
 reproduce plz?

 ** **

Thank you,

 Edson

 On Fri, Dec 9, 2011 at 6:34 PM, jmgreen john.gr...@hp.com wrote:

 I was able to work around this problem by filtering out the
 KnowledgePackage
 containing my NormalizedEvent.   In Drools 5.2.0 there was no problem
 adding
 this KnowledgePackage multiple times but apparently 5.3.0 doesn't cope with
 it well.   I'm still not sure if that is a feature or a defect in 5.3.0.
 In any event doing the following make the exception go away.

 I'm still curious if this is a feature or a defect in 5.3.0.   Any thoughts
 or opinions regarding are welcome.



String globals = readDrlfile(globals.drl);
String newRules = readDrlfile(rulesToAdd.drl);
knowledgeBuilder.add(ResourceFactory.newReaderResource(new
 StringReader(globals + newRules)));
if (knowledgeBuilder.hasErrors()) {
throw exception ...
}
// No exception so compile succeeded --- BTW, it's using JANINO

   CollectionKnowledgePackage pkgs =
 knowledgeBuilder.getKnowledgePackages();


 pkgs=filterOutAnyPackageThatHasNoRulesAndNameMatchingNormalizeEventPackageName(pkgs);
   knowledgeBase.addKnowledgePackages(pkgs);  // NO ERROR ANYMORE




 --
 View this message in context:
 http://drools.46999.n3.nabble.com/rules-users-5-3-0-Final-throws-RuntimeDroolsException-Unable-to-merge-resource-attribute-for-type-den-tp3573815p3574420.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users



 

 ** **

 --
   Edson Tirelli
   JBoss Drools Core Development
   JBoss by Red Hat @ www.jboss.com

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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Temporal operators for point-in-time events

2011-12-13 Thread Edson Tirelli
   Your use of the after operator is correct. The documentation tells you
about that, although in textual form:

http://docs.jboss.org/drools/release/5.3.0.Final/drools-fusion-docs/html_single/index.html#d0e611

   This presentation has the 2 tables of operators:

http://www.slideshare.net/ge0ffrey/applying-cep-drools-fusion-drools-jbpm-bootcamps-2011

Edson

On Tue, Dec 13, 2011 at 12:11 PM, Mike Melton mike.mel...@gmail.com wrote:

 Apologies for the stupid question, but I haven't seen anything in the
 documentation regarding this and I want to verify my solution. Say I
 have a point-in-time event (i.e., duration of 0) that I want to
 correlate to another point-in-time event. I want a rule that will
 activate if the timestamp of one is greater than or equal to the
 other, basically after or coincides. I wrote a test using the
 following rule and it seemed to work:

 rule Greater Than or Equal
  when
$e1 : TestEvent( $id : id )
$e2 : TestEvent( id != id, this after[0ms] $e1 )
  then
System.out.println($e2 +  is greater than or equal to  + $e1);
 end

 I realize this rule will fire twice if the event timestamps are equal,
 but it's just for demonstration purposes; my question is specifically
 about the after[0ms] part. Is this the way to go to accomplish what
 I need? It seems so simple but I have this annoying feeling that I'm
 missing something.

 On a slightly related topic, is there an updated version of the
 temporal operators image from the Drools Fusion homepage? It is a
 great visual description of the operators and I want to print it out
 and post it at my desk, but it doesn't include all of the operators.

 Image:
 http://www.jboss.org/drools/drools-fusion/mainColumnParagraphs/02/imageBinary/temporal-operators.png
 From page: http://www.jboss.org/drools/drools-fusion.html

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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] 5.3.0.Final throws RuntimeDroolsException: Unable to merge resource attribute for type declaration

2011-12-09 Thread Edson Tirelli
   Looks like a bug in the merging algorithm for types. Can any of you
please open a JIRA with a small test case and/or instructions on how to
reproduce plz?

   Thank you,
Edson

On Fri, Dec 9, 2011 at 6:34 PM, jmgreen john.gr...@hp.com wrote:

 I was able to work around this problem by filtering out the
 KnowledgePackage
 containing my NormalizedEvent.   In Drools 5.2.0 there was no problem
 adding
 this KnowledgePackage multiple times but apparently 5.3.0 doesn't cope with
 it well.   I'm still not sure if that is a feature or a defect in 5.3.0.
 In any event doing the following make the exception go away.

 I'm still curious if this is a feature or a defect in 5.3.0.   Any thoughts
 or opinions regarding are welcome.


String globals = readDrlfile(globals.drl);
String newRules = readDrlfile(rulesToAdd.drl);
knowledgeBuilder.add(ResourceFactory.newReaderResource(new
 StringReader(globals + newRules)));
if (knowledgeBuilder.hasErrors()) {
throw exception ...
}
// No exception so compile succeeded --- BTW, it's using JANINO
CollectionKnowledgePackage pkgs =
 knowledgeBuilder.getKnowledgePackages();


 pkgs=filterOutAnyPackageThatHasNoRulesAndNameMatchingNormalizeEventPackageName(pkgs);
   knowledgeBase.addKnowledgePackages(pkgs);  // NO ERROR ANYMORE




 --
 View this message in context:
 http://drools.46999.n3.nabble.com/rules-users-5-3-0-Final-throws-RuntimeDroolsException-Unable-to-merge-resource-attribute-for-type-den-tp3573815p3574420.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Need clarification on how event expiration offset is calculated in 5.3.0.FINAL

2011-12-07 Thread Edson Tirelli
   Scott,

   The event expiration algorithm in Drools works with compile time
analysis of temporal constraints. It calculates the transitive closure on
the temporal intervals created by each temporal constraint and from that it
infers the required time for an event to stay in memory, expiring them
after that. Some interactions are pretty hard to calculate manually, but as
you already realized, you can enable the Drools MBeans and use jconsole (or
visualvm as you mentioned) to inspect them.

In your case, first things first, I assume you are running the engine
in STREAM mode? the default is CLOUD mode, and in CLOUD mode there is no
expiration of events. Second, there was a bug in one of the released
versions of Drools (I think 5.2 or 5.3) that was fixed after where the
calculation was wrong if the events were in different packages. Finally,
you are using external timestamps for the events (on its attributes), so
make sure your clock is in line with the externally timestamped events.

If everything I mentioned is working as expected and your events are
still not being expired, please try adding an explicit expiration policy
(e.g., @expires( 1m ) ), and submit a bug (JIRA) with your findings.

Edson

2011/12/7 Scott Embler stemb...@gmail.com

 Hi,

 I've recently started using some of the temporal operators that drools
 supports (coincides, starts, finishes, during) and have had trouble with
 events not being expired, causing severe memory consumption.
 I'd first like to make sure that I'm using these operators appropriately,
 so as a test case I have rules like:

 declare A
   @role( event )
   @timestamp( timestamp )
   @duration( duration )
 end

 declare B
   @role( event )
   @timestamp( timestamp )
   @duration( duration )
 end

 rule coincides events
 when
   $a: A() from entry-point a
   $b: B(this coincides $a) from entry-point b
 then insert(coincides); end

 With classes like:

 public class A{
 public final long timestamp;
 public final long duration;
 public A(long timestamp, long duration){
 this.timestamp = timestamp;
 this.duration = duration;
 }
 }

 //B is identical to A.

 Using a knowledge base configured with stream mode, and a knowledge
 session with a pseudo clock I'd run this test:

 A a = new A(0, 1000);
 B b = new B(0, 1000);

 entryPointA.insert(a);
 entryPointB.insert(b);
 clock.advanceTime(1000, TimeUnit.MILLISECONDS);
 ksession.fireAllRules();

 In this test I'm expecting that the rule will fire to insert coincides
 and expire both A and B.  But instead, coincides is inserted, B is
 expired, but A remains in memory permanently.  If I use jvisualvm to
 inspect the expirationOffset for A, I see that it is the Long.MAX value of
 9223372036854775807.  This behavior persists even after adding an explicit
 expiration to A.  I was under the impression that the offset would be zero
 (of close to it) since Drools would only need to retain A until the clock
 reaches A's endTimestamp.  The documentation does not cover the calculation
 of event expiration in great detail, so have I missed something?  Thanks in
 advance.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Fusion : must declare @role(event) for all class hierarchy ?

2011-11-28 Thread Edson Tirelli
 sample class look like the real one, but I can't reproduce ..).

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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Fusion : must declare @role(event) for all class hierarchy ?

2011-11-14 Thread Edson Tirelli
   Vincent,

   Fact types are supposed to inherit the @role of their parent classes, so
if you define the parent class/interface as an event, all subclasses will
inherit the event role. If it is not working like this, it is a bug, but I
am pretty sure we have tests for it. Please open a JIRA and provide a test
case to reproduce the behavior otherwise.

   Thank you,
   Edson

2011/11/14 Vincent LEGENDRE vincent.legen...@eurodecision.com

 Hi all

 We are using Fusion to make some simplification and grouping on some
 events.
 We have several classes of events, all derivated from a top-level class.

 With fusion version 5.3 (and 5.2 too), we must declare the @role(event)
 for the top-level class, *but also for all its classes hierarchy*, ie the
 role is not inherited by subclasses.

 Is it done and purpose ?
 Is it a bug ?

 Thanks.

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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Fwd: 5.3.0 Final - Rule using accumulate with windows:length delivers an unexpected result

2011-11-14 Thread Edson Tirelli
   Sorry, but which results exactly are you seeing?

   Edson

2011/11/14 Michael Anstis michael.ans...@gmail.com

 I'd have to defer to the drools-expert people.. as the problem appears to
 be with 5.3.0.Final of drools-expert.

 As a reminder, the DRL failing in 5.3.0.Final (or giving different results
 to 5.2.0?) is:-

 rule Event Processing Evaluation
  dialect mvel
 when
$list:java.util.List() from collect( evalEvent(wam == 'D1', f != null)over 
 window:length( 1 ))
 $average:Double() from accumulate( evalEvent($vf:f) from
$list,average($vf) )
eval($average  5)
 then
internalEvent fact0 = new internalEvent();
fact0.setDesrc( Internal Event: + $average );
insert(fact0 );
 end

 -- Forwarded message --
 From: axel axel.poeschm...@solutions.endress.com
 Date: 14 November 2011 08:16
 Subject: Re: [rules-users] Guvnor (5.3.0 Final)- Rule using accumulate
 with windows:length delivers an unexpected result
 To: rules-users@lists.jboss.org


 Thanks Mike.

 So, now I've included Drools 5.3.0 Final in my Eclipse Drools Project too
 and discovered the same problem as in Guvnor with my example. There is a
 difference between 5.2.0 Final (works well) and 5.3.0 Final (fails) in my
 case.

 Is there a major change with event processing with sliding windows or is it
 a just bug in the new version?

 The DRL between Eclipse and Guvnor is the same, in principle. It means, I
 started the project within Guvnor using the build features with the Editor
 supporting creating a model in Guvnor and the business rule. These two
 files, I couldn't reuse in my Eclipse project 1:1 (I used New File from
 Guvnor Ressource in Eclipse for that), failed to compile and even to open
 for the brl-file. So, I made the same model as Java Classes and a new DRL
 in
 Eclipse copy the stuff from the Guvnors view source windows adding the
 includes for the Java model and adding the Event declaration by hand. By
 the
 way, are there any other hints for that ...

 With regards,

 Axel


 --
 View this message in context:
 http://drools.46999.n3.nabble.com/rules-users-Guvnor-5-3-0-Final-Rule-using-accumulate-with-windows-length-delivers-an-unexpected-resut-tp3489548p3506191.html
 Sent from the Drools: User forum 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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Showstopper issues for Drools Adoption in our organization

2011-11-11 Thread Edson Tirelli
   Ivan,

   The more complex your problem gets, more technologies you will need to
employ to solve it properly. Indeed Drools does not work directly with
persistent storages, because its focus is on the efficient processing of
business rules, processes and events, delegating the management of
persistent and historical data to specialized tools (all kinds of
databases, caches, etc). But Drools integrates with them by several
different means, including pulling data from them on demand.

   I suggest you watch the presentation Drools and Large Data Sets by
Alexandre Porcelli, at the bootcamp in Argentina back in June:
http://blog.athico.com/2011/08/drools-jbpm5-sessions-argentina-june.html .
The solution is obviously tailored to the problem in question (constantly
dealing with 30 million rows of historical data with high performance if I
remember correctly), as any solutions for any major problems are. In other
words, using each tool for what they do best and build the puzzle from
there.

   Regarding your second point, my understanding is that it has nothing to
do with Drools per se. Does not matter if you implement your rules in
Drools, in Java, or any other technology/language, you will have the same
mapping problem. Solutions for that include a translator for the rules as
you mentioned, or a translator for the data (smooks is a good open source
one), or even use an adapter fact model that allows rules to work under the
user friendly model, but execute actions on the engineering model.

   Hope it helps,

   Edson

On Fri, Nov 11, 2011 at 5:53 AM, kapokfly ivan.jiang...@foxmail.com wrote:

 Not sure if these are also your questions you might have with the rule
 engine
 adoption, but we have seen 2 showstopper issues for drools adoption in our
 organization, or it is just because we are lack of some necessary
 knowledge.

 Issue 1) : pattern match for large data

 There are cases in a rule we need find matched records against a large
 population of data and perform some actions.

 Example:
From 2 millions employee directory, find those belongs to Depart1 and
 with salary increased by 10% last year.

Inserting all these employee's data into WorkingMemory is HUGE and
 mission impossible, we can't simply load the entire db into the working
 memory, do we have any other approach to accomplish or this is just not a
 use case can be resolved by a rule engine?


 Issue 2): Map business object to real engineering implementation

 What we are trying to do is to build a rule UI which a business user
 without
 engineering background of our codebase can work with; the business object
 we
 show on the UI might be different with the real engineering objects already
 in system, for example, on the UI a user might be able to able to see
 something like person.address.addressLine1 but the actually implementation
 might not be an object traverse implementation.

 Example, the model could be Long Person.addressId ; then referring to his
 address we need another lookup and we want to hide such complexity to the
 end user.

 The approach we took is to design a translation layer to translate the user
 input to drools rule string, is this the right approach?

 If not, any suggestions? I know Drools is mainly designed for developers
 but
 just trying to see if there is any way we can work it around.

 Thanks and looking forward to your recommendations.

 Ivan








 -
 Ivan, your Panda, forever
 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Showstopper-issues-for-Drools-Adoption-in-our-organization-tp3499367p3499367.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Bugs in Drools 5.3.0 break Fusion event processing

2011-11-10 Thread Edson Tirelli
   Thanks Richard,

   I will fix them for the next release.

   Edson

2011/11/9 Richard Calmbach rcalm...@gmail.com

 Edson: Thanks for the quick reply. I created these JIRA issues:

 F1: Duplicate job scheduling in
 org.drools.time.impl.DefaultTimerJobInstance.call()
 - https://issues.jboss.org/browse/JBRULES-3284

 F2: NullPointerException in
 org.drools.time.impl.DefaultTimerJobInstance.compareTo(DefaultTimerJobInstance)
 - https://issues.jboss.org/browse/JBRULES-3285

 F3: org.drools.time.TimerService.scheduleJob(Job, JobContext, Trigger)
 suddenly requires non-null JobContext
 - https://issues.jboss.org/browse/JBRULES-3286

 While you are working on the event scheduling system, you may also want to
 look at these two earlier bug reports for Drools 5.2.0:

 Long.MAX_VALUE duration for A and not(B after A) type rules causes
 invalid session clock time in rule RHS when running with pseudo clock
 - https://issues.jboss.org/browse/JBRULES-3100

 A and not(B after A) type rules don't fire when session clock has
 negative values (pre Unix epoch)
 - https://issues.jboss.org/browse/JBRULES-3103

 I have not checked their status in Drools 5.3.0, but the description
 should tell you whether they still apply.

 FWIW, among all of these, F2 (JBRULES-3285) has the highest priority (as
 it's breaking my unit tests), followed by F1 (JBRULES-3284). Thanks!

 Vincent: Yes, I think there is risk. Even if you don't use jobs
 explicitly, Drools uses the same event scheduling system for both internal
 events and application-defined events and jobs. The main problem is this:
 How do you establish correctness of your code and the overall system? Well,
 you make sure your unit tests and functional tests pass. As it stands, I
 cannot get my tests to pass with Drools 5.3.0, so I cannot put Drools 5.3.0
 in production. No matter which version you use, only good test coverage
 will give you the assurance that your system is functioning properly. I
 encourage you to try out Drools 5.3.0 (in a test environment) and to report
 any issues you run into. It can only help make Drools better.

 2011/11/9 Vincent LEGENDRE vincent.legen...@eurodecision.com

 Just wondering : does these problems happends because you use clocks and
 jobs, or is it general to fusion 5.3 ?
 Did not migrate my project on 5.3 for now.
 So do you think there is a risk, knowing that I only use very basic
 fusion features ?

 --
 *De: *Edson Tirelli ed.tire...@gmail.com
 *À: *Rules Users List rules-users@lists.jboss.org
 *Envoyé: *Mercredi 9 Novembre 2011 14:53:00
 *Objet: *Re: [rules-users] Bugs in Drools 5.3.0 break Fusion event
 processing



Richard,

This is great info. Yes, please open JIRA's for all 3 issues and we
 will make sure this is fixed for the next release.

Thank you,
Edson


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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Bugs in Drools 5.3.0 break Fusion event processing

2011-11-09 Thread Edson Tirelli
 PriorityQueueE.siftUpComparable(int, E) line: 582
 PriorityQueueE.siftUp(int, E) line: 574
 PriorityQueueE.offer(E) line: 274
 PriorityQueueE.add(E) line: 251
 PseudoClockScheduler.internalSchedule(TimerJobInstance) line: 136
 PseudoClockScheduler.scheduleJob(Job, JobContext, Trigger) line: 126
 ObjectTypeNode.assertObject(InternalFactHandle, PropagationContext,
 InternalWorkingMemory) line: 230
 EntryPointNode.assertObject(InternalFactHandle, PropagationContext,
 ObjectTypeConf, InternalWorkingMemory) line: 244
 NamedEntryPoint.insert(InternalFactHandle, Object, Rule, Activation,
 ObjectTypeConf) line: 330
 NamedEntryPoint.insert(Object, boolean, boolean, Rule, Activation) line:
 291
 NamedEntryPoint.insert(Object) line: 116
 NamedEntryPoint.insert(Object) line: 48
 my code calling into Drools

 Here is method
 org.drools.time.impl.DefaultTimerJobInstance.compareTo(DefaultTimerJobInstance):

 public int compareTo(DefaultTimerJobInstance o) {
 return this.trigger.hasNextFireTime().compareTo(
 o.getTrigger().hasNextFireTime() );
 }


 Essentially, this method calls java.util.Date.compareTo(Date) with a null
 argument, which, as documented, causes a NullPointerException. Sometimes,
 this.trigger.hasNextFireTime() already returns null, and then the NPE gets
 thrown in DefaultTimerJobInstance.compareTo() itself.

 I've seen different stack traces leading to this NPE, so this must be
 affecting scheduling and job execution quite broadly.

 Issue F3:
 It is debatable whether this is a bug, but it is a backward-compatibility
 breaking change. Previously, when scheduling a job with
 org.drools.time.TimerService.scheduleJob(Job job, JobContext ctx, Trigger
 trigger) (for both real-time and pseudo clock), you could pass a null
 JobContext (say, because you didn't need one), and it would work. However,
 in Drools 5.3.0, this causes a NullPointerException at:

 org.drools.time.impl.DefaultTimerJobFactoryManager.createTimerJobInstance(Job,
 JobContext, Trigger, JobHandle, InternalSchedulerService) line: 25

 I realize that if it's not in knowledge-api-version.jar, it's not an
 official API, but the available interfaces and classes in
 org.drools.time.** (as used in the Broker example) are *very* useful for
 test harnesses *and* for production code (for implementing dynamic timers,
 for instance). So, this is more of a heads-up: If you are suddenly getting
 an NPE, this might be the cause.


 Please let me know whether I should create JIRA bug reports for issues F1
 and F2. Also, I'd be interested to hear whether others have run into issues
 with Fusion in Drools 5.3.0.

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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Security test cases for Drools

2011-11-09 Thread Edson Tirelli
   Against external attacks, Drools supports knowledge base signing and
checking using standard asymmetric keys infrastructure. Regarding the web
application,  I will let one of the guvnor guys to talk about. Against
internal attacks, i.e., someone deliberately adding a malicious rule into
the application, the only way is through company policies and processes
that ensure a workflow for rule approval. Drools offers audit logs
(runtime) and standard versioning history (in guvnor, authoring time) to
track changes.

   Edson


On Wed, Nov 9, 2011 at 11:42 AM, kapokfly ivan.jiang...@foxmail.com wrote:

 Not sure if anyone can share their experiences what kind of test cases on
 Drools security should be developed and ensured?

 As the rule is just a piece of codes in String format which can be hooked
 into JVM, we can assume that might open some holes and necessary security
 test cases need to be designed against.

 Anyone can share their experiences on this?

 Thanks...

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Security-test-cases-for-Drools-tp3494072p3494072.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] How to parse comments in drl file using DrlParser?

2011-11-04 Thread Edson Tirelli
   Praveen,

   Comments are parsed into an ANTLR hidden channel. Check the ANTLR
documentation about how to capture tokens for a hidden channel if you want
to pursue that path.

   My suggestion for you is to use an annotation to store your
documentation instead. This allows you to easily access it from code:

rule X
   @doc( This is the documentation for rule X... )
...

   Edson

On Fri, Nov 4, 2011 at 7:55 AM, Praveen praveen.sa...@gmail.com wrote:

 Hi,

 The system we are building requires rulenames and rule
 description(comments) to be displayed in the UI(built using JQuery).
 I am using DrlParser to convert the drl(generated using Guvnor) to XML so
 that it could be used to display in the UI.
 However, the comments written in drl are not visible in the converted XML.
 Please let me know how to parse comments using DrlParser so that I can
 use
 it to display as rule description.

 Thanks  Regards,
 Praveen.

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/How-to-parse-comments-in-drl-file-using-DrlParser-tp3479895p3479895.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Sliding Length Windows

2011-10-31 Thread Edson Tirelli
   import java.util.List

   Edson

2011/10/31 diana-mendes diana-men...@hotmail.com

 Hello,

 Thank you for your response, I understand how the sliding window works now.
 However, when I use the code you wrote I get the following error:

 Exception in thread main java.lang.RuntimeException: Unable to resolve
 ObjectType 'List' : [Rule name='Rule2']

 Unable to Analyse Expression $last2:
 [Error: unable to resolve method using strict-mode:
 java.lang.Object.$last2()]


 My rule looks like this:

 rule Rule2
when
   $last2: List() from collect( Notif() over window:length(2) )
  $nNewONT : Number() from accumulate ( Notif( specificProblem
 == New ONT ) from $last2, count() )
 then
  ...
 end


 Do Lists require any additional code?...

 Thanks in advance,

 Diana



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Sliding-Length-Windows-tp3438408p3467432.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] confusing behaviour of enum comparison

2011-10-27 Thread Edson Tirelli
   Make sure you try with Drools 5.3 and the proper mvel version.

   Edson

2011/10/27 lhorton lhor...@abclegal.com

 thank you for taking the time to test this, Wolf.I have other tests
 with
 the same syntax that have tested ok as well.  It is puzzling.  I will test
 tomorrow with the mvel jar that I'm using.  I went to the beta 6 mvel
 because it compiles a lot faster for 5.2 but perhaps there are side
 effects.

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/confusing-behaviour-of-enum-comparison-tp3455245p3456711.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Rule, import with wildcards and variable / patternBinding

2011-10-25 Thread Edson Tirelli
   Per,

   This looks like a bug. Can you please open a JIRA for it with the
information on this e-mail?

   Thank you,
  Edson

2011/10/25 Per Sterner pelle...@yahoo.de

 Hello,

 Yesterday I wanted to upgrade my drools version to 5.3 (from 5.1). I got
 the exception java.lang.NoClassDefFoundError:
 de/pelle7/testpackage/event/myEvent (wrong name:
 de/pelle7/testpackage/event/MyEvent) while adding my resources.
 I removed the import wildcards and the error disappeard.

 Finally I found the problem:
 I used the patternBinding 'myEvent' and there is a class called
 'MyEvent' and I used an wildcard import where the class 'MyEvent' is
 located.

 Example code:
 
 package de.pelle7.testrules.impl.drools

 import de.pelle7.testpackage.event.*

 rule Test rule 1
 dialect java
 salience 50
 when
 myEvent : MyEvent( )
 myEvent2 : MyEvent( data == myEvent.data ) -- here the Exception
 is thrown
 then
 System.err.println(Output);
 end
 
 My solution is that I replaced all my pattern bindings with the suffix
 '$' which is more convenient.


 Perhaps it would be nice to produce an rule-compilation error. with a
 line notice.

 Regard,

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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Advice on varying rule behavior based on object tested?

2011-10-25 Thread Edson Tirelli
   Zack,

   The use of rule names as part of your logic (LHS) is a bad practice (as
you noticed already) for many reasons. I discussed this yesterday during my
presentation at the Rules Fest... I will make the presentation available
later this week.

   I think the problem is that you are mixing data driven constraints with
rule explicit constraints. There are several ways of improving your rules
depending on your goals. For instance, if your AlertThreshold is supposed to
constrain your instance, then it should know which attribute should be
tested. Using a strategy pattern (or simply method overload if you prefer),
you could have the method testing your instance directly:

   $entity : TestedEntity( )
   AlertThreshold( entity == $entity, isOverThreshold( $entity ) )

   Another way is to have an ENUM for the type of threshold you are dealing
with. This will avoid arbitrarily creating dependencies between facts and
rules.

   $entity : TestedEntity( )
   AlertThreshold( entity == $entity, type == ThresholdType.TEMPERATURE,
maxThreshold  $entity.temp )

   My .02c. Hope it helps,

Edson


2011/10/25 zstlaw zstla...@akamai.com

 Each item I am testing MAY have overridden the default thresholds or
 disable
 the rule entirely.  I would prefer to have this data related to the item I
 am testing rather than have each rule manage customized behavior for
 thousands of different types of objects.

 The object could have a map of rule thresholds it overrides, but for
 simplicity I assume there is a method to return the current threshold for
 the current object.  is there a better way to perform this kind of logic?
 Example of my current code:

 declare TestedEntity
temp : Double
 end

 declare AlertThreshold
maxAllowed : Double
 end

 rule Check temperature
when
$entity : TestedEntity( )
// would prefer to use drools.getRule().getName() on next line
AlertThreshold($entity.temp  maxAllowed)  from
 $entity.getAlertThresholdForRule(Check temperature)
then
// raise alert
 end

 I dislike hard-coding the rule name as it leads to copy paste errors.  I
 can't insert thresholds easily unless I define different ones for each rule
 and I want to be able to fall back to defaults easily.  This is a type of
 problem I have come up against several times now so I feel like others must
 have dealt with it before.  The idea of writing copies of rules tailored to
 each Entity appeals less than a generalized way of doing this.  By doing
 this I want to contain complexity.  Dozens of slightly different
 implementations of the same rule would be much harder to test and support.
 I am dealing with hundreds of thousands of facts today and will need to
 scale to millions before I can deploy fully.  But with that large number I
 need to have ways to manage exceptions to the general case just to keep
 complexity manageable.

 Thanks,
 Zack

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Advice-on-varying-rule-behavior-based-on-object-tested-tp3452814p3452814.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Drools Performance /Memory Leak Issue

2011-10-24 Thread Edson Tirelli
   I assume you are calling dispose() after using each session? Using
stateless session is an option as well.

   If so, with Drools 5.2 we had a problem with jbpm being in the classpath,
fixed in 5.3. Did you tried Drools 5.3 yet?

   To enable MBeans, just use the MBeansOption.ENABLED in the KBase
configuration, or set the system property: drools.mbeans=enabled.

   Edson

2011/10/24 arrehman arrehma...@yahoo.com

 Hi,

 Are there any instructions on how to enable JMX Beans and monitor Drools
 using JConsole or JVisualVM anywhere?

 Thanks,
 Abdul

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Drools-Performance-Memory-Leak-Issue-tp3448321p3448342.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] JBRULES-3260: Events forced to zero expirationOffset

2011-10-22 Thread Edson Tirelli
   Hi Robert,

   Good catch. I fixed this and will commit it in a few minutes. It will be
included in the next release. You will be able to download fixed binaries
from hudson or you can build them yourself.

   Edson

2011/10/22 Robert Crawford crawf...@kloognome.com

 It seems like ever since I found this, I can't stop tripping this
 condition.

 Basically, while adding the DRL files to the KnowledgeBuilder,
 ReteooRuleBase decides it has to reconcile event definitions from different
 packages, so it looks for any that are assignable. At first I thought
 this
 was just a guard against having a parent expire quicker than a child class
 and breaking rules for the child. But now I'm getting this condition for A
 SINGLE CLASS WITH NO INHERITANCE.

 At the root of the problem is ReteooRuleBase line 477:
 node.setExpirationOffset( Math.max( node.getExpirationOffset(),
 typeDeclaration.getExpirationOffset()+1 ) );

 Since neither node nor typeDeclaration have declared expirations, they both
 have expirationOffset values of -1. The code evaluates:

 max(-1, -1 + 1)

 sets the expirationOffset for node to zero, and from then on my objects are
 expired literally as I insert them.

 If someone could more clearly state the conditions that trip this code, I'd
 do my best to avoid them. I've already eliminated inheritance among my
 events, but that doesn't seem to be enough.



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/JBRULES-3260-Events-forced-to-zero-expirationOffset-tp3444069p3444069.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Sliding Length Windows

2011-10-21 Thread Edson Tirelli
   Hi Diana,

   This happens because the order in which things happen. Up to Drools 5.3,
Drools apply first filters (a.k.a., alpha constraints or literal
constraints), then the sliding windows, then the joins.

   So in your case,

Notif( specificProblem == New ONT ) over window:length(2)

   Drools is first filtering your Notif events with specificProblem == New
ONT, and on those it is applying the sliding window.

   To do what you want, you need to separate the definition of the window
from the actual filter:

$last2: List() from collect( Notif() over window:length(2) )
$nNewONT : Number() from accumulate ( Notif( specificProblem == New ONT )
from $last2, count() )

   I know this is confusing in some cases and for Drools 5.4 we will add
explicit window declarations, so that (among other advantages) we reduce
surprises like that and completely separate window-scoped filters from
rule-scoped filters.

   Edson

2011/10/20 diana-mendes diana-men...@hotmail.com

 Hello,


 I'm having trouble using sliding length windows. Either I'm implementing
 them wrong or I have misunderstood how they're supposed to work.


 I have a class named Notif:

 *public class Notif implements Serializable{
   ...
   private String specificProblem;
   ...
   public String getSpecificProblem() {
return specificProblem;
   }

   public void setSpecificProblem(String specificProblem) {
this.specificProblem = specificProblem;
   }
 }*


 These Notif's represent my events. I want to know how many Notifs with
 specificProblem New ONT are there in the last 2 received events.

 My .drl file looks like this:


 *declare Notif
@role( event )
 end

 rule Rule1
when
$event : Notif()
$nNewONT : Number() from accumulate (
Notif( specificProblem == New ONT ) over window:length(2),
 count() )
then
System.out.println(In the last 2 events there were
 +$nNewONT+ events
 'New ONT');
 end*


 My test file:

 *...
 session.insert(ONTIsInactive1);
 session.insert(newONT1);
 session.insert(ONTIsInactive2);
 session.insert(newONT2);
 session.insert(LOKS1);
 session.insert(LOKS2);
 session.insert(LOKS3);
 session.insert(newONT3);
 session.fireAllRules(); *

 As you probably can tell by the names, the events I'm looking for are the
 2nd, the 4th and the last one.

 But the output I get is:


 In the last 2 events there were 2 events 'New ONT'
 In the last 2 events there were 2 events 'New ONT'
 In the last 2 events there were 2 events 'New ONT'
 In the last 2 events there were 2 events 'New ONT'
 In the last 2 events there were 2 events 'New ONT'
 In the last 2 events there were 2 events 'New ONT'
 In the last 2 events there were 2 events 'New ONT'
 In the last 2 events there were 2 events 'New ONT'


 The output I'm looking for is:

 In the last 2 events there were 0 events 'New ONT' (because the received
 event is ONTIsInactive)
 In the last 2 events there were 1 events 'New ONT' (because the last 2
 received events are ONTIsInactive and New ONT)
 In the last 2 events there were 1 events 'New ONT' (because the last 2
 received events are New ONT and ONTIsInactive)
 ...
 and so on...

 What am I doing wrong? Any help would be appreciated!
 Thanks in advance,

 Diana

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Sliding-Length-Windows-tp3438408p3438408.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Help! Activations firing out of salience order

2011-10-18 Thread Edson Tirelli
   This was a duplicate of https://issues.jboss.org/browse/JBRULES-3111 that
was fixed last week. It will be released in 5.3.0.final.

   Edson

2011/10/18 Swindells, Thomas tswinde...@nds.com

 Ouch looks like we and anybody on 5.1.1 needs to desperately update then.*
 ***

 Though I am rather concerned by this issue
 https://issues.jboss.org/browse/JBRULES-3211  “Rules fires on incorrect
 condition” – has this been looked at/is the issue correct as a rules engine
 which fires random rules when it shouldn’t would be problematic!

 ** **

 Thomas

 ** **

 *From:* rules-users-boun...@lists.jboss.org [mailto:
 rules-users-boun...@lists.jboss.org] *On Behalf Of *Wolfgang Laun
 *Sent:* 18 October 2011 11:05
 *To:* Rules Users List
 *Subject:* Re: [rules-users] Help! Activations firing out of salience
 order

 ** **

 There used to be a subtle bug in the PriorityHeapQueue containing the
 activations.

 See https://issues.jboss.org/browse/JBRULES-3044

 -W

 2011/10/18 Swindells, Thomas tswinde...@nds.com

 In our project we have been experiencing a large number of intermittent
 unit test failures when we are testing our rules (on drools 5.1.1).

 After a lot of debugging, examining our rules for logic errors,
 experimenting and generally scratching our head trying to work out what is
 wrong, we have noticed that sometimes (but very intermittently) activations
 are firing in the wrong order.

  

 In our rulebase we have two rules, Rule A salience 80 and Rule B salience
 70. Whilst debugging we made Rule A and B are identical other than rule B
 having some additional constraints on the end. 

 Dumping out the agenda events we have observed the following actions
 occurring:

 BEFORE_FIRED rule X

 CREATED_ACTIVATION Rule A

 CREATED_ACTIVATION Rule B

 AFTER_FIRED rule X

  

 … (no references to either rule/activation)

  

 BEFORE_FIRED Rule B

 CANCELLED Rule A

 AFTER_FIRED Rule B

  

 How can Rule B be firing before Rule A when both activations exist?

 Does anybody know of any bugs in 5.1.1 that may be causing this? 

 We have a branch of code on 5.3 and that also has had intermittent unit
 test failures, we’ve not had chance to examine whether this is the same
 pattern or just a different logic issue.

  

 Please help,

  

 Thomas

  

  

 ** **
 --



 **
 This message is confidential and intended only for the addressee. If you
 have received this message in error, please immediately notify the
 postmas...@nds.com and delete it from your system as well as any copies.
 The content of e-mails as well as traffic data may be monitored by NDS for
 employment and security purposes. To protect the environment please do not
 print this e-mail unless necessary.

 NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18
 4EX, United Kingdom. A company registered in England and Wales. Registered
 no. 3080780. VAT no. GB 603 8808 40-00

 **
 


 ___
 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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] How to handle generics in Drools?

2011-10-17 Thread Edson Tirelli
   Geoffrey is correct. Java erasure makes it impossible to match objects
based on generic types. It is also a best practice anyway to not use general
purpose collections as your business entities in your business model. Best
to use a properly defined business entity and then the generics issue is not
really an issue.

   Edson

2011/10/17 Geoffrey De Smet ge0ffrey.s...@gmail.com

 **
 Java's generics are implemented by erasure,
 which implies that there no information available at runtime that a
 instance of a List is of a certain generic type, for example Boost.
 So I don't think this is possible.

 Note that some things do work in erasure IIRC, like the generic type of a
 defined field in a class is available at runtime:
 public class Foo {
   private ListBar list;
 }
 but that's not useful in this case :)

 Op 17-10-11 11:30, Martin A schreef:

 Hello,

  In my rules file I'd like to set something like this:

  rule mayThrowDice
 when
 $user : User($gp : gameplay)
 $gameplay(this == $gp)
 then
 exists ListBoost() {
 . some business logic
 }
 end

  But it looks like there is no generics support. How can I make sure there
 is a List of type Boost inserted into the session?

  Thank you,
 Martin


 ___
 rules-users mailing 
 listrules-users@lists.jboss.orghttps://lists.jboss.org/mailman/listinfo/rules-users


 --
 With kind regards,
 Geoffrey De Smet


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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Fusion appears to be working properly, but...

2011-10-14 Thread Edson Tirelli
   Wolfgang is correct. Just an additional distinction that is important:
expiring an event is different then retracting an event/fact. Imagine that
there was a computer with infinite processing power and infinite memory. In
that case, we would never need to expire any events, we would just keep them
all in memory forever. This is obviously not the case, but it gives us the
sense of truth. An event represents something that happened and as so it
is true. Since the past can't be changed, it will be true forever. So
expiring an event is a way to optimize the resource consumption of the
limited hardware we have, but it does not make events false. So any
activation created due to events, will remain active until they are fired,
even if the events that created it expire.

   In other words: if your event has an expiration policy of 2 seconds, it
comes into the system and activates rules for the next 2 seconds. After that
time, that event will no longer create any other activation. Also:

* If you are running fireUntilHalt(), the rules will fire asap, depending on
the conflict resolution with other rules.

* If you are running fireAllRules(), even if it takes 10 minutes for your
application to fire the rules, they will still fire, because **expiration**
of events do not cancel activations. **Retraction** of facts/events and
**modifications** of facts might cause activations to be cancelled.

   Hope it is clear.

   Edson

2011/10/14 Wolfgang Laun wolfgang.l...@gmail.com

 On 14 October 2011 06:31, slyfox bobby.richa...@gmail.com wrote:

 thanks for the response, that makes a little more sense.  That is an issue
 because the whole idea of CEP is to process events as they happen.  My
 next
 step is adding camel support so that I can consume the amqp feed without
 manually inserting into the session.  I guess fireuntilhalt is my only
 option.  But what does fire until halt do, is it just a continuous loop or
 is is smart enough to only process events when they come in?


 There is one reasons for the thread running a Drools engine until halt
 to become active: when a fact is inserted. After doing the work resulting
 from this, the thread falls back into suspension.


 so what would happen if the event is given an expiration of say 2 seconds?
 if you were calling fireallrules in anything over a 2 second interval you
 would miss a lot.


 An event that has expired any time before you fireAllRules is discarded
 soon after this call is entered. What could you miss in the time between
 the scheduled expiry and the actual removal?

 Note that any application that expects to produce real-time reactions
 is bound to fireUntilHalt.



 I do not really see the benefit of fusion then, seems like its redundant?
  I
 hope that I am missing something.


 There isn't really a Fusion thing. (Think of it as a marketing gag.)
 The Drools Rule Engine is capable of dealing with facts that have the
 distinct traits of what is called event: timestamp, duration and
 expiry; the Engine is clever enough to retract stale events automatically,
 and there's a set of operators for comparing numbers that may
 represent points in time with some fancy overlap options. If you don't
 need anything of this, don't use it; OTOH, if you compare dates, just
 using the temporal operators may help.

 -W


 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Fusion-appears-to-be-working-properly-but-tp3420043p3420701.html
 Sent from the Drools: User forum 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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Fusion appears to be working properly, but...

2011-10-14 Thread Edson Tirelli
   Unfortunately, it is a hard question to answer, because it is the same as
asking: what is the performance of a database (postgreSQL, Oracle, etc)? It
is totally dependent on the data you load, the queries you write and the
indexes you use.

   So you need to think about overhead and pay-off of using such a
technology. If you are considering performance alone, an nothing else (ease
of rule maintenance, knowledge management lifecycle, time to market,
training costs, etc) and you have 10 rules, the optimizations that the
engine bring into place will probably not pay off in terms of performance
and it would be more performant to write the 10 rules in java. If you have
10k rules, then the optimizations will pay off multiple times and you will
have better performance than coding the rules in java (unless you are coding
your rules like a rules engine compiler does).

   The more rules you have, the more advantage you have using a rules
engine.

   Finally, when talking about high volumes, you will have to think about
horizontal scalability as it vertical scalability is much more expensive to
achieve. Using multiple agents is an easy way to do that, as long as you can
partition your data.

   I can tell you I've personally worked with customers with knowledge bases
in the order of several tens of thousands of rules large, as well as
customers with millions of facts simultaneously in memory. So it is possible
to scale, but the performance of your system will depend on your use case
and the more rules you have, the more benefits you get.

   Edson




2011/10/14 slyfox bobby.richa...@gmail.com

 ok bad example.

 Are there any metrics on drools performance that I could reference?

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Fusion-appears-to-be-working-properly-but-tp3420043p3422055.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Fusion appears to be working properly, but...

2011-10-13 Thread Edson Tirelli
   Fusion is a set of features added to all the Expert features, so in the
end, they just leverage each other... it is not like Fusion only uses
events, and Expert only uses facts... the goal of the Drools platform is to
make it completely transparent for the user to write their
rules/queries/processes using all the features together...

   Having said that, yes, you must either call fireAllRules() from time to
time (for instance, after each insert, or every 20 seconds, or whatever), or
you can start a thread and call fireUntilHalt() to place the engine in
reactive mode (probably what you were looking for).

   Edson

2011/10/13 slyfox bobby.richa...@gmail.com

 i did not but I was under the impression that the fireallrules method was
 for
 expert an not fusion.  So anytime I have an 'event' come in I must call
 this
 method?

 I see that it works now, but this seems inefficient to me, how does this
 differentiate fusion, if its just like expert in a loop?

 Thanks for the response,
 Bobby



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Fusion-appears-to-be-working-properly-but-tp3420043p3420143.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] How to improve drools performance?

2011-10-12 Thread Edson Tirelli
   That works. Just FYI, the same data is available through the Drools
MBeans... you can use jconsole to monitor it or any other JMX console.

   Edson

2011/10/12 Dean Whisnant d...@basys.com

 You could create a listener and combine it with a log.  There is
 org.drools.event.rule.DefaultAgendaEventListener that has two methods I use
 to log which rule started firing and when the rule completes firing with:

@Override
public void beforeActivationFired(BeforeActivationFiredEvent event)
{
try
{
logFile.write(Package( +
 event.getActivation().getRule().getPackageName() + ).Rule( +
 event.getActivation().getRule().getName() + ) firing ... );
}
catch (Exception e) { }
}

@Override
public void afterActivationFired(AfterActivationFiredEvent event)
{
try
{
logFile.write(done!\n);
}
catch (Exception e) { }
}

 You could obviously do other logging with time and date stamps, or send it
 to a database rather than a .log file like I'm doing here.  In my case I get
 a list of all rules that fire in a fireallrules session.  I can see if a
 rule fires multiple times, or ends up in an endless loop.

 Peace!

 Dean

 -Original Message-
 From: rules-users-boun...@lists.jboss.org [mailto:
 rules-users-boun...@lists.jboss.org] On Behalf Of arrehman
 Sent: Wednesday, October 12, 2011 1:21 PM
 To: rules-users@lists.jboss.org
 Subject: [rules-users] How to improve drools performance?

 Is there a way to log / monitor the time taken for rule in a Drools rule
 set?

 Is there a way to make sure that one rule is not executed more than once(It
 seems to be happening in my case)

 What are the general guidelines on improving Drools performance?

 Currently I am using a one single DRL file with 100 odd rules.

 Any additiional information you need will be provided.

 Thanks,

 Abdul


 --
 View this message in context:
 http://drools.46999.n3.nabble.com/How-to-improve-drools-performance-tp3416326p3416326.html
 Sent from the Drools: User forum 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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Typecasting problem

2011-10-11 Thread Edson Tirelli
   Which version of Drools are you using?

   Latest Drools versions changed the behavior of from to deal with it as
you mentioned. So it will not raise ClassCastException. Instead:

$doc: Document(...) from $job.item  // only matches if the returned item is
a Document

$msg: Message(...) from $job.item // only matches if the returned item is a
Message

   I think 5.2 was the first version released with this change, but need to
double check. For sure 5.3 works like that.

   Edson


2011/10/11 hsherlock citad...@gmail.com

 I have a following scenario in which a complex logic (distributed over
 multiple .DRL files) need to process incoming jobs as fast as possible. A
 job definition looks something like describing what to do (type), what to
 process (item) with some additional data supplied (args).

 enum JobType
 {
VALIDATE,
SEND
 }

 class Job
 {
String type;
Object item;
Object[] args;
 }

 In order to implement the processing I need to put the business logic into
 rules which fire depending on the kind of processing requested and type of
 the item passed:

 rule process [VALIDATION] on [Document]
when
$job: Job(type==JobType.VALIDATE)
$doc: Document(issued==true) from $job.item
then
insert(new DocumentAlreadyIssuedFact());
 end

 rule process [SENDING] on [Message]
when
$job: Job(type==JobType.SEND)
$msg: Message() from $job.item
then
//do the sending
 end

 Unfortunately this does not work and results in ClassCastException being
 thrown, because it looks that Drools tries to cast any passed item to the
 class expected by the particular rule. In my opinion behaviour one can
 expect from Drools here is to first match the item class to the one
 expected
 by the rule and on success to perform the type casting.
 Is it a Drools bug or a missing feature?

 So after stidying the documention and example code I found only one way to
 workaround this – by using eval and instanceof which should have its
 performance implications due to extensive use of the eval.

 rule process [VALIDATION] on [Message]
when
$job: Job(type==”validate”)
$msg: Message() from $job.item
then
//do the validation
 end

 rule process [SENDING] on [Message]
when
$job: Job(type==”send”)
$msg: Message() from $job.item
then
//do the sending
 end

 Such an implementation works, but I see it as some form of workaround as my
 feeling is that it will not allow the optimizations of Drools to shine.

 Please recommend more effective and elegant way of implementing this.

 Thank you in advance

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Typecasting-problem-tp3412494p3412494.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.

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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Map errors and quirks

2011-10-11 Thread Edson Tirelli
   Zack,

   Thanks for the update and please, do open JIRAs for everything you found
that is not working and ping me after.

   I am working on the binding with extra variables issue at the moment.
E.g.:

$x : someMap[$y]

   The problem here is that Drools always used a fly weight pattern with no
additional inputs for variable bindings. This means it is not possible as of
Drools 5.3 to support that kind of variable binding. What I am doing at the
moment is implementing a more friendly error message for 5.3. For 5.4 I am
discussing it with Mark, but I think we should add support for it.

   Please note that as a work around, in 5.3, you can still bind the
variable to the map ($x : someMap) and then on usage apply the key:

foo == $x[$y]

Edson

2011/10/11 zstlaw zstla...@akamai.com

 Ok finished doing some in depth testing on 5.4.  I was wrong on a few
 accounts above the internal variable access to a hash still fails only in a
 different way.

 First off I added a few new methods to my Mailbox object just for testing :

 // returns an statically defined inner enum
 public FolderType getDefaultFolderType() {
return FolderType.INBOX;
 }

 // returns an external enum
 public MailType getMailType() {
return MailType.WORK;
 }

 // takes a statically defined inner enum and returns an external enum
 public MailType getMailTypeForFolderType(FolderType pType) {
return MailType.WORK;
 }

 Test I found that generally enums work much better but internal defined
 instances still cause problems.  Also there was some asymmetry where
 FolderType.INBOX != $folderType was legal but $folderType !=
 FolderType.INBOX was not.

 I will start opening issues in JIRA but expect I may need to open one or
 two
 large issues and a lot of sub issues to keep clarity.  In particular the
 issue with having an assignments and a variable in the same row continues
 to
 be vexing (i.e. $myvar : getFoo($otherVar) always has problems evaluating
 $otherVar since it wants to check it as a inner field of the return type
 and
 not a local variable passed to the procedure call.)

 Hope some of this can get in the next build.  I have some huge projects
 coming up where we really want to use drools but I am having to really
 simplify our data to work around some of these issues.

 Thanks,
 Zack

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Map-errors-and-quirks-tp3404106p3413546.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] NPE on fact insertion if rule has sliding window

2011-10-07 Thread Edson Tirelli
   This is fixed in master. Will be in 3.1 final release.

   Edson

2011/10/7 mike9322 michael.melton@navy.mil


 laune wrote:
 
  There's a bug in the incremental build as done by the KnowledgeAgent. If
  the
  KA configuration property drools.agent.newInstance is set to false, some
  type information is not put into the new KBase.
 

 I added the following comment to the JIRA related to this issue
 (https://issues.jboss.org/browse/JBRULES-3145).  Cross-posting here in
 case
 anyone else is having the issue and arrives here via Google like I did.

 I am seeing the same behavior with my KA newInstance = true. I was able to
 workaround it by ensuring that my event POJOs are defined in the same
 package as my rules.

 In other words, this DOES NOT work:
 Rule package: com.example.rules
 POJO package: com.example.rules.model (import statements included in DRL)

 This DOES work:
 Rule package: com.example.rules
 POJO package: com.example.rules (no import statements required)

 I did not have to move my event declaration to my DRL; they are still
 POJOs.
 I would prefer to have my POJOs in their own package but I can live with
 this workaround for now.

 Mike


 --
 View this message in context:
 http://drools.46999.n3.nabble.com/NPE-on-fact-insertion-if-rule-has-sliding-window-tp3163261p3403934.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] NPE on fact insertion if rule has sliding window

2011-10-07 Thread Edson Tirelli
   Lol, I guess I need a cup of coffee.

   Yes, that was what I meant.

   Edson

2011/10/7 Michael Anstis michael.ans...@gmail.com

 Edson, you mean 5.3.Final?

 sent on the move

 On 7 Oct 2011 21:08, Edson Tirelli ed.tire...@gmail.com wrote:


This is fixed in master. Will be in 3.1 final release.

Edson

 2011/10/7 mike9322 michael.melton@navy.mil


 laune wrote:
 
  There's a bug in the incremental build as done by the KnowledgeAgent.
 If
  the
  KA configuration property drools.agent.newInstance is set to false,
 some
  type information is not put into the new KBase.
 

 I added the following comment to the JIRA related to this issue
 (https://issues.jboss.org/browse/JBRULES-3145).  Cross-posting here in
 case
 anyone else is having the issue and arrives here via Google like I did.

 I am seeing the same behavior with my KA newInstance = true. I was able
 to
 workaround it by ensuring that my event POJOs are defined in the same
 package as my rules.

 In other words, this DOES NOT work:
 Rule package: com.example.rules
 POJO package: com.example.rules.model (import statements included in DRL)

 This DOES work:
 Rule package: com.example.rules
 POJO package: com.example.rules (no import statements required)

 I did not have to move my event declaration to my DRL; they are still
 POJOs.
 I would prefer to have my POJOs in their own package but I can live with
 this workaround for now.

 Mike


 --
 View this message in context:
 http://drools.46999.n3.nabble.com/NPE-on-fact-insertion-if-rule-has-sliding-window-tp3163261p3403934.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




 --
   Edson Tirelli
   JBoss Drools Core Development
   JBoss by Red Hat @ www.jboss.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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Map errors and quirks

2011-10-07 Thread Edson Tirelli
;String, Dategt; recentContacts = new
 HashMaplt;String,
 Dategt;();
private String owneremail;

public Mailbox(String username) {
owneremail = username;

// create contact for self
recentContacts.put(owneremail, new Date());

// create default folders
folders.put(FolderType.SENT, new ArrayListMessage());
folders.put(FolderType.TRASH, new ArrayListMessage());
folders.put(FolderType.INBOX, new ArrayListMessage());
}

/** parameterized accessor */
public ListMessage getFolder(FolderType t) {
return folders.get(t);
}

public Maplt;FolderType, Listlt;Messagegt; getFolders() {
return folders;
}

public Maplt;String, Dategt; getRecentContacts() {
return recentContacts;
}

public String getOwneremail() {
return owneremail;
}
 }

 /* more complicated rule */
 package com.sample
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import com.sample.Mailbox;
 import com.sample.Mailbox.FolderType;
 import com.sample.Mailbox.Message;


 rule check folders hash mvel
 dialect mvel
when
$m : Mailbox(
// Each commented line will result in the file no
 longer compiling
$type1 : FolderType.INBOX,
$type2 : com.sample.Mailbox$FolderType.INBOX,
$work1 : getFolder(null),
$work2 :
 getFolder(com.sample.Mailbox$FolderType.INBOX),
$work3 :
 getFolder(com.sample.Mailbox$FolderType.INBOX).size,
 //  getFolder(FolderType.INBOX), // HAS ERROR - unable
 to resolve
 using strict mode
getFolder($type1) != null,
 //  $err1 : getFolder($type1), // again HAS ERROR only
 when doing
 variable assignment
getFolder($type2) != null,
 //  $err2 : getFolder($type2), // again HAS ERROR only
 when doing
 variable assignment
getFolder($type1).size()  0,
getFolder($type1).isEmpty(),
 //  $err3 : folders[FolderType.INBOX], // HAS ERROR
 //  $err4 :
 folders[com.sample.Mailbox.FolderType.INBOX], // HAS
 ERROR - bad path syntax obviously
 //  $err5 :
 folders[com.sample.Mailbox$FolderType.INBOX], // HAS
 ERROR
 //  folders[$type1]!=null, // HAS ERROR
 //  folders[$type2]!=null, // HAS ERROR
$work6 : folders,
$work7 : folders.size,

  folders.containsKey(com.sample.Mailbox$FolderType.INBOX),
folders.containsKey($type2),
!folders.isEmpty,
 //  $err6: folders.size(),  // HAS ERROR
 //  $err7: folders.isEmpty(),  // HAS ERROR
 //  folders.get(FolderType.INBOX)!=null, // HAS ERROR
 //
  folders.get(com.sample.Mailbox.FolderType.INBOX)!=null, // HAS
 ERROR - bad path syntax obviously
 //
  folders.get(com.sample.Mailbox$FolderType.INBOX)!=null, // HAS
 ERROR
 //  folders.get($type1)!=null, // HAS ERROR
 //  folders.get($type2)!=null, // HAS ERROR
$work8 : getFolders(),
$work9 : getFolders().size,
 //  getFolders().size(), // HAS ERROR
0  1
)
then
System.out.println( folders were accessible );
 end

 Now you can see my real problem.  Dealing with a hash of enum to other
 object I get a lot of odd behavior on hash keying depending on how I make
 each call and while I really need to store the result to do many
 comparisons
 I can not unless I hardcode the parameter by which I am accessing the data
 which would profoundly weaken the rules I am writing.

 While I could register every object in the hash the problem then becomes
 the
 profusion of meta objects and the management of them especially given the
 memory leaks not fixed until 5.3.Final is released.

 Thank you for any assistance!

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Map-errors-and-quirks-tp3404106p3404106.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] NPE in SlidingTimeWindow$SlidingTimeWindowComparator

2011-10-07 Thread Edson Tirelli
  Hi Rob,

  Can you please provide the test case (open a JIRA with it) or at least a
description of what kind of events are you feeding in and with which
frequency so that we can try to reproduce the problem?

  The NPE where you mentioned is the symptom... the problem is elsewhere...

  Edson

2011/10/6 Rob Crawford crawf...@kloognome.com

 I'm getting a null pointer exception on either line 232 or 233 of
 SlidingTimeWindow. The only window I'm using is:

 rule Mark up to date
   timer(int: 5m)
 when
   $store: Store()
   exists (SensorReading (this.store == $store) over window:time(5m))
 then
   ...
 end

 The rule never fires; this happens when the sliding time window is expiring
 tuples.

 It appears the comparator needs to handle nulls, but there's nothing in the
 JavaDocs about that.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Cookbook: How to test rules using xUnit

2011-10-06 Thread Edson Tirelli
   Hi all,

   Not sure why the syntax highlighter is not working on the blog, but in
any case, you can read the content.

http://blog.athico.com/2011/10/cookbook-how-to-test-rules-using-xunit.html

   Hopefully it will be helpful to some people.

   Edson

-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Compilation errors with 5.3.0.CR1

2011-10-05 Thread Edson Tirelli
.MVEL.analysisCompile(MVEL.java:672)
at
 
 org.drools.rule.builder.PatternBuilder.setInputs(PatternBuilder.java:854)
at
 org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:595)
at
 
 org.drools.rule.builder.PatternBuilder.processConstraintsAndBinds(PatternB
  uilder.java:397)
at
 org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:309)
at
 org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:132)
at
 
 org.drools.rule.builder.GroupElementBuilder.build(GroupElementBuilder.jav
  a:65)
at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:80)
at
 org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:2241)
at
  org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:802)
at
 
 org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java
  :388)
at
  org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder
  .java:566)
at
 
 org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.ja
  va:35)
at
  com.proximetry.elmgr.services.DependenciesBean$Expander.addDrl(Depen
  denciesBean.java:110)
 
 
  It is
 
  (def0: EmParamDefinition(paramName == p2, listIndex == -1) and
  EmParamValue(paramDefinitionId == def0, requiredValue == 1))
 
 
  line that causes the problem - the exeption disappears after removing
 it.
  What's interesting, when I add '$' sign to binding variable name, and
 the line
  looks like:
 
  ($def0: EmParamDefinition(paramName == p2, listIndex == -1) and
  EmParamValue(paramDefinitionId == $def0, requiredValue == 1))
 
 
  instead of the exception I get DRL error:
 
  [DialectError message='Unable to wire compiled classes, probably
 related to
  compilation
 failures:sun.reflect.generics.reflectiveObjects.WildcardTypeImpl
  cannot be cast to java.lang.Class']
 
 
  For completness, this is how I add DRL resources:
 
  public void addDrl(Reader rdr) {
 KnowledgeBuilder kBuilder =
  KnowledgeBuilderFactory.newKnowledgeBuilder();
 
 kBuilder.add( ResourceFactory.newReaderResource(rdr),
  ResourceType.DRL);
 if( kBuilder.hasErrors() ){
 for( KnowledgeBuilderError err: kBuilder.getErrors()
 ){
 StackTrace.error(this, err);
 }
 throw new IllegalStateException( DRL errors );
 }
 knowledgeBase.addKnowledgePackages(
  kBuilder.getKnowledgePackages() );
 }
 
 
  I would be grateful if someone has an idea, why after switching Drools
  version such problem exists.
  ___
  rules-users mailing list
  rules-users@lists.jboss.org
  https://lists.jboss.org/mailman/listinfo/rules-users
 
 
 **
  This message is confidential and intended only for the addressee. If
 you have received this message in error, please immediately notify the
 postmas...@nds.com and delete it from your system as well as any copies.
 The content of e-mails as well as traffic data may be monitored by NDS for
 employment and security purposes. To protect the environment please do not
 print this e-mail unless necessary.
 
  NDS Limited. Registered Office: One London Road, Staines, Middlesex,
 TW18 4EX, United Kingdom. A company registered in England and Wales.
 Registered no. 3080780. VAT no. GB 603 8808 40-00
 
 **
 
  ___
  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
 
  ___
  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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] 5.3.0 CR1 has broken existing rules/flows

2011-10-04 Thread Edson Tirelli
   The difference in that area from 5.2 to 5.3 is that in 5.3 the
interaction between Terminal Nodes and the agenda was refactored into a
listerner pattern . This is required for future features we are working
on. It seems the change introduced the regression.

   This is probably enough info to recreate the problem and I bet the
different agenda groups are really important in recreating it.

   I am working in a couple tasks at the moment, but if you can meanwhile
open a JIRA with this info I will fix it for the 5.3 final release. If you
can, please try to isolate a test case with this scenario:

If 021 fires to turn off the lookup AND 042B fires to turn on the
lookup, then 022 gets and NPE.

   If you are unable to, no problem.

   BTW, I liked Wolfgang's handler as well. If he would like to contribute
the code, more than happy to add it to the codebase.

   Edson

2011/10/4 Jamie js...@llbean.com

 Thanks for all of the feedback.  I haven't tried W's handler, but I'm
 planning to.  I did take Edson's advice and was able to get some more info.

 It appears to involve the interaction between 3 rules.  For background,
 this
 is a fraud detection application.  Under certain conditions, we need to
 look
 up additional customer information.  Some rules are run to determine
 whether
 the lookup is required and then another rule actually does the lookup.  In
 this case:

 Rule 021 says if the order is small, set the lookup flag to false
 Rule 042B says if the order is from a 'bad' country, set the lookup flag to
 true
 Rule 022 says if the lookup flag is true, do the lookup

 If rule 021 fires alone, then 022 does not fire and all is well.
 If rule 042B fires alone, then 022 fires and all is well.
 If 021 fires to turn off the lookup AND 042B fires to turn on the lookup,
 then 022 gets and NPE.

 As Edson suspected, the item is null and the 'rule' variable points to rule
 021.

 I'm not sure if it matters, but each rules involved is in a different
 agenda
 group.

 As I mentioned, this works in 5.2.0.Final, but breaks in 5.3.0.CR1.

 Hope this helps pinpoint the issue.


 --
 View this message in context:
 http://drools.46999.n3.nabble.com/5-3-0-CR1-has-broken-existing-rules-flows-tp3390922p3393730.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] 5.3.0 CR1 has broken existing rules/flows

2011-10-03 Thread Edson Tirelli
)
at
 com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:862)
at

 com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1583)
at
 com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:178)
at

 com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)
at

 com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)
at

 com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:272)
at

 com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at

 com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
at

 com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at

 com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at

 com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
at

 com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1550)
 Caused by: java.lang.NullPointerException
at

 org.drools.reteoo.RuleTerminalNode.createActivations(RuleTerminalNode.java:276)
at

 org.drools.reteoo.RuleTerminalNode.modifyLeftTuple(RuleTerminalNode.java:326)
at

 org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateModifyChildLeftTuple(SingleLeftTupleSinkAdapter.java:273)
at

 org.drools.reteoo.EvalConditionNode.modifyLeftTuple(EvalConditionNode.java:234)
at

 org.drools.reteoo.CompositeLeftTupleSinkAdapter.propagateModifyChildLeftTuple(CompositeLeftTupleSinkAdapter.java:295)
at org.drools.reteoo.JoinNode.modifyLeftTuple(JoinNode.java:380)
at org.drools.reteoo.BetaNode.modifyLeftTuple(BetaNode.java:450)
at org.drools.reteoo.JoinNode.modifyLeftTuple(JoinNode.java:446)
at

 org.drools.reteoo.CompositeLeftTupleSinkAdapter.doPropagateModifyObject(CompositeLeftTupleSinkAdapter.java:260)
at

 org.drools.reteoo.CompositeLeftTupleSinkAdapter.propagateModifyObject(CompositeLeftTupleSinkAdapter.java:275)
at

 org.drools.reteoo.LeftInputAdapterNode.modifyObject(LeftInputAdapterNode.java:174)
at

 org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateModifyObject(CompositeObjectSinkAdapter.java:461)
at

 org.drools.reteoo.CompositeObjectSinkAdapter.propagateModifyObject(CompositeObjectSinkAdapter.java:429)
at
 org.drools.reteoo.ObjectTypeNode.modifyObject(ObjectTypeNode.java:277)
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

 com.llbean.droolstest.Rule_Rule_022___Load_Buyer_Activity.defaultConsequence(Rule_Rule_022___Load_Buyer_Activity.java:15)
at

 com.llbean.droolstest.Rule_Rule_022___Load_Buyer_ActivityDefaultConsequenceInvokerGenerated.evaluate(Unknown
 Source)
at

 com.llbean.droolstest.Rule_Rule_022___Load_Buyer_ActivityDefaultConsequenceInvoker.evaluate(Unknown
 Source)
at
 org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1091)
... 45 more


 --
 View this message in context:
 http://drools.46999.n3.nabble.com/5-3-0-CR1-has-broken-existing-rules-flows-tp3390922p3390922.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Memory leak in 5.2/5.3

2011-10-03 Thread Edson Tirelli
   I don't know all the details about this problem, but as far as I heard,
the leak was happening because jBPM was adding its listener to the kbase
and/or ksession and not removing it on disposals... so the easiest way to
get around the leak is to simply remove it yourself before disposing the
session.

   Whoever fixed the problem can probably give you details about how to do
that.

   Having said that, if you are using community version, I strongly
recommend you to move to 5.3 when it is released as it brings tons of fixes
and some good features. Older community versions are not maintained. If you
are a Red Hat subscriber, just open a ticket for the version you want to use
and they will provide you with patched binaries.

   Edson

2011/10/3 alopez alo...@termmed.com

 This memory leak is giving us a lot of problems... we need to iteratively
 test 400,000 items, one session for each. It was working fine with 5.1.1
 and
 now is failing.

 Thanks for the test case, is very simple to reproduce, but I tried running
 it with:

 dependency
groupIdorg.drools/groupId
artifactIdknowledge-api/artifactId
version5.3.0.CR1/version
 /dependency
 ... etc.

 And still fails, so I don't fully trust that this will be fixed on 5.3.0...
 do you have confirmation?

 I need to decide if I wait for 5.3 or if I advice to roll back to 5.1.1.

 Thanks

 Alejandro

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/rules-users-Memory-leak-in-5-2-5-3-tp3280351p3391578.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Drools 5 PseudoClock with StatelessKnowledgeSession

2011-09-30 Thread Edson Tirelli
   I think there might be a conceptual problem here. Stateless sessions are
supposed to take a snapshot of facts (and/or events) and run all rules for
them and dispose the session. Since it is a snapshot, there is no concept of
time flow during the execution and so it can only run in the equivalent of
CLOUD mode for stateful sessions. That is why no session clock is provided
for stateless sessions.

   In order to use the SessionClock, one needs to use a stateful session
configured in STREAM mode.

   I believe we can add features in the future like the ability to run a
session with a given reference time, even if it does not involve time flow,
but that is not there. Also, since date-effective and date-expiration are
really old features, from the drools 2-3 versions, and they have quite a
number of limitations, you are probably better using enabled expressions
than using those attributes.

   Edson


2011/9/29 Mark Proctor mproc...@codehaus.org

  Look at the interval timer test here from line 254 onwards, and the
 subsequent cron tests:

 https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/java/org/drools/integrationtests/TimerAndCalendarTest.java#L254



 On 13/10/2009 00:32, Ben Scott wrote:

   Note: This e-mail is subject to the disclaimer contained at the bottom
 of this message.

  --
 
 I'm wanting to use the date-effective and date-expiry rule metadata to add
 date specific rule variants within my app. To test these I was planning on
 using the pseudo clock and setting the expected date prior to executing the
 rules within a StatelessKnowledgeSession. I can set the clock easily enough,
 but can't understand why the getSessionClock() method is missing? It's on
 the StatefulKnowledgeSession, but not on the Stateless.
 I'm initialising the session like this:
 SessionConfiguration sessionConfiguration = new SessionConfiguration();
 sessionConfiguration.setClockType( ClockType.PSEUDO_CLOCK );
 StatelessKnowledgeSession session =
 _testKnowledgeBase.newStatelessKnowledgeSession(sessionConfiguration);
 The only thing I could think of to set the pseudo clock was to write a
 command something like:
 private static class SetPseudoClockCommand implements
 org.drools.process.command.CommandBoolean {
 public Boolean execute(ReteooWorkingMemory session) {
 // Set the clock to the current date
 pseudoSessionClock.advanceTime(new DateTime().getMillis(),
 TimeUnit.MILLISECONDS);
 // Add a couple of days
 pseudoSessionClock.advanceTime(2, TimeUnit.DAYS);
 return true;
 }
 }
 But this doesn't appear to take any effect whilst rules are running.
 Is there another way to get programmatic access to the session clock, or
 some better way of changing the underlying date prior to rule execution?
 Ben.


  --

 The information transmitted in this message and its attachments (if any) is
 intended only for the person or entity to which it is addressed.

 The message may contain confidential and/or privileged material. Any
 review, retransmission, dissemination or other use of, or taking of any
 action in reliance upon this information, by persons or entities other than
 the intended recipient is prohibited.

 

 If you have received this in error, please contact the sender and delete
 this e-mail and associated material from any computer.

 

 The intended recipient of this e-mail may only use, reproduce, disclose or
 distribute the information contained in this e-mail and any attached files,
 with the permission of the sender.

 

 This message has been scanned for viruses with Symantec Scan Engine and
 cleared by MailMarshal.

 

  --
 

 ___
 rules-users mailing 
 listrules-users@lists.jboss.orghttps://lists.jboss.org/mailman/listinfo/rules-users



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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Regression with Drools 5.3.0-CR1

2011-09-29 Thread Edson Tirelli
   JBRULES-2995 is fixed now, except for a corner case when using .class
literals with fully qualified class names. This will be fixed in MVEL for
5.3 final release.

   This works fine now:

Primitives( classAttr == (java.lang.String.class),
  eval(classAttr.equals( java.lang.String.class ) ),
  classAttr == String.class )

Also, some improvements on the free form expression support:

$p1 : Person( age  2*10, 10  age )
$p2 : Person( age  2*$p1.age )

Please let me know if you find any other cases where free form
expressions are raising errors.

Thank you,
Edson

2011/9/26 Edson Tirelli ed.tire...@gmail.com


Ok, this is fixed:

 https://issues.jboss.org/browse/JBRULES-3224

I will check JBRULES-2995 now.

Edson


 2011/9/26 Edson Tirelli ed.tire...@gmail.com


Thanks Wolfgang. That is a different issue related to how MVEL deals
 with class literals. I will check what's the status on it anyway.

Edson


 2011/9/26 Wolfgang Laun wolfgang.l...@gmail.com

 Note that https://issues.jboss.org/browse/JBRULES-2995 reported against
 5.2.0.CR1 and still open might be related.

 -W

 2011/9/26 Edson Tirelli ed.tire...@gmail.com


Thomas,

Thanks for reporting. I will look into it.

Did you open a JIRA yet? Let me know or I will do it otherwise.

Edson

 2011/9/26 Swindells, Thomas tswinde...@nds.com

  I’ve just tried upgrading from Drools 5.3.0-CR1 from the beta and
 I’ve hit a regression.

 ** **

 JBoss seems to have been down for most of today so I haven’t been able
 to raise a Jira for it.

 ** **

 In our model we have Facts which contain fields of java.lang.class, we
 then have a rule which checks that they aren’t null.

 Eg

 Fact { ClassObject classField}

 ** **

 Rule “xyz”

 When

 Fact(classField != null)

 Then

 …

 End

 ** **

 This is giving the following exception

 ** **

 Caused by: java.lang.ClassCastException:
 org.drools.base.field.ObjectFieldImpl cannot be cast to
 org.drools.base.field.ClassFieldImpl

 at
 org.drools.base.evaluators.EqualityEvaluatorsDefinition$ClassEqualEvaluator.evaluate(EqualityEvaluatorsDefinition.java:1772)
 

 at
 org.drools.rule.LiteralRestriction.isAllowed(LiteralRestriction.java:87)
 

 at
 org.drools.rule.LiteralConstraint.isAllowed(LiteralConstraint.java:109)
 

 at
 org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:130)

 at
 org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:451)
 

 at
 org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:369)
 

 at
 org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:134)

 at
 org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:451)
 

 at
 org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:379)
 

 at
 org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:204)
 

 at
 org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:244)
 

 at
 org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:330)

 at
 org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:291)

 at
 org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:882)
 

 at
 org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:180)
 

 ... 149 more

 ** **

 Wrapping the classField != null within an eval appears to be a work
 around.

 ** **

 This is in the suspect method:

 *public* *boolean* evaluate(InternalWorkingMemory
 workingMemory,

 *final* InternalReadAccessor
 extractor,

 *final* Object object1, *final*FieldValue 
 object2) {
 

 Object value1 = extractor.getValue( workingMemory, object1
 );

 Object value2 = object2.getValue();

 *if* ( value2 == *null* ) {

 ClassFieldImpl classField = (ClassFieldImpl) object2;*
 ***

 value2 = classField.resolve( workingMemory );

 }

 *return* *comparator*.equals( value1, value2 );

 }

 ** **

 I think the if statement just needs an instanceof check as well or some
 other way to track the fact that null may be a valid value to be comparing
 with!

 ** **

 ** **

 Thomas

 --


 **
 This message is confidential and intended only

Re: [rules-users] Not able to call parameterizied Java method in LHS

2011-09-27 Thread Edson Tirelli
   Assuming callA() and callB() are methods on $C, you are missing a comma
in between them.

modify ($C)
{
 callA(UNIX),
 callB(PERL)
}

   Edson

2011/9/27 Tinku dibya@gmail.com

 I try to add two java method calls in the RHS of the rule .It doesnot allow
 me to save the DRL file in eclipse .It complaints Multiple Markers at this
 line.

 However ,commenting one of the method in the RHS works fine ,with-out any
 issue..

 Could you pls help me in this..

 Example :

 when
 $B : customObject()
 $C :result()

 eval($B.getValue(Database).equals(ORACLE))

 then
 modify ($C)
 {
  callA(UNIX)
  callB(PERL)
 }

 end


 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Not-able-to-call-parameterizied-Java-method-in-LHS-tp3372552p3374183.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Regression with Drools 5.3.0-CR1

2011-09-26 Thread Edson Tirelli
   Thomas,

   Thanks for reporting. I will look into it.

   Did you open a JIRA yet? Let me know or I will do it otherwise.

   Edson

2011/9/26 Swindells, Thomas tswinde...@nds.com

  I’ve just tried upgrading from Drools 5.3.0-CR1 from the beta and I’ve
 hit a regression.

 ** **

 JBoss seems to have been down for most of today so I haven’t been able to
 raise a Jira for it.

 ** **

 In our model we have Facts which contain fields of java.lang.class, we then
 have a rule which checks that they aren’t null.

 Eg

 Fact { ClassObject classField}

 ** **

 Rule “xyz”

 When

 Fact(classField != null)

 Then

 …

 End

 ** **

 This is giving the following exception

 ** **

 Caused by: java.lang.ClassCastException:
 org.drools.base.field.ObjectFieldImpl cannot be cast to
 org.drools.base.field.ClassFieldImpl

 at
 org.drools.base.evaluators.EqualityEvaluatorsDefinition$ClassEqualEvaluator.evaluate(EqualityEvaluatorsDefinition.java:1772)
 

 at
 org.drools.rule.LiteralRestriction.isAllowed(LiteralRestriction.java:87)**
 **

 at
 org.drools.rule.LiteralConstraint.isAllowed(LiteralConstraint.java:109)***
 *

 at
 org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:130)

 at
 org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:451)
 

 at
 org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:369)
 

 at
 org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:134)

 at
 org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:451)
 

 at
 org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:379)
 

 at
 org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:204)

 at
 org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:244)

 at
 org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:330)

 at
 org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:291)

 at
 org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:882)
 

 at
 org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:180)
 

 ... 149 more

 ** **

 Wrapping the classField != null within an eval appears to be a work around.
 

 ** **

 This is in the suspect method:

 *public* *boolean* evaluate(InternalWorkingMemory workingMemory,**
 **

 *final* InternalReadAccessor extractor,***
 *

 *final* Object object1, *final* FieldValue
 object2) {

 Object value1 = extractor.getValue( workingMemory, object1 );*
 ***

 Object value2 = object2.getValue();

 *if* ( value2 == *null* ) {

 ClassFieldImpl classField = (ClassFieldImpl) object2;

 value2 = classField.resolve( workingMemory );

 }

 *return* *comparator*.equals( value1, value2 );

 }

 ** **

 I think the if statement just needs an instanceof check as well or some
 other way to track the fact that null may be a valid value to be comparing
 with!

 ** **

 ** **

 Thomas

 --


 **
 This message is confidential and intended only for the addressee. If you
 have received this message in error, please immediately notify the
 postmas...@nds.com and delete it from your system as well as any copies.
 The content of e-mails as well as traffic data may be monitored by NDS for
 employment and security purposes. To protect the environment please do not
 print this e-mail unless necessary.

 NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18
 4EX, United Kingdom. A company registered in England and Wales. Registered
 no. 3080780. VAT no. GB 603 8808 40-00

 **

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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Regression with Drools 5.3.0-CR1

2011-09-26 Thread Edson Tirelli
   Thanks Wolfgang. That is a different issue related to how MVEL deals with
class literals. I will check what's the status on it anyway.

   Edson

2011/9/26 Wolfgang Laun wolfgang.l...@gmail.com

 Note that https://issues.jboss.org/browse/JBRULES-2995 reported against  
 5.2.0.CR1
 and still open might be related.

 -W

 2011/9/26 Edson Tirelli ed.tire...@gmail.com


Thomas,

Thanks for reporting. I will look into it.

Did you open a JIRA yet? Let me know or I will do it otherwise.

Edson

 2011/9/26 Swindells, Thomas tswinde...@nds.com

  I’ve just tried upgrading from Drools 5.3.0-CR1 from the beta and I’ve
 hit a regression.

 ** **

 JBoss seems to have been down for most of today so I haven’t been able to
 raise a Jira for it.

 ** **

 In our model we have Facts which contain fields of java.lang.class, we
 then have a rule which checks that they aren’t null.

 Eg

 Fact { ClassObject classField}

 ** **

 Rule “xyz”

 When

 Fact(classField != null)

 Then

 …

 End

 ** **

 This is giving the following exception

 ** **

 Caused by: java.lang.ClassCastException:
 org.drools.base.field.ObjectFieldImpl cannot be cast to
 org.drools.base.field.ClassFieldImpl

 at
 org.drools.base.evaluators.EqualityEvaluatorsDefinition$ClassEqualEvaluator.evaluate(EqualityEvaluatorsDefinition.java:1772)
 

 at
 org.drools.rule.LiteralRestriction.isAllowed(LiteralRestriction.java:87)
 

 at
 org.drools.rule.LiteralConstraint.isAllowed(LiteralConstraint.java:109)*
 ***

 at
 org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:130)

 at
 org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:451)
 

 at
 org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:369)
 

 at
 org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:134)

 at
 org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:451)
 

 at
 org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:379)
 

 at
 org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:204)**
 **

 at
 org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:244)**
 **

 at
 org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:330)

 at
 org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:291)

 at
 org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:882)
 

 at
 org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:180)
 

 ... 149 more

 ** **

 Wrapping the classField != null within an eval appears to be a work
 around.

 ** **

 This is in the suspect method:

 *public* *boolean* evaluate(InternalWorkingMemory workingMemory,
 

 *final* InternalReadAccessor extractor,*
 ***

 *final* Object object1, *final*FieldValue 
 object2) {
 

 Object value1 = extractor.getValue( workingMemory, object1 );
 

 Object value2 = object2.getValue();

 *if* ( value2 == *null* ) {

 ClassFieldImpl classField = (ClassFieldImpl) object2;***
 *

 value2 = classField.resolve( workingMemory );

 }

 *return* *comparator*.equals( value1, value2 );

 }

 ** **

 I think the if statement just needs an instanceof check as well or some
 other way to track the fact that null may be a valid value to be comparing
 with!

 ** **

 ** **

 Thomas

 --


 **
 This message is confidential and intended only for the addressee. If you
 have received this message in error, please immediately notify the
 postmas...@nds.com and delete it from your system as well as any copies.
 The content of e-mails as well as traffic data may be monitored by NDS for
 employment and security purposes. To protect the environment please do not
 print this e-mail unless necessary.

 NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18
 4EX, United Kingdom. A company registered in England and Wales. Registered
 no. 3080780. VAT no. GB 603 8808 40-00

 **

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




 --
   Edson Tirelli
   JBoss Drools Core

Re: [rules-users] Regression with Drools 5.3.0-CR1

2011-09-26 Thread Edson Tirelli
   Ok, this is fixed:

https://issues.jboss.org/browse/JBRULES-3224

   I will check JBRULES-2995 now.

   Edson

2011/9/26 Edson Tirelli ed.tire...@gmail.com


Thanks Wolfgang. That is a different issue related to how MVEL deals
 with class literals. I will check what's the status on it anyway.

Edson


 2011/9/26 Wolfgang Laun wolfgang.l...@gmail.com

 Note that https://issues.jboss.org/browse/JBRULES-2995 reported against  
 5.2.0.CR1
 and still open might be related.

 -W

 2011/9/26 Edson Tirelli ed.tire...@gmail.com


Thomas,

Thanks for reporting. I will look into it.

Did you open a JIRA yet? Let me know or I will do it otherwise.

Edson

 2011/9/26 Swindells, Thomas tswinde...@nds.com

  I’ve just tried upgrading from Drools 5.3.0-CR1 from the beta and I’ve
 hit a regression.

 ** **

 JBoss seems to have been down for most of today so I haven’t been able
 to raise a Jira for it.

 ** **

 In our model we have Facts which contain fields of java.lang.class, we
 then have a rule which checks that they aren’t null.

 Eg

 Fact { ClassObject classField}

 ** **

 Rule “xyz”

 When

 Fact(classField != null)

 Then

 …

 End

 ** **

 This is giving the following exception

 ** **

 Caused by: java.lang.ClassCastException:
 org.drools.base.field.ObjectFieldImpl cannot be cast to
 org.drools.base.field.ClassFieldImpl

 at
 org.drools.base.evaluators.EqualityEvaluatorsDefinition$ClassEqualEvaluator.evaluate(EqualityEvaluatorsDefinition.java:1772)
 

 at
 org.drools.rule.LiteralRestriction.isAllowed(LiteralRestriction.java:87)
 

 at
 org.drools.rule.LiteralConstraint.isAllowed(LiteralConstraint.java:109)
 

 at
 org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:130)

 at
 org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:451)
 

 at
 org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:369)
 

 at
 org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:134)

 at
 org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:451)
 

 at
 org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:379)
 

 at
 org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:204)*
 ***

 at
 org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:244)*
 ***

 at
 org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:330)

 at
 org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:291)

 at
 org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:882)
 

 at
 org.drools.base.DefaultKnowledgeHelper.insert(DefaultKnowledgeHelper.java:180)
 

 ... 149 more

 ** **

 Wrapping the classField != null within an eval appears to be a work
 around.

 ** **

 This is in the suspect method:

 *public* *boolean* evaluate(InternalWorkingMemory
 workingMemory,

 *final* InternalReadAccessor extractor,
 

 *final* Object object1, *final*FieldValue 
 object2) {
 

 Object value1 = extractor.getValue( workingMemory, object1
 );

 Object value2 = object2.getValue();

 *if* ( value2 == *null* ) {

 ClassFieldImpl classField = (ClassFieldImpl) object2;**
 **

 value2 = classField.resolve( workingMemory );

 }

 *return* *comparator*.equals( value1, value2 );

 }

 ** **

 I think the if statement just needs an instanceof check as well or some
 other way to track the fact that null may be a valid value to be comparing
 with!

 ** **

 ** **

 Thomas

 --


 **
 This message is confidential and intended only for the addressee. If you
 have received this message in error, please immediately notify the
 postmas...@nds.com and delete it from your system as well as any
 copies. The content of e-mails as well as traffic data may be monitored by
 NDS for employment and security purposes. To protect the environment please
 do not print this e-mail unless necessary.

 NDS Limited. Registered Office: One London Road, Staines, Middlesex,
 TW18 4EX, United Kingdom. A company registered in England and Wales.
 Registered no. 3080780. VAT no. GB 603 8808 40-00

Re: [rules-users] Question about custom accumulation functions

2011-09-14 Thread Edson Tirelli
   Good. Thanks for letting us know.

   Edson

2011/9/14 Bruno Freudensprung bruno.freudenspr...@temis.com


 Hi Edson,

 Good news: the problem does not happen, neither with the 5.2.0.Final nor
 with the latest snapshot.
 Best regards,

 Bruno.

 Le 08/09/2011 17:17, Edson Tirelli a écrit :
 
 Bruno,
 
 Can you please test it with latest snapshot? If it is still a
  problem, then please open a JIRA and provide the test to reproduce it...
 
 
 https://hudson.jboss.org/jenkins/view/Drools%20jBPM/job/drools/lastSuccessfulBuild/artifact/drools-distribution/target/
 
 Thanks,
   Edson

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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Question about custom accumulation functions

2011-09-08 Thread Edson Tirelli
   It looks like a bug, as it should not raise a NPE no matter what
which version of Drools are you using?

   Edson

2011/9/8 Bruno Freudensprung bruno.freudenspr...@temis.com

 **

 Hi Edson, hi all,

 To stick to the subject, I have a strange problem (stack trace in PS) with
 a rule containing two accumulate calls, the result of the first one is
 re-injected as the input of the second one. Those accumulate functions are
 home made.
 The first one (tokenize) returns an ArrayList of Token objects built by
 tokenizing the text of the Sentence objects.
 The second one (build10windows) returns an ArrayList of Window objects,
 each one them containing 10 consecutive tokens.
 Here is the rule

 when
 $budget : ManualAnnotation(text == something)
 *$tokens* : java.util.ArrayList() *from accumulate *($s :
 Sentence(), *tokenize*($s))
 $windows : java.util.ArrayList() *from accumulate *($t : Token() *from
 $tokens*, *build10windows*($t))
 # removed a part here but the problem occurs even without this part
 then
 retract($budget);

 Is there anything else one should be aware of when implementing their own
 accumulate function? I mean things related to the fact that classical
 accumulate functions (sum, average) return an immutable object that does not
 share anything with the context object.
 Although accumulate, reverse, and getResult methods of my functions are
 unit tested, I suspect something that could be related to stateless/stateful
 considerations.
 What do you think?

 Many thanks,

 Bruno.

 PS :

 The stack trace is:
 at
 org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
 at
 org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:927)
 at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:856)
 at
 org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1071)
 at
 org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:785)
 at
 org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:751)
 at
 org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:218)
 at
 org.drools.command.runtime.rule.FireAllRulesCommand.execute(FireAllRulesCommand.java:99)
 at
 org.drools.command.runtime.rule.FireAllRulesCommand.execute(FireAllRulesCommand.java:33)
 at
 org.drools.command.runtime.BatchExecutionCommandImpl.execute(BatchExecutionCommandImpl.java:159)
 at
 org.drools.command.runtime.BatchExecutionCommandImpl.execute(BatchExecutionCommandImpl.java:81)
 at
 org.drools.impl.StatelessKnowledgeSessionImpl.execute(StatelessKnowledgeSessionImpl.java:262)
 ... 5 more
 Caused by: java.lang.NullPointerException
 at
 org.drools.reteoo.AccumulateNode.getFirstMatch(AccumulateNode.java:967)
 at org.drools.reteoo.AccumulateNode.splitList(AccumulateNode.java:920)
 at
 org.drools.reteoo.AccumulateNode.removePreviousMatchesForLeftTuple(AccumulateNode.java:874)
 at
 org.drools.reteoo.AccumulateNode.retractLeftTuple(AccumulateNode.java:205)
 at
 org.drools.reteoo.CompositeLeftTupleSinkAdapter.doPropagateRetractLeftTuple(CompositeLeftTupleSinkAdapter.java:238)
 at
 org.drools.reteoo.CompositeLeftTupleSinkAdapter.propagateRetractLeftTupleDestroyRightTuple(CompositeLeftTupleSinkAdapter.java:138)
 at
 org.drools.reteoo.AccumulateNode.retractLeftTuple(AccumulateNode.java:212)
 at
 org.drools.reteoo.ObjectTypeNode.retractObject(ObjectTypeNode.java:240)
 at
 org.drools.reteoo.EntryPointNode.retractObject(EntryPointNode.java:231)
 at
 org.drools.common.AbstractWorkingMemory.retract(AbstractWorkingMemory.java:1288)
 at
 org.drools.base.DefaultKnowledgeHelper.retract(DefaultKnowledgeHelper.java:201)
 at
 org.drools.base.DefaultKnowledgeHelper.retract(DefaultKnowledgeHelper.java:214)
 at
 defaultpkg.Rule_Display_windows_0.defaultConsequence(Rule_Display_windows_0.java:21)
 at
 defaultpkg.Rule_Display_windows_0DefaultConsequenceInvoker.evaluate(Rule_Display_windows_0DefaultConsequenceInvoker.java:29)
 at
 org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:917)
 ... 15 more



 Bruno.

 Le 24/08/2011 16:21, Edson Tirelli a écrit :


 Yes, evaluation is incremental, so for every new fact, it will call
 accumulate() and getResult().

 We do want to reduce the calls to getResult(), improving performance,
 but it is not easy to figure out a way, as from an engine perspective, it
 never knows when the application is done inserting facts and it is time to
 calculate the final result.

 Edson

 2011/8/24 Bruno Freudensprung bruno.freudenspr...@temis.com

 Hi,

 While testing my custom accumulation function I noticed an unexpected
 behavior (th'ats of course a personal point of view).
 It seems that Drools 5.1 calls accumulate(...) and getResult(...) as
 many times as the number

Re: [rules-users] Question about custom accumulation functions

2011-09-08 Thread Edson Tirelli
   Bruno,

   Can you please test it with latest snapshot? If it is still a problem,
then please open a JIRA and provide the test to reproduce it...

https://hudson.jboss.org/jenkins/view/Drools%20jBPM/job/drools/lastSuccessfulBuild/artifact/drools-distribution/target/

   Thanks,
 Edson

2011/9/8 Bruno Freudensprung bruno.freudenspr...@temis.com

 **

 I am using Drools 5.1.1.
 Do you want me to package a small maven project exhibiting that error, and
 post a Jira?

 Bruno.

 Le 08/09/2011 15:04, Edson Tirelli a écrit :


 It looks like a bug, as it should not raise a NPE no matter what
 which version of Drools are you using?

 Edson

 2011/9/8 Bruno Freudensprung bruno.freudenspr...@temis.com


 Hi Edson, hi all,

 To stick to the subject, I have a strange problem (stack trace in PS) with
 a rule containing two accumulate calls, the result of the first one is
 re-injected as the input of the second one. Those accumulate functions are
 home made.
 The first one (tokenize) returns an ArrayList of Token objects built by
 tokenizing the text of the Sentence objects.
 The second one (build10windows) returns an ArrayList of Window objects,
 each one them containing 10 consecutive tokens.
 Here is the rule

 when
 $budget : ManualAnnotation(text == something)
 *$tokens* : java.util.ArrayList() *from accumulate *($s :
 Sentence(), *tokenize*($s))
 $windows : java.util.ArrayList() *from accumulate *($t : Token()
 *from $tokens*, *build10windows*($t))
 # removed a part here but the problem occurs even without this
 part
 then
 retract($budget);

 Is there anything else one should be aware of when implementing their own
 accumulate function? I mean things related to the fact that classical
 accumulate functions (sum, average) return an immutable object that does not
 share anything with the context object.
 Although accumulate, reverse, and getResult methods of my functions are
 unit tested, I suspect something that could be related to stateless/stateful
 considerations.
 What do you think?

 Many thanks,

 Bruno.

 PS :

 The stack trace is:
 at
 org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39)
 at
 org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:927)
 at
 org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:856)
 at
 org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1071)
 at
 org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:785)
 at
 org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:751)
 at
 org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:218)
 at
 org.drools.command.runtime.rule.FireAllRulesCommand.execute(FireAllRulesCommand.java:99)
 at
 org.drools.command.runtime.rule.FireAllRulesCommand.execute(FireAllRulesCommand.java:33)
 at
 org.drools.command.runtime.BatchExecutionCommandImpl.execute(BatchExecutionCommandImpl.java:159)
 at
 org.drools.command.runtime.BatchExecutionCommandImpl.execute(BatchExecutionCommandImpl.java:81)
 at
 org.drools.impl.StatelessKnowledgeSessionImpl.execute(StatelessKnowledgeSessionImpl.java:262)
 ... 5 more
 Caused by: java.lang.NullPointerException
 at
 org.drools.reteoo.AccumulateNode.getFirstMatch(AccumulateNode.java:967)
 at org.drools.reteoo.AccumulateNode.splitList(AccumulateNode.java:920)
 at
 org.drools.reteoo.AccumulateNode.removePreviousMatchesForLeftTuple(AccumulateNode.java:874)
 at
 org.drools.reteoo.AccumulateNode.retractLeftTuple(AccumulateNode.java:205)
 at
 org.drools.reteoo.CompositeLeftTupleSinkAdapter.doPropagateRetractLeftTuple(CompositeLeftTupleSinkAdapter.java:238)
 at
 org.drools.reteoo.CompositeLeftTupleSinkAdapter.propagateRetractLeftTupleDestroyRightTuple(CompositeLeftTupleSinkAdapter.java:138)
 at
 org.drools.reteoo.AccumulateNode.retractLeftTuple(AccumulateNode.java:212)
 at
 org.drools.reteoo.ObjectTypeNode.retractObject(ObjectTypeNode.java:240)
 at
 org.drools.reteoo.EntryPointNode.retractObject(EntryPointNode.java:231)
 at
 org.drools.common.AbstractWorkingMemory.retract(AbstractWorkingMemory.java:1288)
 at
 org.drools.base.DefaultKnowledgeHelper.retract(DefaultKnowledgeHelper.java:201)
 at
 org.drools.base.DefaultKnowledgeHelper.retract(DefaultKnowledgeHelper.java:214)
 at
 defaultpkg.Rule_Display_windows_0.defaultConsequence(Rule_Display_windows_0.java:21)
 at
 defaultpkg.Rule_Display_windows_0DefaultConsequenceInvoker.evaluate(Rule_Display_windows_0DefaultConsequenceInvoker.java:29)
 at
 org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:917)
 ... 15 more



 Bruno.

 Le 24/08/2011 16:21, Edson Tirelli a écrit :


  Yes, evaluation is incremental, so for every new fact, it will call
 accumulate() and getResult().

 We do want

Re: [rules-users] Drools Fusion demo using twitter4j, Drools Workshop, Argentina (2011)

2011-08-23 Thread Edson Tirelli
  Hi Alex,

  It is here:
https://github.com/droolsjbpm/droolsjbpm-contributed-experiments/tree/master/twittercbr

  We would like to develop a proper web GUI for it and integrate it with
Guvnor that now supports CEP constructs, but did not had the time to do it
yet... if anyone would like to help, it would be most appreciated... :) we
could then move the example to the drools examples project and include it in
the distribution package.

   Edson

2011/8/23 Alex Ross s.alexandra.r...@gmail.com

 Did Edson ever post the example code.  If yes, from where might I download
 it?
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Do really support the containsKey() function on maps?

2011-08-20 Thread Edson Tirelli
   I think your data is somehow not matching, but you can try to simplify
your rule like this (assuming Drools 5.2):

rule transport
   when
   $pfMapType : MapType( name  ==  transport )
   $inputKey : InputKey( email == true )
   $ldapResponseMap : Map( this[zimbraMailDeliveryAddress]
== $inputKey ||
   this[zimbraDomainName] ==
$inputKey )
   then
   $pfMapType.setQueryFilterCheck(true);
end

   Edson


2011/8/20 dvsnmurty murty.devarako...@teamaol.com

 Hello Wolfgang,
 Thanks for the quick reply.  So if equals($inputKey) is the culprit, how
 can
 I modify the rule to make it work?  My best guess is to do something like
 this:

 rule transport
when
$pfMapType : MapType( name  ==  transport )
$inputKey : InputKey( email == true )
$ldapResponseMap : Map()
 then
updateTransportMap($pfMapType, $inputKey, $ldapResponseMap)
 end

 And then add the function updateTransportMap() to do the required checks
 that I am doing in the eval above.  Do you think of any other way?

 Regards,
 Murty.

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Do-really-support-the-containsKey-function-on-maps-tp3269570p3270684.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Condition syntax to access Map

2011-07-29 Thread Edson Tirelli
   Yes, that is exactly what I think. Pattern matching constraints are like
query parameters. They need to exist and evaluate to true in order to match.
So, for this to match:

a.b.c == null

   a needs to exist and be non-null, b needs to exist and be non-null, c
needs to exist and be null. So it is not just NP safe navigation... it is an
existence test at the same time. So for maps

a[x].b[y].c[z] == null

   The keys x, y and z need to exist, and c[z] must have a value of null.
That is what the expression above is asking for, in my understanding.

   This presents no loss of completeness to the language, as you can still
test non-existence of keys if that is what you want, but the most common
case you are looking for the opposite and it becomes much simpler to write
rules that way.

 So, a builder option to turn this on is allright with me.

   We can probably do that and have a configuration option to turn this
feature on/off.

   Edson


2011/7/29 Mark Proctor mproc...@codehaus.org

  Lets forget that these are nested accessors and the problems they bring.
 Lets look at what they would be if they were real relations:


 On 29/07/2011 08:55, Wolfgang Laun wrote:

 Whoa! See below...

 2011/7/28 Edson Tirelli ed.tire...@gmail.com


I think we need to differentiate paradigms here. When using rules,
 contrary to imperative code, what we are doing is pattern matching.

  X( a.b.c == value )

 In the above case, we are looking for Xs that make that whole
 constraint true (i.e. match). If a or b are null, the whole expression will
 be false, does not matter the value of c or the value it is being compared
 against.


 (Edson: Only if you define it so. The logical implication of c being null
 in an absent a.b (i.e., a.b==null) could very well be that a.b.c does not
 exist, and you can't claim that a.b.c exists if a.b. doesn't!

 Is there no house at some address?
 (city.street[name].house[number] == null)  # true = no such house

 $c : City()
 $s : Street( city == $c, street = name )
House( number ==  null)

 The above is identical logic to the more convenient form of nested
 accessors, it's the proper relational form. In this case if there was no
 Street, it wouldn't match.




 This test data with false when null: Vienna/TirelliStrasse/42 returns
 false, hence there *is* such a house. But we don't have a Tirelli Street
 in Vienna (yet)!

 Confer this to Perl's
 ! exists $city{-streets}{Tirelli}[42]
 )


  Raising a null pointer exception, IMO, brings no advantage at all to the
 table... on the contrary, makes writing rules more difficult.


 Edson, Mark,... please do recall the times where you have had an NPE in the
 code in a boolean expression? How painful would it have been if Java would
 have returned false, continuing to cover a coding error made elsewhere?

 Why don't other languages tolerate null silently? (Perl, the most
 pragmatic of all, doesn't - it has introduced an operator I can use or not.)

 I have no problem when folks want to take shortcuts and live la dolce vita,
 but
 emI don't want to be led into the bog without my consent./em

 So, a builder option to turn this on is allright with me.


 Another example we had in the past:

  class Circle implements Shape
 class Square implements Shape

  rule X
 when
 Circle() from $shapes
 ...

 In the above example, $shapes is a list and the rule is clearly
 looking for Circles. If there are Squares in there, they will just not
 match. Raising a ClassCastException like it would happen in an imperative
 language brings no advantage to the table, IMO.


 This is an entirely different matter than the previous one. I see no reason
 whatsoever, not to define this from as working with an implicit filter.

 -W




 So, IMO, all property navigation should be null pointer safe in the
 LHS of the rules.

 This is not what happens today, but I think it should be fixed.

 Edson




 2011/7/28 Vincent LEGENDRE vincent.legen...@eurodecision.com

  Hi all,

 I agree with W. : NPE should be the default, and null cases behaviour
 should be planned by programmers.
 But I am not sure about using a new operator in rules (and do the update
 in Guvnor ...).
 Why not using some drools annotations on the getter specifying the
 behaviour of an eval on a null value returned by this getter ?
 And may be these annotation could be added to an existing POJO via the
 declared type syntax (just like event role in fusion) ?

 Vincent.

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




 --
   Edson Tirelli
   JBoss Drools Core Development
   JBoss by Red Hat @ www.jboss.com

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




 ___
 rules-users mailing 
 listrules-users

  1   2   3   4   5   6   7   8   9   10   >