2016-10-25 2 views
0

나는 Cumulocity에서 쓴 몇 가지 규칙을 테스트 중이었고, 원하는 결과를 얻을 수 없었으므로 비교를 위해 Esper EPL online tool을 사용해 보았습니다. 내가 설명 할 수없는 두 가지 결과물의 차이점을 발견했다.cumulocity epr와 esper의 차이

기본적으로 소스로 분할되고 "시작"및 "중지"이벤트로 구분 된 컨텍스트를 만듭니다. 내 상황이 끝나면 시작과 끝 이벤트에서 세부 정보 (유형과 시간) 만 표시하고 싶습니다. (그 순간의 이벤트는 신경 쓰지 않습니다.) 여기

(그들은 이미 "기본적으로"정의되기 때문에 생성 스키마가 Cumulocity 제거 될 수있다) 내 규칙입니다 :

create schema EventCreated(
    source String, 
    type String, 
    time Date 
); 

create schema CreateMeasurement(
    source String, 
    type String, 
    time Date, 
    fragments Object 
); 



@Name("create_context") 
create context Trip 
    context bySource 
     partition by source from EventCreated, 

    context byEvents 
     start EventCreated(
      type = "c8y_ObdConnectionReport" or 
      type = "c8y_PowerOnReport" or 
      type = "c8y_FixedReport" or 
      type = "c8y_HarshBehaviorReport") as startEvent 

     end EventCreated(
      type = "c8y_ObdDisconnectionReport" or 
      type = "c8y_PowerOffReport" or 
      type = "c8y_SilentTracker") as endEvent; 



@Name("context_end") 
context Trip 
    insert into 
     CreateMeasurement 

    select 
     context.bySource.key1 as source, 
     "Trip" as type, 
     e.time as time, 
     { 
      "startedBy", context.byEvents.startEvent.type, 
      "startedAt", context.byEvents.startEvent.time, 
      "endedBy", e.type, 
      "endedAt", e.time 
     } as fragments 

    from 
     EventCreated e 

    output 
     last when terminated; 

그리고 여기에 차이를 볼 수있는 간단한 이벤트 순서입니다 :

EventCreated = { 
    source = '1672192', 
    type = 'c8y_ObdConnectionReport', 
    time = '2016-10-07T10:00:00.000' 
} 

t = t.plus(5 minutes) 

EventCreated = { 
    source = '1672192', 
    type = 'c8y_FixedReport', 
    time = '2016-10-07T10:05:00.000' 
} 

t = t.plus(5 minutes) 

EventCreated = { 
    source = '1672192', 
    type = 'c8y_ObdDisconnectionReport', 
    time = '2016-10-07T10:10:00.000' 
} 

At: 2016-10-07 10:05:00.000 
    Statement: context_end 
     Insert 
      CreateMeasurement={ 
       source='1672192', 
       type='Trip', 
       time='2016-10-07T10:05:00.000', 
       fragments[ 
        'startedBy','c8y_ObdConnectionReport', 
        'startedAt','2016-10-07T10:00:00.000', 
        'endedBy','c8y_ObdDisconnectionReport', 
        'endedAt','2016-10-07T10:10:00.000']} 

이 : 그래서 여기

는 EPL 온라인 시뮬레이터의를 사용하여 결과입니다 내가 원하는대로, 예상대로 첫 번째와 마지막 이벤트의 세부 정보를 얻었습니다.

{ 
    "source":{ 
     "id":"1672192", 
     "name":"Tracker 123456789000000", 
     "self":"http://tracker.post-iot.lu/inventory/managedObjects/1672192"}, 
    "type":"Trip", 
    "time":"2016-10-25T11:56:46.983+02:00", 
    "self":"http://tracker.post-iot.lu/measurement/measurements/null", 
    "startedBy":"c8y_ObdConnectionReport", 
    "startedAt":"2016-10-25 11:56:44+0200", 
    "endedBy":"c8y_FixedReport", 
    "endedAt":"2016-10-25 11:56:46+0200" 
} 

(내가 Cumulocity와 실시간으로 일하고 있어요, 날짜를 무시) : 지금 이것은 내가 Cumulocity로 무엇을 얻을 수 있습니다. 보시다시피, 마지막 이벤트는 DisconnectionReport 대신 FixedReport로 간주됩니다. 그래서 Cumulocity에서 기본적으로 일어나는 일은 (다양한 상황을 시도했습니다) 때마다 컨텍스트의 종료 이벤트는 무시되고이므로 마지막에서 두 번째 이벤트 만 검색 할 수 있습니다.

위의 Esper 엔진과의 차이점은 무엇입니까? 어떻게 생각해야 할 것처럼이 일을 할 수 있습니까?

+0

이제 시작 이벤트에서 동일한 문제가 발생합니다 (context.byEvents.startEvent를 사용할 때 두 번째 이벤트 만 검색 함). –

답변

0

esper 온라인 도구가 항상 마지막 이벤트, 즉 cumulocity를 처리하는 것은 우발적 인 문제 일 수 있습니다. 경우가 발생

는 ("create_context 또는"context_end ")이 @Priority 주석이 제공되지 않는 그러나 문장의 실행 순서는 무작위입니다. 먼저 실행 될 문에 따라 달라집니다.

에스퍼 설명서의 노트에 따르면, 같은 조건에 일치하는 이벤트 필터 또는 패턴을 지정 컨텍스트를 참조 이벤트 필터 또는 컨텍스트 파티션의 종료 조건으로 패턴과 문을 지정한 경우 (http://www.espertech.com/esper/release-5.3.0/esper-reference/html/context.html#context_def_nonoverlapping)

, 지시 @Priority를 ​​사용 문맥 관리 또는 문장 평가가 필요한 엔진 우선 순위 (우선 순위 실행 구성에 대해서는 아래를 참조하십시오).예를 들어 , 당신의 상황에 맞는 선언은 다음과 같은 경우 :

create context MyCtx start MyStartEvent end MyEndEvent 

그리고 문맥에 의해 관리되는 문은 다음과 같습니다 @Priority를 ​​사용하여

context MyCtx select count(*) as cnt from MyEndEvent output when terminated 

(1) 및 계산 문에 대한 @Priority (0) 문맥 분할 관리가 우선 순위를두기 때문에 계산 문은 마지막 MyEndEvent를 계산하지 않습니다. 생성 문맥에 @Priority (0)을 사용하고 계산 문에 @Priority (1)을 사용하면 계산 문이 가장 중요하기 때문에 계산 문은 마지막 MyEndEvent를 계산합니다.

수정 : @Priority (0)을 "create_context"문과 @Priority (1)을 "context_end"문에 추가하십시오.

+0

나는 이것을 시험해 보겠다. 그러나 실제로 나는 "무작위"측면을 믿지 않는다. 왜냐하면 언제나 EPL 온라인 플랫폼에서 기대했던대로 작동하고 Cumulocity에 없었기 때문이다. 또한 위에서 언급 한 것처럼 이제는 시작 이벤트에 동일한 문제가 있습니다.이 문제는 더 이상 컨텍스트의 끝에서 검색 할 수 없습니다 (이벤트 # 2 만 해당). –

+0

그것이 효과가 없다는 것을 확인했습니다. –