aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers
diff options
context:
space:
mode:
authorSmokowski, Steve (ss835w) <ss835w@us.att.com>2018-09-20 11:04:00 -0400
committerSmokowski, Steve (ss835w) <ss835w@us.att.com>2018-09-20 11:08:27 -0400
commitc4347b25ddf03c4f8e25b9443e0e25be102d0ba6 (patch)
tree50602a362db32978814e185d84227634418215b1 /mso-api-handlers
parent19659e205ef636cec767e32a62cc549cf9156d5b (diff)
Update Logging
Update logging to meet Casablanca Spec Change-Id: I029d6c63765992d6f091d96e2b4c34c60d30c484 Issue-ID: SO-947 Signed-off-by: Smokowski, Steve (ss835w) <ss835w@us.att.com>
Diffstat (limited to 'mso-api-handlers')
-rw-r--r--mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaClient.java31
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ApiHandlerApplication.java5
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java4
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java4
5 files changed, 34 insertions, 12 deletions
diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaClient.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaClient.java
index e9062effad..3ebad8b02c 100644
--- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaClient.java
+++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandler/common/CamundaClient.java
@@ -24,6 +24,7 @@ package org.onap.so.apihandler.common;
import java.io.IOException;
+import java.util.UUID;
import javax.xml.bind.DatatypeConverter;
@@ -32,6 +33,7 @@ import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.apihandler.camundabeans.CamundaBooleanInput;
import org.onap.so.apihandler.camundabeans.CamundaInput;
import org.onap.so.apihandler.camundabeans.CamundaIntegerInput;
@@ -39,6 +41,7 @@ import org.onap.so.apihandler.camundabeans.CamundaRequest;
import org.onap.so.apihandler.camundabeans.CamundaVIDRequest;
import org.onap.so.logger.MessageEnum;
import org.onap.so.logger.MsoLogger;
+import org.slf4j.MDC;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
@@ -63,6 +66,22 @@ public class CamundaClient extends RequestClient{
StringEntity input = new StringEntity(jsonReq);
input.setContentType(CommonConstants.CONTENT_TYPE_JSON);
msoLogger.info("Camunda Request Content: " + jsonReq);
+
+
+ post.setEntity(input);
+ setupHeaders(post);
+
+ HttpResponse response = client.execute(post);
+ msoLogger.debug("Response is: " + response);
+
+ return response;
+ }
+
+
+ private void setupHeaders(HttpPost post) {
+ post.addHeader(ONAPLogConstants.Headers.REQUEST_ID, MDC.get(ONAPLogConstants.MDCs.REQUEST_ID));
+ post.addHeader(ONAPLogConstants.Headers.INVOCATION_ID, UUID.randomUUID().toString());
+
String encryptedCredentials = null;
if(props!=null){
encryptedCredentials = props.getProperty(CommonConstants.CAMUNDA_AUTH);
@@ -73,12 +92,6 @@ public class CamundaClient extends RequestClient{
}
}
}
-
- post.setEntity(input);
- HttpResponse response = client.execute(post);
- msoLogger.debug("Response is: " + response);
-
- return response;
}
@Override
@@ -86,10 +99,10 @@ public class CamundaClient extends RequestClient{
throws ClientProtocolException, IOException{
HttpPost post = new HttpPost(url);
msoLogger.debug(CAMUNDA_URL_MESAGE + url);
- //String jsonReq = wrapRequest(camundaReqXML, requestId, serviceInstanceId, requestTimeout, schemaVersion);
StringEntity input = new StringEntity(jsonReq);
input.setContentType(CommonConstants.CONTENT_TYPE_JSON);
+ setupHeaders(post);
String encryptedCredentials = null;
if(props!=null){
@@ -102,6 +115,7 @@ public class CamundaClient extends RequestClient{
}
}
+
post.setEntity(input);
HttpResponse response = client.execute(post);
msoLogger.debug("Response is: " + response);
@@ -120,6 +134,9 @@ public class CamundaClient extends RequestClient{
StringEntity input = new StringEntity(jsonReq);
input.setContentType(CommonConstants.CONTENT_TYPE_JSON);
+
+ setupHeaders(post);
+
String encryptedCredentials = null;
if(props!=null){
encryptedCredentials = props.getProperty(CommonConstants.CAMUNDA_AUTH);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ApiHandlerApplication.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ApiHandlerApplication.java
index afe55a23a7..f3f98f3f2a 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ApiHandlerApplication.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ApiHandlerApplication.java
@@ -22,17 +22,19 @@ package org.onap.so.apihandlerinfra;
import java.util.concurrent.Executor;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+import org.onap.so.logging.jaxrs.filter.MDCTaskDecorator;
@SpringBootApplication(scanBasePackages = { "org.onap"})
@EnableAsync
public class ApiHandlerApplication {
-
+
@Value("${mso.async.core-pool-size}")
private int corePoolSize;
@@ -64,6 +66,7 @@ public class ApiHandlerApplication {
executor.setMaxPoolSize(maxPoolSize);
executor.setQueueCapacity(queueCapacity);
executor.setThreadNamePrefix("mso-apihandler-infra-");
+ executor.setTaskDecorator(new MDCTaskDecorator());
executor.initialize();
return executor;
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java
index 2427dd2734..7ad7e6626d 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java
@@ -35,6 +35,7 @@ import org.onap.so.apihandlerinfra.tenantisolationbeans.OperationalEnvironment;
import org.onap.so.logger.MessageEnum;
import org.onap.so.logger.MsoLogger;
import org.onap.so.requestsdb.RequestsDBHelper;
+import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.scheduling.annotation.Async;
@@ -61,6 +62,7 @@ public class TenantIsolationRunnable {
@Async
public void run(Action action, String operationalEnvType, CloudOrchestrationRequest cor, String requestId) throws ApiException {
+
msoLogger.debug ("Starting threadExecution in TenantIsolationRunnable for Action " + action.name() + " and OperationalEnvType: " + operationalEnvType);
try {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java
index eec68d8079..f4fede15e1 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java
@@ -107,7 +107,7 @@ public class ManualTasksTest extends BaseTest{
for(ILoggingEvent logEvent : TestAppender.events)
if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
- logEvent.getMarker().getName().equals("ENTRY")
+ logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")
){
Map<String,String> mdc = logEvent.getMDCPropertyMap();
assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
@@ -117,7 +117,7 @@ public class ManualTasksTest extends BaseTest{
assertEquals("tasks/v1/55/complete",mdc.get(MsoLogger.SERVICE_NAME));
assertEquals("INPROGRESS",mdc.get(MsoLogger.STATUSCODE));
}else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
- logEvent.getMarker().getName().equals("EXIT")){
+ logEvent.getMarker() != null && logEvent.getMarker().getName().equals("EXIT")){
Map<String,String> mdc = logEvent.getMDCPropertyMap();
assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
assertNotNull(mdc.get(MsoLogger.ENDTIME));
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
index f726194fb7..464d5e6bba 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
@@ -197,7 +197,7 @@ public class ServiceInstancesTest extends BaseTest{
for(ILoggingEvent logEvent : TestAppender.events)
if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
- logEvent.getMarker().getName().equals("ENTRY")
+ logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")
){
Map<String,String> mdc = logEvent.getMDCPropertyMap();
assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
@@ -207,7 +207,7 @@ public class ServiceInstancesTest extends BaseTest{
assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances",mdc.get(MsoLogger.SERVICE_NAME));
assertEquals("INPROGRESS",mdc.get(MsoLogger.STATUSCODE));
}else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
- logEvent.getMarker().getName().equals("EXIT")){
+ logEvent.getMarker() != null && logEvent.getMarker().getName().equals("EXIT")){
Map<String,String> mdc = logEvent.getMDCPropertyMap();
assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
assertNotNull(mdc.get(MsoLogger.ENDTIME));