[rules-users] IllegalStateException happens when ResourceChangeScanner working on Version 5.3.0.CR1

2011-10-04 Thread Oliver Liu
Hi Guys,

I want to upgrade drools from 5.1.1 to 5.3.0 CR1, but i found
ResourceChangeScanner could't work.

In version 5.1.1, i wrote this code to get a KnowledgeAgent

KnowledgeAgent kagent =
KnowledgeAgentFactory.newKnowledgeAgent(ReleaseAgent);
kagent.addEventListener(new ReloadingRuleEventListener(this));

kagent.applyChangeSet(ResourceFactory.newClassPathResource(changeset-url.xml));

changeset-url.xml content is like:
change-set xmlns='http://drools.org/drools-5.0/change-set'
xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'
xs:schemaLocation='http://drools.org/drools-5.0/change-set
   
http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/main/resources/change-set-1.0.0.xsd'

   add
  resource
 
source='http://hostname:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/PackageName1/snapshot_release'
  type='PKG' basicAuthentication=enabled username=user1
password=123456 /
  
  resource
 
source='http://hostname:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/PackageName2/snapshot_release'
  type='PKG' basicAuthentication=enabled username=user1
password=123456 /

  resource
 
source='http://hostname:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/PackageName3/snapshot_release'
  type='PKG' basicAuthentication=enabled username=user1
password=123456 /
   /add
/change-set

then wrote this code to scan if there is a new version snapshot on guvnor
ResourceChangeScannerConfiguration sconf = ResourceFactory
.getResourceChangeScannerService()
.newResourceChangeScannerConfiguration();
sconf.setProperty(drools.resource.scanner.interval,60);


ResourceFactory.getResourceChangeScannerService().configure(sconf);
ResourceFactory.getResourceChangeScannerService().start();
ResourceFactory.getResourceChangeNotifierService().start();

It works very well, each time when ResourceChangeScanner finding there is
new snapshot, it can reload the rules from guvnor properly.

But when i updated to 5.3.0 CR1, ran this code, error happens:
Exception in thread Thread-2 java.lang.IllegalStateException: reader does
have
 a modified date
at
org.drools.io.impl.ReaderResource.getLastModified(ReaderResource.java
:64)
at
org.drools.io.impl.ResourceChangeScannerImpl.scan(ResourceChangeScann
erImpl.java:169)
at
org.drools.io.impl.ResourceChangeScannerImpl$ProcessChangeSet.run(Res
ourceChangeScannerImpl.java:326)
at java.lang.Thread.run(Thread.java:619)

It seems in new version, UrlResource was parsed to ReaderResource(i rememer
in 5.1.1, each resource in changeset-url.xml was parsed to UrlResource).


Can you give a help?
Thanks a lot


--
View this message in context: 
http://drools.46999.n3.nabble.com/IllegalStateException-happens-when-ResourceChangeScanner-working-on-Version-5-3-0-CR1-tp3393027p3393027.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] OutOfMemoryError happens when dynamic loading of Rules from Guvnor frequently

2011-06-22 Thread Oliver Liu
I read the source code of org.drools.agent.impl.KnowledgeAgentImpl, in this
segment
private void rebuildResources(ChangeSetState changeSetState) {
...
/*
 * Rebuild a new knowledge base. Try to use the old configuration if
 * possible
 */
if (this.kbase != null) {
this.kbase =
KnowledgeBaseFactory.newKnowledgeBase(((InternalRuleBase)
((KnowledgeBaseImpl) this.kbase).ruleBase).getConfiguration());
} else {
this.kbase = KnowledgeBaseFactory.newKnowledgeBase();
}
...
}

