<div>Thanks Wolfgang,</div><div><br></div>Yes, we do have a lot of events/hour, because it is a complex network we're monitoring. Our system has been running for some time, but the Drools rules engine is a new addition to attempt to manage some of the complexity.<div>
<br></div><div>Perhaps I should clarify events and alarms: Our main system tracks alarms within the network, but each alarm may have several events, like an event when the alarm is first raised, an event when its status goes from major to critical and an event when the alarm is cleared. So the main entity in our rules is an Alarm, and whenever we get an event we insert a new Alarm into the knowledge base if we've never seen the Alarm before, or update the Alarm if we have. <br>
<div>
<br></div><div>We have one other rule that removes all Alarms whose status haven't changed for 24 hours, regardless of whether they have cleared or not. This rule's syntax is very similar to the one from my previous email. We specifically have this rule to try and keep the fact count in the rules engine manageable.
</div><div><br></div><div><div><font face="courier new, monospace"> rule "Old, Inactive Alarm?"</font></div><div><font face="courier new, monospace"> timer(int: 30m 30m)</font></div><div><font face="courier new, monospace"> salience -10</font></div>
<div><font face="courier new, monospace"> when</font></div><div><font face="courier new, monospace"><span class="Apple-tab-span" style="white-space:pre">        </span>$a : Alarm(severity != "cleared")</font></div><div>
<font face="courier new, monospace"> then</font></div><div><font face="courier new, monospace"><span class="Apple-tab-span" style="white-space:pre">        </span>double lastUpdate = minutesSince($a.getEventTime());</font></div>
<div><font face="courier new, monospace"><span class="Apple-tab-span" style="white-space:pre">        </span>if(lastUpdate > 24 * 60) {<span class="Apple-tab-span" style="white-space:pre">                </span></font></div><div><font face="courier new, monospace"><span class="Apple-tab-span" style="white-space:pre">                </span>retract($a);</font></div>
<div><font face="courier new, monospace"><span class="Apple-tab-span" style="white-space:pre">        </span>}</font></div><div><font face="courier new, monospace"> end</font></div></div><div><br></div><div>So what you said would explain the memory usage. All Alarms end up in <span style="font-family:'courier new',monospace">"Old, Inactive Alarm?"</span>'s queue waiting for 24 hours.</div>
<div><br></div><div>I'm going to disable this rule <span style="font-family:'courier new',monospace">"Old, Inactive Alarm?"</span> for the time being. Unfortunately the nature of the problem means that I'll have to monitor it for a day or two before I can draw any conclusions.</div>
<div><br></div><div>It seems that the proper solution to this problem would be to get more memory. </div>
<div><br></div><div><div>Thank you,</div><div>Werner</div><div><br><div class="gmail_quote">On Tue, May 29, 2012 at 9:35 AM, Wolfgang Laun <span dir="ltr"><<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>On 29/05/2012, Werner Stoop <<a href="mailto:wstoop@gmail.com" target="_blank">wstoop@gmail.com</a>> wrote:<br>
> Hi, thank you for your response.<br>
><br>
> We use Drools 5.3.1 through Maven. When I invoke Drools, for each event I<br>
> receive I do the following:<br>
><br>
> ksession.insert(obj);<br>
> ksession.fireAllRules();<br>
><br>
</div>This is OK.<br>
<div><br>
><br>
> Yes, we do use timers. In one case we want to remove alarms that have been<br>
> cleared for more than an hour from the knowledgebase. We don't remove them<br>
> immediately because some alarms clear briefly and then come back. The rule<br>
> I've written to handle this situation is the following:<br>
><br>
> rule "Old Cleared Alarm?"<br>
> timer(int: 10m 10m)<br>
> salience -10<br>
> when<br>
> $a : Alarm(severity == "cleared")<br>
> then<br>
> double lastUpdate = minutesSince($a.getEventTime());<br>
> if(lastUpdate > 60) {<br>
> logger.debug("Alarm " + $a.getAlarmId() + " is old. Removing...");<br>
> retract($a);<br>
> }<br>
> end<br>
><br>
> Is there any other way to write this? I've found that I can't put the<br>
> minutesSince($a.getEventTime()) in the rule's when-clause.<br>
<br>
</div>It's fine as you have it; it would not be evaluated correctly on the LHS.<br>
<br>
But considering 2000000 events, if they were all Alarm, you'd have a<br>
rate of 17800 events/hour, and so you'd have that many scheduled<br>
agenda items.<br>
<br>
What about the other timer rules for other Event types? Are there<br>
similar scenarios?<br>
<span><font color="#888888"><br>
-W<br>
</font></span><div><div><br>
><br>
> Thank you,<br>
> Werner<br>
><br>
> On Tue, May 29, 2012 at 8:10 AM, Wolfgang Laun<br>
> <<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>>wrote:<br>
><br>
>> Just to make sure: How do you invoke the Engine? (I suppose you don't<br>
>> call with a limit for rule firings.)<br>
>><br>
>> Unless it's a bug (BTW: your Drools version is?), it's due to one or<br>
>> more of your rules.<br>
>><br>
>> Are you using timers? How?<br>
>><br>
>> A detailed investigation of the whereabouts of these<br>
>> ScheduledAgendaItem objects might be done by investigating (via the<br>
>> unstable API) the Agenda and its various components.<br>
>><br>
>> -W<br>
>><br>
>> On 28/05/2012, Werner Stoop <<a href="mailto:wstoop@gmail.com" target="_blank">wstoop@gmail.com</a>> wrote:<br>
>> > Hi,<br>
>> ><br>
>> > We're using Drools with a StatefulKnowledgeSession to process events<br>
>> coming<br>
>> > from equipment in our network. The system draws conclusions about the<br>
>> state<br>
>> > of the equipment and writes those conclusions to a table in our<br>
>> > database. All our rules work as we expected and the system produces the<br>
>> > correct results.<br>
>> ><br>
>> > However, the memory usage of the JVM steadily goes up when the system<br>
>> runs<br>
>> > for extended periods of time until we start getting<br>
>> > OutOfMemoryExceptions<br>
>> > and the server has to be restarted. This is in spite of the fact that<br>
>> > the<br>
>> > fact count reported by<br>
>> > the StatefulKnowledgeSession.getFactCount() stays reasonably stable,<br>
>> > with around 30 000 facts (give or take) at any point in time.<br>
>> ><br>
>> > I have run the Eclipse Memory Analyzer tool<br>
>> > (<a href="http://www.eclipse.org/mat/" target="_blank">http://www.eclipse.org/mat/</a><br>
>> )<br>
>> > against heap dumps from the JVM several times now, and every time it<br>
>> > reports more and more instances<br>
>> > of org.drools.common.ScheduledAgendaItem referenced from one instance<br>
>> > of<br>
>> > java.lang.Object[]<br>
>> ><br>
>> > To be concrete, since this morning the uptime is more than 112 hours in<br>
>> > total, during which the system has processed little over 2 000 000<br>
>> > events<br>
>> > from the network. It has 29 000 facts in the knowledge session, yet in<br>
>> the<br>
>> > heap dump we see 829 632 instances of<br>
>> > org.drools.common.ScheduledAgendaItem.<br>
>> ><br>
>> > What is the ScheduledAgendaItem for? Is there something wrong with my<br>
>> rules<br>
>> > that causes this many instances to be held? Is there something I should<br>
>> do<br>
>> > to release these instances or the Object[] holding on to them?<br>
>> ><br>
>> > Thanks,<br>
>> > Werner Stoop<br>
>> ><br>
>> _______________________________________________<br>
>> rules-users mailing list<br>
>> <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
>> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
>><br>
><br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br></div></div>
</div>