Question about custom accumulation functions
by Bruno Freudensprung
Hi,
While testing my custom accumulation function I noticed an unexpected
behavior (th'ats of course a personal point of view).
It seems that Drools 5.1 calls accumulate(...) and getResult(...) as
many times as the number of accumulated facts (accumulate, getResult,
accumulate, getResult, etc...).
Is it supposed to work like this?
Best regards,
Bruno.
11 years, 2 months
gives error while retracting an object
by Ganesh
Hi Team,
I am using drools-guvnor 5.4 version and designer 2.1 version,
I am calling an drools object from web service
While retracting an object I am getting
classCastException,"*java.lang.boolean cannot be cast to
org.drools.spi.activation* "
I am using session.retract(droolsobject);-Every time I got the error in this
line
This issue rise very often,
I think this issue is due to increase on load on object ,As I found this is
the reason while I search in INTERNET
Can you please tell me how to solve this
Regards
Ganesh N Neelekani
--
View this message in context: http://drools.46999.n3.nabble.com/gives-error-while-retracting-an-object-...
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 2 months
Please help me on hibernate-meet-drools
by Hong Ju
Hi,
I would like Drools to save my POJO objects as Hibernate Entities so that I can see my POJO objects as db tables in my database.
I tried to make this work by searching on the net, but there is very limited example on this topic, my code does not have any error, but it does not save any tables in my db. I attached my project in this email, if someone can help me on this, this will be so great and make me move forward.
Thank you so much in advance,
Hong Lily Ju
Software Engineer
hong.ju(a)steward.org<mailto:derrick.smith@steward.org>
Steward Heath Care
[Description: cid:image001.png@01CD0DC1.C0D81BD0]
Office: 781-375-3034
Cell: 781-801-9313
11 years, 2 months
Implementation of my use case - what am I doing wrong?
by Elran Dvir
Hi all,
A few weeks ago I posted a question about my use case to the mailing list. The correspondence is attached.
This is the example of the use case I implemented:
Port scan event - the basic event is connection log. For each combination
of source_ip and destination_ip, detect a port scan event,
if over 5 seconds there were more than 2 connection logs with
different ports .
The event will stay open for 10 seconds and an update will be
sent for any new port detected. Every update will contain the count of
connection logs combining it and their id ("marker").
the drl fie:
package test;
import correlation.impl.drools.Log
import correlation.impl.drools.CorrelatedEvent
global correlation.server.EventsHandler externalEventsHandler;
declare Log
@role( event)
end
declare CorrelatedEvent
@role( event)
@timestamp( getTimestamp().getTime() )
@expires( 10s )
@duration( getDuration() )
end
// this rule will create a "Port Scan" event if none exist for this group-by values
rule "Create Port Scan Event"
dialect "java"
no-loop
when
$log : Log() from entry-point "Log stream" //get all the logs in the last 5 seconds
accumulate( Log( this after[0s,5s] $log, fieldsMap.get("src") == $log.fieldsMap.get("src") , fieldsMap.get("dst") == $log.fieldsMap.get("dst"), $port : fieldsMap.get("port")) from entry-point "Log stream";
$portSet : collectSet($port);
$portSet.size > 2 )
accumulate( Log( this after[0s,5s] $log, fieldsMap.get("src") == $log.fieldsMap.get("src") , fieldsMap.get("dst") == $log.fieldsMap.get("dst"), $marker : fieldsMap.get("marker")) from entry-point "Log stream";
$markerSet : collectSet($marker))
not CorrelatedEvent(getName() == "portScan" , fieldsMap.get("src") == $log.fieldsMap.get("src") , fieldsMap.get("dst") == $log.fieldsMap.get("dst"))
then
System.out.println(drools.getRule().getName());
CorrelatedEvent $ce = new CorrelatedEvent();
$ce.setName("portScan");
$ce.setEventsHandler(externalEventsHandler);
$ce.setDurationInSec(10);
$ce.fieldsMap.put("src", $log.fieldsMap.get("src"));
$ce.fieldsMap.put("dst", $log.fieldsMap.get("dst"));
$ce.endUpdate($markerSet);
insert($ce);
end
rule "Create Port Scan Event - update"
dialect "java"
no-loop
when
$ce: CorrelatedEvent(getName() == "portScan")
accumulate( Log(fieldsMap.get("src") == $ce.fieldsMap.get("src") , fieldsMap.get("dst") == $ce.fieldsMap.get("dst") , $port : fieldsMap.get("port") , (this meets $ce || this during $ce || this metby $ce)) from entry-point "Log stream";
$portSet : collectSet($port);
$portSet.size > 0 )
accumulate( Log(fieldsMap.get("src") == $ce.fieldsMap.get("src") , fieldsMap.get("dst") == $ce.fieldsMap.get("dst") , $marker : fieldsMap.get("marker") , (this meets $ce || this during $ce || this metby $ce)) from entry-point "Log stream";
$markerSet : collectSet($marker))
then
System.out.println(drools.getRule().getName());
modify( $ce ) {endUpdate($markerSet)}
end
my questions:
1) If I have only one stream of data , can I omit the use of entry point and insert logs to the session ? Or the use of entry points is mandatory in Drools Fusion?
2) When I tested it with matching data, rule "Create Port Scan Event - update" was never fired. When I replaced "(this meets $ce || this during $ce || this metby $ce)" with "this after $ce.getStartTime() , this before $ce.getEndTime()" everything worked fine.
Why?
3) I tried to use sliding windows in rule "Create Port Scan Event" and an exception was thrown at runtime. I decided to use "this after[0s,5s] $log" instead. Is it correct?
4) Is my basic Implementation correct?
Thank you all very much.
Log class:
public class Log {
public HashMap<String, Object> fieldsMap = new HashMap<>();
}
CorrelatedEvent class:
public class CorrelatedEvent
{
public Map<String, Object> fieldsMap;
private String name;
private Set<String> markersSet;
private long logsCount;
private Calendar startTime;
private Calendar endTime;
private int duration;
private EventsHandler eventsHandler;
public CorrelatedEvent()
{
startTime = Calendar.getInstance();
endTime = Calendar.getInstance();
endTime.setTime(startTime.getTime());
fieldsMap = new HashMap<>();
markersSet = new HashSet<>();
logsCount = 0;
}
public Date getTimestamp()
{
return startTime.getTime();
}
public Date getStartTime()
{
return startTime.getTime();
}
public Date getEndTime()
{
return endTime.getTime();
}
public void setDurationInSec(int duration)
{
this.duration = duration;
endTime.setTime(startTime.getTime());
endTime.add(Calendar.SECOND, duration);
}
public int getDuration()
{
return duration;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
fieldsMap.put("name", name);
}
public void setEventsHandler(EventsHandler eventsHandler)
{
this.eventsHandler = eventsHandler;
}
public void endUpdate(Set<String> markersSet)
{
this.markersSet.addAll(markersSet);
if (this.markersSet.size() > logsCount) {
logsCount = this.markersSet.size();
if (eventsHandler == null)
return;
Map<String, Object> clonedFieldsMap = getClonedFieldsMap();
clonedFieldsMap.put("markers", this.markersSet.toString()); //need a function that converts a set of markers to a "\n" separated list
clonedFieldsMap.put("count", logsCount);
eventsHandler.handleEvent(clonedFieldsMap);
}
}
private Map<String, Object> getClonedFieldsMap()
{
Map<String, Object> clonedFieldsMap = new HashMap<>();
clonedFieldsMap.putAll(fieldsMap);
return clonedFieldsMap;
}
}
11 years, 2 months
Guvnor 5.5 bug - when the advanced enum feature is used, the selected value is not saved in special condition
by Sean Su
When there are 3 drop downs, one determines the values of the other, the
selection in the last drop down is not saved when changing the rules twice
in the row.
For example: I have the following statement:
in fact [field1] [field2][field3]
each of the field is presented as a drop down by using the advanced ENUM
feature - 1 determines the values in 2 and the selection of 2 determines
the value of 3.
After the value in field3 is selected, I can move on and make the changes
in the rule. When the first change occurred, Guvnor remembers the values
being selected in all 3 fields. But when another change is make, the
selected value in the last field (field3) will be forgotten. Please note
this is only happening to the last field. I did not go further and make the
statement contain more than 3 drop downs.
I have tested this several times and am confident this is a bug in the 5.5
final version.
Thanks
Sean
11 years, 2 months
replace session clock at runtime
by Alexander Wolf
Drools 5.5
Hey guys,
Is it possible to replace the session clock of an existing stateful knowledge session (STREAM mode) while it is running or at least by pausing and restarting it?
I need to feed old events into the session to restore a certain session state before switching the sessions to "realtime" mode and continue with new incoming events...
A code snippet would make me very happy ;)
- Alex
11 years, 2 months
Reevaluate rules on collect
by gboro54
I have the following three rules:
rule "Create Acct Context"
when
$Acct:Acct()
not (exists(AcctContext(Acct ==$Acct)))
then
insert(new AcctContext($Acct));
end
rule "Add Acct Statuses to AcctContext"
no-loop true
when
$AcctContext:AcctContext($Acct:Acct)
$AcctStatuses : List()
from collect ( AcctPerformanceStatus(acctId==$Acct.id))
then
modify($AcctContext) {addAllAcctStatuses($AcctStatuses) };
end
rule "Test"
when
AcctContext(getAcctStatus("Test1")!=null)
then
System.out.println("Good!");
end
I would expect that after the first 2 rules fire, that my 3rd rule would
fire if the data is there successfully(which I have done in my unit test).
However the 3rd rule never fires. Any thoughts into how to accomplish this?
We are using drools 5.5 so perhaps property reactive? These rules are
creating a context/wrapper object to make decision tables easier to
write/manage for our business users.
Thanks!
--
View this message in context: http://drools.46999.n3.nabble.com/Reevaluate-rules-on-collect-tp4026194.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
11 years, 2 months