Orange-OpenSource/fiware-cepheus

Cepheus CEP DELETE request doesn't unsubscribe Provider

pooja1pathak opened this issue · 0 comments

Experimenting with Cepheus I discovered that if a Cepheus CEP configuration is deleted by sending request:

DELETE cepheus:8080/v1/admin/config

It deletes the configuration file but does not unsubscribe from Orion for that entity.
So whenever there is an update occurs in Orion it receives a notification and throws an Event processing error.
Logs which I received:

2018-10-18 09:49:59.873  INFO 15232 --- [nio-8080-exec-4] c.e.e.c.service.EPServiceProviderImpl    : Destroying engine URI 'default'
2018-10-18 09:50:00.176  INFO 15232 --- [nio-8080-exec-4] c.o.c.cep.persistence.JsonPersistence    : Delete configuration from C:\Users\<user>\AppData\Local\Temp\/cep-default-.json
2018-10-18 09:50:00.188 DEBUG 15232 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet        : Successfully completed request
2018-10-18 09:50:55.191 DEBUG 15232 --- [nio-8080-exec-5] o.s.web.servlet.DispatcherServlet        : DispatcherServlet with name 'dispatcherServlet' processing POST request for [/ngsi10/notifyContext]
2018-10-18 09:50:55.193 DEBUG 15232 --- [nio-8080-exec-5] c.o.c.cep.controller.NgsiController      : notifyContext incoming request id:5bc809d8b2b093eb19f1af0c originator:localhost
2018-10-18 09:50:55.193  INFO 15232 --- [nio-8080-exec-5] c.o.cepheus.cep.EsperEventProcessor      : EventIn: Event{type='Test', values={CO2Level=170, id=Test1}}
2018-10-18 09:50:55.194 DEBUG 15232 --- [nio-8080-exec-5] .m.m.a.ExceptionHandlerExceptionResolver : Resolving exception from handler [public final org.springframework.http.ResponseEntity<com.orange.ngsi.model.NotifyContextResponse> com.orange.ngsi.server.NgsiBaseController.notifyContextRequest(com.orange.ngsi.model.NotifyContext,javax.servlet.http.HttpServletRequest) throws java.lang.Exception]: com.orange.cepheus.cep.exception.EventProcessingException: Event type named 'Test' has not been defined or is not a Map event type, the name 'Test' has not been defined as an event type
2018-10-18 09:50:55.196 DEBUG 15232 --- [nio-8080-exec-5] .m.m.a.ExceptionHandlerExceptionResolver : Invoking @ExceptionHandler method: public org.springframework.http.ResponseEntity<java.lang.Object> com.orange.cepheus.cep.controller.NgsiController.eventProcessinExceptionHandler(javax.servlet.http.HttpServletRequest,com.orange.cepheus.cep.exception.EventProcessingException)
2018-10-18 09:50:55.196 ERROR 15232 --- [nio-8080-exec-5] c.o.c.cep.controller.NgsiController      : Event processing error: {}

com.orange.cepheus.cep.exception.EventProcessingException: Event type named 'Test' has not been defined or is not a Map event type, the name 'Test' has not been defined as an event type

2018-10-18 09:50:55.198 DEBUG 15232 --- [nio-8080-exec-5] o.s.w.s.m.m.a.HttpEntityMethodProcessor  : Written [NotifyContextResponse{responseCode=StatusCode{code='500', reasonPhrase='event processing error', detail='com.orange.cepheus.cep.exception.EventProcessingException: Event type named 'Test' has not been defined or is not a Map event type, the name 'Test' has not been defined as an event type'}}] as "application/json;charset=UTF-8" using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@6136773b]
2018-10-18 09:50:55.198 DEBUG 15232 --- [nio-8080-exec-5] o.s.web.servlet.DispatcherServlet        : Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling

The same I have tested with Cepheus CEP in multi-tenant profile by changing application.properties as:
spring.profiles.active=multi-tenant
There also no unsubscribe request is executed in DELETE request of configuration and any update context in Orion notifies Cepheus CEP and throws NullPointerException.
Logs are as:

2018-10-18 09:42:47.930  INFO 20984 --- [nio-8080-exec-4] c.e.e.c.service.EPServiceProviderImpl    : Destroying engine URI 'testservice/testservicepath'
2018-10-18 09:42:48.131  INFO 20984 --- [nio-8080-exec-4] c.e.e.c.service.EPServiceProviderImpl    : Initializing engine URI 'testservice/testservicepath' version 5.3.0
2018-10-18 09:42:48.232  INFO 20984 --- [nio-8080-exec-4] c.o.c.cep.persistence.JsonPersistence    : Delete configuration from C:\Users\<user>\AppData\Local\Temp\/cep-testservice-testservicepath.json
2018-10-18 09:42:48.238 DEBUG 20984 --- [nio-8080-exec-4] o.s.web.servlet.DispatcherServlet        : Successfully completed request
2018-10-18 09:43:11.786 DEBUG 20984 --- [nio-8080-exec-5] o.s.web.servlet.DispatcherServlet        : DispatcherServlet with name 'dispatcherServlet' processing POST request for [/ngsi10/notifyContext]
2018-10-18 09:43:11.786 DEBUG 20984 --- [nio-8080-exec-5] s.w.s.m.m.a.RequestMappingHandlerMapping : Returning handler method [public final org.springframework.http.ResponseEntity<com.orange.ngsi.model.NotifyContextResponse> com.orange.ngsi.server.NgsiBaseController.notifyContextRequest(com.orange.ngsi.model.NotifyContext,javax.servlet.http.HttpServletRequest) throws java.lang.Exception]
2018-10-18 09:43:11.787 DEBUG 20984 --- [nio-8080-exec-5] c.o.c.cep.controller.NgsiController      : notifyContext incoming request id:5bc80826b2b093eb19f1af0b originator:localhost
2018-10-18 09:43:11.788 DEBUG 20984 --- [nio-8080-exec-5] .m.m.a.ExceptionHandlerExceptionResolver : Resolving exception from handler [public final org.springframework.http.ResponseEntity<com.orange.ngsi.model.NotifyContextResponse> com.orange.ngsi.server.NgsiBaseController.notifyContextRequest(com.orange.ngsi.model.NotifyContext,javax.servlet.http.HttpServletRequest) throws java.lang.Exception]: java.lang.NullPointerExceptioncom.orange.ngsi.server.NgsiBaseController.exceptionHandler(javax.servlet.http.HttpServletRequest,java.lang.Exception)
2018-10-18 09:43:11.791 ERROR 20984 --- [nio-8080-exec-5] c.orange.ngsi.server.NgsiBaseController  : Exception handler: {}

java.lang.NullPointerException: null

2018-10-18 09:43:11.794 DEBUG 20984 --- [nio-8080-exec-5] o.s.w.s.m.m.a.HttpEntityMethodProcessor  : Written [NotifyContextResponse{responseCode=StatusCode{code='500', reasonPhrase='Receiver internal error', detail='An unknown error at the receiver has occured'}}] as "application/json;charset=UTF-8" using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@1027cbcc]
2018-10-18 09:43:11.795 DEBUG 20984 --- [nio-8080-exec-5] o.s.web.servlet.DispatcherServlet        : Successfully completed request

It would seem that these Exceptions occur because DELETE request doesn't unsubscribe Cepheus CEP from Provider.
It should unsubscribe from Provider at the time of DELETE request.