[rules-users] ClassCastException trying to deserialize a drools session
Hi. I'm getting this trying to read a serialized drools session (java 7, drools 5.1.1): Caused by: java.lang.ClassCastException: org.drools.reteoo.RuleTerminalNode cannot be cast to org.drools.reteoo.RightTupleSink at org.drools.marshalling.impl.InputMarshaller.readRightTuple(InputMarshaller.java:401) [drools-core.jar:5.1.1] at org.drools.marshalling.impl.InputMarshaller.readRightTuples(InputMarshaller.java:391) [drools-core.jar:5.1.1] at org.drools.marshalling.impl.InputMarshaller.readFactHandles(InputMarshaller.java:326) [drools-core.jar:5.1.1] at org.drools.marshalling.impl.InputMarshaller.readSession(InputMarshaller.java:205) [drools-core.jar:5.1.1] at org.drools.marshalling.impl.DefaultMarshaller.unmarshall(DefaultMarshaller.java:91) [drools-core.jar:5.1.1] this happens when trying to deserialize using Marshaller.unmarshal(). is this a known (hopefully fixed?) issue with 5.1.1 ? is it possible im doing something wrong? -- View this message in context: http://drools.46999.n3.nabble.com/ClassCastException-trying-to-deserialize-a-drools-session-tp4022048.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
Re: [rules-users] strict-mode and nested object property access in drools 5.4.0.Final - can i cast?
doh. thank you very much lhorton and Wolfgang. -- View this message in context: http://drools.46999.n3.nabble.com/strict-mode-and-nested-object-property-access-in-drools-5-4-0-Final-can-i-cast-tp4013373p4017584.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
Re: [rules-users] strict-mode and nested object property access in drools 5.4.0.Final - can i cast?
i tried this: rule "Naive Payload Access" @typesafe( false ) when $container : ClassWithPayload(key == "someKey", (payload != null && ((PayloadClass)payload.getSomeProp()) == "someValue")) then System.err.println("boom"); end which results in java.lang.AssertionError: Unable to Analyse Expression ((PayloadClass)payload.getSomeProp()): [Error: unable to resolve method using strict-mode: java.lang.Object.getSomeProp()] [Near : {... ((PayloadClass)payload.getSomeProp()) }] and: rule "Naive Payload Access" @typesafe( false ) when $container : ClassWithPayload(key == "someKey", (payload != null && payload.getSomeProp() == "someValue")) then System.err.println("boom"); end which, similarly, leads to: java.lang.AssertionError: Unable to Analyse Expression payload.getSomeProp(): [Error: unable to resolve method using strict-mode: java.lang.Object.getSomeProp()] [Near : {... payload.getSomeProp() }] was that what you meant? -- View this message in context: http://drools.46999.n3.nabble.com/strict-mode-and-nested-object-property-access-in-drools-5-4-0-Final-can-i-cast-tp4013373p4013569.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
Re: [rules-users] accessing session clock from accumulation function or rule body?
thanks for your reply. if i place the session clock as a fact, will this have any issues with session serialization, or will it just work ? -- View this message in context: http://drools.46999.n3.nabble.com/accessing-session-clock-from-accumulation-function-or-rule-body-tp4012348p4013375.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] strict-mode and nested object property access in drools 5.4.0.Final - can i cast?
hello. I have the following 2 classes: public class ClassWithPayload { private String key; private Object payload; // getters setters etc ommitted } public class PayloadClass { public String someProp; //getters setters etc ommitted } and im trying to get the following rule to compile: rule "Naive Payload Access" when $container : ClassWithPayload(key == "someKey", (payload != null && payload.someProp == "someValue")) then System.err.println("boom"); end which results in the following error: java.lang.AssertionError: Unable to Analyse Expression payload.someProp: [Error: unable to resolve method using strict-mode: java.lang.Object.someProp()] [Near : {... payload.someProp }] is there some way for me to cast payload.someProp to the proper class ? (PayloadClass in this case). this is a simplification of a bigger migration issue from drools 5.1 to 5.4 so the payload property has to remain an Object in the general case. there's a casting syntax mentioned here (https://community.jboss.org/wiki/DroolsPatternLanguage) but i take it its not been implemented yet? (or maybe i just cant understand it properly?) i've tried this: rule "Naive Payload Access" when $container : ClassWithPayload(key == "someKey", (payload != null && payload.#PayloadClass(someProp == "someValue"))) then System.err.println("boom"); end but it doesnt compile: java.lang.AssertionError: [8,51]: [ERR 101] Line 8:51 no viable alternative at input '(' in rule "Naive Payload Access" [0,0]: Parser returned a null Package and if i cant cast, how can i get this sort of rule to behave as it did in 5.1.1 ? thanks in advance for any assistance, Radai. -- View this message in context: http://drools.46999.n3.nabble.com/strict-mode-and-nested-object-property-access-in-drools-5-4-0-Final-can-i-cast-tp4013373.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] accessing session clock from accumulation function or rule body?
hi. i'm writing an accumulation function taht needs access to the session clock - is this possible from within the accumulation function ? if not, is this possible from the rule code (the when section) ? i could pass the current time as an argument ... thanks in advance for any assistance. -- View this message in context: http://drools.46999.n3.nabble.com/accessing-session-clock-from-accumulation-function-or-rule-body-tp4012348.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
Re: [rules-users] Sliding window of length (1) equals latest event?!
I came across a very similar behavior, but as far as i can tell its far worse: https://issues.jboss.org/browse/JBRULES-2862 in my case events just stay in memory forever (until the jvm dies). this means any rule i've tried with 2 windows is a memory leak. On Sat, Jan 29, 2011 at 6:17 PM, OlliSee wrote: > > Hey again everyone, > > I seem to be having another problem. > > When I have a rule like that > > when >A() over window:length(1) >B() over window:length(1) > then >... > > I imagine now having two windows of length 1. One always keeping the latest > A event and one always keeping the latest B event. And I expect them to > update themselves once a new event comes in. > > But if I have events coming in like this... > > A1, A2, B1 > > The rule fires for (A2, B1) > > then another event B2 is coming in and it fires for (A2,B2) > So far so good. > > Then another event A3 is coming in and the rule fires for (A3,B2) and > (A3,B1). > Why? Shouldn't the B window only have B2 inside since it arrived and thus > fire only for (A3,B2)? > > I have already been searching for this problem, found this > > http://drools-java-rules-engine.46999.n3.nabble.com/DROOLS-problem-with-sliding-windows-td2039892.html > but I'm not sure if this is the same problem as mine. > > Helping me understand this is highly appreciated, since I thought I had > completely understood the window behaviour. > > Thanks in advance. > Kind regards > Oliver > -- > View this message in context: > http://drools-java-rules-engine.46999.n3.nabble.com/Sliding-window-of-length-1-equals-latest-event-tp2370162p2370162.html > Sent from the Drools - User mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] help with diagnosing CEP performance issue
ah, events werent being evicted because RHS was only evaluated during fire(), which was after a batch. i have altered my test code according to your suggestion, to look like this: public void testLargeBatches() { Node node1 = new Node("node 1"); node1.setId(1L); s.insert(node1); clock.advanceTime(1L, TimeUnit.DAYS); int batchSize = 4; int daysToRun = 10; ArrayList batch = new ArrayList(batchSize); ArrayList nodeIds = new ArrayList(); nodeIds.add(1L); DateTime engineTime; long start; long accumulated = 0; long currentTime; long eventTime; long delta; System.err.println("days: "+daysToRun+". batch: "+batchSize+". rules: "+ruleFile); for (int i=0; i > You are inserting a day's worth of backup events at a time. In this loop > the engine is forced to evaluate both rules, for an ever-increasing number > of events. It's the second rule that requires a comparison between any two > backup events, and this causes a quadratic increment in processing time. > > CEP is short for "continuous event processing", and that's what you should > let the engine do, i.e., not only evaluate the conditions but also the > execute the consequences. This is done by calling fireAllRules() after each > insertion. Alternatively, consider running fireUntilHalt() in once thread > and insert in another thread. > > Ideally, the test should generate events ordered by time, and the > pseudo-clock might be advanced due to the time stamp in the generated > events. This would give you a very close approximation to a production run. > > -W > > > 2010/12/26 radai > > well, fixed now :-) >> the benchmark (part of a junit) looks like this: >> >> protected void init() { >> KnowledgeBuilderConfiguration bConf = >> KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(); >> KnowledgeBuilder builder = >> KnowledgeBuilderFactory.newKnowledgeBuilder(bConf); >> builder.add(...); >> >> KnowledgeBaseConfiguration kbConf = >> KnowledgeBaseFactory.newKnowledgeBaseConfiguration(); >> kbConf.setOption( EventProcessingOption.STREAM ); >> //todo - turn this on when >> https://issues.jboss.org/browse/JBRULES-2845 is fixed >> //kbConf.setOption( MultithreadEvaluationOption.YES ); >> kb = KnowledgeBaseFactory.newKnowledgeBase(kbConf); >> kb.addKnowledgePackages(builder.getKnowledgePackages()); >> >> KnowledgeSessionConfiguration sConf = >> KnowledgeBaseFactory.newKnowledgeSessionConfiguration(); >> sConf.setOption(ClockTypeOption.get("pseudo")); >> Environment env = EnvironmentFactory.newEnvironment(); >> s = kb.newStatefulKnowledgeSession(sConf ,env); >> >> clock = (SessionPseudoClock) s.getSessionClock(); >> >> backupStream = s.getWorkingMemoryEntryPoint("Backup Stream"); >> } >> >> followed by a test method that looks like this: >> >> public void testLargeBatches() { >> >> Node node1 = new Node("node 1"); >> node1.setId(1L); >> s.insert(node1); >> s.fireAllRules(); >> >> clock.advanceTime(1L, TimeUnit.DAYS); >> s.fireAllRules(); >> >> int batchSize = 4; >> int daysToRun = 1; >> ArrayList batch = new ArrayList(batchSize); >> ArrayList nodeIds = new ArrayList(); >> nodeIds.add(1L); >> DateTime engineTime; >> >> long start; >> long accumulated = 0; >> >> System.err.println("days: "+daysToRun+". batch: "+batchSize+". >> rules: "+ruleFile); >> >> for (int i=0; i> engineTime = new DateTime(clock.getCurrentTime(), >> DateTimeZone.UTC); >> batch.clear(); >> //generate random >> BackupGenerationUtil.fillBackupBatch(batch, nodeIds, >> engineTime.minusHours(23).minusMinutes(59).minusSeconds(59), >> engineTime.minusSeconds(1), batchSize); >> >> start = System.currentTimeMillis(); >> >> //feed the batch in >> for (Backup b : batch) { >> backupStream.insert(b); >> } >> >> //advance a day and run all rules >> s.fireAllRules(); >> clock.advanceTime(1L, TimeUnit.DAYS); >> s.fireAllRules(); >> >>
Re: [rules-users] help with diagnosing CEP performance issue
just to be clear, the "fixed" was only referring to my nick on gmail ... ;-) On Sun, Dec 26, 2010 at 6:24 AM, radai wrote: > well, fixed now :-) > the benchmark (part of a junit) looks like this: > > protected void init() { > KnowledgeBuilderConfiguration bConf = > KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(); > KnowledgeBuilder builder = > KnowledgeBuilderFactory.newKnowledgeBuilder(bConf); > builder.add(...); > > KnowledgeBaseConfiguration kbConf = > KnowledgeBaseFactory.newKnowledgeBaseConfiguration(); > kbConf.setOption( EventProcessingOption.STREAM ); > //todo - turn this on when > https://issues.jboss.org/browse/JBRULES-2845 is fixed > //kbConf.setOption( MultithreadEvaluationOption.YES ); > kb = KnowledgeBaseFactory.newKnowledgeBase(kbConf); > kb.addKnowledgePackages(builder.getKnowledgePackages()); > > KnowledgeSessionConfiguration sConf = > KnowledgeBaseFactory.newKnowledgeSessionConfiguration(); > sConf.setOption(ClockTypeOption.get("pseudo")); > Environment env = EnvironmentFactory.newEnvironment(); > s = kb.newStatefulKnowledgeSession(sConf ,env); > > clock = (SessionPseudoClock) s.getSessionClock(); > > backupStream = s.getWorkingMemoryEntryPoint("Backup Stream"); > } > > followed by a test method that looks like this: > > public void testLargeBatches() { > > Node node1 = new Node("node 1"); > node1.setId(1L); > s.insert(node1); > s.fireAllRules(); > > clock.advanceTime(1L, TimeUnit.DAYS); > s.fireAllRules(); > > int batchSize = 4; > int daysToRun = 1; > ArrayList batch = new ArrayList(batchSize); > ArrayList nodeIds = new ArrayList(); > nodeIds.add(1L); > DateTime engineTime; > > long start; > long accumulated = 0; > > System.err.println("days: "+daysToRun+". batch: "+batchSize+". > rules: "+ruleFile); > > for (int i=0; i engineTime = new DateTime(clock.getCurrentTime(), > DateTimeZone.UTC); > batch.clear(); > //generate random > BackupGenerationUtil.fillBackupBatch(batch, nodeIds, > engineTime.minusHours(23).minusMinutes(59).minusSeconds(59), > engineTime.minusSeconds(1), batchSize); > > start = System.currentTimeMillis(); > > //feed the batch in > for (Backup b : batch) { > backupStream.insert(b); > } > > //advance a day and run all rules > s.fireAllRules(); > clock.advanceTime(1L, TimeUnit.DAYS); > s.fireAllRules(); > > accumulated += (System.currentTimeMillis() - start); > } > > long averageBatchProcessingTime = > (long)(accumulated/(double)daysToRun); > double perBackupEventTime = > ((double)accumulated)/(batchSize*daysToRun); > int eventsPerSecond = (int)(1000D/perBackupEventTime); > > System.err.println("average batch processing time is > "+averageBatchProcessingTime+" which is "+perBackupEventTime+"/event or > "+eventsPerSecond+" events/second"); > } > > running this with or without the 2nd "trimming" rules makes a huge > difference. on my machine i can run the non-trimming version in batches of > 300K @~2500 events/second @1GB RAM. with the trimming rule i cant get > anywhere near that - the above value (40K) is already enough to slow it down > to ~1800 events/second, and i dont understand whats so "heavy" about my > attempt to save memory. > > any help/thoughts/clues would be most welcome. > > > 2010/12/23 Mauricio Salatino > > hehe yes.. the same happens to "me" :) >> >> 2010/12/23 Wolfgang Laun >> >> (OT: your nick "me" is confusing other gmail users. I see your mail as if >>> I had sent it to myself. I was almost binning it.) >>> >>> The delay you see may depend on the way you run the test with 40K events. >>> Please describe the sequence of insertions and calls to fire...(), the >>> session setup (pseudo-clock, etc.) >>> >>> -W >>> >>> >>> 2010/12/23 me >>> >>>> Hi. >>>> >>>> im trying to demo drools-fusion for a system that processes backup >>>> events. >>>> i have the following 2 CEP rules: >>>> >>>> rule "Backup Not Succeeded For At Least 3 Day
Re: [rules-users] help with diagnosing CEP performance issue
well, fixed now :-) the benchmark (part of a junit) looks like this: protected void init() { KnowledgeBuilderConfiguration bConf = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(); KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder(bConf); builder.add(...); KnowledgeBaseConfiguration kbConf = KnowledgeBaseFactory.newKnowledgeBaseConfiguration(); kbConf.setOption( EventProcessingOption.STREAM ); //todo - turn this on when https://issues.jboss.org/browse/JBRULES-2845 is fixed //kbConf.setOption( MultithreadEvaluationOption.YES ); kb = KnowledgeBaseFactory.newKnowledgeBase(kbConf); kb.addKnowledgePackages(builder.getKnowledgePackages()); KnowledgeSessionConfiguration sConf = KnowledgeBaseFactory.newKnowledgeSessionConfiguration(); sConf.setOption(ClockTypeOption.get("pseudo")); Environment env = EnvironmentFactory.newEnvironment(); s = kb.newStatefulKnowledgeSession(sConf ,env); clock = (SessionPseudoClock) s.getSessionClock(); backupStream = s.getWorkingMemoryEntryPoint("Backup Stream"); } followed by a test method that looks like this: public void testLargeBatches() { Node node1 = new Node("node 1"); node1.setId(1L); s.insert(node1); s.fireAllRules(); clock.advanceTime(1L, TimeUnit.DAYS); s.fireAllRules(); int batchSize = 4; int daysToRun = 1; ArrayList batch = new ArrayList(batchSize); ArrayList nodeIds = new ArrayList(); nodeIds.add(1L); DateTime engineTime; long start; long accumulated = 0; System.err.println("days: "+daysToRun+". batch: "+batchSize+". rules: "+ruleFile); for (int i=0; i > hehe yes.. the same happens to "me" :) > > 2010/12/23 Wolfgang Laun > > (OT: your nick "me" is confusing other gmail users. I see your mail as if I >> had sent it to myself. I was almost binning it.) >> >> The delay you see may depend on the way you run the test with 40K events. >> Please describe the sequence of insertions and calls to fire...(), the >> session setup (pseudo-clock, etc.) >> >> -W >> >> >> 2010/12/23 me >> >>> Hi. >>> >>> im trying to demo drools-fusion for a system that processes backup >>> events. >>> i have the following 2 CEP rules: >>> >>> rule "Backup Not Succeeded For At Least 3 Days" >>> @ruleId(1) >>> when >>> Node($id : id) >>> not ( Backup(clientId == $id, $state: state == >>> BackupStateEnum.FINISHED) over window:time( 3d ) from entry-point "Backup >>> Stream" ) >>> then >>> //nothing for now >>> end >>> >>> rule "Prune Previous Successful Backups" >>> @ruleId(2) >>> when >>> $prevBackup : Backup($id : clientId, state == >>> BackupStateEnum.FINISHED) from entry-point "Backup Stream" >>> $newerBackup : Backup(clientId == $id, state == >>> BackupStateEnum.FINISHED, this after $prevBackup) from entry-point "Backup >>> Stream" >>> then >>> drools.retract($prevBackup); >>> end >>> >>> rule #2 is my attempt to cut down on memory usage. the problem is that >>> rule #2 slows down the processing very very considerably (2 orders of >>> magnitude slower when simulating batches of 40K events/day). >>> >>> what would be my next step in trying to find the reason for it? my >>> intuition tells me that with 2 events in the system at any given time >>> instead of 120K (single node, 40K events/day 3 day window) i should have >>> seen either a speedup or reduced memory consumption (if not both) and yet >>> the results im seeing are the exact opposite. >>> is there anything im missing ? i could try adding some sort of >>> LastSuccessfulBackup "marker" object into main memory and updating it using >>> events from the backup stream, but then how would i express rule #1 ? >>> >>> any help/clues/suggestions would be greatly appreciated, >>> >>>radai. >>> >>> ___ >>> 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 >> >> > > > -- > - CTO @ http://www.plugtree.com > - MyJourney @ http://salaboy.wordpress.com > - Co-Founder @ http://www.jbug.com.ar > > - Salatino "Salaboy" Mauricio - > > ___ > 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