1

我使用 Siddhi CEP 3.0.2 作为独立库。我有一个带有以下流和查询定义的执行计划,以关联连续事件并检测更改。我正在调用自定义函数调用。流定义中提到的对象属性是自定义 java 对象和 java.util.Map 对象类型。

在每个事件定期发生 5 分钟后,我可以看到 CPU 利用率在一秒钟内达到 40% 到 50% 左右,然后逐渐下降。但是这个 CPU 利用率每 5 分钟就会增加一次。

我使用模式查询的方式有问题。对此有什么帮助吗?

define stream portStream (source string,seq long, portInfo object); 
define stream deviceStream (source string,seq long, deviceinfo object); 

partition with (source of portstream, source of deviceStream) begin " +

@info(name = 'query1')
from (every e1= portStream->e2=portStream[e1.seq != e2.seq]) within 6 min "+ 
select e2.seq as currSeq, e1.source, 
custom:findPortStatus(e1.portInfo, e2.portInfo) as affecteddata "
insert into portStatusStream; 

@info(name = 'query2’) 
from (every e1=deviceStream-> e2=deviceStream [seq!=e1.seq]) within 6 min 
select e2.seq as curSeq, custom:findDeviceStatus(e1.deviceinfo,e2.deviceinfo) 
    as affectedDeviceInfo
insert into dStatusChangedStream; "

end;
4

1 回答 1

0

预计 CPU 利用率会增加。让我通过例子来解释这一点。如果您有一个模式every A -> B within 10 seconds,那么对于事件 A 的每次到达,都会产生一个单独的线程,该线程将等待 B 事件 10 秒。如果在 A 到达后 10 秒内没有 B 事件到达,则丢弃事件 B。我在研究工作中进行了许多实验,并看到了类似的行为。然而,我模拟的输入流具有恒定的到达间隔时间。因此,传入流的分布是一个重要因素,因为它决定了 A 事件何时到来,创建一个新线程,以及 B 事件导致匹配。

在您的情况下,可能是这样的情况,很多 A 事件发生在第 5 分钟,这导致 CPU 利用率增加。我也想知道,你用什么方法来计算 CPU 利用率。

于 2018-05-23T01:04:07.230 回答