Handle CLM findings 13/84213/2
authorStavros Kanarakis <stavros.kanarakis@nokia.com>
Thu, 4 Apr 2019 09:05:02 +0000 (12:05 +0300)
committerStavros Kanarakis <stavros.kanarakis@nokia.com>
Mon, 8 Apr 2019 08:20:06 +0000 (11:20 +0300)
Along with CLM scan findings resolution, some minor SONAR fixes are included
and a README.md file about BBS-ep service.

Change-Id: Ifaeb9db0156aa459f5e5ee5fe2ae09c5f5669ece
Issue-ID: DCAEGEN2-1388
Signed-off-by: Stavros Kanarakis <stavros.kanarakis@nokia.com>
components/bbs-event-processor/README.md
components/bbs-event-processor/dpo/blueprints/bbs-event-processor-input.yaml
components/bbs-event-processor/pom.xml
components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/controllers/BbsEventProcessorController.java
components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/model/AuthenticationState.java
components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/pipelines/CpeAuthenticationPipeline.java
components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/pipelines/ReRegistrationPipeline.java
components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/tasks/DmaapCpeAuthenticationConsumerTaskImpl.java
components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/tasks/DmaapReRegistrationConsumerTaskImpl.java
components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/utilities/AaiReactiveClient.java

index e69de29..14ecc8c 100644 (file)
@@ -0,0 +1,76 @@
+# BBS use case event processor
+
+---
+
+## Overview
+
+BBE-ep is responsible for handling two types of events for the BBS use case. 
+
+First are PNF re-registration internal events published by PRH (in **unauthenticated.PNF_UPDATE** DMaaP topic). 
+BBS-ep must process these internal events to understand if they actually constitute ONT(CPE) relocation events. 
+In the relocation case, it publishes an event towards **unauthenticated.DCAE_CL_OUTPUT** DMaaP topic to trigger 
+further Policy actions related to BBS use case.
+
+Second type of events are CPE authentication events originally published by the Edge SDN M&C component of BBS 
+use case architecture. Through RestConf-Collector or VES-Collector, these events are consumed by BBS-ep 
+(in **unauthenticated.CPE_AUTHENTICATION** DMaaP topic) and they are forwarded towards **unauthenticated.DCAE_CL_OUTPUT** 
+DMaaP topic to trigger further Policy actions related to BBS use case.
+
+BBE-ep periodically polls for the two events. Polling interval is configurable and can be changed dynamically from Consul. I
+Its implementation is based on Reactive Streams (Reactor library), so it is fully asynchronous and non-blocking.
+
+## Installation and Removal
+
+BBS-ep is delivered as a Spring-Boot application ready to be deployed in Docker (via docker-compose). 
+
+For Dublin release, it will be a DCAE component that can dynamically be deployed via Cloudify blueprint installation.
+Steps to deploy are shown below
+
+- Transfer blueprint component file in DCAE bootstrap POD under /blueprints directory. Blueprint can be found in
+  <https://gerrit.onap.org/r/gitweb?p=dcaegen2/services.git;a=blob_plain;f=components/bbs-event-processor/dpo/blueprints/k8s-bbs-event-processor.yaml-template;hb=refs/heads/master>
+- Transfer blueprint component inputs file in DCAE bootstrap POD under / directory. Blueprint inputs file can be found in
+  <https://gerrit.onap.org/r/gitweb?p=dcaegen2/services.git;a=blob_plain;f=components/bbs-event-processor/dpo/blueprints/bbs-event-processor-input.yaml;h=36e69cf64bee3b46ee2e1b95f1a16380b7046482;hb=refs/heads/master>
+- Enter the Bootstrap POD
+- Validate blueprint
+    cfy blueprints validate /blueprints/k8s-bbs-event-processor.yaml-template
+- Upload validated blueprint
+    cfy blueprints upload -b bbs-ep /blueprints/k8s-bbs-event-processor.yaml-template
+- Create deployment
+    cfy deployments create -b bbs-ep -i /bbs-event-processor-input.yaml bbs-ep
+- Deploy blueprint
+    cfy executions start -d bbs-ep install
+
+To un-deploy BBS-ep, steps are shown below
+
+- Validate blueprint by running command
+    cfy uninstall bbs-ep
+- Validate blueprint by running command
+    cfy blueprints delete bbs-ep
+## Functionality
+
+For more details about the exact flows and where BBS-EP fits in the overall BBS flows, visit [use case official documentation](https://wiki.onap.org/display/DW/BBS+Notifications)
+
+## Compiling BBS-ep
+
+BBS-ep is a sub-project of dcaegen2/services (inside components directory).
+To build just the BBS-ep component, run the following maven command from within **components/bbs-event-processor** directory
+
+`mvn clean install`   
+
+## Main API Endpoints
+
+Running with dev-mode of BBS-ep
+
+  - **Heartbeat**
+    - GET http://<container_address>:8100/heartbeat
+  - **Start Polling for events** 
+    - POST http://<container_address>:8100/start-tasks
+  - **Stop Polling for events** 
+    - POST http://<container_address>:8100/cancel-tasks
+  - **Execute just one polling for PNF re-registration internal events**
+    - POST http://<container_address>:8100/poll-reregistration-events
+  - **Execute just one polling for CPE authentication events** 
+    - POST http://<container_address>:8100/poll-cpe-authentication-events
+  - **Change application logging level** 
+    - POST http://<container_address>:8100/logging/{level}
\ No newline at end of file
index 420b501..a7adbbb 100644 (file)
@@ -16,7 +16,7 @@
 # ============LICENSE_END=========================================================
 
 
-tag_version: nexus3.onap.org:10003/onap/org.onap.dcaegen2.services.components.bbs-event-processor:1.0.0-SNAPSHOT
+tag_version: nexus3.onap.org:10001/onap/org.onap.dcaegen2.services.components.bbs-event-processor:1.0.0-SNAPSHOT
 pnf_reregistration_url: http:message-router:3904/events/unauthenticated.PNF_UPDATE
 cpe_authentication_url: http:message-router:3904/events/unauthenticated.CPE_AUTHENTICATION
 close_loop_url: http:message-router:3904/events/unauthenticated.DCAE_CL_OUTPUT
@@ -26,4 +26,4 @@ application_cpeAuth_policy_scope: policyScopeCpeAuth
 application_cpeAuth_cl_control_name: clControlNameCpeAuth
 application_cbs_polling_interval_sec: 120
 dmaap_consumer_id: c12
-dmaap_consumer_group: OpenDcae-c12
+dmaap_consumer_group: OpenDcae-c12
\ No newline at end of file
index ae9583e..7ebe18e 100644 (file)
@@ -5,9 +5,9 @@
     <modelVersion>4.0.0</modelVersion>
     
     <parent>
-       <groupId>org.onap.oparent</groupId>
-       <artifactId>oparent</artifactId>
-       <version>1.2.3</version>
+        <groupId>org.onap.oparent</groupId>
+        <artifactId>oparent</artifactId>
+        <version>1.2.3</version>
     </parent>
 
     <groupId>org.onap.dcaegen2.services.components</groupId>
@@ -28,8 +28,7 @@
     <properties>
         <java.version>8</java.version>
         <immutables.version>2.7.5</immutables.version>
-        <spring.version>5.1.2.RELEASE</spring.version>
-        <spring-boot.version>2.1.0.RELEASE</spring-boot.version>
+        <spring-boot.version>2.1.3.RELEASE</spring-boot.version>
         <tomcat.version>8.5.32</tomcat.version>
         <slf4j.version>1.7.25</slf4j.version>
         <junit-platform.version>1.1.0</junit-platform.version>
@@ -37,7 +36,6 @@
         <sdk.version>1.1.2-SNAPSHOT</sdk.version>
         <common.sdk.version>1.1.3</common.sdk.version>
         <cbs.version>1.1.3</cbs.version>
-        <hibernate-validator.version>5.2.4.Final</hibernate-validator.version>
         <wiremock.version>2.21.0</wiremock.version>
         <springfox-swagger.version>2.8.0</springfox-swagger.version>
         <maven.build.timestamp.format>yyyyMMdd'T'HHmmss</maven.build.timestamp.format>
                 <artifactId>gson</artifactId>
                 <version>${immutables.version}</version>
             </dependency>
-            <dependency>
-                <groupId>org.hibernate</groupId>
-                <artifactId>hibernate-validator</artifactId>
-                <version>${hibernate-validator.version}</version>
-            </dependency>
             <dependency>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-dependencies</artifactId>
             <artifactId>lombok</artifactId>
         </dependency>
         <dependency>
-            <groupId>org.hibernate</groupId>
-            <artifactId>hibernate-validator</artifactId>
+            <groupId>com.fasterxml.jackson.datatype</groupId>
+            <artifactId>jackson-datatype-jsr310</artifactId>
+            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>com.github.tomakehurst</groupId>
             <artifactId>wiremock-jre8</artifactId>
             <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>com.fasterxml.jackson.core</groupId>
+                    <artifactId>jackson-core</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>com.fasterxml.jackson.core</groupId>
+                    <artifactId>jackson-annotations</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>com.fasterxml.jackson.core</groupId>
+                    <artifactId>jackson-databind</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
     </dependencies>
 
index 135b41d..fda553f 100644 (file)
@@ -47,6 +47,8 @@ import reactor.core.publisher.Mono;
 @Api(value = "BbsEventProcessorController", description = "Manage bbs-event-processor microService")
 public class BbsEventProcessorController {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(BbsEventProcessorController.class);
+
     private ReRegistrationPipeline reRegistrationPipeline;
     private CpeAuthenticationPipeline cpeAuthenticationPipeline;
     private Scheduler scheduler;
@@ -66,8 +68,6 @@ public class BbsEventProcessorController {
         this.scheduler = scheduler;
     }
 
-    private static final Logger LOGGER = LoggerFactory.getLogger(BbsEventProcessorController.class);
-
     /**
      * Responds to health-check heartbeats.
      * @return Proper HTTP response based on application health
@@ -180,6 +180,13 @@ public class BbsEventProcessorController {
      * @return Proper HTTP response based on change logging level result
      */
     @PostMapping("logging/{level}")
+    @ApiOperation(value = "Returns result of request to change application logging level")
+    @ApiResponses(value = {
+            @ApiResponse(code = 200, message = "Application logging level was successfully changed"),
+            @ApiResponse(code = 401, message = "Not authorized to view the resource"),
+            @ApiResponse(code = 403, message = "Resource access is forbidden"),
+            @ApiResponse(code = 404, message = "Resource is not found"),
+            @ApiResponse(code = 406, message = "Application logging level change failure. Check logs")})
     public Mono<ResponseEntity<String>> changeLoggingLevel(@PathVariable String level) {
         return Mono.defer(() ->  {
                 if (LoggingUtil.changeLoggingLevel(level)) {
index cef24b5..fd17023 100644 (file)
@@ -28,12 +28,12 @@ public enum AuthenticationState {
     IN_SERVICE(IN_SERVICE_NAME_IN_ONAP),
     OUT_OF_SERVICE(OUT_OF_SERVICE_NAME_IN_ONAP);
 
+    private String nameInOnap;
+
     AuthenticationState(String nameInOnap) {
         this.nameInOnap = nameInOnap;
     }
 
-    private String nameInOnap;
-
     public String getNameInOnap() {
         return nameInOnap;
     }
index d468859..711ab18 100644 (file)
@@ -140,6 +140,7 @@ public class CpeAuthenticationPipeline {
                                 LOGGER.info("Nothing to consume from DMaaP");
                             } else {
                                 LOGGER.error("DMaaP Consumer error: {}", e.getMessage());
+                                LOGGER.debug("Error\n", e);
                             }
                         })
                         .onErrorResume(
index 0f28d7c..9a42ed2 100644 (file)
@@ -139,6 +139,7 @@ public class ReRegistrationPipeline {
                                 LOGGER.info("Nothing to consume from DMaaP");
                             } else {
                                 LOGGER.error("DMaaP Consumer error: {}", e.getMessage());
+                                LOGGER.debug("Error\n", e);
                             }
                         })
                         .onErrorResume(
index 4c5122d..e6bef52 100644 (file)
@@ -87,7 +87,8 @@ public class DmaapCpeAuthenticationConsumerTaskImpl
             LOGGER.info("DMaaP CPE authentication consumer update due to new application configuration");
             httpClient = httpClientFactory.create(this.configuration.getDmaapCpeAuthenticationConsumerConfiguration());
         } catch (SSLException e) {
-            LOGGER.error("Error while updating HTTP Client after a config update: SSL exception");
+            LOGGER.error("SSL error while updating HTTP Client after a config update");
+            LOGGER.debug("SSL exception\n", e);
         }
     }
 
@@ -101,6 +102,7 @@ public class DmaapCpeAuthenticationConsumerTaskImpl
                 .doOnError(e -> {
                     if (!(e instanceof EmptyDmaapResponseException)) {
                         LOGGER.error("DMaaP Consumption Exception: {}", e.getMessage());
+                        LOGGER.debug("Exception\n", e);
                     }
                 });
     }
index 6985396..92f5a86 100644 (file)
@@ -87,7 +87,8 @@ public class DmaapReRegistrationConsumerTaskImpl implements DmaapReRegistrationC
             LOGGER.info("DMaaP PNF reregistration consumer update due to new application configuration");
             httpClient = httpClientFactory.create(this.configuration.getDmaapReRegistrationConsumerConfiguration());
         } catch (SSLException e) {
-            LOGGER.error("Error while updating HTTP Client after a config update: SSL exception");
+            LOGGER.error("SSL error while updating HTTP Client after a config update");
+            LOGGER.debug("SSL exception\n", e);
         }
     }
 
@@ -101,6 +102,7 @@ public class DmaapReRegistrationConsumerTaskImpl implements DmaapReRegistrationC
                 .doOnError(e -> {
                     if (!(e instanceof EmptyDmaapResponseException)) {
                         LOGGER.error("DMaaP Consumption Exception: {}", e.getMessage());
+                        LOGGER.debug("Exception\n", e);
                     }
                 });
     }
index e07de4b..19b81a8 100644 (file)
@@ -95,7 +95,8 @@ public class AaiReactiveClient implements ConfigurationChangeObserver {
                 try {
                     setupWebClient();
                 } catch (SSLException e) {
-                    LOGGER.error("AAI Reactive client error while re-configuring WebClient");
+                    LOGGER.error("AAI Reactive client SSL error while re-configuring WebClient");
+                    LOGGER.debug("SSL Exception\n", e);
                 }
             }
         }