2017-01-11 6 views
0

이벤트의 부재 일치 5 분부터내가 객체의 상태에 대한 간단한 스트림이

define stream statusStream (id string, success bool); 

나는 "실패"하는 모든 오브젝트를 조회 할 (성공 = 거짓 일) : statusStream의 모든 이벤트를 (, false) 이벤트가없는 곳 (같은 id, true).

이러한 종류의 작업에 가장 간단한 siddhi 쿼리는 무엇입니까? 현재

내가 가진 :

당신이 다음, 실패를 표시 실행 계획 아래 시도의 성공 == false '로 메시지를 받고 경우
define stream statusStream (id string, success bool); 

from statusStream[ success == false ]#window.time(5 minutes) 
insert expired events into expiredStatusStream; 

from every status = statusStream[ success == false ] 
    -> ackStatus = statusStream[ success == true and id == status.id] 
    or expiredStatus = expiredStatusStream[ id == status.id ] 
select status.id, ackStatus.id as ackId 
into filteredStatusStream; 

from filteredStatusStream[ ackStatus.id is null ] 
insert into failedStatusStream; 

답변

1

: 여기

@Import('statusStream:1.0.0') 
define stream statusStream (id string, success bool); 

@Export('alertStream:1.0.0') 
define stream alertStream (alert string); 

from statusStream 
select id, success, time:timestampInMilliseconds() as ts 
insert into statusStreamWithTS; 

from every e1=statusStreamWithTS[success==false], statusStreamWithTS[success==false]*, e2=statusStreamWithTS[success==false AND (e2.ts - e1.ts) >= 500000] 
select 'some message' as alert 
insert into alertStream; 

, 경고가 될 것입니다 우리가 5 분 동안 '성공 == 거짓'메시지를 계속 받으면 생성됩니다.