Best way to have multiple kieBase dynamically
by lukes
Hi,
What's the best way to have multiple kieBases dynamically on
same/different KieFileSystem. let's say if i have 3 different drl(this can
grow dynamically, so don't want to put in kconfig.xml)l files and i want all
three of them to reside in different kiebases so that each session(stateful
and stateless) created from the kiebase can have it's independent set of
rules. Currently i a doing something like below:
this.kFileSystem.write("com.sample" + filename + ".drl", content);
this.kBuilder = this.kService.newKieBuilder(this.kFileSystem);
this.kBuilder.buildAll(); // kieModule is automatically deployed to
KieRepository if successfully built.
if (this.kBuilder.getResults().hasMessages(Level.ERROR)) {
throw new RuntimeException("Build Errors:\n" +
this.kBuilder.getResults().toString());
}
this.kContainer =
this.kService.newKieContainer(this.kRepository.getDefaultReleaseId());
But here, everything goes in to the same knowledgeBase. The actual problems
i am trying to solve are below :
1) If i'll rebuild 1 kieBuilder and kieContainer, others won't get affected
and users can work on them at the same time during runtime.
2) For the stateless sessions, there's no getAgendaGroup(name).setFocus(),
so it won't have to execute all the rules in the universal kieBase in my
case.
Thanks in advance.
--
View this message in context: http://drools.46999.n3.nabble.com/Best-way-to-have-multiple-kieBase-dynam...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years
Object size affect on session insertion performance
by mikerod
Does the size of objects inserted into the session as facts directly affect
performance?
I have ran some very simple tests, with a kb with 1 rule that
accumulated/collected over all facts in working memory of a type.
If I have a really simple/small class, say SimpleClass
It looks like:
```
rule "collecting"
when
$res : List() from
accumulate( $s : SimpleClass(),
init( List l = new ArrayList(); ),
action( l.add($s); ),
result( l ))
then
System.out.println("Done");
end
```
If I have a more complex class that will result in deeply nested objects,
say ComplexClass
It looks like:
```
rule "collecting"
when
$res : List() from
accumulate( $s : ComplexClass(), // this is the only difference from
above
init( List l = new ArrayList(); ),
action( l.add($s); ),
result( l ))
then
System.out.println("Done");
end
Now my Java test is just a simple one that puts a timer before and after
insert like:
```
// initialize kb and session as usual
// make N number of objects to insert of type SimpleClass or ComplexClass;
depending on test run
// store them in local variable cs
final long start = System.nanoTime();
for (final SimpleClass c : cs) { // This would be ComplexClass when
comparing
ksession.insert(c);
}
final double end = ((System.nanoTime() - start) / 1000000.0);
final int firedRules = ksession.fireAllRules(); // not really needed
here
```
What I notice from these tests, is that for something like N=5000 of
SimpleClass inserted into the session runs quick, say something like 35 sec.
However, for the same N=5000 of ComplexClass inserted into the session, the
time jumps to something like 148 sec.
I haven't done exhaustive performance testing around this, but I am seeing
this in more complex scenarios as well.
I know that heap space (maybe perm space) play a role in this, but I have
monitored my JVM processes during execution and there is no lack of
available heap space and my machine has a lot of resources available still
in both SimpleClass and ComplexClass scenarios.
I am trying to understand if the actual size of an object inserted into the
session has an affect on its overall performance.
This may be a trivial question and I'm just overlooking something, but I'd
appreciate any advice and feedback on this subject. I have not successfully
been able to find any resources on the internet where this has been
explicitly asked to base any thought off of. I also have read up some on
Rete (and variations e.g. Drools), but I don't see how the size of the
objects inserted as facts applies to the insert performance.
Thanks!
--
View this message in context: http://drools.46999.n3.nabble.com/Object-size-affect-on-session-insertion...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years
6.0.1.F Artifact Repository vs <container>/lib dir
by SrjTx
I am not 100% clear on the relationship between these two.
I want to have an enumeration that is populated from a DB.
It makes sense to me that I have to put the jar with the DB access class in
the repository. I know that I have to also put it in the /lib dir, but I
don't understand the relationship and why I have to do it.
Also, once I add the db access class, there are my.com.tenancy classes and
org.hibernate classes that get flagged as class not found.
I can add them to the repo, but since I don't access them directly, I
guessed that I wouldn't have to put them there and only in the ./lib
Can anyone elaborate on this or share a good link?
Thanks!
--
View this message in context: http://drools.46999.n3.nabble.com/6-0-1-F-Artifact-Repository-vs-containe...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years
Find the lowest and highest dates
by LarryW
I'm really new to Drools so this is probably a basic question. However, it
has consequences as to coding style.
I have to go through a class and find the lowest and highest dates. I have
a simple rule that works, below. I know there's also a way to do it using
accumulate, but it's ugly and probably not easily maintainable. Someone
told me I should not use java in the THEN segment, but I don't see anyway
around it. Is there a better way to write this rule than what I have here?
The problem is that the Then segment need only fire once, while the file may
contain any number of service lines. You have to process all service lines
before you know if the dates are the lowest and highest.
rule "FindLowestHighestDates"
when
$claim : Claim();
then
LocalDate lowestBeginDate =
$claim.getServiceLineInfoList().get(0).getServiceRelatedDates().getServiceDates().getBeginDate();
LocalDate highestEndDate =
$claim.getServiceLineInfoList().get(0).getServiceRelatedDates().getServiceDates().getEndDate();
for (ServiceLineDetail srvc: $claim.getServiceLineInfoList())
{
DateRange relDates =
srvc.getServiceRelatedDates().getServiceDates();
if (relDates.getBeginDate() != null &&
relDates.getBeginDate().isBefore(lowestBeginDate))
{
lowestBeginDate = relDates.getBeginDate();
}
if (relDates.getEndDate() != null &&
relDates.getEndDate().isAfter(highestEndDate))
{
highestEndDate = relDates.getEndDate();
}
}
ClaimDates cd = $claim.getClaimDates();
if (cd == null) cd = $claim.createClaimDates();
DateRange sd = cd.getServiceDates();
if (sd == null) sd = cd.createServiceDates();
sd.setBeginDate(lowestBeginDate);
sd.setEndDate(highestEndDate);
end
--
View this message in context: http://drools.46999.n3.nabble.com/Find-the-lowest-and-highest-dates-tp402...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years
Rule flow example
by Raja Sekhar
Hi
Can you any one provide me with rule flow samples
Regards,
--
Raja Sekhar Amirapu
------------------------------------------------------
"If any anyone can do it, i can do it. If no one else can do it, i must do
it"
12 years
Does a drools fact have a handle?
by Yoncho Yonchev
Hello, in order to distinguish my fact instances I need them to have some sort of number/id. Before implementing it I realized that the KieSession is not working with my business instance references, but with FactHandles, so it occurs to me that there might be some standard id that is defined and populated by the Drools in runtime.
So here is my question - Can a fact be identified by some sort of identifier after KieSession execution? May be if we get the FactHandles from it, or if we use the KieBase for that?
Thanks in advance!
Yoncho Yonchev.
12 years
How to configure Sequential Mode with Spring for Stateless session
by mattmadhavan
Hello,
Can some one let me know how I can set sequential mode when I have a
StatelessKnowledge Session configured using Spring?
I have hundreds of Facts and they are identical instances and I do not need
inference since I am only computing values based on each row and not
changing any facts.
I am injecting a StatelessKnowledge Session using Spring and I cannot find a
way to configure Sequential Mode either via Spring or programmatically since
I have Stateless Session Injected and I see no API for doing so!
Thanks in advance!
Matt
--
View this message in context: http://drools.46999.n3.nabble.com/How-to-configure-Sequential-Mode-with-S...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years
OutOfMemoryError using 6.0.1
by john poole
I've converted some NurseRostering rules, which worked in Drools 5.50, to
OptaPlanner 6.0.1. While it works far better for the time it runs, it uses
up whatever memory I can give it (9GB) and then eventually crashes the GUI.
with:
Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: GC
overhead limit exceeded
Is there a way to limit how much memory OptaPlanner uses? Or is it likely
that I'm just adding fact to the WorkingMemory in a way that wasn't a
problem in 5.5 but is a problem in 6.0?
--
View this message in context: http://drools.46999.n3.nabble.com/OutOfMemoryError-using-6-0-1-tp4028183....
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years