I'm sending this again, as it seems it didn't make the list yesterday.
Sorry if you receive this twice.
-W
The rule you have shown is not capable of producing that error message. Which version of Drools are you using?
(1) You cannot use "=" (in: MyEvent(prop1="XYZ") to compare two values.
(2) You cannot use "matches" in eval, where Java expressions are expected (in: eval((prop3 matches ...).
(3) You must use one argument for a call to count (in: accumulate(..., count())), even though this argument does not matter.
(4) You should not use eval where it is not necessary.
(5) Your must use correct regular expressions, there is an error in: matches ("MatchOne|MatchTwo){1}::"+... and also in: matches "(second|Third{1}_CONNECT".
(6) It is highly unusual to use a repeat count of 1 for a subpattern in a regular expression.
Anyway, below is a correct version of the LHS except for the patterns, where I don't know what you really need to match.
Moreover, I urgently suggest that youThe following code has been compiled successfully using Drools 5.1.1, but some regular expressions contain errors, which will throw an exception at runtime.
- DO NOT post the same question twice within 24 hours. Cleaning up the mess takes time.
- Read the Drools Expert documentation before you write rules.
- Start with simple conditions and test that they work.
- Read the Drools Expert documentation.
- Build and test more complex patterns once simple patterns work as expected.
- Read the Java documentation on regular expressions.
declare MyEvent
@role( event )
prop1 : String
prop2 : int
prop3 : String
end
function String getFirstNameRegex(){ return "blah"; }
function String getMMSCNameRegex(){ return "gaga"; }
function String getServerID(){ return "R2D2"; }
function int getNodeCount(){ return 20; }
function int getConnectionCount(){ return 20; }
function int getThirdNodeCount(){ return 20; }
rule "or-or-or"
whenNumber($i1 : doubleValue > (getNodeCount()*0.35) ) from accumulate(
MyEvent(prop1 == "XYZ") over window:time(1m) from entry-point MyStream
or
( MyEvent() over window:time(1m) from entry-point MyStream
and
MyEvent(
prop1 == "CONNECT",
prop2 == 3,prop3 matches ("match " + getFirstNameRegex() + " Connect")
) over window:time(1m) from entry-point MyStream,count(1) )Number($i2 : doubleValue > (getConnectionCount()*0.4) ) from accumulate(
)
or
( MyEvent() over window:time(1m) from entry-point MyStream
and
MyEvent(
prop1 matches "(second|Third{1}_CONNECT",
prop2 == 1,prop3 matches ("MatchOne|MatchTwo){1}::" + getMMSCNameRegex()+", failure")
) over window:time(1m) from entry-point MyStream,count(1) )Number($i3 : doubleValue > (getThirdNodeCount()*0.5) ) from accumulate(
)
or
( MyEvent() over window:time(1m) from entry-point MyStream
and
MyEvent(
prop1 matches "(E1|E2){1}_CONNECT",
prop2 == 3,prop3 matches ("REPT (one|five|seven){1}::" + getServerID()+" is down")
) over window:time(1m) from entry-point MyStream,count(1) )
)
then
System.out.println( "match" );
end-WOn 28 January 2011 07:08, Ayush <ayush.vatsyayan@alcatel-lucent.com> wrote:
When I'm trying to execute multiple evals I'm getting errors. Below is what
I'm trying to do
MyEvent(prop1="XYZ") over window:time(1m) from entry-point
MyStream
or
(MyEvent() over window:time(1m) from entry-point MyStream
and
Number($i1 : doubleValue)
from accumulate(
MyEvent(
prop1 == "CONNECT",
prop2 == 3,
eval((prop3 matches ("match "+getFirstNameRegex()+"
Connect")) == true)
) over window:time(1m) from entry-point MyStream,
count()
)
and
eval($i1 > getNodeCount()*0.35))
or
(MyEvent() over window:time(1m) from entry-point MyStream
and
Number($i2 : doubleValue)
from accumulate(
MyEvent(
prop1 matches "(second|Third{1}_CONNECT",
prop2 == 1,
eval((prop3 matches
("MatchOne|MatchTwo){1}::"+getMMSCNameRegex()+", failure")) == true)
) over window:time(1m) from entry-point MyStream,
count()
)
and
eval($i2 > getConnectionCount()*0.4))
or
(MyEvent() over window:time(1m) from entry-point MyStream
and
Number($i3 : doubleValue)
from accumulate(
MyEvent(
prop1 matches "(E1|E2){1}_CONNECT",
prop2 == 3,
eval((prop3 matches ("REPT (one|five|seven){1}::
"+getServerID()+" is down")) == true)
) over window:time(1m) from entry-point MyStream,
count()
)
and
eval($i3 > getThirdNodeCount()*0.5))
When I'm trying to execute the above LHS I get
org.drools.rule.InvalidPatternException: Required Declarations not bound:
'$i1'.
I even tried using below approach
AlertReceivedEvent() over window:time(1m) from entry-point
NotificationStream
$I1 : Double() from getIsgNodeCount()
Number(doubleValue > $I1) from accumulate(
AlertReceivedEvent(
entity == "NPMMS_NE_CONNECT",
probableCause == 3,
eval((specificProblems matches ("REPT ISG
NPMMS::Unable to connect to "+getPxmmsNameRegex()+" node: PXMMS")) == true)
) over window:time(1m) from entry-point
NotificationStream, count()
)
But when I'm placing parentheses () around it, it throws exception stating
mismatched input '$I1' expecting ')' in rule. For now I'd placed these 3
statements in separate rules. Can anyone please help me solving it? Thanks
in advance.
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Problem-implementing-multiple-evals-tp2365761p2365761.html
Sent from the Drools - User mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users