KnowledgeAgentImpl registeredResourceMap memory issue
by Cwen
We are seeing this HashMap (KnowledgeAgentImpl.registeredResourceMap) keeps
growing when a pkg is updated. It looks like creating more
CompositeClassLoader and not removing the old rule references. So it causes
KnowledgeAgentImpl use large memory. We are using 5.5.0.final.I am attaching
an image from memory analyzer to show how the HashMap holds up multiple
CompositeClassLoader and they are using about 230MB of memory. It increases
when the pkg gets updated with about 150 rules.
--
View this message in context: http://drools.46999.n3.nabble.com/KnowledgeAgentImpl-registeredResourceMa...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 7 months
Drools causes switch(enum e) to break?
by Leonard93
So I have a really weird problem and I think it could be relate-able to
Drools, or maybe not but maybe some people here have seen it before.
I have a simple enum called 'RuleTypes' which is defined in its own file.
I have somewhere in my class a switch statement where I use the enum like
this:
(The method is not finished, but its enough to show the problem)
public IResult EvaluateRule(Object obj, RuleType type)
{
//TODO
switch(type)
{
case Discount :
TripRequest lr = (TripRequest) obj;
_Session.execute(lr);
return lr.getResult();
case Content:
break;
case None:
break;
default:
break;
}
return null;
}
But I get an error saying 'Cannot switch on a value of type RuleType. Only
convertible int values or enum variables are permitted'. While RuleType an
enum is 100% sure.
Yet if I make a new project (with no drools libraries), make the same
RuleType enum in its own file and have an empty class doing:
public Test(RuleType type)
{
switch(type)
{
case Discount :
break;
case Content:
break;
case None:
break;
default:
break;
}
}
There are no compiler errors. Anyone know here what could possibly happen?
The only thing I could find was a possible Eclipse bug but that one had a
fix that does not work for me (
https://bugs.eclipse.org/bugs/show_bug.cgi?id=413368 ).
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-causes-switch-enum-e-to-break-tp...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 7 months
how KnowledgeAgent to use guvnor cluster?
by 窦晓峰
Hello, every one:
I am newbie for drools and guvnor, so excuse me if the question is
duplicated for others.
I am use guvnor 5.5.0 final and set up two nodes guvnor cluster
successfully. But I don’t know how to configure the knowledge agent to use
the cluster for HA?(before the cluster set up a nginx for banlance?)
Thx a lot
10 years, 7 months
Pooling stateful sessions to have threaded executions of a ruleset
by Maxime Falaize
Hello,
I want to ask you if it is a good practive to pool stateful sessions for a
specific ruleset to improve the execution performance.
Actually in my application I execute my rules by calling SOAP webservice.
For performance purpose, I test multithreaded calls to my webservice and I
noted that when I pool sessions in the server side, it improves the
performance a lot.
To pool sessions, I just declare multiple ksession tag in my kmodule.xml :
<kbase name="KBase" packages="com.example.*">
<ksession name="KSession1"/>
<ksession name="KSession2"/>
<ksession name="KSession3"/>
<ksession name="KSession4"/>
<ksession name="KSession5"/>
</kbase>
In my spring webservice endpoint I just put that code to handle the pool :
@Endpoint
public class ExampleEndpoint implements InitializingBean {
@Autowired
private ExampleRuleService ruleService;
private Map<Integer, Boolean> isRunningMap = new HashMap<Integer,
Boolean>();
private static final int NB_POOL_SESSIONS = 5;
@PayloadRoot(localPart = "com.example.ExampleRequest")
@ResponsePayload
public ExampleResponse handleRequest(
@RequestPayload ExampleRequest request) throws
InterruptedException {
KieServices ks = KieServices.Factory.get();
KieContainer kc = ks.getKieClasspathContainer();
while (true) {
for (int i = 0; i < NB_POOL_SESSIONS; i++) {
boolean run = false;
synchronized (isRunningMap) {
if (!isRunningMap.get(i)) {
isRunningMap.put(i, true);
run = true;
}
}
if (run) {
KieSession ksession = kc.newKieSession("KSession" + (i
+ 1));
ExampleResponse response = ruleService.run(ksession,
request);
ksession.dispose();
isRunningMap.put(i, false);
return response;
}
}
Thread.sleep(100);
}
}
public void afterPropertiesSet() throws Exception {
for (int i = 1; i <= NB_POOL_SESSIONS; i++) {
isRunningMap.put((i - 1), false);
}
}
}
It works well because in my benchmark I improve 5 times the performance (as
I have 5 different threads) but I wondered if it is a good practice and if
it does not hide any issues that I could have in the future.
Thanks for your help.
--
Maxime FALAIZE
10 years, 7 months
Problem with Collection
by mohanm
Hi,
I am using Drools 5.5.0 Final Expert to do Alarm Co-relation. I was trying
to collect the facts in to the ArrayList collection. My drl file will look
like below. From the Rule I calling an Java method to access the collected
facts.
/rule "Rule [Alarm Collection]"
no-loop
when
$alarmColl : ArrayList() from collect(Alarm
(
JustInserted == true;
))
then
// act on $alarmColl
end/
while in my Java code I am loop through the collection to set an attribute
of the Alarm Object. But while I am trying to set this attribute in the
collection, the collection is getting updated and indexes are changed. Due
to which all the objects are not updated. Even I tried using the iterator to
access the ArrayList collection. Still the same issue.
/
while(index < alarmColl.size()){
Alarm alarmObj=alarmColl.get(index)
if(alarmObj.isJustInserted()) {
alarmObj.setJustInserted(false);
theScenario.getSession().update(alarmObj);
}
index++;
}/
How can I update the objects in collection without changing the index or any
other way to achieve this.
--
View this message in context: http://drools.46999.n3.nabble.com/Problem-with-Collection-tp4029219.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 7 months
Guvnor - Importing Drl FIle and its associated model
by mattmadhavan
Hello,
In have a working Drools project. I would like to import existing DRL files
and associated Model file.
I have a custom operator as well. I have packaged the Model and necessary
operators and util global functions into a jar with their dependencies.
How do I import my DRL and the model jar so that, the DRL's imports 'see'
the referenced operators and functions and the Model (FACT) classes.
Can some one please let me have the sequence of steps?
Thanks
Matt
--
View this message in context: http://drools.46999.n3.nabble.com/Guvnor-Importing-Drl-FIle-and-its-assoc...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 7 months
If I have a rule that has a lot of permutation, which is the best approach to set it up? (Currently using decision table)
by SSWA
Attached is a sample rule decision table that I have set up.
As you can see, I have designed my conditions very nicely in the picture.
But if I were to add a new check, I will actually have to slowly key in the
values.
I'm wondering if there is any way that when I slot a condition into row 4,
it will auto populate the other fields that are "grouped" together. This
way, I wouldn't have to re-write those condition's information.
So example if I have a new module coming in for P1 called MODULE-A, and I
want to create a condition for it to say if the nationality is FR and
Eligibility is Y, it is 500 dollar. I will probably click the + button at
row 5 or even row 6. Then the fields, "P1", "Nationality", "Eligibility",
"Fee Code" will all be populated since they are grouped, and I will just key
in the Module Code.
Is there any way to do this?
--
View this message in context: http://drools.46999.n3.nabble.com/If-I-have-a-rule-that-has-a-lot-of-perm...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 7 months
Best practices to hand over from dev to business
by djb
Hi,
So I've worked with Drools v5 on a few projects, and made the move to v6
yesterday.
My programs typically have a model of pojos, plus some service utilities
that do the stuff that's easier in Java than in Drools.
I have implemented the system with DRLs and agenda groups, and one of the
next steps is to hand over to business. My comments will allow a junior
developer to maintain the program, but you'd be surprised how non-technical
the business users can be. They won't touch code.
So I'm hoping that Workbench will be what I need to facilitate the
transition. With Drools 6, I've separated my web app from the DRL files,
which now reside in their own mavenized Jar.
Deployment is also very manual at the moment. Run mvn install, ftp war to
server, drop in Jboss.
So step 1 is probably to load the model and drl files into WB. Should a
kiesession jar have pojos too? Only the parts you want to manage in WB?
Then I presume that the main goal of WB is to provide a graphical ui to
maintain rules, with business users messing around in their sandbox, making
new snapshot versions of the rules jar?
Then i change the web app's dependency to the new snapshot, rebuild and
redeploy?
What is the best scenario, to allow business users a UI and myself a simple
deployment mechanism when business users want to test their changes, that i
can hope to achieve with Drools and it's Uberfire parts?
--
View this message in context: http://drools.46999.n3.nabble.com/Best-practices-to-hand-over-from-dev-to...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 7 months
Drools 6 Unable to load pom.properties
by djb
Hi guys,
Drools 5 was so nice. I am struggling with 6. (6.0.1-Final)
So I've made a Maven project, ctCharges-0.1-SNAPSHOT, to contain my rules,
and it's basically the same as the named-kiesession example, without any
java files in it. Same kmodule.xml, just my own parentless maven group
instead of org.drools.
I add the dependency to my main project, but when I try this:
KieServices kServices = KieServices.Factory.get();
KieContainer kContainer = kServices.getKieClasspathContainer();
KieSession ksession = kContainer.newKieSession("ksession1");
it gets this:
Found kmodule:
vfs:/C:/jboss-eap/standalone/deployments/iconRules6.war/WEB-INF/lib/ctCharges-0.1-SNAPSHOT.jar/META-INF/kmodule.xml
Virtual file physical path =
C:\jboss-eap\standalone\tmp\vfs\deployment\deployment59bc0232401e9992\ctCharges-0.1-SNAPSHOT.jar-2808edf3c95bef92\ctCharges-0.1-SNAPSHOT.jar
*Unable to load pom.properties*
from\jboss-eap\standalone\tmp\vfs\deployment\deployment59bc0232401e9992\ctCharges-0.1-SNAPSHOT.jar-2808edf3c95bef92\ctCharges-0.1-SNAPSHOT.jar
null
(And then repeats this error couple of times)
If I look in the jar, I see:
META-INF/maven/com.mycompany/myArtifactName/pom.xml and pom.properties
What is going on?
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-6-Unable-to-load-pom-properties-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
10 years, 7 months