Get rid of finalize() in KnowledgeSession
by Lubos
Hi,
My application uses many threads, each one creates KnowledgeSession from a
common shared KnowledgeBase to perform a task. The task is fast and at the
end session is disposed. When the thread starts to perform next task it
creates new session.
We had a scalability issues because of garbage collection. It happened too
often and took too long so we could not benefit from adding more CPUs. No GC
tuning helped.
After analysis I commented out finalize() method, which only calls
dispose(), which I call anyway after I'm done with the session. That was the
only change, i didn't modify application or JVM settings. Now the
application scales very well and all garbage collections are lighting fast.
After this experience I'm sure I will comment out finalize() in every drools
release I will use in the future, but maybe you could consider removing it
in the official release?
Lubos
--
View this message in context: http://drools.46999.n3.nabble.com/Get-rid-of-finalize-in-KnowledgeSession...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 7 months
How best to get back the updates that rules perform on declarative fact objects onto the domain objects (Dynamic fact generation with Declarative Fact Model)
by Vidya
Hi,
I am trying to evaluate using Drools in our EDM product. Our domain model is
very generic and complicated to be used as is as the fact model. Also new
domain entities will be added frequently and we would not want to write the
java fact model and supply the jar to the application (which needs
application bouncing...). So we may have to implement dynamic code
generation (using say javaassist).
Now I see that it can be partly achieved with the use of declarative fact
model (which does the dynamic code generation part for us).
But I have these questions -
When the rules fire, any update it makes on the fact needs to be updated
back onto our domain object obviously. Given that the fact model could be
potentially big, we were wondering
- if there can be anyway by which the application can be notified of
updates to the declared fact so we can copu only the changed attributes
backour domain object instead of copying all attributes back
OR
- if there was any way to introduce a dynamic proxy to the declared facts
so that the update (setXXX()) would have been called on the proxy which in
turn could update our domain object directly. As I see, this cannot be done
currently as the declarative facts are concrete classes and do not implement
any interface (its not possible to declare interfaces in drl files)
Is there any other better way to achieve this or should we go for dynamic
code generation in our application itself as mentioned in the beginning and
supply them as facts?
Thanks
Vidya
--
View this message in context: http://drools.46999.n3.nabble.com/How-best-to-get-back-the-updates-that-r...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 7 months
Rule firing issue in Drools 5.1.1...
by prashant.badhe
Hi,
Following are details of our configurations for Drools:
1. Drools v 5.1.1
2. Drools statefull kSession is initialized using Spring framework
3. We are using Resource scanner through change-set.xml. Scan interval is
set as 1 second. drools.Clocktype=realtime. drools.agent.newInstance=false.
4. There are about 8 DRL resources in the repository folder that resource
scanner scans.
5. Each DRL file has multiple rules. Within each DRL file, I am using same
aganda-group.
Issue:
After web server startup, it is observed that rules from some of the DRL
files fires. But, rules from 1 DRL file DO NOT fire at all.
There are no compilation errors/warnings appearing in log files after web
server startup.
If I remove this DRL file from repository (this is the location which
resource scanner scans) and copy it again after say 2-3 seconds, then the
rules from this file starts firing when appropriate facts are introduced in
WM.
Earlier I was using fireUntilHalt() to trigger rules, but now I am issuing
fireAllRules(). This was changed as I observed a 100% CPU consumption issue
when fireUntilHalt() even when the application is in idle state. See
"http://drools.46999.n3.nabble.com/fireUntilHalt-is-doing-busy-wait-and-co..."
I am using resource scanner feature to dynamically add/remove DRL files
without requiring restart of web server on production servers.
Does anybody faced similar issue in Drools 5.1.1 final?
Does resource scanner requires re-initialization of kSession after
add/update of DRL file in repository folder?
Thanks in advance,
Prashant Badhe
--
View this message in context: http://drools.46999.n3.nabble.com/Rule-firing-issue-in-Drools-5-1-1-tp388...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 8 months
Multi Access to Stateful Session
by gboro54
I have a stateful session which is having objects inserted and updated from
multiple threads. The thread managing the session is using the fireUntilHalt
method as below:
@Override
public void run() {
if (logger.isDebugEnabled()) {
logger.debug("Starting session...");
}
threadName = Thread.currentThread().getName();
session.fireUntilHalt();
}
The code being invoked to insert/modify objects is below:
public synchronized void insertOrUpdate(Object fact) {
Preconditions.checkNotNull(fact);
FactHandle factHandle = session.getFactHandle(fact);
if (factHandle == null) {
session.insert(fact);
} else {
session.update(factHandle, fact);
}
}
The problem I am running into is that I have a control fact which keeps an
internal counter(messages coming in are sequenced and need to be processed
in order) and a list of "deregister messages"(messages that are not going
to be inserted for various reasons). The problem I am having is that 75% of
the time it seems something goes wrong with the counter and messages stop
being processed and build up in the session. If i pass every message in and
don't try and deregister any everything works ok. The rules I have for
working with the message deregister is as follows(this is a an example there
are will be other rules added eventually):
rule "Dereg Message"
salience 10000
when
$controller:MessageControl($pos:currentPosition,excludedPositions[$pos]!=null)
then
modify( $controller ){
moveCurrentPositionForward(1)
}
end
rule "Remove Message"
salience -15000
when
$controller:MessageControl($pos:currentPosition,excludedPositions[$pos]==null)
$tsc:Message(rank==$pos)
then
cdiEvent.fire(new CDIEvent($tsc));
retract($tsc);
modify( $controller ){
moveCurrentPositionForward(1)
}
end
The controller class is:
private BigInteger currentPosition = new BigInteger("0");
private Map<BigInteger, BigInteger> excludedPositions = new
ConcurrentHashMap<BigInteger, BigInteger>();
public synchronized void addPositionToExclusionList(BigInteger position) {
excludedPositions.put(position, position);
}
public synchronized BigInteger getCurrentPosition() {
return currentPosition;
}
public synchronized void moveCurrentPositionForward(Integer value) {
currentPosition = currentPosition.add(new BigInteger(value.toString()));
}
public synchronized Map<BigInteger, BigInteger> getExcludedPositions() {
return excludedPositions;
}
public synchronized Collection<BigInteger> getExclusionList() {
return excludedPositions.values();
}
Any thoughts to why this may be occuring? I have been banging my head on
this problem for a couple days. We are using drools 5.3
--
View this message in context: http://drools.46999.n3.nabble.com/Multi-Access-to-Stateful-Session-tp3877...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 8 months
Drools performance
by Hassan
Hi everyone,
In one of my tests, I inserted 1000000 objects into the working memory,
drools engine made a lot of time to execute the program and it throws
Exception : "java.lang.OutOfMemoryError !!
Please if someone could help me to improve drools performance and specially
reduce the drools execution time
thanks
-----
Youssef AZBAKH.
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-performance-tp3870569p3870569.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years, 8 months
Rules Deployment Issue
by srinivas gullapalli
Hi,
We have a rule deployment directory where we can deploy the
rules.Currently we have written a new rule and deploying to the same to the
deployment directory.
what i observed is when i deploy the rule for the first time and passing
the corresponding data to fire the rule, the rule is not getting fired.If
copy the same file to some other
temporary directory and removing the same from current directory.Finally i
am copying the same file from the temporary directory(to which i copied
before removing the file) to our deployment directory then the rule is
getting fired as expected .
Could you please provide any pointers to resolve the issue.
we are uing 5.1.1 version of drools.
Regards,
Srinivas
12 years, 8 months
Inconsistent rule firing on a boolean field.
by Creighton Kirkendall
I have two rules below; the first fails to fire for all values of photo
(photo is a boolean field). The second rule give the correct behavior when
photo is true and false. I am new to drools and could be wrong but this
feels like a bug. Can anyone give me a reason for this behavior.
*BAD RULE:*
# rule values at C137, header at C132
rule "Photochromatic_137"
when
RxOrderType(product[0].lens.material.photo == true,
product[0].lens.design.lensType=="SV")
then
addResult("e1",results);
System.out.println("Single Vision-Photo");
end
*GOOD RULE (notice the - true &&):*
# rule values at C137, header at C132
rule "Photochromatic_137"
when
RxOrderType(true && product[0].lens.material.photo == true,
product[0].lens.design.lensType=="SV")
then
addResult("e1",results);
System.out.println("Single Vision-Photo");
end
Creighton Kirkendall
12 years, 8 months