2017-04-05 11 views
0

아래 스트림에서 온도가 90을 초과하면 두 번 발생했던 이벤트를 경고하고 싶습니다. 경고를 받음). 나는이 같은 것을 쓴WSO2 CEP : Siddhi QL : 특정 조건과 일치하면 이벤트를 일관되게 경고하는 방법

InputStream=[1001,91] 
InputStream=[1001,86] 
InputStream=[1002,70] 
InputStream=[1001,85] 
InputStream=[1003,70] 
InputStream=[1003,85] 
InputStream=[1002,70] 
InputStream=[1003,70] 
InputStream=[1003,87] 
InputStream=[1002,70] 
InputStream=[1001,95] 
InputStream=[1001,96] 
InputStream=[1001,97] 
InputStream=[1001,98] 
InputStream=[1001,98] 

:

@Plan:name('TestExecutionPlan') 

define stream InputStream (id string, temp int); 

partition with (id of InputStream) 
begin 
from InputStream 
select id, temp 
having temp > 90 
insert into CriticalStream 
end; 

from CriticalStream[count(id) == 2] 
select id, temp 
group by id 
--having count(id) == 2 
insert into EventReporter; 

의이 EventReporter 스트림 만 1 이벤트를 경고하지만.

Below is the screen shot from Try It

내가 [1001,97]을 가지도록 EventReporter 스트림을 기대하고 있고 [1001,98]뿐만 아니라, 지금은 [1001,95] 만 기록을 가지고있다. 누군가 내가 여기서 잘못하고있는 것을 지적 해 주시겠습니까? 그룹화 한 후 이벤트를 반복 할 수 있습니까? window.time과 window.length를 추가하려고했지만 원하는 출력을 얻지 못했습니다. 어떤 도움이나지도라도 정말 감사 할 것입니다. 고맙습니다.

답변

1

파티션이 필요하지 않습니다. 원하는 출력을 얻으려면 필터와 길이 배치 창을 사용하기 만하면됩니다. 실행 계획 아래에서 시도하십시오.

@Plan:name('ExecutionPlan') 

@Import('InputStream:1.0.0') 
define stream InputStream (id string, temp int); 

/* Filter events with temp > 90 */ 
from InputStream[temp > 90] 
insert into CriticalStream; 

/* Aggregate within a lengthBatch window, while group by id*/ 
from CriticalStream#window.lengthBatch(2) 
select id, temp, count() as count 
group by id 
insert into EventReporter; 

/* Just for logging the result in the cosole */ 
from EventReporter#log("Logging EventReporter : ") 
insert into #temp; 
+0

안녕하세요 Grainier, 그 해결책이 효과가있었습니다. 시간과 도움을 주셔서 대단히 감사합니다. – Kannan

+0

그래 니어, 여기에 또 다른 질문이 있습니다. http://stackoverflow.com/questions/43186895/wso2-cep-siddhi-ql-creating-a-unique-stream-with-similar-event-records 정말 고맙습니다. 그것을보고 당신의 귀중한 의견을 줄 수 있습니다. 고맙습니다. – Kannan