diff options
32 files changed, 499 insertions, 405 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java index 8ccf40eff5..e15311eb0e 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java @@ -111,7 +111,7 @@ public class CatalogDBRestTest { assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); for(ILoggingEvent logEvent : TestAppender.events) if(logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor") && - logEvent.getMarker().getName().equals("ENTRY") + logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY") ){ Map<String,String> mdc = logEvent.getMDCPropertyMap(); assertNotNull(mdc.get(ONAPLogConstants.MDCs.INSTANCE_UUID)); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/MsoOpenstackAdaptersApplication.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/MsoOpenstackAdaptersApplication.java index 02aa0843ae..a9aa50f654 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/MsoOpenstackAdaptersApplication.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/MsoOpenstackAdaptersApplication.java @@ -22,6 +22,8 @@ package org.onap.so.adapters.openstack; import java.util.concurrent.Executor; +import org.onap.so.logging.jaxrs.filter.MDCTaskDecorator; +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; @@ -38,6 +40,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; @EntityScan({ "org.onap.so.db.catalog.beans", "org.onap.so.db.request.beans"}) public class MsoOpenstackAdaptersApplication { + @Value("${mso.async.core-pool-size}") private int corePoolSize; @@ -63,6 +66,7 @@ public class MsoOpenstackAdaptersApplication { @Bean public Executor asyncExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); + executor.setTaskDecorator(new MDCTaskDecorator()); executor.setCorePoolSize(corePoolSize); executor.setMaxPoolSize(maxPoolSize); executor.setQueueCapacity(queueCapacity); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/ValetClient.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/ValetClient.java index 5cce4dd35f..2f688dbf48 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/ValetClient.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/valet/ValetClient.java @@ -50,6 +50,8 @@ import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; +import org.springframework.http.client.BufferingClientHttpRequestFactory; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.web.client.RestTemplate; import org.springframework.stereotype.Component; @@ -108,13 +110,11 @@ public class ValetClient { URI uri = builder.build(); ValetCreateRequest vcr = this.createValetCreateRequest(regionId, tenantId, serviceInstanceId, vnfId, vnfName, vfModuleId, vfModuleName, keystoneUrl, heatRequest); - RestTemplate restTemplate = new RestTemplate(); String body = mapper.writeValueAsString(vcr); HttpHeaders headers = generateHeaders(requestId); - HttpEntity<String> entity = new HttpEntity<>(body, headers); - LOGGER.debug("valet create req: " + uri.toString() + HEADERS + headers.toString() + BODY + body); + HttpEntity<String> entity = new HttpEntity<>(body, headers); - response = restTemplate.exchange(uri, HttpMethod.POST, entity, ValetCreateResponse.class); + response = getRestTemplate().exchange(uri, HttpMethod.POST, entity, ValetCreateResponse.class); gvr = this.getGVRFromResponse(response); } catch (Exception e) { LOGGER.error("An exception occurred in callValetCreateRequest", e); @@ -123,6 +123,12 @@ public class ValetClient { return gvr; } + private RestTemplate getRestTemplate(){ + RestTemplate restTemplate = new RestTemplate(); + restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory())); + return restTemplate; + } + /* * This method will be invoked to send an Update request to Valet. */ @@ -135,14 +141,13 @@ public class ValetClient { UriBuilder builder = UriBuilder.fromPath(baseUrl).path(basePath).queryParam(REQUEST_ID, requestId); URI uri = builder.build(); - ValetUpdateRequest vur = this.createValetUpdateRequest(regionId, tenantId, serviceInstanceId, vnfId, vnfName, vfModuleId, vfModuleName, keystoneUrl, heatRequest); - RestTemplate restTemplate = new RestTemplate(); + ValetUpdateRequest vur = this.createValetUpdateRequest(regionId, tenantId, serviceInstanceId, vnfId, vnfName, vfModuleId, vfModuleName, keystoneUrl, heatRequest); String body = mapper.writeValueAsString(vur); HttpHeaders headers = generateHeaders(requestId); HttpEntity<String> entity = new HttpEntity<>(body, headers); - LOGGER.debug("valet update req: " + uri.toString() + HEADERS + headers.toString() + BODY + body); + - response = restTemplate.exchange(uri, HttpMethod.PUT, entity, ValetUpdateResponse.class); + response = getRestTemplate().exchange(uri, HttpMethod.PUT, entity, ValetUpdateResponse.class); gvr = this.getGVRFromResponse(response); } catch (Exception e) { LOGGER.error("An exception occurred in callValetUpdateRequest", e); @@ -163,13 +168,13 @@ public class ValetClient { URI uri = builder.build(); ValetDeleteRequest vdr = this.createValetDeleteRequest(regionId, tenantId, vfModuleId, vfModuleName); - RestTemplate restTemplate = new RestTemplate(); + String body = mapper.writeValueAsString(vdr); HttpHeaders headers = generateHeaders(requestId); HttpEntity<String> entity = new HttpEntity<>(body, headers); - LOGGER.debug("valet delete req: " + uri.toString() + HEADERS + headers.toString() + ", body=" + body); - response = restTemplate.exchange(uri, HttpMethod.DELETE, entity, ValetDeleteResponse.class); + + response = getRestTemplate().exchange(uri, HttpMethod.DELETE, entity, ValetDeleteResponse.class); gvr = this.getGVRFromResponse(response); } catch (Exception e) { LOGGER.error("An exception occurred in callValetDeleteRequest", e); @@ -190,13 +195,13 @@ public class ValetClient { URI uri = builder.build(requestId); ValetConfirmRequest vcr = this.createValetConfirmRequest(stackId); - RestTemplate restTemplate = new RestTemplate(); + String body = mapper.writeValueAsString(vcr); HttpHeaders headers = generateHeaders(requestId); HttpEntity<String> entity = new HttpEntity<>(body, headers); LOGGER.debug("valet confirm req: " + uri.toString() + HEADERS + headers.toString() + BODY + body); - response = restTemplate.exchange(uri, HttpMethod.PUT, entity, ValetConfirmResponse.class); + response = getRestTemplate().exchange(uri, HttpMethod.PUT, entity, ValetConfirmResponse.class); gvr = this.getGVRFromResponse(response); } catch (Exception e) { LOGGER.error("An exception occurred in callValetConfirmRequest", e); @@ -217,13 +222,13 @@ public class ValetClient { URI uri = builder.build(requestId); ValetRollbackRequest vrr = this.createValetRollbackRequest(stackId, suppressRollback, errorMessage); - RestTemplate restTemplate = new RestTemplate(); + String body = mapper.writeValueAsString(vrr); HttpHeaders headers = generateHeaders(requestId); HttpEntity<String> entity = new HttpEntity<>(body, headers); - LOGGER.debug("valet rollback req: " + uri.toString() + HEADERS + headers.toString() + BODY + body); - response = restTemplate.exchange(uri, HttpMethod.PUT, entity, ValetRollbackResponse.class); + + response = getRestTemplate().exchange(uri, HttpMethod.PUT, entity, ValetRollbackResponse.class); gvr = this.getGVRFromResponse(response); } catch (Exception e) { LOGGER.error("An exception occurred in callValetRollbackRequest", e); diff --git a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java index 21ec8f7518..fc12120166 100644 --- a/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java +++ b/adapters/mso-requests-db-adapter/src/test/java/org/onap/so/adapters/requestsdb/adapters/HealthCheckHandlerTest.java @@ -68,7 +68,7 @@ public class HealthCheckHandlerTest { assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); for(ILoggingEvent logEvent : TestAppender.events) if(logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor") && - logEvent.getMarker().getName().equals("ENTRY") + logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY") ){ Map<String,String> mdc = logEvent.getMDCPropertyMap(); assertNotNull(mdc.get(ONAPLogConstants.MDCs.INSTANCE_UUID)); @@ -78,7 +78,7 @@ public class HealthCheckHandlerTest { assertEquals("/manage/health",mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME)); assertEquals("INPROGRESS",mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE)); }else if(logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor") && - logEvent.getMarker()!= null && logEvent.getMarker().getName().equals("EXIT")){ + logEvent.getMarker() != null && logEvent.getMarker()!= null && logEvent.getMarker().getName().equals("EXIT")){ Map<String,String> mdc = logEvent.getMDCPropertyMap(); assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID)); assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID)); diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/SDNCAdapterApplication.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/SDNCAdapterApplication.java index 3d88a1467a..f88aab08a6 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/SDNCAdapterApplication.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/SDNCAdapterApplication.java @@ -22,6 +22,8 @@ package org.onap.so.adapters.sdnc; import java.util.concurrent.Executor; +import org.onap.so.logging.jaxrs.filter.MDCTaskDecorator; +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; @@ -35,6 +37,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; @EntityScan({ "org.onap.so.db.request.beans"}) public class SDNCAdapterApplication { + @Value("${mso.async.core-pool-size}") private int corePoolSize; @@ -61,7 +64,7 @@ public class SDNCAdapterApplication { @Bean public Executor asyncExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - + executor.setTaskDecorator(new MDCTaskDecorator()); executor.setCorePoolSize(corePoolSize); executor.setMaxPoolSize(maxPoolSize); executor.setQueueCapacity(queueCapacity); diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/Application.java b/asdc-controller/src/main/java/org/onap/so/asdc/Application.java index a365d0740d..bd3b2d1c54 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/Application.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/Application.java @@ -26,6 +26,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication(scanBasePackages = { "org.onap.so" }) public class Application { + private static final String MSO_CONFIG_PATH = "mso.config.path"; private static final String LOGS_DIR = "logs_dir"; private static void setLogsDir() { @@ -33,11 +34,16 @@ public class Application { System.getProperties().setProperty(LOGS_DIR, "./logs/asdc/"); } } + + private static void setConfigPath() { + if(System.getProperty(MSO_CONFIG_PATH) == null) + System.getProperties().setProperty(MSO_CONFIG_PATH, "."); + } public static void main(String[] args) { SpringApplication.run(Application.class, args); System.getProperties().setProperty("mso.db", "MARIADB"); - System.getProperties().setProperty("mso.config.path", "."); + System.getProperties().setProperty("server.name", "Springboot"); setLogsDir(); } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy index 1e2a703e70..0692e5022a 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/AbstractServiceTaskProcessor.groovy @@ -755,8 +755,6 @@ public abstract class AbstractServiceTaskProcessor implements ServiceTaskProcess public void setBasicDBAuthHeader(DelegateExecution execution, isDebugLogEnabled) { try { String basicAuthValueDB = UrnPropertiesReader.getVariable("mso.adapters.db.auth", execution) - utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB, isDebugLogEnabled) - def encodedString = utils.getBasicAuth(basicAuthValueDB, UrnPropertiesReader.getVariable("mso.msoKey", execution)) execution.setVariable("BasicAuthHeaderValueDB",encodedString) } catch (IOException ex) { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/baseclient/BaseClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/baseclient/BaseClient.java index c3511e69a4..78f3e96978 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/baseclient/BaseClient.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/baseclient/BaseClient.java @@ -20,13 +20,14 @@ package org.onap.so.bpmn.common.baseclient; +import org.onap.so.logging.jaxrs.filter.SpringClientFilter; import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.http.client.BufferingClientHttpRequestFactory; -import org.springframework.http.client.SimpleClientHttpRequestFactory; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestTemplate; @@ -59,11 +60,12 @@ public class BaseClient<I,O> { public O post(I data, ParameterizedTypeReference<O> typeRef, Object... uriVariables) throws RestClientException { return run(data, HttpMethod.POST, typeRef, uriVariables); } - + public O run(I data, HttpMethod method, ParameterizedTypeReference<O> typeRef, Object... uriVariables) throws RestClientException { HttpEntity<I> requestEntity = new HttpEntity<I>(data, getHttpHeader()); RestTemplate restTemplate = new RestTemplate(); - restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(new SimpleClientHttpRequestFactory())); + restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory())); + restTemplate.getInterceptors().add(new SpringClientFilter()); ResponseEntity<O> responseEntity = restTemplate.exchange(getTargetUrl(), method, requestEntity, typeRef, uriVariables); return responseEntity.getBody(); diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/CompleteMsoProcess.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/CompleteMsoProcess.bpmn index 67bd961844..63c867f3c7 100644 --- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/CompleteMsoProcess.bpmn +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/CompleteMsoProcess.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_EsMs0HcuEeW2U_kkOHX1ZQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.10.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_EsMs0HcuEeW2U_kkOHX1ZQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.7.1" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> <bpmn2:process id="CompleteMsoProcess" name="CompleteMsoProcess" isExecutable="true"> <bpmn2:scriptTask id="preProcessRequest" name="Pre-Process Request" scriptFormat="groovy"> <bpmn2:incoming>SequenceFlow_18</bpmn2:incoming> @@ -56,6 +56,7 @@ completeMsoProcess.setUpdateDBstatustoSuccessPayload(execution)]]></bpmn2:script <camunda:map> <camunda:entry key="content-type">application/soap+xml</camunda:entry> <camunda:entry key="Authorization">#{BasicAuthHeaderValueDB}</camunda:entry> + <camunda:entry key="X-ONAP-RequestID">#{CMSO_request_id}</camunda:entry> </camunda:map> </camunda:inputParameter> <camunda:inputParameter name="method">POST</camunda:inputParameter> @@ -88,7 +89,7 @@ buildDataErrorMessage.buildDataError(execution, "Complete MSO -- Update DB stat <bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="ExclusiveGateway_7" targetRef="BuildErrorMessage" /> <bpmn2:boundaryEvent id="BoundaryEvent_7" name="" attachedToRef="updateInfraRequest"> <bpmn2:outgoing>SequenceFlow_0mipf25</bpmn2:outgoing> - <bpmn2:errorEventDefinition id="_ErrorEventDefinition_84" errorRef="Error_1" /> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_84" errorRef="Error_1" camunda:errorCodeVariable="gJavaErrorCode" camunda:errorMessageVariable="gJavaErrorMessage" /> </bpmn2:boundaryEvent> <bpmn2:endEvent id="EndEvent_1"> <bpmn2:incoming>SequenceFlow_1pzb94j</bpmn2:incoming> diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/FalloutHandler.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/FalloutHandler.bpmn index c59564b1e3..990863ec93 100644 --- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/FalloutHandler.bpmn +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/FalloutHandler.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_3SPHsLr9EeWak-hhutJWuQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.8.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="_3SPHsLr9EeWak-hhutJWuQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.7.1" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> <bpmn2:process id="FalloutHandler" name="Fallout Handler" isExecutable="true"> <bpmn2:parallelGateway id="ParallelGateway_1"> <bpmn2:incoming>SequenceFlow_12</bpmn2:incoming> @@ -139,6 +139,7 @@ falloutHandler.buildDBWorkflowException(execution, "FH_updateRequestInfraRespons <camunda:map> <camunda:entry key="content-type">application/soap+xml</camunda:entry> <camunda:entry key="Authorization">#{BasicAuthHeaderValueDB}</camunda:entry> + <camunda:entry key="X-ONAP-RequestID">#{FH_request_id}</camunda:entry> </camunda:map> </camunda:inputParameter> <camunda:inputParameter name="payload"> @@ -168,7 +169,7 @@ return updateRequestInfra.updateRequestInfraPayload(execution)]]></camunda:scrip </bpmn2:sequenceFlow> <bpmn2:boundaryEvent id="BoundaryEvent_3" name="Connect Fault" attachedToRef="ServiceTask_2"> <bpmn2:outgoing>SequenceFlow_80</bpmn2:outgoing> - <bpmn2:errorEventDefinition id="_ErrorEventDefinition_90" errorRef="Error_2" /> + <bpmn2:errorEventDefinition id="_ErrorEventDefinition_90" errorRef="Error_2" camunda:errorCodeVariable="gJavaErrorCode" camunda:errorMessageVariable="gJavaErrorMessage" /> </bpmn2:boundaryEvent> <bpmn2:sequenceFlow id="SequenceFlow_80" name="" sourceRef="BoundaryEvent_3" targetRef="ScriptTask_7" /> <bpmn2:subProcess id="SubProcess_1" name="Event Handler" triggeredByEvent="true"> diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java index da24ba14fd..9ea97258ef 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java @@ -31,7 +31,6 @@ import org.camunda.bpm.engine.variable.impl.VariableMapImpl; import org.onap.so.bpmn.common.workflow.context.WorkflowResponse; import org.onap.so.logger.MsoLogger; import org.openecomp.mso.bpmn.common.workflow.service.WorkflowProcessorException; -import org.slf4j.MDC; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; @@ -46,19 +45,14 @@ public class WorkflowProcessor extends ProcessEngineAwareService { @Async public void startProcess( String processKey, VariableMapImpl variableMap) throws InterruptedException { - MDC.getCopyOfContextMap(); + long startTime = System.currentTimeMillis(); Map<String, Object> inputVariables = null; String processInstanceId = null; try { inputVariables = getInputVariables(variableMap); - setLogContext(processKey, inputVariables); - // This variable indicates that the flow was invoked asynchronously inputVariables.put("isAsyncProcess", "true"); - - - setLogContext(processKey, inputVariables); // Note: this creates a random businessKey if it wasn't specified. String businessKey = getBusinessKey(inputVariables); @@ -87,14 +81,6 @@ public class WorkflowProcessor extends ProcessEngineAwareService { } } - protected static void setLogContext(String processKey, - Map<String, Object> inputVariables) { - MsoLogger.setServiceName("MSO." + processKey); - if (inputVariables != null) { - MsoLogger.setLogContext(getKeyValueFromInputVariables(inputVariables,"mso-request-id"), getKeyValueFromInputVariables(inputVariables,"mso-service-instance-id")); - } - } - protected static String getKeyValueFromInputVariables(Map<String,Object> inputVariables, String key) { if (inputVariables == null) { return ""; diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java index 00ee6eb235..9b65cca6c9 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java @@ -70,9 +70,7 @@ import org.springframework.stereotype.Component; * Plugin for MSO logging and URN mapping. */ @Component -public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin { - private static MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, LoggingAndURNMappingPlugin.class); - private static final String FSPROPKEY = "URNMapping.FileSystemLoading.Enabled"; +public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin { @Autowired private LoggingParseListener loggingParseListener; @@ -198,7 +196,6 @@ public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin { @Override public void parseSequenceFlow(Element sequenceFlowElement, ScopeImpl scopeElement, TransitionImpl transition) { - //injectLogExecutionListener(activity); } @Override @@ -216,9 +213,9 @@ public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin { injectLogExecutionListener(timerActivity); } - @Override + @Override public void parseRootElement(Element rootElement, List<ProcessDefinitionEntity> processDefinitions) { - //injectLogExecutionListener(activity); + } @Override @@ -298,17 +295,7 @@ public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin { } @Override - public void notify(DelegateExecution execution) throws Exception { - logger.trace("Logging for activity---------------:" + event + ":" - + execution.getCurrentActivityName() - + ", processDefinitionId=" - + execution.getProcessDefinitionId() + ", activtyId=" - + execution.getCurrentActivityId() + ", activtyName='" - + execution.getCurrentActivityName() + "'" - + ", processInstanceId=" - + execution.getProcessInstanceId() + ", businessKey=" - + execution.getProcessBusinessKey() + ", executionId=" - + execution.getId()); + public void notify(DelegateExecution execution) throws Exception { //required for legacy groovy processing in camunda execution.setVariable("isDebugLogEnabled", "true"); if (!isBlank(execution.getCurrentActivityName())) { @@ -322,20 +309,7 @@ public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin { .singleResult() .getName(); - if (execution.getBpmnModelElementInstance() instanceof StartEvent) { - logger.debug("Starting process: " + processName); - } - if (execution.getBpmnModelElementInstance() instanceof EndEvent) { - logger.debug("Ending process: " + processName); - } - - String serviceName = MDC.get(MsoLogger.SERVICE_NAME); - - if(serviceName != null && !serviceName.contains(processName)) - MsoLogger.setServiceName( serviceName + "." + processName); - else if(serviceName == null) - MsoLogger.setServiceName(processName); - + MsoLogger.setServiceName(processName); String requestId = (String) execution.getVariable("mso-request-id"); String svcid = (String) execution.getVariable("mso-service-instance-id"); MsoLogger.setLogContext(requestId, svcid); diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java index db2304d6b7..efd73ba4f2 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java @@ -30,6 +30,8 @@ import org.camunda.bpm.engine.ProcessEngine; import org.camunda.bpm.spring.boot.starter.annotation.EnableProcessApplication; import org.onap.so.bpmn.common.DefaultToShortClassNameBeanNameGenerator; import org.onap.so.logger.MsoLogger; +import org.onap.so.logging.jaxrs.filter.MDCTaskDecorator; +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; @@ -102,7 +104,7 @@ public class MSOInfrastructureApplication { @Primary public Executor asyncExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - + executor.setTaskDecorator(new MDCTaskDecorator()); executor.setCorePoolSize(corePoolSize); executor.setMaxPoolSize(maxPoolSize); executor.setQueueCapacity(queueCapacity); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index a998f6934f..02459d789d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -35,6 +35,7 @@ import java.util.stream.Collectors; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.javatuples.Pair; +import org.slf4j.LoggerFactory; import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.L3Network; import org.onap.aai.domain.yang.Relationship; @@ -61,8 +62,6 @@ import org.onap.so.db.catalog.beans.VnfVfmoduleCvnfcConfigurationCustomization; import org.onap.so.db.catalog.beans.macro.NorthBoundRequest; import org.onap.so.db.catalog.beans.macro.OrchestrationFlow; import org.onap.so.db.catalog.client.CatalogDbClient; -import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoLogger; import org.onap.so.serviceinstancebeans.ModelInfo; import org.onap.so.serviceinstancebeans.ModelType; import org.onap.so.serviceinstancebeans.Networks; @@ -71,6 +70,7 @@ import org.onap.so.serviceinstancebeans.Service; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; import org.onap.so.serviceinstancebeans.VfModules; import org.onap.so.serviceinstancebeans.Vnfs; +import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -79,6 +79,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; @Component public class WorkflowAction { + private static final String WORKFLOW_ACTION_ERROR_MESSAGE = "WorkflowActionErrorMessage"; + private static final String SERVICE_INSTANCES = "serviceInstances"; + private static final String WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI = "WorkflowAction was unable to verify if the instance name already exist in AAI."; private static final String G_ORCHESTRATION_FLOW = "gOrchestrationFlow"; private static final String G_ACTION = "requestAction"; private static final String G_CURRENT_SEQUENCE = "gCurrentSequence"; @@ -100,7 +103,7 @@ public class WorkflowAction { private static final String CREATEINSTANCE = "createInstance"; private static final String USERPARAMSERVICE = "service"; private static final String supportedTypes = "vnfs|vfModules|networks|networkCollections|volumeGroups|serviceInstances"; - private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, WorkflowAction.class); + private static final Logger logger = LoggerFactory.getLogger(WorkflowAction.class); @Autowired protected BBInputSetup bbInputSetup; @@ -239,7 +242,7 @@ public class WorkflowAction { for(WorkflowType type : WorkflowType.values()){ foundObjects = foundObjects + type + " - " + resourceCounter.stream().filter(x -> type.equals(x.getResourceType())).collect(Collectors.toList()).size() + " "; } - msoLogger.info("Found " + foundObjects); + logger.info("Found {}", foundObjects); if (orchFlows == null || orchFlows.isEmpty()) { orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, aLaCarte); @@ -247,7 +250,7 @@ public class WorkflowAction { flowsToExecute = buildExecuteBuildingBlockList(orchFlows, resourceCounter, requestId, apiVersion, resourceId, resourceType, requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails); if (!resourceCounter.stream().filter(x -> WorkflowType.NETWORKCOLLECTION == x.getResourceType()).collect(Collectors.toList()).isEmpty()) { - msoLogger.info("Sorting for Vlan Tagging"); + logger.info("Sorting for Vlan Tagging"); flowsToExecute = sortExecutionPathByObjectForVlanTagging(flowsToExecute, requestAction); } if (resourceType == WorkflowType.SERVICE @@ -267,9 +270,9 @@ public class WorkflowAction { throw new IllegalStateException("Macro did not come up with a valid execution path."); } - msoLogger.info("List of BuildingBlocks to execute:"); + logger.info("List of BuildingBlocks to execute:"); for (ExecuteBuildingBlock ebb : flowsToExecute) { - msoLogger.info(ebb.getBuildingBlock().getBpmnFlowName()); + logger.info(ebb.getBuildingBlock().getBpmnFlowName()); } execution.setVariable(G_CURRENT_SEQUENCE, 0); @@ -296,7 +299,7 @@ public class WorkflowAction { private void updateResourceIdsFromAAITraversal(List<ExecuteBuildingBlock> flowsToExecute, List<Resource> resourceCounter, List<Pair<WorkflowType, String>> aaiResourceIds) { for(Pair<WorkflowType,String> pair : aaiResourceIds){ - msoLogger.debug(pair.getValue0() + ", " + pair.getValue1()); + logger.debug(pair.getValue0() + ", " + pair.getValue1()); } Arrays.stream(WorkflowType.values()).filter(type -> !type.equals(WorkflowType.SERVICE)).forEach(type -> { @@ -389,12 +392,12 @@ public class WorkflowAction { if (service.getVnfCustomizations() == null || service.getVnfCustomizations().isEmpty()) { List<CollectionResourceCustomization> customizations = service.getCollectionResourceCustomizations(); if(customizations.isEmpty()) { - msoLogger.debug("No Collections found. CollectionResourceCustomization list is empty."); + logger.debug("No Collections found. CollectionResourceCustomization list is empty."); }else{ CollectionResourceCustomization collectionResourceCustomization = findCatalogNetworkCollection(execution, service); if(collectionResourceCustomization!=null){ resourceCounter.add(new Resource(WorkflowType.NETWORKCOLLECTION,collectionResourceCustomization.getModelCustomizationUUID(),false)); - msoLogger.debug("Found a network collection"); + logger.debug("Found a network collection"); if(collectionResourceCustomization.getCollectionResource()!=null){ if(collectionResourceCustomization.getCollectionResource().getInstanceGroup() != null){ String toscaNodeType = collectionResourceCustomization.getCollectionResource().getInstanceGroup().getToscaNodeType(); @@ -413,7 +416,7 @@ public class WorkflowAction { minNetworks = collectionInstCust.getSubInterfaceNetworkQuantity(); } } - msoLogger.debug("minNetworks: " + minNetworks); + logger.debug("minNetworks: {}" , minNetworks); CollectionNetworkResourceCustomization collectionNetworkResourceCust = null; for(CollectionNetworkResourceCustomization collectionNetworkTemp : instanceGroup.getCollectionNetworkResourceCustomizations()) { if(collectionNetworkTemp.getNetworkResourceCustomization().getModelCustomizationUUID().equalsIgnoreCase(collectionResourceCustomization.getModelCustomizationUUID())) { @@ -429,21 +432,21 @@ public class WorkflowAction { } } } else { - msoLogger.debug("Instance Group tosca node type does not contain NetworkCollection: " + toscaNodeType); + logger.debug("Instance Group tosca node type does not contain NetworkCollection: {}" , toscaNodeType); } }else{ - msoLogger.debug("No Instance Group found for network collection."); + logger.debug("No Instance Group found for network collection."); } }else{ - msoLogger.debug("No Network Collection found. collectionResource is null"); + logger.debug("No Network Collection found. collectionResource is null"); } } else { - msoLogger.debug("No Network Collection Customization found"); + logger.debug("No Network Collection Customization found"); } } if (resourceCounter.stream().filter(x -> WorkflowType.NETWORKCOLLECTION == x.getResourceType()).collect(Collectors.toList()).isEmpty()) { if (service.getNetworkCustomizations() == null) { - msoLogger.debug("No networks were found on this service model"); + logger.debug("No networks were found on this service model"); } else { for (int i = 0; i < service.getNetworkCustomizations().size(); i++) { resourceCounter.add(new Resource(WorkflowType.NETWORK,service.getNetworkCustomizations().get(i).getModelCustomizationUUID(),false)); @@ -491,7 +494,7 @@ public class WorkflowAction { } } if (serviceInstanceMSO.getCollection() != null) { - msoLogger.debug("found networkcollection"); + logger.debug("found networkcollection"); aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.NETWORKCOLLECTION, serviceInstanceMSO.getCollection().getId())); resourceCounter.add(new Resource(WorkflowType.NETWORKCOLLECTION,serviceInstanceMSO.getCollection().getId(),false)); } @@ -613,9 +616,10 @@ public class WorkflowAction { } } } - msoLogger.debug("found " + configurations.size() + " configurations"); + logger.debug("found {} configurations" , configurations.size() ); return configurations; } catch (Exception ex){ + logger.error("Error in finding configurations", ex); return configurations; } } @@ -649,7 +653,7 @@ public class WorkflowAction { Boolean generated = false; if (m.find()) { - msoLogger.debug("found match on " + uri + ": " + m); + logger.debug("found match on {} : {} " , uri , m); String type = m.group("type"); String id = m.group("id"); String action = m.group("action"); @@ -657,7 +661,7 @@ public class WorkflowAction { throw new IllegalArgumentException("Uri could not be parsed. No type found. " + uri); } if (action == null) { - if (type.equals("serviceInstances") && (id == null || id.equals("assign"))) { + if (type.equals(SERVICE_INSTANCES) && (id == null || id.equals("assign"))) { id = UUID.randomUUID().toString(); generated = true; } @@ -727,9 +731,9 @@ public class WorkflowAction { } return generatedResourceId; } catch (Exception ex) { - msoLogger.error(ex); + logger.error(WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI, ex); throw new IllegalStateException( - "WorkflowAction was unable to verify if the instance name already exist in AAI."); + WORKFLOW_ACTION_WAS_UNABLE_TO_VERIFY_IF_THE_INSTANCE_NAME_ALREADY_EXIST_IN_AAI); } } @@ -737,7 +741,7 @@ public class WorkflowAction { if (!type.matches(supportedTypes)) { return type; } else { - if (type.equals("serviceInstances")) { + if (type.equals(SERVICE_INSTANCES)) { return SERVICE; } else { return type.substring(0, 1).toUpperCase() + type.substring(1, type.length() - 1); @@ -948,20 +952,19 @@ public class WorkflowAction { } protected void buildAndThrowException(DelegateExecution execution, String msg, Exception ex) { - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, msg, ex); - execution.setVariable("WorkflowActionErrorMessage", msg); + logger.error(msg, ex); + execution.setVariable(WORKFLOW_ACTION_ERROR_MESSAGE, msg); exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, msg); } protected void buildAndThrowException(DelegateExecution execution, String msg) { - msoLogger.error(msg); - execution.setVariable("WorkflowActionErrorMessage", msg); + logger.error(msg); + execution.setVariable(WORKFLOW_ACTION_ERROR_MESSAGE, msg); exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, msg); } public void handleRuntimeException (DelegateExecution execution){ - StringBuffer wfeExpMsg = new StringBuffer("Runtime error "); + StringBuilder wfeExpMsg = new StringBuilder("Runtime error "); String runtimeErrorMessage = null; try{ String javaExpMsg = (String) execution.getVariable("BPMN_javaExpMsg"); @@ -969,10 +972,10 @@ public class WorkflowAction { wfeExpMsg = wfeExpMsg.append(": ").append(javaExpMsg); } runtimeErrorMessage = wfeExpMsg.toString(); - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, runtimeErrorMessage, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, runtimeErrorMessage); - execution.setVariable("WorkflowActionErrorMessage", runtimeErrorMessage); + logger.error(runtimeErrorMessage); + execution.setVariable(WORKFLOW_ACTION_ERROR_MESSAGE, runtimeErrorMessage); } catch (Exception e){ + logger.error("Runtime error", e); //if runtime message was mulformed runtimeErrorMessage = "Runtime error"; } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java index a4b40393a3..67843a7ef9 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SDNCClient.java @@ -64,28 +64,10 @@ public class SDNCClient { STOClient.setTargetUrl(targetUrl); HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth()); STOClient.setHttpHeader(httpHeader); - msoLogger.info("Running SDNC CLIENT for TargetUrl: " + targetUrl); LinkedHashMap<?, ?> output = STOClient.post(jsonRequest, new ParameterizedTypeReference<LinkedHashMap<? ,?>>() {}); - Optional<String> sdncResponse = logSDNCResponse(output); - if(sdncResponse.isPresent()){ - msoLogger.info(sdncResponse.get()); - } - msoLogger.info("Validating output..."); return sdnCommonTasks.validateSDNResponse(output); } - protected Optional<String> logSDNCResponse(LinkedHashMap<?, ?> output) { - ObjectMapper mapper = new ObjectMapper(); - String sdncOutput = ""; - try { - sdncOutput = mapper.writeValueAsString(output); - return Optional.of(sdncOutput); - } catch (JsonProcessingException e) { - msoLogger.debug("Failed to map response from sdnc to json string for logging purposes."); - } - return Optional.empty(); - } - /** * * @param queryLink @@ -102,12 +84,9 @@ public class SDNCClient { String jsonRequest = sdnCommonTasks.buildJsonRequest(request); String targetUrl = UriBuilder.fromUri(properties.getHost()).path(queryLink).build().toString(); STOClient.setTargetUrl(targetUrl); - msoLogger.info("TargetUrl: " + targetUrl); HttpHeaders httpHeader = sdnCommonTasks.getHttpHeaders(properties.getAuth()); STOClient.setHttpHeader(httpHeader); - msoLogger.info("Running SDNC CLIENT..."); LinkedHashMap<?, ?> output = STOClient.get(jsonRequest, new ParameterizedTypeReference<LinkedHashMap<? ,?>>() {}); - msoLogger.info("Validating output..."); return sdnCommonTasks.validateSDNGetResponse(output); } diff --git a/common/src/main/java/org/onap/so/client/RestClientSSL.java b/common/src/main/java/org/onap/so/client/RestClientSSL.java index cb2839ae1f..ac4a8d1a7c 100644 --- a/common/src/main/java/org/onap/so/client/RestClientSSL.java +++ b/common/src/main/java/org/onap/so/client/RestClientSSL.java @@ -56,7 +56,7 @@ public abstract class RestClientSSL extends RestClient { KeyStore ks = getKeyStore(); if(ks != null) { client = ClientBuilder.newBuilder().keyStore(ks, System.getProperty(RestClientSSL.SSL_KEY_STORE_PASSWORD_KEY)).build(); - logger.debug("RestClientSSL not using default SSL context - setting keystore here."); + logger.info("RestClientSSL not using default SSL context - setting keystore here."); return client; } } diff --git a/common/src/main/java/org/onap/so/client/RestTemplateConfig.java b/common/src/main/java/org/onap/so/client/RestTemplateConfig.java index ad833208dc..14556f1211 100644 --- a/common/src/main/java/org/onap/so/client/RestTemplateConfig.java +++ b/common/src/main/java/org/onap/so/client/RestTemplateConfig.java @@ -20,8 +20,10 @@ package org.onap.so.client; +import org.onap.so.logging.jaxrs.filter.SpringClientFilter; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.http.client.BufferingClientHttpRequestFactory; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.web.client.RestTemplate; @@ -30,6 +32,9 @@ public class RestTemplateConfig { @Bean public RestTemplate restTemplate() { - return new RestTemplate( new HttpComponentsClientHttpRequestFactory()); + RestTemplate restTemplate = new RestTemplate(); + restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory())); + restTemplate.getInterceptors().add(new SpringClientFilter()); + return restTemplate; } } diff --git a/common/src/main/java/org/onap/so/logger/LogConstants.java b/common/src/main/java/org/onap/so/logger/LogConstants.java new file mode 100644 index 0000000000..ea3c8e2c4a --- /dev/null +++ b/common/src/main/java/org/onap/so/logger/LogConstants.java @@ -0,0 +1,26 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 ONAP - SO + * ================================================================================ + * 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.so.logger; + +public class LogConstants { + public static final String TARGET_ENTITY_HEADER="X-Target-Entity"; + public static final String UNKNOWN_TARGET_ENTITY="Unknown-Target-Entity"; +} diff --git a/common/src/main/java/org/onap/so/logger/MsoLogger.java b/common/src/main/java/org/onap/so/logger/MsoLogger.java index 94ffa71169..c4fba671bb 100644 --- a/common/src/main/java/org/onap/so/logger/MsoLogger.java +++ b/common/src/main/java/org/onap/so/logger/MsoLogger.java @@ -207,30 +207,9 @@ public class MsoLogger { private MsoLogger(MsoLogger.Catalog cat, Class<?> clazz) { this.logger = LoggerFactory.getLogger(clazz); this.auditLogger = LoggerFactory.getLogger("AUDIT"); - this.metricsLogger = LoggerFactory.getLogger("METRIC"); - MsoLogger.initialization(); + this.metricsLogger = LoggerFactory.getLogger("METRIC"); setDefaultLogCatalog(cat); } - - private static synchronized void initialization() { - if (instanceUUID == null || ("").equals(instanceUUID)) { - instanceUUID = getInstanceUUID(); - } - - if (serverIP == null || serverName == null || ("").equals(serverIP) || ("").equals(serverName)) { - try { - InetAddress server = InetAddress.getLocalHost(); - serverIP = server.getHostAddress(); - serverName = server.getHostName(); - } catch (UnknownHostException e) { - initLOGGER.error("Could not get local hostname", e); - serverIP = ""; - serverName = ""; - } - } - } - - public static MsoLogger getMsoLogger(MsoLogger.Catalog cat, Class<?> clazz) { return new MsoLogger(cat,clazz); diff --git a/common/src/main/java/org/onap/so/logging/jaxrs/filter/JaxRsClientLogging.java b/common/src/main/java/org/onap/so/logging/jaxrs/filter/JaxRsClientLogging.java index 49dc71e773..6c2a96c87d 100644 --- a/common/src/main/java/org/onap/so/logging/jaxrs/filter/JaxRsClientLogging.java +++ b/common/src/main/java/org/onap/so/logging/jaxrs/filter/JaxRsClientLogging.java @@ -64,7 +64,7 @@ public class JaxRsClientLogging implements ClientRequestFilter,ClientResponseFil private static Logger logger = LoggerFactory.getLogger(JaxRsClientLogging.class); public void setTargetService(TargetEntity targetEntity){ - MDC.put("TargetEntity", targetEntity.toString()); + MDC.put(ONAPLogConstants.MDCs.TARGET_ENTITY, targetEntity.toString()); } @Override @@ -90,7 +90,7 @@ public class JaxRsClientLogging implements ClientRequestFilter,ClientResponseFil MDC.put(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME, clientRequest.getUri().toString()); MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.INPROGRESS.toString()); setInvocationId(); - MDC.put("TargetEntity",MDC.get("TargetEntity")); + MDC.put(ONAPLogConstants.MDCs.TARGET_ENTITY,MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY)); } private String extractRequestID(ClientRequestContext clientRequest) { @@ -123,7 +123,7 @@ public class JaxRsClientLogging implements ClientRequestFilter,ClientResponseFil MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, String.valueOf(responseContext.getStatus())); MDC.put(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION,getStringFromInputStream(responseContext)); MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, statusCode); - logger.info(MarkerFactory.getMarker("INVOKE_RETURN"), "InvokeReturn"); + logger.info(ONAPLogConstants.Markers.INVOKE_RETURN, "InvokeReturn"); clearClientMDCs(); } catch ( Exception e) { logger.warn("Error in outgoing JAX-RS Inteceptor", e); @@ -136,6 +136,10 @@ public class JaxRsClientLogging implements ClientRequestFilter,ClientResponseFil MDC.remove(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE); MDC.remove(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION); MDC.remove(ONAPLogConstants.MDCs.RESPONSE_CODE); + MDC.remove(ONAPLogConstants.MDCs.TARGET_ENTITY); + MDC.remove(ONAPLogConstants.MDCs.PARTNER_NAME); + MDC.remove(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME); + MDC.remove(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP); } private static String getStringFromInputStream(ClientResponseContext clientResponseContext) { diff --git a/common/src/main/java/org/onap/so/logging/jaxrs/filter/JaxRsFilterLogging.java b/common/src/main/java/org/onap/so/logging/jaxrs/filter/JaxRsFilterLogging.java index 7d02136860..85a6498748 100644 --- a/common/src/main/java/org/onap/so/logging/jaxrs/filter/JaxRsFilterLogging.java +++ b/common/src/main/java/org/onap/so/logging/jaxrs/filter/JaxRsFilterLogging.java @@ -76,7 +76,7 @@ public class JaxRsFilterLogging implements ContainerRequestFilter,ContainerRespo mdcSetup.setClientIPAddress(httpServletRequest); mdcSetup.setInstanceUUID(); mdcSetup.setEntryTimeStamp(); - MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, "INPROGRESS"); + MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.INPROGRESS.toString()); logger.info(ONAPLogConstants.Markers.ENTRY, "Entering"); } catch (Exception e) { logger.warn("Error in incoming JAX-RS Inteceptor", e); @@ -163,6 +163,16 @@ public class JaxRsFilterLogging implements ContainerRequestFilter,ContainerRespo MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, containerRequest.getUriInfo().getPath()); } + private void clearClientMDCs() { + MDC.remove(ONAPLogConstants.MDCs.INVOCATION_ID); + MDC.remove(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION); + MDC.remove(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE); + MDC.remove(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION); + MDC.remove(ONAPLogConstants.MDCs.RESPONSE_CODE); + MDC.remove(ONAPLogConstants.MDCs.TARGET_ENTITY); + MDC.remove(ONAPLogConstants.MDCs.PARTNER_NAME); + MDC.remove(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME); + } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientLogResponseTest.java b/common/src/main/java/org/onap/so/logging/jaxrs/filter/MDCTaskDecorator.java index e28c465437..cc2ccb5c2e 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/sdnc/SDNCClientLogResponseTest.java +++ b/common/src/main/java/org/onap/so/logging/jaxrs/filter/MDCTaskDecorator.java @@ -18,26 +18,25 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.client.sdnc; +package org.onap.so.logging.jaxrs.filter; -import static org.junit.Assert.*; +import java.util.Map; -import java.util.LinkedHashMap; -import java.util.Optional; +import org.slf4j.MDC; +import org.springframework.core.task.TaskDecorator; -import org.junit.Test; - -public class SDNCClientLogResponseTest { - - private SDNCClient sdncClient = new SDNCClient(); - - @Test - public void logSDNCResponseTest() { - LinkedHashMap<String, String> output = new LinkedHashMap<>(); - output.put("response-code", "404"); - output.put("response-message", "not found"); - Optional<String> response = sdncClient.logSDNCResponse(output); - assertEquals(true, response.isPresent()); - assertEquals("{\"response-code\":\"404\",\"response-message\":\"not found\"}",response.get()); - } -} +public class MDCTaskDecorator implements TaskDecorator { + + @Override + public Runnable decorate(Runnable runnable) { + Map<String, String> contextMap = MDC.getCopyOfContextMap(); + return () -> { + try { + MDC.setContextMap(contextMap); + runnable.run(); + } finally { + MDC.clear(); + } + }; + } +}
\ No newline at end of file diff --git a/common/src/main/java/org/onap/so/logging/jaxrs/filter/SpringClientFilter.java b/common/src/main/java/org/onap/so/logging/jaxrs/filter/SpringClientFilter.java index 6af7a916d0..cecef1945b 100644 --- a/common/src/main/java/org/onap/so/logging/jaxrs/filter/SpringClientFilter.java +++ b/common/src/main/java/org/onap/so/logging/jaxrs/filter/SpringClientFilter.java @@ -20,8 +20,12 @@ package org.onap.so.logging.jaxrs.filter; +import org.onap.logging.ref.slf4j.ONAPLogConstants; +import org.onap.so.logger.LogConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.slf4j.MDC; +import org.springframework.http.HttpHeaders; import org.springframework.http.HttpRequest; import org.springframework.http.client.ClientHttpRequestExecution; import org.springframework.http.client.ClientHttpRequestInterceptor; @@ -30,20 +34,31 @@ import org.springframework.util.StreamUtils; import java.io.IOException; import java.nio.charset.Charset; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.util.List; +import java.util.UUID; +import javax.ws.rs.core.Response; public class SpringClientFilter implements ClientHttpRequestInterceptor { private final Logger log = LoggerFactory.getLogger(this.getClass()); + + private static final String TRACE = "trace-#"; + private static final String SO = "SO"; @Override public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException { - logRequest(request, body); + processRequest(request, body); ClientHttpResponse response = execution.execute(request, body); - logResponse(response); + processResponse(response); return response; } - private void logRequest(HttpRequest request, byte[] body) throws IOException { + private void processRequest(HttpRequest request, byte[] body) throws IOException { + setupHeaders(request); + setupMDC(request); if (log.isDebugEnabled()) { log.debug("===========================request begin================================================"); log.debug("URI : {}", request.getURI()); @@ -53,8 +68,60 @@ public class SpringClientFilter implements ClientHttpRequestInterceptor { log.debug("==========================request end================================================"); } } + + private void setupHeaders(HttpRequest clientRequest) { + HttpHeaders headers = clientRequest.getHeaders(); + headers.add(ONAPLogConstants.Headers.REQUEST_ID, extractRequestID(clientRequest)); + headers.add(ONAPLogConstants.Headers.INVOCATION_ID, MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID)); + headers.add(ONAPLogConstants.Headers.PARTNER_NAME, SO); + } + + private String extractRequestID(HttpRequest clientRequest) { + String requestId = MDC.get(ONAPLogConstants.MDCs.REQUEST_ID); + if(requestId == null || requestId.isEmpty() || requestId.equals(TRACE)){ + requestId = UUID.randomUUID().toString(); + log.warn("Could not Find Request ID Generating New One: {}",clientRequest.getURI()); + } + return requestId; + } + + private void setupMDC(HttpRequest clientRequest) { + MDC.put(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP, ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT)); + MDC.put(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME, clientRequest.getURI().toString()); + MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.INPROGRESS.toString()); + setInvocationId(); + MDC.put(ONAPLogConstants.MDCs.TARGET_ENTITY,extractTargetEntity(clientRequest)); + } + + private String extractTargetEntity(HttpRequest clientRequest) { + HttpHeaders headers = clientRequest.getHeaders(); + String headerTargetEntity = null; + List<String> headerTargetEntityList = headers.get(LogConstants.TARGET_ENTITY_HEADER); + if(headerTargetEntityList!= null && !headerTargetEntityList.isEmpty()) + headerTargetEntity = headerTargetEntityList.get(0); + String targetEntity = MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY); + if(targetEntity != null && + !targetEntity.isEmpty() ){ + return targetEntity; + }else if(headerTargetEntity != null && + !headerTargetEntity.isEmpty()){ + targetEntity = headerTargetEntity; + }else{ + targetEntity = LogConstants.UNKNOWN_TARGET_ENTITY; + log.warn("Could not Target Entity: {}",clientRequest.getURI()); + } + return targetEntity; + } + + private void setInvocationId() { + String invocationId = MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID); + if(invocationId == null || invocationId.isEmpty()) + invocationId =UUID.randomUUID().toString(); + MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, invocationId); + } + - private void logResponse(ClientHttpResponse response) throws IOException { + private void processResponse(ClientHttpResponse response) throws IOException { if (log.isDebugEnabled()) { log.debug("============================response begin=========================================="); log.debug("Status code : {}", response.getStatusCode()); @@ -63,5 +130,28 @@ public class SpringClientFilter implements ClientHttpRequestInterceptor { log.debug("Response body: {}", StreamUtils.copyToString(response.getBody(), Charset.defaultCharset())); log.debug("=======================response end================================================="); } + String statusCode; + if(Response.Status.Family.familyOf(response.getRawStatusCode()).equals(Response.Status.Family.SUCCESSFUL)){ + statusCode=ONAPLogConstants.ResponseStatus.COMPLETED.toString(); + }else{ + statusCode=ONAPLogConstants.ResponseStatus.ERROR.toString(); + } + MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, String.valueOf(response.getRawStatusCode())); + MDC.put(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION,""); + MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, statusCode); + log.info(ONAPLogConstants.Markers.INVOKE_RETURN, "InvokeReturn"); + clearClientMDCs(); + } + + private void clearClientMDCs() { + MDC.remove(ONAPLogConstants.MDCs.INVOCATION_ID); + MDC.remove(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION); + MDC.remove(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE); + MDC.remove(ONAPLogConstants.MDCs.RESPONSE_DESCRIPTION); + MDC.remove(ONAPLogConstants.MDCs.RESPONSE_CODE); + MDC.remove(ONAPLogConstants.MDCs.TARGET_ENTITY); + MDC.remove(ONAPLogConstants.MDCs.PARTNER_NAME); + MDC.remove(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME); + MDC.remove(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP); } } diff --git a/common/src/main/java/org/onap/so/logging/spring/interceptor/LoggingInterceptor.java b/common/src/main/java/org/onap/so/logging/spring/interceptor/LoggingInterceptor.java index 194a445ce2..4084ad3ff0 100644 --- a/common/src/main/java/org/onap/so/logging/spring/interceptor/LoggingInterceptor.java +++ b/common/src/main/java/org/onap/so/logging/spring/interceptor/LoggingInterceptor.java @@ -45,7 +45,7 @@ public class LoggingInterceptor extends HandlerInterceptorAdapter { Logger logger = LoggerFactory.getLogger(LoggingInterceptor.class); @Autowired - MDCSetup mdcSetup; + private MDCSetup mdcSetup; @Context private Providers providers; @@ -53,7 +53,8 @@ public class LoggingInterceptor extends HandlerInterceptorAdapter { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { - Map<String, String> headers = Collections.list(((HttpServletRequest) request).getHeaderNames()) + + Map<String, String> headers = Collections.list((request).getHeaderNames()) .stream() .collect(Collectors.toMap(h -> h, request::getHeader)); setRequestId(headers); @@ -64,12 +65,27 @@ public class LoggingInterceptor extends HandlerInterceptorAdapter { mdcSetup.setEntryTimeStamp(); mdcSetup.setInstanceUUID(); mdcSetup.setServerFQDN(); - MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, "INPROGRESS"); + MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.INPROGRESS.toString()); logger.info(ONAPLogConstants.Markers.ENTRY, "Entering"); + if (logger.isDebugEnabled()) + logRequestInformation(request); return true; } - @Override + protected void logRequestInformation(HttpServletRequest request) { + Map<String, String> headers = Collections.list((request).getHeaderNames()) + .stream() + .collect(Collectors.toMap(h -> h, request::getHeader)); + + logger.debug("===========================request begin================================================"); + logger.debug("URI : {}", request.getRequestURI()); + logger.debug("Method : {}", request.getMethod()); + logger.debug("Headers : {}", headers); + logger.debug("==========================request end================================================"); + + } + + @Override public void postHandle( HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { @@ -80,7 +96,7 @@ public class LoggingInterceptor extends HandlerInterceptorAdapter { MDC.clear(); } - private void setResponseStatusCode(HttpServletResponse response) { + protected void setResponseStatusCode(HttpServletResponse response) { String statusCode; if(Response.Status.Family.familyOf(response.getStatus()).equals(Response.Status.Family.SUCCESSFUL)){ statusCode=ONAPLogConstants.ResponseStatus.COMPLETED.toString(); @@ -90,26 +106,26 @@ public class LoggingInterceptor extends HandlerInterceptorAdapter { MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, statusCode); } - private void setServiceName(HttpServletRequest request) { + protected void setServiceName(HttpServletRequest request) { MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, request.getRequestURI()); } - private void setRequestId(Map<String, String> headers) { - String requestId=headers.get(ONAPLogConstants.Headers.REQUEST_ID); + protected void setRequestId(Map<String, String> headers) { + String requestId=headers.get(ONAPLogConstants.Headers.REQUEST_ID.toLowerCase()); if(requestId == null || requestId.isEmpty()) - requestId = UUID.randomUUID().toString(); + requestId = UUID.randomUUID().toString(); MDC.put(ONAPLogConstants.MDCs.REQUEST_ID,requestId); } - private void setInvocationId(Map<String, String> headers) { - String invocationId = headers.get(ONAPLogConstants.Headers.INVOCATION_ID); + protected void setInvocationId(Map<String, String> headers) { + String invocationId = headers.get(ONAPLogConstants.Headers.INVOCATION_ID.toLowerCase()); if(invocationId == null || invocationId.isEmpty()) invocationId =UUID.randomUUID().toString(); MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, invocationId); } - private void setMDCPartnerName(Map<String, String> headers) { - String partnerName=headers.get(ONAPLogConstants.Headers.PARTNER_NAME); + protected void setMDCPartnerName(Map<String, String> headers) { + String partnerName=headers.get(ONAPLogConstants.Headers.PARTNER_NAME.toLowerCase()); if(partnerName == null || partnerName.isEmpty()) partnerName = ""; MDC.put(ONAPLogConstants.MDCs.PARTNER_NAME,partnerName); 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)); diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java index e29d88cb89..84e4156efa 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java @@ -27,6 +27,7 @@ import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization; import org.onap.so.db.catalog.beans.ControllerSelectionReference; import org.onap.so.db.catalog.beans.CvnfcCustomization; +import org.onap.so.db.catalog.beans.ExternalServiceToInternalService; import org.onap.so.db.catalog.beans.InstanceGroup; import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization; import org.onap.so.db.catalog.beans.NetworkRecipe; @@ -47,6 +48,7 @@ import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization; import org.onap.so.db.catalog.beans.macro.NorthBoundRequest; import org.onap.so.db.catalog.beans.macro.OrchestrationFlow; import org.onap.so.db.catalog.beans.macro.RainyDayHandlerStatus; +import org.onap.so.logger.LogConstants; import org.onap.so.logging.jaxrs.filter.SpringClientFilter; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpHeaders; @@ -118,6 +120,8 @@ public class CatalogDbClient { private static final String WORK_STEP = "workStep"; private static final String CLLI = "clli"; private static final String CLOUD_VERSION = "cloudVersion"; + + private static final String TARGET_ENTITY = "SO:CatalogDB"; private String findFirstByModelNameURI = "/findFirstByModelNameOrderByModelVersionDesc"; private String findFirstByServiceModelUUIDAndActionURI = "/findFirstByServiceModelUUIDAndAction"; @@ -255,6 +259,7 @@ public class CatalogDbClient { restTemplate.getInterceptors().add((request, body, execution) -> { request.getHeaders().add(HttpHeaders.AUTHORIZATION, msoAdaptersAuth); + request.getHeaders().add(LogConstants.TARGET_ENTITY_HEADER,TARGET_ENTITY); return execution.execute(request, body); }); }).build().buildClientFactory(); diff --git a/packages/docker/src/main/docker/docker-files/configs/logging/logback-spring.xml b/packages/docker/src/main/docker/docker-files/configs/logging/logback-spring.xml index 5c8894300f..89482fdcda 100644 --- a/packages/docker/src/main/docker/docker-files/configs/logging/logback-spring.xml +++ b/packages/docker/src/main/docker/docker-files/configs/logging/logback-spring.xml @@ -10,32 +10,36 @@ language governing permissions and limitations under the License. ============LICENSE_END========================================================= --> <configuration scan="true" debug="false"> - <contextListener class="org.onap.so.logger.LoggerStartupListener" /> - <include resource="org/springframework/boot/logging/logback/base.xml" /> + <contextListener class="org.onap.so.logger.LoggerStartupListener" /> + <include resource="org/springframework/boot/logging/logback/defaults.xml" /> - <property name="queueSize" value="256" /> - <property name="maxFileSize" value="200MB" /> - <property name="maxHistory" value="30" /> - <property name="totalSizeCap" value="10GB" /> + <property name="queueSize" value="256" /> + <property name="maxFileSize" value="200MB" /> + <property name="maxHistory" value="30" /> + <property name="totalSizeCap" value="10GB" /> - <!-- log file names --> - <property name="errorLogName" value="error" /> - <property name="metricsLogName" value="metrics" /> - <property name="auditLogName" value="audit" /> - <property name="debugLogName" value="debug" /> - <property name="saneLogName" value="sane" /> + <!-- log file names --> + <property name="errorLogName" value="error" /> + <property name="metricsLogName" value="metrics" /> + <property name="auditLogName" value="audit" /> + <property name="debugLogName" value="debug" /> + + <property name="currentTimeStamp" value="%d{"yyyy-MM-dd'T'HH:mm:ss.SSSXXX",UTC}"/> - <property name="errorPattern" - value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestId}|%thread|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%.-5level|%X{ErrorCode}|%X{ErrorDesc}|%msg%n" /> + <property name="errorPattern" + value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestID}|%thread|%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%.-5level|%X{ErrorCode}|%X{ErrorDesc}|%msg%n" /> - <property name="auditPattern" - value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread||%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDesc}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{Timer}|%X{ServerFQDN}|%X{RemoteHost}||||||||%msg%n" /> + <property name="debugPattern" + value="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%X{RequestID}| %logger{50} - %msg%n" /> - <property name="metricPattern" - value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{RequestId}|%X{ServiceInstanceId}|%thread||%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDesc}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{Timer}|%X{ServerFQDN}|%X{RemoteHost}||||%X{TargetVirtualEntity}|||||%msg%n" /> + <property name="auditPattern" + value="%X{EntryTimestamp}|%date{yyyy-MM-dd'T'HH:mm:ss.SSSXXX,UTC}|%X{RequestID}|%X{ServiceInstanceId}|%thread||%X{ServiceName}|%X{PartnerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDesc}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{Timer}|%X{ServerFQDN}|%X{RemoteHost}||||||||%msg%n" /> - <property name="defaultPattern" - value="%nopexception%logger + <property name="metricPattern" + value="%X{InvokeTimestamp}|%date{yyyy-MM-dd'T'HH:mm:ss.SSSXXX,UTC}|%X{RequestID}|%X{ServiceInstanceId}|%thread||%X{ServiceName}|%X{PartnerName}|%X{TargetEntity}|%X{TargetServiceName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDesc}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}|%X{ServerIPAddress}|%X{Timer}|%X{ServerFQDN}|%X{RemoteHost}||||%X{TargetVirtualEntity}|||||%msg%n" /> + + <property name="defaultPattern" + value="%nopexception%logger \t%date{yyyy-MM-dd'T'HH:mm:ss.SSSXXX,UTC} \t%level \t%replace(%replace(%message){'\t','\\\\t'}){'\n','\\\\n'} @@ -45,123 +49,151 @@ \t%thread \t%n" /> - <appender name="Audit" - class="ch.qos.logback.core.rolling.RollingFileAppender"> - <file>${logs_dir:-.}/${auditLogName}.log</file> - <rollingPolicy - class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> - <fileNamePattern>${logs_dir:-.}/${auditLogName}.%d{yyyy-MM-dd}.%i.log.zip - </fileNamePattern> - <maxFileSize>${maxFileSize}</maxFileSize> - <maxHistory>${maxHistory}</maxHistory> - <totalSizeCap>${totalSizeCap}</totalSizeCap> - </rollingPolicy> - <encoder> - <pattern>${auditPattern}</pattern> - </encoder> - </appender> - - <appender name="asyncAudit" class="ch.qos.logback.classic.AsyncAppender"> - <queueSize>256</queueSize> - <appender-ref ref="Audit" /> - </appender> - - <appender name="Metric" - class="ch.qos.logback.core.rolling.RollingFileAppender"> - <file>${logs_dir:-.}/${metricsLogName}.log</file> - <rollingPolicy - class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> - <fileNamePattern>${logs_dir:-.}/${metricsLogName}.%d{yyyy-MM-dd}.%i.log.zip - </fileNamePattern> - <maxFileSize>${maxFileSize}</maxFileSize> - <maxHistory>${maxHistory}</maxHistory> - <totalSizeCap>${totalSizeCap}</totalSizeCap> - </rollingPolicy> - <encoder> - <pattern>${metricPattern}</pattern> - </encoder> - </appender> - - - <appender name="asyncMetric" class="ch.qos.logback.classic.AsyncAppender"> - <queueSize>256</queueSize> - <appender-ref ref="Metric" /> - </appender> - - <appender name="Error" - class="ch.qos.logback.core.rolling.RollingFileAppender"> - <filter class="ch.qos.logback.classic.filter.LevelFilter"> - <level>ERROR</level> - <onMatch>ACCEPT</onMatch> - <onMismatch>DENY</onMismatch> - </filter> - <file>${logs_dir:-.}/${errorLogName}.log</file> - <rollingPolicy - class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> - <fileNamePattern>${logs_dir:-.}/${errorLogName}.%d{yyyy-MM-dd}.%i.log.zip - </fileNamePattern> - <maxFileSize>${maxFileSize}</maxFileSize> - <maxHistory>${maxHistory}</maxHistory> - <totalSizeCap>${totalSizeCap}</totalSizeCap> - </rollingPolicy> - <encoder> - <pattern>${errorPattern}</pattern> - </encoder> - </appender> - - <appender name="asyncError" class="ch.qos.logback.classic.AsyncAppender"> - <queueSize>256</queueSize> - <appender-ref ref="Error" /> - </appender> - - <appender name="Debug" - class="ch.qos.logback.core.rolling.RollingFileAppender"> - <file>${logs_dir:-.}/${debugLogName}.log</file> - <rollingPolicy - class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> - <fileNamePattern>${logs_dir:-.}/${debugLogName}.%d{yyyy-MM-dd}.%i.log.zip - </fileNamePattern> - <maxFileSize>${maxFileSize}</maxFileSize> - <maxHistory>${maxHistory}</maxHistory> - <totalSizeCap>${totalSizeCap}</totalSizeCap> - </rollingPolicy> - <encoder> - <pattern>${defaultPattern}</pattern> - </encoder> - </appender> - - <appender name="asyncDebug" class="ch.qos.logback.classic.AsyncAppender"> - <queueSize>256</queueSize> - <appender-ref ref="Debug" /> - <includeCallerData>true</includeCallerData> - </appender> - - <!-- Spring related loggers --> - <logger name="org.springframework" level="WARN" /> - - <!-- Camunda related loggers --> - <logger name="org.camunda.bpm.engine.jobexecutor.level" level="WARN" /> - <logger - name="org.camunda.bpm.engine.impl.persistence.entity.JobEntity.level" - level="WARN" /> - - <logger name="db.migration" level="DEBUG" /> - <logger name="org.apache.wire" level="DEBUG" /> - <logger name="org.onap" level="DEBUG" /> - <logger name="com.att.ecomp" level="DEBUG" /> - <logger name="org.apache.cxf" level="INFO" /> - - <logger name="AUDIT" level="INFO" additivity="false"> - <appender-ref ref="asyncAudit" /> - </logger> - - <logger name="METRIC" level="INFO" additivity="false"> - <appender-ref ref="asyncMetric" /> - </logger> - - <root level="WARN"> - <appender-ref ref="asyncDebug" /> - <appender-ref ref="asyncError" /> - </root> - -</configuration> + <appender name="Audit" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <filter class="ch.qos.logback.core.filter.EvaluatorFilter"> + <evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator"> + <marker>EXIT</marker> + </evaluator> + <onMismatch>DENY</onMismatch> + <onMatch>ACCEPT</onMatch> + </filter> + <file>${logs_dir:-.}/${auditLogName}.log</file> + <rollingPolicy + class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> + <fileNamePattern>${logs_dir:-.}/${auditLogName}.%d{yyyy-MM-dd}.%i.log.zip + </fileNamePattern> + <maxFileSize>${maxFileSize}</maxFileSize> + <maxHistory>${maxHistory}</maxHistory> + <totalSizeCap>${totalSizeCap}</totalSizeCap> + </rollingPolicy> + <encoder> + <pattern>${auditPattern}</pattern> + </encoder> + </appender> + + <appender name="asyncAudit" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="Audit" /> + </appender> + + <appender name="Metric" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <filter class="ch.qos.logback.core.filter.EvaluatorFilter"> + <evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator"> + <marker>INVOKE_RETURN</marker> + </evaluator> + <onMismatch>DENY</onMismatch> + <onMatch>ACCEPT</onMatch> + </filter> + <file>${logs_dir:-.}/${metricsLogName}.log</file> + <rollingPolicy + class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> + <fileNamePattern>${logs_dir:-.}/${metricsLogName}.%d{yyyy-MM-dd}.%i.log.zip + </fileNamePattern> + <maxFileSize>${maxFileSize}</maxFileSize> + <maxHistory>${maxHistory}</maxHistory> + <totalSizeCap>${totalSizeCap}</totalSizeCap> + </rollingPolicy> + <encoder> + <pattern>${metricPattern}</pattern> + </encoder> + </appender> + + + <appender name="asyncMetric" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="Metric" /> + </appender> + + <appender name="Error" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <filter class="ch.qos.logback.classic.filter.LevelFilter"> + <level>ERROR</level> + <onMatch>ACCEPT</onMatch> + <onMismatch>DENY</onMismatch> + </filter> + <file>${logs_dir:-.}/${errorLogName}.log</file> + <rollingPolicy + class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> + <fileNamePattern>${logs_dir:-.}/${errorLogName}.%d{yyyy-MM-dd}.%i.log.zip + </fileNamePattern> + <maxFileSize>${maxFileSize}</maxFileSize> + <maxHistory>${maxHistory}</maxHistory> + <totalSizeCap>${totalSizeCap}</totalSizeCap> + </rollingPolicy> + <encoder> + <pattern>${errorPattern}</pattern> + </encoder> + </appender> + + <appender name="asyncError" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="Error" /> + </appender> + + <appender name="Debug" + class="ch.qos.logback.core.rolling.RollingFileAppender"> + <filter class="ch.qos.logback.core.filter.EvaluatorFilter"> + <evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator"> + <marker>INVOKE</marker> + <marker>INVOKE_RETURN</marker> + <marker>ENTRY</marker> + <marker>EXIT</marker> + </evaluator> + <onMismatch>ACCEPT</onMismatch> + <onMatch>DENY</onMatch> + </filter> + <file>${logs_dir:-.}/${debugLogName}.log</file> + <rollingPolicy + class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> + <fileNamePattern>${logs_dir:-.}/${debugLogName}.%d{yyyy-MM-dd}.%i.log.zip + </fileNamePattern> + <maxFileSize>${maxFileSize}</maxFileSize> + <maxHistory>${maxHistory}</maxHistory> + <totalSizeCap>${totalSizeCap}</totalSizeCap> + </rollingPolicy> + <encoder> + <pattern>${debugPattern}</pattern> + </encoder> + </appender> + + <appender name="asyncDebug" class="ch.qos.logback.classic.AsyncAppender"> + <queueSize>256</queueSize> + <appender-ref ref="Debug" /> + <includeCallerData>true</includeCallerData> + </appender> + + <!-- Spring related loggers --> + <logger name="org.springframework" level="WARN" /> + <logger + name="org.springframework.security.authentication.dao.DaoAuthenticationProvider" + level="DEBUG" /> + + <!-- Camunda related loggers --> + <logger name="org.camunda.bpm.engine.jobexecutor.level" level="WARN" /> + <logger + name="org.camunda.bpm.engine.impl.persistence.entity.JobEntity.level" + level="WARN" /> + + <logger name="org.apache.wire" level="DEBUG" /> + <logger name="org.onap" level="DEBUG" /> + <logger name="com.att.ecomp" level="DEBUG" /> + <logger name="org.apache.cxf.interceptor" level="DEBUG" /> + + <logger name="AUDIT" level="INFO" additivity="false"> + <appender-ref ref="asyncAudit" /> + </logger> + + <logger name="METRIC" level="INFO" additivity="false"> + <appender-ref ref="asyncMetric" /> + </logger> + + <root level="WARN"> + <appender-ref ref="asyncDebug" /> + <appender-ref ref="asyncError" /> + <appender-ref ref="asyncAudit" /> + <appender-ref ref="asyncMetric" /> + </root> + +</configuration>
\ No newline at end of file diff --git a/packages/docker/src/main/docker/docker-files/scripts/start-jboss-server.sh b/packages/docker/src/main/docker/docker-files/scripts/start-jboss-server.sh deleted file mode 100755 index 1a38fff899..0000000000 --- a/packages/docker/src/main/docker/docker-files/scripts/start-jboss-server.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/sh -# Copyright 2015 AT&T Intellectual Properties -############################################################################## -# Script to initialize the chef-repo branch and.chef -# -############################################################################## -# Copy the certificates -echo 'Copying the *.crt provided in /shared folder' -cp --verbose /shared/*.crt /usr/local/share/ca-certificates -update-ca-certificates --fresh - -echo 'Running in JBOSS' -su - jboss - -#Start the chef-solo if mso-docker.json contains some data. -if [ -s /var/berks-cookbooks/${CHEF_REPO_NAME}/environments/mso-docker.json ] -then - echo "mso-docker.json has some configuration, replay the recipes." - chef-solo -c /var/berks-cookbooks/${CHEF_REPO_NAME}/solo.rb -o recipe[mso-config::apih],recipe[mso-config::bpmn],recipe[mso-config::jra] -else - echo "mso-docker.json is empty, do not replay the recipes." -fi - -JBOSS_PIDFILE=/tmp/jboss-standalone.pid -$JBOSS_HOME/bin/standalone.sh -c standalone-full-ha-mso.xml & -JBOSS_PID=$! -# Trap common signals and relay them to the jboss process -trap "kill -HUP $JBOSS_PID" HUP -trap "kill -TERM $JBOSS_PID" INT -trap "kill -QUIT $JBOSS_PID" QUIT -trap "kill -PIPE $JBOSS_PID" PIPE -trap "kill -TERM $JBOSS_PID" TERM -if [ "x$JBOSS_PIDFILE" != "x" ]; then - echo $JBOSS_PID > $JBOSS_PIDFILE -fi -# Wait until the background process exits -WAIT_STATUS=128 -while [ "$WAIT_STATUS" -ge 128 ]; do - wait $JBOSS_PID 2>/dev/null - WAIT_STATUS=$? - if [ "$WAIT_STATUS" -gt 128 ]; then - SIGNAL=`expr $WAIT_STATUS - 128` - SIGNAL_NAME=`kill -l $SIGNAL` - echo "*** JBossAS process ($JBOSS_PID) received $SIGNAL_NAME signal ***" >&2 - fi -done -if [ "$WAIT_STATUS" -lt 127 ]; then - JBOSS_STATUS=$WAIT_STATUS -else - JBOSS_STATUS=0 -fi -if [ "$JBOSS_STATUS" -ne 10 ]; then - # Wait for a complete shudown - wait $JBOSS_PID 2>/dev/null -fi -if [ "x$JBOSS_PIDFILE" != "x" ]; then - grep "$JBOSS_PID" $JBOSS_PIDFILE && rm $JBOSS_PIDFILE -fi |