Loading src/main/java/org/etsi/osl/tmf/sim638/api/ServiceApiRouteBuilder.java +40 −5 Original line number Diff line number Diff line Loading @@ -20,12 +20,15 @@ package org.etsi.osl.tmf.sim638.api; import java.io.IOException; import java.util.Date; import java.util.Map; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.camel.Exchange; import org.apache.camel.LoggingLevel; import org.apache.camel.Processor; import org.apache.camel.ProducerTemplate; import org.apache.camel.RuntimeCamelException; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.model.dataformat.JsonLibrary; import org.apache.commons.logging.Log; Loading @@ -44,6 +47,11 @@ import org.springframework.context.annotation.Configuration; import org.springframework.stereotype.Component; import org.etsi.osl.model.nfv.DeploymentDescriptor; import org.etsi.osl.model.nfv.ExperimentMetadata; import org.etsi.osl.model.nfv.Product; import org.etsi.osl.model.nfv.ValidationJob; import org.etsi.osl.model.nfv.ValidationStatus; import org.etsi.osl.model.nfv.VxFMetadata; @Configuration //@RefreshScope Loading Loading @@ -111,6 +119,9 @@ public class ServiceApiRouteBuilder extends RouteBuilder { @Override public void configure() throws Exception { from( CATALOG_ADD_SERVICE ) .log(LoggingLevel.INFO, log, CATALOG_ADD_SERVICE + " message received and will be processed for service inventory!") .to("log:DEBUG?showBody=true&showHeaders=true") Loading Loading @@ -190,7 +201,6 @@ public class ServiceApiRouteBuilder extends RouteBuilder { from( EVENT_RESOURCE_STATE_CHANGED ) .log(LoggingLevel.INFO, log, EVENT_RESOURCE_STATE_CHANGED + " message received and will be processed for service inventory!") .to("log:DEBUG?showBody=true&showHeaders=true") Loading @@ -199,6 +209,13 @@ public class ServiceApiRouteBuilder extends RouteBuilder { from( EVENT_RESOURCE_CREATE ) .errorHandler(deadLetterChannel("direct:retriesDeadLetters") .maximumRedeliveries(5) .redeliveryDelay(1000).useOriginalMessage() .logExhausted(true) .logHandled(true) .retriesExhaustedLogLevel(LoggingLevel.ERROR) .retryAttemptedLogLevel(LoggingLevel.ERROR)) .log(LoggingLevel.INFO, log, EVENT_RESOURCE_CREATE + " message received and will be processed for service inventory!") .to("log:DEBUG?showBody=true&showHeaders=true") .unmarshal().json( JsonLibrary.Jackson, ResourceCreateNotification.class, true) Loading @@ -208,12 +225,30 @@ public class ServiceApiRouteBuilder extends RouteBuilder { from( EVENT_RESOURCE_ATTRIBUTE_VALUE_CHANGED ) .errorHandler(deadLetterChannel("direct:retriesDeadLetters") .maximumRedeliveries(5) .redeliveryDelay(1000).useOriginalMessage() .logExhausted(true) .logHandled(true) .retriesExhaustedLogLevel(LoggingLevel.ERROR) .retryAttemptedLogLevel(LoggingLevel.ERROR)) .log(LoggingLevel.INFO, log, EVENT_RESOURCE_ATTRIBUTE_VALUE_CHANGED + " message received and will be processed for service inventory!") .to("log:DEBUG?showBody=true&showHeaders=true") .unmarshal().json( JsonLibrary.Jackson, ResourceAttributeValueChangeNotification.class, true) .bean( serviceRepoService, "resourceAttrChangedEvent(${body})"); /** * dead Letter Queue msgs if everything fails to connect */ from("direct:retriesDeadLetters") //.setBody() //.body(String.class) //.process( ErroneousValidationProcessor ) .to("log:DEBUG?showBody=true&showHeaders=true") .to("stream:out"); } Loading src/main/java/org/etsi/osl/tmf/sim638/service/ServiceRepoService.java +63 −40 Original line number Diff line number Diff line Loading @@ -818,6 +818,7 @@ public class ServiceRepoService { // this.updateService( parentServiceId, servUpd, false, null, childService); // } @Transactional public String getServiceEagerAsString(String id) throws JsonProcessingException { Service s = this.getServiceEager(id); ObjectMapper mapper = new ObjectMapper(); Loading @@ -838,6 +839,7 @@ public class ServiceRepoService { return res; } @Transactional public Service getServiceEager(String id) { if ( id == null || id.equals("")) { return null; Loading Loading @@ -904,6 +906,7 @@ public class ServiceRepoService { /** * @return */ @Transactional public List<ServiceActionQueueItem> findAllServiceActionQueueItems() { return (List<ServiceActionQueueItem>) this.serviceActionQueueRepo.findFirst10ByOrderByInsertedDate(); Loading Loading @@ -934,6 +937,7 @@ public class ServiceRepoService { * @param id * @return */ @Transactional public Void deleteServiceActionQueueItemByUuid(String id) { Optional<ServiceActionQueueItem> optso = this.serviceActionQueueRepo.findByUuid(id); Loading Loading @@ -1077,6 +1081,7 @@ public class ServiceRepoService { @Transactional public void resourceAttrChangedEvent(@Valid ResourceAttributeValueChangeNotification resNotif) { try { logger.debug("ResourceAttributeValueChangeNotification"); Resource res = resNotif.getEvent().getEvent().getResource(); Loading Loading @@ -1113,25 +1118,42 @@ public class ServiceRepoService { //} } }catch (Exception e) { e.printStackTrace(); } } @Transactional public void resourceCreatedEvent(@Valid ResourceCreateNotification resNotif) { try { Resource res = resNotif.getEvent().getEvent().getResource(); logger.debug("resourceCreatedEvent for: " + res.getName()); updateServiceFromresourceChange(res); }catch (Exception e) { e.printStackTrace(); } } @Transactional public void resourceStateChangedEvent(@Valid ResourceStateChangeNotification resNotif) { try { Resource res = resNotif.getEvent().getEvent().getResource(); logger.debug("resourceStateChangedEvent for: " + res.getName()); updateServiceFromresourceChange(res); }catch (Exception e) { e.printStackTrace(); } } @Transactional private void updateServiceFromresourceChange(Resource res) { logger.info("Will update services related to this resource with id = " + res.getId() ); Loading Loading @@ -1172,6 +1194,7 @@ public class ServiceRepoService { } @Transactional private void updateResourceFromKubernetesLabel(Resource res) { logger.debug("updateResourceFromKubernetesLabel for: " + res.getName()); Loading Loading
src/main/java/org/etsi/osl/tmf/sim638/api/ServiceApiRouteBuilder.java +40 −5 Original line number Diff line number Diff line Loading @@ -20,12 +20,15 @@ package org.etsi.osl.tmf.sim638.api; import java.io.IOException; import java.util.Date; import java.util.Map; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.camel.Exchange; import org.apache.camel.LoggingLevel; import org.apache.camel.Processor; import org.apache.camel.ProducerTemplate; import org.apache.camel.RuntimeCamelException; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.model.dataformat.JsonLibrary; import org.apache.commons.logging.Log; Loading @@ -44,6 +47,11 @@ import org.springframework.context.annotation.Configuration; import org.springframework.stereotype.Component; import org.etsi.osl.model.nfv.DeploymentDescriptor; import org.etsi.osl.model.nfv.ExperimentMetadata; import org.etsi.osl.model.nfv.Product; import org.etsi.osl.model.nfv.ValidationJob; import org.etsi.osl.model.nfv.ValidationStatus; import org.etsi.osl.model.nfv.VxFMetadata; @Configuration //@RefreshScope Loading Loading @@ -111,6 +119,9 @@ public class ServiceApiRouteBuilder extends RouteBuilder { @Override public void configure() throws Exception { from( CATALOG_ADD_SERVICE ) .log(LoggingLevel.INFO, log, CATALOG_ADD_SERVICE + " message received and will be processed for service inventory!") .to("log:DEBUG?showBody=true&showHeaders=true") Loading Loading @@ -190,7 +201,6 @@ public class ServiceApiRouteBuilder extends RouteBuilder { from( EVENT_RESOURCE_STATE_CHANGED ) .log(LoggingLevel.INFO, log, EVENT_RESOURCE_STATE_CHANGED + " message received and will be processed for service inventory!") .to("log:DEBUG?showBody=true&showHeaders=true") Loading @@ -199,6 +209,13 @@ public class ServiceApiRouteBuilder extends RouteBuilder { from( EVENT_RESOURCE_CREATE ) .errorHandler(deadLetterChannel("direct:retriesDeadLetters") .maximumRedeliveries(5) .redeliveryDelay(1000).useOriginalMessage() .logExhausted(true) .logHandled(true) .retriesExhaustedLogLevel(LoggingLevel.ERROR) .retryAttemptedLogLevel(LoggingLevel.ERROR)) .log(LoggingLevel.INFO, log, EVENT_RESOURCE_CREATE + " message received and will be processed for service inventory!") .to("log:DEBUG?showBody=true&showHeaders=true") .unmarshal().json( JsonLibrary.Jackson, ResourceCreateNotification.class, true) Loading @@ -208,12 +225,30 @@ public class ServiceApiRouteBuilder extends RouteBuilder { from( EVENT_RESOURCE_ATTRIBUTE_VALUE_CHANGED ) .errorHandler(deadLetterChannel("direct:retriesDeadLetters") .maximumRedeliveries(5) .redeliveryDelay(1000).useOriginalMessage() .logExhausted(true) .logHandled(true) .retriesExhaustedLogLevel(LoggingLevel.ERROR) .retryAttemptedLogLevel(LoggingLevel.ERROR)) .log(LoggingLevel.INFO, log, EVENT_RESOURCE_ATTRIBUTE_VALUE_CHANGED + " message received and will be processed for service inventory!") .to("log:DEBUG?showBody=true&showHeaders=true") .unmarshal().json( JsonLibrary.Jackson, ResourceAttributeValueChangeNotification.class, true) .bean( serviceRepoService, "resourceAttrChangedEvent(${body})"); /** * dead Letter Queue msgs if everything fails to connect */ from("direct:retriesDeadLetters") //.setBody() //.body(String.class) //.process( ErroneousValidationProcessor ) .to("log:DEBUG?showBody=true&showHeaders=true") .to("stream:out"); } Loading
src/main/java/org/etsi/osl/tmf/sim638/service/ServiceRepoService.java +63 −40 Original line number Diff line number Diff line Loading @@ -818,6 +818,7 @@ public class ServiceRepoService { // this.updateService( parentServiceId, servUpd, false, null, childService); // } @Transactional public String getServiceEagerAsString(String id) throws JsonProcessingException { Service s = this.getServiceEager(id); ObjectMapper mapper = new ObjectMapper(); Loading @@ -838,6 +839,7 @@ public class ServiceRepoService { return res; } @Transactional public Service getServiceEager(String id) { if ( id == null || id.equals("")) { return null; Loading Loading @@ -904,6 +906,7 @@ public class ServiceRepoService { /** * @return */ @Transactional public List<ServiceActionQueueItem> findAllServiceActionQueueItems() { return (List<ServiceActionQueueItem>) this.serviceActionQueueRepo.findFirst10ByOrderByInsertedDate(); Loading Loading @@ -934,6 +937,7 @@ public class ServiceRepoService { * @param id * @return */ @Transactional public Void deleteServiceActionQueueItemByUuid(String id) { Optional<ServiceActionQueueItem> optso = this.serviceActionQueueRepo.findByUuid(id); Loading Loading @@ -1077,6 +1081,7 @@ public class ServiceRepoService { @Transactional public void resourceAttrChangedEvent(@Valid ResourceAttributeValueChangeNotification resNotif) { try { logger.debug("ResourceAttributeValueChangeNotification"); Resource res = resNotif.getEvent().getEvent().getResource(); Loading Loading @@ -1113,25 +1118,42 @@ public class ServiceRepoService { //} } }catch (Exception e) { e.printStackTrace(); } } @Transactional public void resourceCreatedEvent(@Valid ResourceCreateNotification resNotif) { try { Resource res = resNotif.getEvent().getEvent().getResource(); logger.debug("resourceCreatedEvent for: " + res.getName()); updateServiceFromresourceChange(res); }catch (Exception e) { e.printStackTrace(); } } @Transactional public void resourceStateChangedEvent(@Valid ResourceStateChangeNotification resNotif) { try { Resource res = resNotif.getEvent().getEvent().getResource(); logger.debug("resourceStateChangedEvent for: " + res.getName()); updateServiceFromresourceChange(res); }catch (Exception e) { e.printStackTrace(); } } @Transactional private void updateServiceFromresourceChange(Resource res) { logger.info("Will update services related to this resource with id = " + res.getId() ); Loading Loading @@ -1172,6 +1194,7 @@ public class ServiceRepoService { } @Transactional private void updateResourceFromKubernetesLabel(Resource res) { logger.debug("updateResourceFromKubernetesLabel for: " + res.getName()); Loading