[JBoss JIRA] Created: (JBRULES-2735) ClassCastException for casting DefaultFactHandle to EventFactHandle when using Sliding Windows
by Will Lauer (JIRA)
ClassCastException for casting DefaultFactHandle to EventFactHandle when using Sliding Windows
----------------------------------------------------------------------------------------------
Key: JBRULES-2735
URL: https://jira.jboss.org/browse/JBRULES-2735
Project: Drools
Issue Type: Bug
Security Level: Public (Everyone can see)
Components: drools-core (fusion)
Affects Versions: 5.1.1.FINAL
Environment: Windows XP SP3, Java 1.6.0_21, Drools 5.1.1
Reporter: Will Lauer
Assignee: Mark Proctor
When playing with a simple sliding window test using a single type of fact with @role(event), the following ClassCastException is generated:
Exception in thread "main" java.lang.ClassCastException: org.drools.common.DefaultFactHandle cannot be cast to org.drools.common.EventFactHandle
at org.drools.base.evaluators.BeforeEvaluatorDefinition$BeforeEvaluator.evaluateCachedLeft(BeforeEvaluatorDefinition.java:333)
at org.drools.rule.VariableRestriction.isAllowedCachedLeft(VariableRestriction.java:110)
at org.drools.rule.VariableConstraint.isAllowedCachedLeft(VariableConstraint.java:115)
at org.drools.common.SingleBetaConstraints.isAllowedCachedLeft(SingleBetaConstraints.java:142)
at org.drools.reteoo.FromNode.checkConstraintsAndPropagate(FromNode.java:274)
at org.drools.reteoo.FromNode.assertLeftTuple(FromNode.java:138)
at org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:189)
at org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:64)
at org.drools.reteoo.AccumulateNode.evaluateResultConstraints(AccumulateNode.java:662)
at org.drools.reteoo.AccumulateNode.assertLeftTuple(AccumulateNode.java:181)
at org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:189)
at org.drools.reteoo.SingleLeftTupleSinkAdapter.createAndPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:138)
at org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:148)
at org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:145)
at org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:450)
at org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:368)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:190)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:145)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1174)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1123)
at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:917)
at org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:251)
at net.wlauer.DroolsEngine.NonSpringRulesEngine.main(NonSpringRulesEngine.java:71)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 2 months
[JBoss JIRA] Created: (JBRULES-2751) NullPointerException in DeclarationTypeFixer: An rule compilation error should give a clear errow warning with an indecation of which rule is the culprit instead of a NPE
by Geoffrey De Smet (JIRA)
NullPointerException in DeclarationTypeFixer: An rule compilation error should give a clear errow warning with an indecation of which rule is the culprit instead of a NPE
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Key: JBRULES-2751
URL: https://jira.jboss.org/browse/JBRULES-2751
Project: Drools
Issue Type: Bug
Security Level: Public (Everyone can see)
Components: drools-compiler (expert)
Affects Versions: 5.1.1.FINAL
Reporter: Geoffrey De Smet
Assignee: Edson Tirelli
Fix For: 5.2.0.M1
{code}
Exception in thread "main" java.lang.NullPointerException
at org.drools.rule.builder.dialect.java.DeclarationTypeFixer.fix(DeclarationTypeFixer.java:17)
at org.drools.rule.builder.dialect.java.AbstractJavaRuleBuilder.createVariableContext(AbstractJavaRuleBuilder.java:90)
at org.drools.rule.builder.dialect.java.JavaAccumulateBuilder.build(JavaAccumulateBuilder.java:112)
at org.drools.rule.builder.dialect.java.JavaAccumulateBuilder.build(JavaAccumulateBuilder.java:54)
at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:223)
at org.drools.rule.builder.PatternBuilder.build(PatternBuilder.java:108)
at org.drools.rule.builder.GroupElementBuilder.build(GroupElementBuilder.java:69)
at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:79)
at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:1149)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:631)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:270)
at org.drools.planner.config.localsearch.LocalSearchSolverConfig.buildRuleBase(LocalSearchSolverConfig.java:209)
at org.drools.planner.config.localsearch.LocalSearchSolverConfig.buildSolver(LocalSearchSolverConfig.java:186)
at org.drools.planner.config.XmlSolverConfigurer.buildSolver(XmlSolverConfigurer.java:93)
at org.drools.planner.examples.cloudbalancing.app.CloudBalancingApp.createSolver(CloudBalancingApp.java:43)
at org.drools.planner.examples.common.app.CommonApp.createSolutionBusiness(CommonApp.java:59)
at org.drools.planner.examples.common.app.CommonApp.<init>(CommonApp.java:38)
at org.drools.planner.examples.cloudbalancing.app.CloudBalancingApp.<init>(CloudBalancingApp.java:30)
at org.drools.planner.examples.cloudbalancing.app.CloudBalancingApp.main(CloudBalancingApp.java:36)
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)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:115)
{code}
Here's the rule which causes this:
{code}
rule "minimalCpuPowerTotal"
when
$cloudComputer : CloudComputer($cpuPower : cpuPower)
$minimalCpuPowerTotal : Number(intValue > $cpuPower) from accumulate(
CloudAssignment(
cloudComputer == $cloudComputer,
$minimalCpuPower : minimalCpuPower), // This is the problem, CloudAssignment.getMinimalCpuPower does not exist yet
sum($minimalCpuPower)
)
then
insertLogical(new IntConstraintOccurrence("minimalCpuPowerTotal", ConstraintType.NEGATIVE_HARD,
$minimalCpuPowerTotal - $cpuPower,
$cloudComputer));
end
{code}
CloudAssignment did not have a getter for minimalCpuPower yet.
The compilation error should clearly say that its the rule minimalCpuPowerTotal which has a problem and that the getter for the field minimalCpuPower wasn't found.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 2 months
[JBoss JIRA] Created: (JBRULES-2696) KnowledgeBaseDefinitionParser Should Always Create KnowledgeBaseOptionsConfiguration
by Anatoly Polinsky (JIRA)
KnowledgeBaseDefinitionParser Should Always Create KnowledgeBaseOptionsConfiguration
------------------------------------------------------------------------------------
Key: JBRULES-2696
URL: https://jira.jboss.org/browse/JBRULES-2696
Project: Drools
Issue Type: Bug
Security Level: Public (Everyone can see)
Components: All
Affects Versions: 5.1.1.FINAL
Environment: N/A
Reporter: Anatoly Polinsky
Assignee: Mark Proctor
KnowledgeBaseOptionsConfiguration:
* <p>
* This class will automatically load default values from a number of places, accumulating properties from each location.
* This list of locations, in given priority is:
* System properties, home directory, working directory, META-INF/ of optionally provided classLoader
* META-INF/ of Thread.currentThread().getContextClassLoader() and META-INF/ of ClassLoader.getSystemClassLoader()
* </p>
Since this properties are only read when "RuleBaseConfiguration" ( KnowledgeBaseOptionsConfiguration implementor ) is constructed, this does not apply/work in case KnowledgeBase is defined via Spring without a <drools:configuration> due to the current sequence of events in "KnowledgeBaseDefinitionParser":
Element kbaseConf = DomUtils.getChildElementByTagName(element, "configuration");
if ( kbaseConf != null ) {
BeanDefinitionBuilder rbaseConfBuilder = BeanDefinitionBuilder.rootBeanDefinition( RuleBaseConfiguration.class );
// ... ... ...
factory.addPropertyValue( "conf", rbaseConfBuilder.getBeanDefinition() );
}
To fix it, RuleBaseConfiguration ( which implements KnowledgeBaseOptionsConfiguration ) should be created even though "<drools:configuration>" was not provided ( kbaseConf == null ):
Element kbaseConf = DomUtils.getChildElementByTagName(element, "configuration");
BeanDefinitionBuilder rbaseConfBuilder = BeanDefinitionBuilder.rootBeanDefinition( RuleBaseConfiguration.class );
if ( kbaseConf != null ) {
// ... ... ...
}
factory.addPropertyValue( "conf", rbaseConfBuilder.getBeanDefinition() );
Thank you,
/Anatoly
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 2 months
[JBoss JIRA] Created: (JBRULES-2695) Spring "Drools Resources" Need to be Modular
by Anatoly Polinsky (JIRA)
Spring "Drools Resources" Need to be Modular
--------------------------------------------
Key: JBRULES-2695
URL: https://jira.jboss.org/browse/JBRULES-2695
Project: Drools
Issue Type: Feature Request
Security Level: Public (Everyone can see)
Components: All
Affects Versions: 5.1.1.FINAL
Environment: N/A
Reporter: Anatoly Polinsky
Assignee: Mark Proctor
When development is done by multiple teams, there should be a way to reference the resources in a modular way.
Here is how it is / can be done now ( which is BAD / not modular ):
<drools:kbase id="kbase">
<drools:resources>
<drools:resource type="DRF" source="classpath:org/drools/container/spring/team1_1.drf"/>
<drools:resource type="DRF" source="classpath:org/drools/container/spring/team1_2.drf"/>
<drools:resource type="DRF" source="classpath:org/drools/container/spring/team2_1.drf"/>
<drools:resource type="DRF" source="classpath:org/drools/container/spring/team2_2.drf"/>
<drools:resource ref="team3_1"/>
<drools:resource ref="team3_2"/>
</drools:resources>
</drools:kbase>
Since clients need to be aware of _every_ little artifact of individual team, and have to reimport all artifacts into a knowledge base one by one.
Here is a better way to do it:
<drools:kbase id="kbase">
<drools:resources ref="team1-resources"/>
<drools:resources ref="team2-resources"/>
<drools:resources ref="team3-resources"/>
</drools:kbase>
where individual team's config may look as:
(e.g. team 1):
<drools:resources id="team1-resources">
<drools:resource type="DRF" source="classpath:org/drools/container/spring/team1_1.drf"/>
<drools:resource type="DRF" source="classpath:org/drools/container/spring/team1_2.drf"/>
</drools:resources/>
------------------------------------------------------------------------------
Long story short:
"drools:resources" needs:
1. ID, to be able to ref to it
2. REF, to be able to ref to an ID
"drools:kbase" needs:
1. To optionally take a list of "drools:resources"
Thank you,
/Anatoly
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 2 months
[JBoss JIRA] Created: (JBRULES-2792) Provide accessability of types and metadata for declare-d types
by Wolfgang Laun (JIRA)
Provide accessability of types and metadata for declare-d types
---------------------------------------------------------------
Key: JBRULES-2792
URL: https://jira.jboss.org/browse/JBRULES-2792
Project: Drools
Issue Type: Feature Request
Security Level: Public (Everyone can see)
Components: drools-api
Affects Versions: 5.1.1.FINAL
Reporter: Wolfgang Laun
Assignee: Mark Proctor
Fix For: FUTURE
* All types created or enhanced by a DRL declare construct must be retrievable from the KnowledgeBase using
Declare getDeclare( String pkg, String name )
* A Declare object must provide getters String getPackageName(), getName(), Map<String,Object> getMetaData() (same as Rule)
* A Declare object must provide Class<?> getFactClass() returning the created or enhanced java-lang.Class.
* A Declare object must provide long getInferredExpires() returning (for @role(event)) the inferred expiration offset or -1 if none.
--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 2 months
[JBoss JIRA] Created: (JBRULES-2782) Potential memory leak when rules are often reloaded
by Konstantin Pentarakis (JIRA)
Potential memory leak when rules are often reloaded
---------------------------------------------------
Key: JBRULES-2782
URL: https://jira.jboss.org/browse/JBRULES-2782
Project: Drools
Issue Type: Bug
Security Level: Public (Everyone can see)
Components: drools-core
Affects Versions: 5.1.1.FINAL
Environment: Windows 7 x64; JVM: Hotspot; JRE build 1.6.0_22-b04 and JRE build 1.5.0_11-b03
Reporter: Konstantin Pentarakis
Assignee: Mark Proctor
Hi!
There could be a small heapsize memory leak.
I encountered the problem when I tried to reload rules very often. The heap-size is permanently growing, eventhough the number of rules is constant! Since the heapsize grows very slowly, this leads to an OutOfMemoryError only, if I have a very large number of rules or if I reload the rules very often.
(code-example see below)
What do I mean by "reloading rules"? I add rules to an existing KnowledgeBase which is hold in memory. The rules come from an external source. For example, I add 500 rules into a KnowledgeBase (first run). Now, I redo this and add the same 500 rules again to the KnowledgeBase (2nd run). And so on. If I try this using a reduced heapsize of 64 MB, this works fine 71 times! But the 72nd time leads to an OutOfMemoryError, because there is no free heapsize left! It doesn't metter whether I remove the previously added rules first and add them afterwords again, or I directly add them.
Using a profiler, I can see, that the heap-consumption constandly increases!
The more rules I use, the less interations are possible (closley linearly). The more max. heapsize I use, the more iterations are possible (of course).
It seams like the Memory is hold by the RETE itself. The KnowledgeBase itself holds the references! If all references to the KnowledgeBase are deleted, the garbage collections frees the lost memory!
I also tried to use sequential mode. But there was no difference at all!
This happens with JRE 1.5 and JRE 1.6.
This also happens with the Drools 5.1.1 KnowledgeBase-Implemantion and the still in Drools 5 existing RuleBase-Implemention. But I didn't tested it yet with previous versions of Drools.
Why do I test this? We are building an application where rules will be created programmatically. There will be a large number of rules (some thousands) and rules can often change. The reload of rules which I tested here is something like a "simulation" of lots of rule changes.
Here is my example. For this example I used a simple Class called "RuleRepository" which has a static String-Array holding the rules as DRL-Strings. I also tried it with files in filesystem - no difference. See the RuleRepository-Class below. I post only 3 dummy-rules here - but that makes no difference. If someone wants to test with more rules, you can simply copy and rename them - or use your own rules!
MassivRuleChangeTest.java:
import java.io.IOException;
import java.util.Collection;
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.ResourceType;
import org.drools.compiler.DroolsParserException;
import org.drools.definition.KnowledgePackage;
import org.drools.io.ResourceFactory;
public class MassivRuleChangeTest {
public void run() throws Exception {
KnowledgeBase kBase = createRuleBase();
Collection<KnowledgePackage> packages;
long counter = 0;
int delCounter = 0;
int ruleCounter = 0;
while (true) {
System.out.println(++counter + ":");
for(int iLoop = 0; iLoop < RuleRepository.getSize(); iLoop++) {
packages = this.getRulePackage(RuleRepository.getRule(iLoop));
delCounter = this.cleanKBase(kBase, packages, delCounter);
kBase.addKnowledgePackages(packages);
ruleCounter++;
}
System.out.println(" - Deleted rules: " + delCounter);
System.out.println(" - Added rules: " + ruleCounter);
delCounter = 0;
ruleCounter = 0;
}
}
private int cleanKBase(KnowledgeBase kBase, Collection<KnowledgePackage> packages, int delCounter) {
if(kBase.getKnowledgePackages().size() > 0) {
for(KnowledgePackage kPkg : packages) {
if(kBase.getKnowledgePackage(kPkg.getName()) != null && kBase.getKnowledgePackage(kPkg.getName()).getRules().size() > 0) {
for(org.drools.definition.rule.Rule rule : kPkg.getRules()) {
if(kBase.getRule(kPkg.getName(), rule.getName()) != null) {
kBase.removeRule(kPkg.getName(), rule.getName());
delCounter++;
}
}
if(kPkg.getRules().size() == 0)
kBase.removeKnowledgePackage(kPkg.getName());
}
}
}
return delCounter;
}
private Collection<KnowledgePackage> getRulePackage(String rule) throws DroolsParserException, IOException {
KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder();
builder.add(ResourceFactory.newByteArrayResource(rule.getBytes()), ResourceType.DRL);
if (builder.hasErrors()) {
System.out.println(builder.getErrors().toString());
throw new RuntimeException("Unable to compile " + rule);
}
return builder.getKnowledgePackages();
}
private KnowledgeBase createRuleBase() throws Exception {
KnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase();
return kBase;
}
public static void main(String[] args) throws Exception {
new MassivRuleChangeTest().run();
}
}
----------------------------------------------------------------------------------------------------------------------------------
RuleRepository.java:
public class RuleRepository {
private static final String[] rules = {
"rule \"Rule001\" when #conditions then #actions end",
"rule \"Rule002\" when #conditions then #actions end",
"rule \"Rule003\" when #conditions then #actions end",
};
public static String getRule(int index) {
return rules[index];
}
public static int getSize() {
return rules.length;
}
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 2 months
[JBoss JIRA] Created: (JBRULES-2777) rule with window:length/accumulate/not( before ) fires twice
by Wolfgang Laun (JIRA)
rule with window:length/accumulate/not( before ) fires twice
------------------------------------------------------------
Key: JBRULES-2777
URL: https://jira.jboss.org/browse/JBRULES-2777
Project: Drools
Issue Type: Bug
Security Level: Public (Everyone can see)
Components: drools-core
Affects Versions: 5.1.1.FINAL
Reporter: Wolfgang Laun
Assignee: Mark Proctor
Fix For: 5.2.0.M1
STREAM, pseudo-clock, insert facts after advancing the clock to the timestamp in the event:
for( Job job: jobs.getJobs() ){
Date jobTime = job.getTimestamp();
long newClock = jobTime.getTime();
if( newClock > oldClock ){
clock.advanceTime( newClock - oldClock, TimeUnit.MILLISECONDS );
oldClock = newClock;
}
System.out.println( "inserting " + job );
session.insert( job );
System.out.println( "advancing by 1ms" );
clock.advanceTime( 1, TimeUnit.MILLISECONDS );
oldClock++;
System.out.println( "fireAllRules" );
session.fireAllRules();
}
A single rule:
declare Job
@role( event )
@timestamp( timestamp )
@duration( duration )
end
Part of output:
inserting Job: 6 at Wed Nov 03 01:40:00 CET 2010 - 1000
advancing by 1ms
clock: 1288744799999, ts of 1st: 1288742400000 - Average interval: 599 seconds
clock: 1288744799999, ts of 1st: 1288743000000 - Average interval: 449 seconds
fireAllRules
inserting Job: 7 at Wed Nov 03 01:45:00 CET 2010 - 1000
advancing by 1ms
clock: 1288745099999, ts of 1st: 1288743000000 - Average interval: 524 seconds
clock: 1288745099999, ts of 1st: 1288743600000 - Average interval: 374 seconds
fireAllRules
Rule firing is erratic. There is no apparent reason why this should fire twice after advancing the clock.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 2 months
[JBoss JIRA] Created: (JGRP-1052) Ergonomics
by Bela Ban (JIRA)
Ergonomics
----------
Key: JGRP-1052
URL: https://jira.jboss.org/jira/browse/JGRP-1052
Project: JGroups
Issue Type: Feature Request
Reporter: Bela Ban
Assignee: Bela Ban
Fix For: 3.0
The goal is to (a) reduce the number of properties needed and (b) determine the values dynamically.
Examples:
- Determine the best min/max size of a thread pool
- Find out what the best timeout values are for retransmission, e.g. based on average retransmission times
- Determine the optimal number of credits in FC
This is similar to the JVM setting where, starting with 1.5, the initial values can be set, but over time, the JVM dynamically changes them.
In the best case, a config contains only a list of protocols without any properties, and JGroups will figure out the correct values.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 2 months