我们有一个事件流,每个事件都具有以下属性:
public class Event {
private String id;
private String src;
private String dst;
}
此外,我们还有一组分层或嵌套规则,我们想用 EPL 和 Esper 建模。当且仅当其所有父规则都已被激活(所有这些规则都发生匹配实例)时,才应应用每个规则。例如:
2 events or more with the same src and dst in 10 seconds
+ 5 or more with src, dst the same as the src, dst in the above rule in 20s
+ 100 or more with src, dst the same as the src, dst in the above rules in 30s
我们要检索与此规则层次结构的每个级别对应的所有事件实例。例如,考虑以下事件:
id ---- source -------------- destination ---------------- arrival time (second)
1 192.168.1.1 192.168.1.2 1
2 192.168.1.1 192.168.1.2 2
3 192.168.1.1 192.168.1.3 3
4 192.168.1.1 192.168.1.2 4
5 192.168.1.5 192.168.1.8 5
6 192.168.1.1 192.168.1.2 6
7 192.168.1.1 192.168.1.2 7
8 192.168.1.1 192.168.1.2 8
.....
100 other events from 192.168.1.1 to 192.168.1.2 in less than 20 seconds
我们希望我们的规则层次结构报告此实例以及与层次结构的每个级别对应的所有事件的 id。例如,需要类似于以下报告的内容:
2 or more events with src 1928.168.1.1 and dst 192.168.1.2 in 10 seconds ( Ids:1,2 )
+ 5 or more with the same src (192.168.1.1) and dst (192.168.1.2) in 20s (Ids:1,2,4,6,7)
+ 100 or more events from 192.168.1.1 to 192.168.1.2 in 30s (Ids:1,2,4,6,7,8,...)
我们如何在 Esper EPL 中实现这一点(检索与所有规则匹配的事件的 id)?