Before giving a new value to  this.kbase, i think maybe we should release
resource in it, so i tried to change code like this:
[6/21/2011 12:34:16 PM] liuyy_skype: if (this.kbase != null) {
for(KnowledgePackage packs : this.kbase.getKnowledgePackages())
{ 
 KnowledgePackageImp kpkg = ((KnowledgePackageImp)packs);
for (Rule rule : kpkg.pkg.getRules()) {
 removeKnowledgeDefinitionFromBase(rule);
}
for (Process process : kpkg.pkg.getRuleFlows().values()) {
 removeKnowledgeDefinitionFromBase(process);
}
for (Function function : kpkg.pkg.getFunctions().values()) {
 removeKnowledgeDefinitionFromBase(function);
}
for (TypeDeclaration dec :
kpkg.pkg.getTypeDeclarations().values()) { 
 removeKnowledgeDefinitionFromBase(dec);
}
   
this.kbase.removeKnowledgePackage(kpkg.getName());
kpkg.pkg.clear();   
Runtime.getRuntime().gc();
}

this.kbase =
KnowledgeBaseFactory.newKnowledgeBase(((InternalRuleBase)
((KnowledgeBaseImpl) this.kbase).ruleBase).getConfiguration());
} else {
this.kbase = KnowledgeBaseFactory.newKnowledgeBase();
}

Then i run my code, the memory indeed increased not so much like before, but
still rise. though the added code work, but i think there are some risk in
it, e.g. if the app are using a session which created from kbase, this code
may cause exception.

Any idea?

Thanks

Oliver

--
View this message in context: 
http://drools.46999.n3.nabble.com/OutOfMemoryError-happens-when-dynamic-loading-of-Rules-from-Guvnor-frequently-tp3079965p3098144.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] OutOfMemoryError happens when dynamic loading of Rules from Guvnor frequently

2011-06-20 Thread Oliver Liu
Any idea is appreciated, it's critical for my project. Thanks.

--
View this message in context: 
http://drools.46999.n3.nabble.com/OutOfMemoryError-happens-when-dynamic-loading-of-Rules-from-Guvnor-frequently-tp3079965p3088701.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] OutOfMemoryError happens when dynamic loading of Rules from Guvnor frequently

2011-06-18 Thread Oliver Liu
I am using Drools 5.1.1 to design our rule engine, the rule engine need to
dynamic loading of rules from Guvnor because our marking team need to change
the rules frequently(about 40~100 times every day), we have over 5000 rules
in Guvnor.

This is my code ahout that:
public KnowledgeBase getKnowledgeBase() {   
// hold a static reference in class
if(kagent != null) {
return kagent.getKnowledgeBase();
}

ResourceChangeScannerConfiguration sconf =
   
ResourceFactory.getResourceChangeScannerService().newResourceChangeScannerConfiguration();
 
sconf.setProperty(drools.resource.scanner.interval, 5);


ResourceFactory.getResourceChangeScannerService().configure(sconf);
ResourceFactory.getResourceChangeScannerService().start();
ResourceFactory.getResourceChangeNotifierService().start();
 
kagent = KnowledgeAgentFactory.newKnowledgeAgent(myagent);

kagent.applyChangeSet(ResourceFactory.newClassPathResource(changeset-url.xml));

return kagent.getKnowledgeBase();
} 

This is content of changeset-url.xml:
change-set xmlns='http://drools.org/drools-5.0/change-set'
xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'
xs:schemaLocation='http://drools.org/drools-5.0/change-set
   
http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-api/src/main/resources/change-set-1.0.0.xsd'

   add
  resource
 
source='http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/PackageName/snapshot_release'
  type='PKG'  /
   /add
/change-set

After i start my service, i found each time When i rebuild package and
created new snapshot to snapshot_release, my service indeed can find the
changing and start to reload rules from guvnor, but memory increased about
50M, it didn't down even if the reloading had finished. After i reput do
this step many times(about 25 times), OutOfMemoryError happened.

So, I want to know, why memory increased continually?It sames drools didn't
do garbage collection. 

Has anyone experienced this?

Thanks 

- Oliver

--
View this message in context: 
http://drools.46999.n3.nabble.com/OutOfMemoryError-happens-when-dynamic-loading-of-Rules-from-Guvnor-frequently-tp3079965p3079965.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