1.正常的单例模式
Pattern<LoginEvent, LoginEvent> pattern = Pattern.<LoginEvent>begin("start").where(new SimpleCondition<LoginEvent>() {
@Override
public boolean filter(LoginEvent value) throws Exception {
return "fail".equals(value.getEventType());
}
}).next("next").where(new SimpleCondition<LoginEvent>() {
@Override
public boolean filter(LoginEvent value) throws Exception {
return "fail".equals(value.getEventType());
} //正常的单例模式
}).within(Time.seconds(2));
2.如果换成循环模式:
Pattern<LoginEvent, LoginEvent> pattern = Pattern.<LoginEvent>begin("start").where(new SimpleCondition<LoginEvent>() {
@Override
public boolean filter(LoginEvent value) throws Exception {
return "fail".equals(value.getEventType());
}
})
.times(2) //注意官方规定的循环模式属于 “宽松近邻” !
.consecutive() //注意必须加一个.consecutive(),使其转变为 “严格紧邻” !
.within(Time.seconds(2));
注意官方规定的循环模式属于 “宽松近邻” !
注意必须加一个.consecutive(),使其转变为 “严格近邻” !
499

被折叠的 条评论
为什么被折叠?



