drools grid or other high availability solution?
by Justin Case
Hello all,
I noticed there's not much fuss about drools-grid (anymore?). Is there something still going on there? Is it recommendable for something reliable?
Or if not, do you have any hints/links/experience on how to achieve a certain high availability level with DRools servers?
Many thanks,
JC
13 years, 3 months
DROOLs 'Guarded entry/block' tactics for Rules synchronization and ordinality?
by Cotton, Ben
Hi,
I have finally gained a tiny bit of control (and maybe even some competency) in using the DROOLs language operators 'no-loop' and 'lock-on-active' as a basis for controlling rule set firing behavior in response to Fact mutation events (during consequence processing).
I now want to (competently!) use DROOLs language tactics that give me ever finer grained control over managing rule set firing behavior on Fact mutation events. Specifically, I want to be able to implement some form of 'Guarded entry/block' controls.
E.g. let's say I have a Fact (InsertedFactPOJO) that I insert into the KS and want to have its 'fireAllRules()' AgendaSet(s) renedered in exact incremental ordinal stages and in perfect isolation. To do this, I am testing the inclusion of a 'countdownLatch' Semaphore reference as a Fact member (initialized to N=`total rule count` value). I then use this to 'Guard' individual rule entry, by generating an explicit predicate participant
(InsertedFactPOJO(countdownLatch == i) )
@ each ith Rule producedby my template.
Is this approach a valid/sound/complete way to implement 'Guarded entry/block' controls in DROOLs? Is there a better way?
As always, my sincerest gratitude to this community for its generosity (and its genius).
Ben
package com.ms.fast.triclear.eligibility.rules.drools_community.questions.posted;
import com.ms.fast.triclear.eligibility.InsertedFactPOJO;
//fact:(backed by Class 'InsertedFactPOJO' has
//- 'countdownLatch' (Semaphore) member
//- 'aList' (List)member
rule "RULE_ALL_RULES_HAVE_FIRED_ONCE_ORDINALLY"
when
fact:InsertedFactPOJO()
InsertedFactPOJO(countdownLatch == 0)
then
System.out.format("\tALL RULES have fired *EXACTLY* once, *EXACTLY* ordinally. "+
" fact.countdownLatch=%d \n\t fact.aList=%s\n\n",
fact.countdownLatch,
fact.aList.toString());
end
rule "RULE_3"
when
fact:InsertedFactPOJO()
InsertedFactPOJO(countdownLatch == 3)
//bunch of other L-Value PREDICATES
then
System.out.format("\t %20.20s"+
" \t(DROOLS agenda: consequence fired for L-value predicate match @RULE="+
"3"+" -- fact.countDownLatch=%d)\n", "Rule 3",fact.countdownLatch);
modify (fact) {
countdownLatch = fact.countdownLatch - 1,
aList.add("Rule 3 pattern-match event added to POJO 'aList' field");
}
end
rule "RULE_2"
when
fact:InsertedFactPOJO()
InsertedFactPOJO(countdownLatch == 2)
//bunch of other L-Value PREDICATES
then
System.out.format("\t %20.20s"+
" \t(DROOLS agenda: consequence fired for L-value predicate match @RULE="+
"2"+" -- fact.countDownLatch=%d)\n", "Rule 2",fact.countdownLatch);
modify (fact) {
countdownLatch = fact.countdownLatch - 1,
aList.add("Rule 2 pattern-match event added to POJO 'aList' field");
}
end
rule "RULE_1"
when
fact:InsertedFactPOJO()
InsertedFactPOJO(countdownLatch == 1)
//bunch of other L-Value PREDICATES
then
System.out.format("\t %20.20s"+
" \t(DROOLS agenda: consequence fired for L-value predicate match @RULE="+
"1"+" -- fact.countDownLatch=%d)\n", "Rule 1",fact.countdownLatch);
modify (fact) {
countdownLatch = fact.countdownLatch - 1,
aList.add("Rule 1 pattern-match event added to POJO 'aList' field");
}
end
Ben D Cotton III
Morgan Stanley & Co.
OTC Derivatives Clearing Technology
1221 AOTA Rockefeller Ctr - Flr 27
New York, NY 10020
(212)762.9094
ben.cotton(a)ms.com<mailto:ben.cotton@ms.com>
________________________________
NOTICE: Morgan Stanley is not acting as a municipal advisor and the opinions or views contained herein are not intended to be, and do not constitute, advice within the meaning of Section 975 of the Dodd-Frank Wall Street Reform and Consumer Protection Act. If you have received this communication in error, please destroy all electronic and paper copies and notify the sender immediately. Mistransmission is not intended to waive confidentiality or privilege. Morgan Stanley reserves the right, to the extent permitted under applicable law, to monitor electronic communications. This message is subject to terms available at the following link: http://www.morganstanley.com/disclaimers If you cannot access these links, please notify us by reply message and we will send the contents to you. By messaging with Morgan Stanley you consent to the foregoing.
13 years, 3 months
Drools Planner: Planning variable gets assigned value out of valueRange
by mr_moe
Hey,
I have a planning entity, which has one planning variable called startDate.
This variable has a defined discrete value range which is a list of numbers
of the type long. Every number represents a timestamp, which is in between
the number firstPossibleStartDate and lastPossibleStartDate.
During the planning process, the number 0 is sometimes assigned to the
planning variable which is definitely not part of the valueRange. I’ve
printed the list to the console, but all values in the list are fine.
Because every planning entity has its own valueRange, the range is defined
in the entity itself.
At the moment I’ve implemented my own mover, but the problem occurs also
with pre-configured mover.
During my research I’ve stumbled upon the following note in the Planner
Documentation:
ValueRange from planning entity is currently not yet supported by the new
MoveSelectors.
Does this has something to do with my problem?
Enclosed you will find the code of the planning entity.
@PlanningEntity
public class DroolTask {
private List<Long> startDateList;
private int id;
private String name;
private long duration;
private long firstPossibleStartDate;
private long lastPossibleStartDate;
private String nextTask = "";
private String previousTask = "";
// Planning variables: changes during planning, between score calculations.
private long startDate;
@PlanningVariable
@ValueRange(type = ValueRangeType.FROM_PLANNING_ENTITY_PROPERTY,
planningEntityProperty = "startDateList")
public long getStartDate(){
return startDate;
}
public void setStartDate(long startDate){
this.startDate = startDate;
}
public List<Long> getStartDateList(){
return this.startDateList;
}
public void setStartDateList(){
startDateList = getPossibleStartDate();
}
public List<Long> getPossibleStartDate(){
startDateList = new ArrayList<Long>();
for(long i = firstPossibleStartDate; i<=lastPossibleStartDate; i = i +
60){
startDateList.add(i);
}
return startDateList;
}
public Long getFirstPossibleStartDate(){
return firstPossibleStartDate;
}
public void setFirstPossibleStartDate(long firstPossibleStartDate){
this.firstPossibleStartDate = firstPossibleStartDate;
}
public Long getLastPossibleStartDate(){
return lastPossibleStartDate;
}
public void setLastPossibleStartDate(long lastPossibleEndDate){
this.lastPossibleStartDate = lastPossibleEndDate;
}
[...]
public DroolTask clone(){
DroolTask clone = new DroolTask();
clone.name = name;
clone.duration = duration;
clone.firstPossibleStartDate = firstPossibleStartDate;
clone.lastPossibleStartDate = lastPossibleStartDate;
clone.startDate = startDate;
clone.nextTask = nextTask;
clone.previousTask = previousTask;
clone.startDateList = startDateList;
return clone;
}
[...]
}
It would be great, if someone could give me a hint.
Many thanks,
Moe
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-Planner-Planning-variable-gets-a...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 3 months
Re: [rules-users] Setting value in LHS for access in RHS
by Stephen Masters
You got it this time ... I'm trying to inspect the field name. As you mention there's a risk that a user could pick a mismatched RHS consequence, so I was hoping to work some DRL magic to avoid that.
So I think I'll get around it by extending my facts and populating them each with the value they should use. It means a lot more up-front calculations, but its probably the safest way.
Michael Anstis <michael.anstis(a)gmail.com> wrote:
>_______________________________________________
>rules-users mailing list
>rules-users(a)lists.jboss.org
>https://lists.jboss.org/mailman/listinfo/rules-users
13 years, 3 months
Re: [rules-users] Setting value in LHS for access in RHS
by Stephen Masters
Apologies for the overly brief explanation ... am at a bank where only internet access is on my phone. Additional apologies if I suffer from auto-correct errors. :)
[condition][] validate "{exposureType:ENUM:exposure types}" = AccountExposure($exp : {exposure type});
[consequence][] Create limit check = insert(new LimitCheck($exp);
Now, dependent on what exposure type I select, I need to use a different value to perform conversions between amounts and percentages. So it would keep things clean if I could pass the property name selected in the LHS to the object inserted on the RHS.
I could do it by having different DSL phrases for consequences, but my audience is very non technical so I'm trying to keep the language as minimal as possible.
Hope that explains it!
Steve
Mauricio Salatino <salaboy(a)gmail.com> wrote:
>_______________________________________________
>rules-users mailing list
>rules-users(a)lists.jboss.org
>https://lists.jboss.org/mailman/listinfo/rules-users
13 years, 3 months
Setting value in LHS for access in RHS
by Stephen Masters
Stephen Masters <stephen.masters(a)me.com> wrote:
>Hi folks,
>
>I'm trying to set up rules where the RHS is able to refer to a value set in the LHS so that it can perform its logics slightly differently.
>
>I'm able to use $var to pick out fields from facts in working memory. However as far as I can tell I'm not able to set a new value.
>
>I'm setting up a DSL to drive guided rules in guvnor and in the RHS I need to know which value was picked from a drop down list in the LHS.
>
>Cheers
>
>Steve
13 years, 3 months
Banking Example 4 to 6 - sorting incorrect
by Peter Gould
Hi,
I'm new to Drools and just working my way through the examples / tutorials
in the Drools Expert PDF. I'm using the 5.5.0 Final runtime. When I run the
BankingExamples 4 - 6 the results are not ordered in date order as the
tutorial suggests they should be.
This is easily resolved by changing the conditionals from:
date < $date
to:
date.time < $date.time
in the rules packages, but it worries me that the examples seem to suggest
that the sorting should be correct as is.
A colleague of mine has also run the examples with the same (incorrect)
results. Does anyone have any idea what's happening here? Is this something
that used to work in a previous version of the runtime but has regressed,
or a mistake in the example code, or something else entirely?
Regards,
Pete
13 years, 3 months
keep only one, retract all other
by Martin Minka
I want to keep only 1 fact with id=="aaaa". But this is not working:
rule "leave only one"
when
$removeUs : java.util.List(size>1)
from collect(Fact(id=="aaaa")
then
size = $removeUs.size();
for (int i=1; i < size; i++) {
retract($removeUs.get(i));
}
end
13 years, 3 months
Problem with rule when loaded as PKG
by Markus Undhagen
Hi
I have have a file with some rules. When I load the rules as a drl-file all my junit-tests work. But when I load the rules as PKG one of the rule is failing.
This is the rule causing the problem
rule "Lookup synonym" when $normalization : NormalizationFact(valid, resultFact == null) NormalizerMetadataService(synonymNames contains $normalization.type ) $synonymService : SynonymService() then System.out.println(drools.getRule().getName()); modify($normalization) { setResultFact(new ResultFact($synonymService.getValue($normalization.getType(), $normalization.getValue()))) }end
After some investigation I can reduce the problem to
setResultFact(new ResultFact("")) <------------------------- WorkingsetResultFact(new ResultFact(null)) <------------------------- Not working, see log below
This is the code executed in ResultFact
public class ResultFact { private final String result; private final boolean valid;
public ResultFact(String result) { this(result, true); }
public ResultFact(String result, Boolean valid) { super(); this.result = result; this.valid = valid; }
other methods ...}
The exception I get is
Exception executing consequence for rule "Lookup synonym" in normalization: [Error: $normalization.setResultFact(new ResultFact(null)): array index out of bounds.][Near : {... $normalization.setResultFact(n ....}] ^[Line: 1, Column: 1] at org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39) at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1297) at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1221) at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1456) at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:710) at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:674) at org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:230) at com.mawell.normalize.service.rule.DroolsRuleEvaluatorImpl.evaluate(DroolsRuleEvaluatorImpl.java:62) at com.mawell.normalize.service.infrastructure.util.backend.SynonymServiceTest.execute(SynonymServiceTest.java:126) at com.mawell.normalize.service.infrastructure.util.backend.SynonymServiceTest.execute(SynonymServiceTest.java:115) at com.mawell.normalize.service.infrastructure.util.backend.SynonymServiceTest.ShouldNotTranslate_q(SynonymServiceTest.java:75) 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 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)Caused by: [Error: $normalization.setResultFact(new ResultFact(null)): array index out of bounds.][Near : {... $normalization.setResultFact(n ....}] ^[Line: 1, Column: 1] at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:424) at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:143) at org.mvel2.ast.ASTNode.optimize(ASTNode.java:159) at org.mvel2.ast.ASTNode.getReducedValueAccelerated(ASTNode.java:115) at org.mvel2.compiler.ExecutableAccessor.getValue(ExecutableAccessor.java:42) at org.mvel2.ast.WithNode$ParmValuePair.eval(WithNode.java:278) at org.mvel2.ast.WithNode.getReducedValueAccelerated(WithNode.java:67) at org.mvel2.ast.InterceptorWrapper.getReducedValueAccelerated(InterceptorWrapper.java:40) at org.mvel2.MVELRuntime.execute(MVELRuntime.java:85) at org.mvel2.compiler.CompiledExpression.getDirectValue(CompiledExpression.java:123) at org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:119) at org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:113) at org.mvel2.MVEL.executeExpression(MVEL.java:930) at org.drools.base.mvel.MVELConsequence.evaluate(MVELConsequence.java:104) at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1287) ... 32 moreCaused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.substring(String.java:1931) at java.lang.String.substring(String.java:1904) at org.mvel2.util.ErrorUtil.rewriteIfNeeded(ErrorUtil.java:12) at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:959) at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:377) ... 46 more
I'm running version 5.5.0.Final of both Drools and Guvnor.
regardsMarkus
13 years, 3 months
Inconsistent behavior of a rule
by dec
See attached DRL. input is: condFt="supportedValue"
I have a rule with the following 'when' part which will not hit, though it
should:
$supportFT: supportFT()
condFT(value == $supportFT.getValue())
$conclusion: testInferred()
while the following one will hit, even though the two seems equivalent:
$supportFT: supportFT(value == null || value !=null)
condFT(value == $supportFT.getValue())
$conclusion: testInferred()
another one that seems equivalent that will hit:
$supportFT: supportFT()
supportFT(value == $condFt.getValue())
$conclusion: testInferred()
Not sure if it is indeed a bug, or a misuse on my part,
but I can't understand why the first rule will not hit. And even stranger,
why the second and third which seems the same will.
testInferred3.drl
<http://drools.46999.n3.nabble.com/file/n4021003/testInferred3.drl>
--
View this message in context: http://drools.46999.n3.nabble.com/Inconsistent-behavior-of-a-rule-tp40210...
Sent from the Drools: User forum mailing list archive at Nabble.com.
13 years, 3 months