summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVijay Venkatesh Kumar <vv770d@att.com>2019-04-02 16:43:39 +0000
committerGerrit Code Review <gerrit@onap.org>2019-04-02 16:43:39 +0000
commita224d68ec23c2985daab026014c58227f7ab8c1a (patch)
tree89201daa06a5bee5fa5fc37197485683f46c1944
parentb424fe44764d94b1bd0492e6c30cf9e2cd5f7a18 (diff)
parentbc054e72de5bf2cca24dbd3f10f4bf5c8b81d242 (diff)
Merge "Externalized Logging Level. Corrected tag name for images"
-rw-r--r--components/bbs-event-processor/dpo/blueprints/bbs-event-processor-input.yaml2
-rw-r--r--components/bbs-event-processor/dpo/blueprints/k8s-bbs-event-processor.yaml-template6
-rw-r--r--components/bbs-event-processor/dpo/spec/bbs-event-processor-spec.json10
-rw-r--r--components/bbs-event-processor/pom.xml14
-rw-r--r--components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/config/ApplicationConfiguration.java3
-rw-r--r--components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/config/ConsulConfigurationGateway.java3
-rw-r--r--components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/controllers/BbsEventProcessorController.java22
-rw-r--r--components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/model/GeneratedAppConfigObject.java3
-rw-r--r--components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/utilities/CpeAuthenticationDmaapConsumerJsonParser.java4
-rw-r--r--components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/utilities/LoggingUtil.java54
-rw-r--r--components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/utilities/ReRegistrationDmaapConsumerJsonParser.java4
-rw-r--r--components/bbs-event-processor/src/test/java/org/onap/bbs/event/processor/config/ApplicationConfigurationTest.java1
-rw-r--r--components/bbs-event-processor/src/test/java/org/onap/bbs/event/processor/config/ConsulConfigurationGatewayTest.java2
13 files changed, 124 insertions, 4 deletions
diff --git a/components/bbs-event-processor/dpo/blueprints/bbs-event-processor-input.yaml b/components/bbs-event-processor/dpo/blueprints/bbs-event-processor-input.yaml
index 36e69cf6..420b5018 100644
--- a/components/bbs-event-processor/dpo/blueprints/bbs-event-processor-input.yaml
+++ b/components/bbs-event-processor/dpo/blueprints/bbs-event-processor-input.yaml
@@ -16,7 +16,7 @@
# ============LICENSE_END=========================================================
-tag_version: nexus3.onap.org:10003/dcae-services/org.onap.dcaegen2.services.components.bbs-event-processor:1.0.0-SNAPSHOT
+tag_version: nexus3.onap.org:10003/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
diff --git a/components/bbs-event-processor/dpo/blueprints/k8s-bbs-event-processor.yaml-template b/components/bbs-event-processor/dpo/blueprints/k8s-bbs-event-processor.yaml-template
index e9550314..2d2c7a5d 100644
--- a/components/bbs-event-processor/dpo/blueprints/k8s-bbs-event-processor.yaml-template
+++ b/components/bbs-event-processor/dpo/blueprints/k8s-bbs-event-processor.yaml-template
@@ -21,7 +21,7 @@ tosca_definitions_version: cloudify_dsl_1_3
imports:
- "http://www.getcloudify.org/spec/cloudify/3.4/types.yaml"
- - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R3/k8splugin/1.4.4/k8splugin_types.yaml
+ - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/k8splugin/1.4.11/k8splugin_types.yaml
inputs:
aai_enrichment_host:
@@ -87,6 +87,9 @@ inputs:
application_cbs_polling_interval_sec:
type: integer
default: 300
+ application_logging_level:
+ type: string
+ default: "INFO"
dmaap_consumer_id:
type: string
dmaap_consumer_group:
@@ -138,6 +141,7 @@ node_templates:
application.reregistration.configKey: "pnf_reregistration"
application.cpeAuth.configKey: "cpe_authentication"
application.closeLoop.configKey: "close_loop"
+ application.loggingLevel: { get_input: application_logging_level }
host_port:
{ get_input: host_port }
container_port:
diff --git a/components/bbs-event-processor/dpo/spec/bbs-event-processor-spec.json b/components/bbs-event-processor/dpo/spec/bbs-event-processor-spec.json
index 8710a877..49b0e8f6 100644
--- a/components/bbs-event-processor/dpo/spec/bbs-event-processor-spec.json
+++ b/components/bbs-event-processor/dpo/spec/bbs-event-processor-spec.json
@@ -280,6 +280,14 @@
"policy_editable": true,
"sourced_at_deployment": true,
"description": "Config-key for Close Loop"
+ },
+ {
+ "name": "application.loggingLevel",
+ "value": "INFO",
+ "designer_editable": false,
+ "policy_editable": false,
+ "sourced_at_deployment": true,
+ "description": "Application Logging Level"
}
],
"auxilary": {
@@ -292,7 +300,7 @@
},
"artifacts": [
{
- "uri": "nexus3.onap.org:10003/dcae-services/org.onap.dcaegen2.services.components.bbs-event-processor:1.0.0-SNAPSHOT",
+ "uri": "nexus3.onap.org:10003/onap/org.onap.dcaegen2.services.components.bbs-event-processor:1.0.0-SNAPSHOT",
"type": "docker image"
}
]
diff --git a/components/bbs-event-processor/pom.xml b/components/bbs-event-processor/pom.xml
index 26a48787..ae9583ec 100644
--- a/components/bbs-event-processor/pom.xml
+++ b/components/bbs-event-processor/pom.xml
@@ -45,7 +45,7 @@
<dependency.dir.name>libs</dependency.dir.name>
<dependency.dir.location>${project.build.directory}/${dependency.dir.name}</dependency.dir.location>
<docker.artifact.dir>/opt</docker.artifact.dir>
- <docker.image.name>dcae-services/${project.groupId}.${project.artifactId}</docker.image.name>
+ <docker.image.name>onap/${project.groupId}.${project.artifactId}</docker.image.name>
<maven.build.timestamp.format>yyyyMMdd'T'HHmmss</maven.build.timestamp.format>
</properties>
@@ -371,6 +371,18 @@
</goals>
</execution>
<execution>
+ <id>tag-and-push-image-latest</id>
+ <phase>deploy</phase>
+ <goals>
+ <goal>tag</goal>
+ </goals>
+ <configuration>
+ <image>${docker.image.name}:latest</image>
+ <newName>${onap.nexus.dockerregistry.daily}/${docker.image.name}:latest</newName>
+ <pushImage>true</pushImage>
+ </configuration>
+ </execution>
+ <execution>
<id>tag-and-push-image-with-version</id>
<phase>deploy</phase>
<goals>
diff --git a/components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/config/ApplicationConfiguration.java b/components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/config/ApplicationConfiguration.java
index 69fa83d2..981d9633 100644
--- a/components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/config/ApplicationConfiguration.java
+++ b/components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/config/ApplicationConfiguration.java
@@ -30,6 +30,7 @@ import org.jetbrains.annotations.NotNull;
import org.onap.bbs.event.processor.exceptions.ApplicationEnvironmentException;
import org.onap.bbs.event.processor.exceptions.ConfigurationParsingException;
import org.onap.bbs.event.processor.model.GeneratedAppConfigObject;
+import org.onap.bbs.event.processor.utilities.LoggingUtil;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapConsumerConfiguration;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.DmaapPublisherConfiguration;
import org.onap.dcaegen2.services.sdk.rest.services.dmaap.client.config.ImmutableDmaapConsumerConfiguration;
@@ -234,6 +235,8 @@ public class ApplicationConfiguration implements ConfigurationChangeObservable {
genericProperties.getReRegistration().setClControlName(newConfiguration.reRegistrationClControlName());
genericProperties.getCpeAuthentication().setPolicyScope(newConfiguration.cpeAuthPolicyScope());
genericProperties.getCpeAuthentication().setClControlName(newConfiguration.cpeAuthClControlName());
+
+ LoggingUtil.changeLoggingLevel(newConfiguration.loggingLevel());
}
notifyObservers();
diff --git a/components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/config/ConsulConfigurationGateway.java b/components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/config/ConsulConfigurationGateway.java
index 6530f0b2..1d27fc0a 100644
--- a/components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/config/ConsulConfigurationGateway.java
+++ b/components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/config/ConsulConfigurationGateway.java
@@ -176,6 +176,8 @@ public class ConsulConfigurationGateway {
final String cpeAuthConfigKey = configObject.get("application.cpeAuth.configKey").getAsString();
final String closeLoopConfigKey = configObject.get("application.closeLoop.configKey").getAsString();
+ final String loggingLevel = configObject.get("application.loggingLevel").getAsString();
+
final JsonObject streamsPublishes = configObject.getAsJsonObject("streams_publishes");
final JsonObject streamsSubscribes = configObject.getAsJsonObject("streams_subscribes");
@@ -208,6 +210,7 @@ public class ConsulConfigurationGateway {
.reRegConfigKey(reRegConfigKey)
.cpeAuthConfigKey(cpeAuthConfigKey)
.closeLoopConfigKey(closeLoopConfigKey)
+ .loggingLevel(loggingLevel)
.streamSubscribesMap(parseStreamsObjects(streamsSubscribes))
.streamPublishesMap(parseStreamsObjects(streamsPublishes))
.build();
diff --git a/components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/controllers/BbsEventProcessorController.java b/components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/controllers/BbsEventProcessorController.java
index 09691c16..135b41d4 100644
--- a/components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/controllers/BbsEventProcessorController.java
+++ b/components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/controllers/BbsEventProcessorController.java
@@ -30,12 +30,14 @@ import java.util.concurrent.Executors;
import org.onap.bbs.event.processor.pipelines.CpeAuthenticationPipeline;
import org.onap.bbs.event.processor.pipelines.ReRegistrationPipeline;
import org.onap.bbs.event.processor.pipelines.Scheduler;
+import org.onap.bbs.event.processor.utilities.LoggingUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -171,4 +173,24 @@ public class BbsEventProcessorController {
);
}
}
+
+ /**
+ * Change logging level for BBS code.
+ * @param level new logging level
+ * @return Proper HTTP response based on change logging level result
+ */
+ @PostMapping("logging/{level}")
+ public Mono<ResponseEntity<String>> changeLoggingLevel(@PathVariable String level) {
+ return Mono.defer(() -> {
+ if (LoggingUtil.changeLoggingLevel(level)) {
+ LOGGER.info("Changed logging level to {}", level);
+ return Mono.just(new ResponseEntity<>("Changed BBS event processor logging level\n",
+ HttpStatus.OK));
+ } else {
+ return Mono.just(new ResponseEntity<>("Unacceptable logging level\n",
+ HttpStatus.NOT_ACCEPTABLE));
+ }
+ }
+ );
+ }
}
diff --git a/components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/model/GeneratedAppConfigObject.java b/components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/model/GeneratedAppConfigObject.java
index 12716ce4..4fdb81be 100644
--- a/components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/model/GeneratedAppConfigObject.java
+++ b/components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/model/GeneratedAppConfigObject.java
@@ -120,6 +120,9 @@ public interface GeneratedAppConfigObject {
@SerializedName(value = "application.closeLoop.configKey", alternate = "application.closeLoop.configKey")
String closeLoopConfigKey();
+ @SerializedName(value = "application.loggingLevel", alternate = "application.loggingLevel")
+ String loggingLevel();
+
@SerializedName(value = "streams_subscribes", alternate = "streams_subscribes")
Map<String, StreamsObject> streamSubscribesMap();
diff --git a/components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/utilities/CpeAuthenticationDmaapConsumerJsonParser.java b/components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/utilities/CpeAuthenticationDmaapConsumerJsonParser.java
index 62ab02d5..2bb5d98a 100644
--- a/components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/utilities/CpeAuthenticationDmaapConsumerJsonParser.java
+++ b/components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/utilities/CpeAuthenticationDmaapConsumerJsonParser.java
@@ -33,6 +33,7 @@ import static org.onap.bbs.event.processor.utilities.CpeAuthenticationEventField
import static org.onap.bbs.event.processor.utilities.CpeAuthenticationEventFields.STATE_INTERFACE;
import static org.onap.bbs.event.processor.utilities.CpeAuthenticationEventFields.SW_VERSION;
+import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
@@ -54,6 +55,7 @@ import reactor.core.publisher.Mono;
public class CpeAuthenticationDmaapConsumerJsonParser {
private static final Logger LOGGER = LoggerFactory.getLogger(CpeAuthenticationDmaapConsumerJsonParser.class);
+ private static final Gson gson = new Gson();
private static final String CPE_AUTHENTICATION_DUMPING_TEMPLATE = "%n{"
+ "\"" + CORRELATION_ID + COMMON_FORMAT + ","
@@ -111,6 +113,8 @@ public class CpeAuthenticationDmaapConsumerJsonParser {
private Mono<CpeAuthenticationConsumerDmaapModel> transform(JsonObject dmaapResponseJsonObject) {
+ LOGGER.trace("Event from DMaaP to be parsed: \n{}", gson.toJson(dmaapResponseJsonObject));
+
if (!containsProperHeaders(dmaapResponseJsonObject)) {
LOGGER.warn("Incorrect CPE Authentication JSON event - missing headers");
return Mono.empty();
diff --git a/components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/utilities/LoggingUtil.java b/components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/utilities/LoggingUtil.java
new file mode 100644
index 00000000..efb90d41
--- /dev/null
+++ b/components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/utilities/LoggingUtil.java
@@ -0,0 +1,54 @@
+/*
+ * ============LICENSE_START=======================================================
+ * BBS-RELOCATION-CPE-AUTHENTICATION-HANDLER
+ * ================================================================================
+ * Copyright (C) 2019 NOKIA Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.bbs.event.processor.utilities;
+
+import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.slf4j.LoggerFactory;
+
+public class LoggingUtil {
+
+ private static final String BBS_EP_APPLICATION_PACKAGE = "org.onap.bbs";
+ private static final Logger applicationLogger = (Logger) LoggerFactory.getLogger(BBS_EP_APPLICATION_PACKAGE);
+ private static final List<String> loggingLevels =
+ Arrays.asList("OFF", "ERROR", "WARN", "INFO", "DEBUG", "TRACE");
+
+ // Non-instantiable class
+ private LoggingUtil() {
+ }
+
+ /**
+ * Change Application logging level.
+ * @param level logging level. Must be one of OFF, ERROR, WARN, INFO, DEBUG, TRACE
+ * @return Flag indicating if it changed the level or not
+ */
+ public static boolean changeLoggingLevel(String level) {
+ if (loggingLevels.contains(level)) {
+ applicationLogger.setLevel(Level.toLevel(level));
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/utilities/ReRegistrationDmaapConsumerJsonParser.java b/components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/utilities/ReRegistrationDmaapConsumerJsonParser.java
index 7dd8a3d2..947d7a7c 100644
--- a/components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/utilities/ReRegistrationDmaapConsumerJsonParser.java
+++ b/components/bbs-event-processor/src/main/java/org/onap/bbs/event/processor/utilities/ReRegistrationDmaapConsumerJsonParser.java
@@ -28,6 +28,7 @@ import static org.onap.bbs.event.processor.utilities.ReRegistrationEventFields.C
import static org.onap.bbs.event.processor.utilities.ReRegistrationEventFields.REMOTE_ID;
import static org.onap.bbs.event.processor.utilities.ReRegistrationEventFields.SVLAN;
+import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
@@ -49,6 +50,7 @@ import reactor.core.publisher.Mono;
public class ReRegistrationDmaapConsumerJsonParser {
private static final Logger LOGGER = LoggerFactory.getLogger(ReRegistrationDmaapConsumerJsonParser.class);
+ private static final Gson gson = new Gson();
private static final String RE_REGISTRATION_DUMPING_TEMPLATE = "%n{"
+ "\"" + CORRELATION_ID + COMMON_FORMAT + ","
@@ -104,6 +106,8 @@ public class ReRegistrationDmaapConsumerJsonParser {
private Mono<ReRegistrationConsumerDmaapModel> transform(JsonObject dmaapResponseJsonObject) {
+ LOGGER.trace("Event from DMaaP to be parsed: \n{}", gson.toJson(dmaapResponseJsonObject));
+
if (!containsProperHeaders(dmaapResponseJsonObject)) {
LOGGER.warn("Incorrect JsonObject - missing headers");
return Mono.empty();
diff --git a/components/bbs-event-processor/src/test/java/org/onap/bbs/event/processor/config/ApplicationConfigurationTest.java b/components/bbs-event-processor/src/test/java/org/onap/bbs/event/processor/config/ApplicationConfigurationTest.java
index 7b81b1be..220466bc 100644
--- a/components/bbs-event-processor/src/test/java/org/onap/bbs/event/processor/config/ApplicationConfigurationTest.java
+++ b/components/bbs-event-processor/src/test/java/org/onap/bbs/event/processor/config/ApplicationConfigurationTest.java
@@ -286,6 +286,7 @@ class ApplicationConfigurationTest {
.reRegConfigKey("config_key_1")
.cpeAuthConfigKey("config_key_2")
.closeLoopConfigKey("config_key_3")
+ .loggingLevel("TRACE")
.streamSubscribesMap(subscribes)
.streamPublishesMap(Collections.singletonMap("config_key_3", streamsObject3))
.build();
diff --git a/components/bbs-event-processor/src/test/java/org/onap/bbs/event/processor/config/ConsulConfigurationGatewayTest.java b/components/bbs-event-processor/src/test/java/org/onap/bbs/event/processor/config/ConsulConfigurationGatewayTest.java
index cd20d1e1..9f5ce6dc 100644
--- a/components/bbs-event-processor/src/test/java/org/onap/bbs/event/processor/config/ConsulConfigurationGatewayTest.java
+++ b/components/bbs-event-processor/src/test/java/org/onap/bbs/event/processor/config/ConsulConfigurationGatewayTest.java
@@ -83,6 +83,7 @@ class ConsulConfigurationGatewayTest {
+ "\"application.reregistration.configKey\": \"config_key_2\","
+ "\"application.cpeAuth.configKey\": \"config_key_1\","
+ "\"application.closeLoop.configKey\": \"config_key_3\","
+ + "\"application.loggingLevel\": \"TRACE\","
+ "\"streams_subscribes\": {"
+ "\"config_key_1\": {"
+ "\"type\": \"message_router\","
@@ -201,6 +202,7 @@ class ConsulConfigurationGatewayTest {
.reRegConfigKey("config_key_2")
.cpeAuthConfigKey("config_key_1")
.closeLoopConfigKey("config_key_3")
+ .loggingLevel("TRACE")
.streamSubscribesMap(subscribes)
.streamPublishesMap(Collections.singletonMap("config_key_3", streamsObject3))
.build();