简体   繁体   English

Drools中有状态的session memory管理

[英]Stateful session memory management in Drools

Just have a general question regarding memory management when using "Stateful sessions" in Drools.在 Drools 中使用“有状态会话”时,有一个关于 memory 管理的一般性问题。 For context, I'm specifically looking to use a ksession in "Stream" mode, together with fireUntilHalt() to process an infinite stream of events.对于上下文,我特别希望在“流”模式下使用 ksession 以及fireUntilHalt()来处理无限的 stream 事件。 Each event is timestamped, however I'm mainly writing rules using length-based windows notation (ie window:length() ) and the from accumulate syntax for decision making.每个事件都有时间戳,但我主要使用基于长度的 windows 符号(即window:length() )和用于决策的from accumulate语法编写规则。

The docs are a little vague though about how memory management works in this case.尽管关于 memory 管理在这种情况下的工作方式,文档有点含糊。 The docs suggest that using temporal operators the engine can automatically remove any facts/events that can no longer match.文档建议使用时间运算符,引擎可以自动删除任何不再匹配的事实/事件。 However, would this also apply to rules that only use the window:length() ?但是,这是否也适用于仅使用window:length()的规则? Or would my system need to manually delete events that are no longer applicable, in order to prevent running OOM?或者我的系统是否需要手动删除不再适用的事件,以防止运行 OOM?

window:time() calculates expiration, so works for automatic removal. window:time()计算到期时间,因此适用于自动删除。 However, window:length() doesn't calculate expiration, so events would be retained.但是, window:length()不会计算到期时间,因此事件将被保留。

You can confirm the behaviour with my example: https://github.com/tkobayas/kiegroup-examples/tree/master/Ex-cep-window-length-8.32您可以通过我的示例确认行为: https://github.com/tkobayas/kiegroup-examples/tree/master/Ex-cep-window-length-8.32

FYI) https://github.com/kiegroup/drools/blob/8.32.0.Final/drools-core/src/main/java/org/drools/core/rule/SlidingLengthWindow.java#L145仅供参考) https://github.com/kiegroup/drools/blob/8.32.0.Final/drools-core/src/main/java/org/drools/core/rule/SlidingLengthWindow.java#L145

You would need to explicitly delete them or set @expires (if it's possible for your application to specify expiration with time) to avoid OOME.您需要明确删除它们或设置@expires (如果您的应用程序可以指定随时间到期)以避免 OOME。

Thank you for pointing that the document is not clear about it.谢谢指点,文档说的不清楚。 I have filed a doc JIRA to explain it.我已经提交了一份 JIRA 文档来解释它。

https://issues.redhat.com/browse/DROOLS-7282 https://issues.redhat.com/browse/DROOLS-7282

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM