diff options
author | Steve Smokowski <ss835w@att.com> | 2019-10-16 16:35:43 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-10-16 16:35:43 +0000 |
commit | 9ef64f9b876fec5a4527c6fe73568469f19ad9fd (patch) | |
tree | ba8efd035e1902bf559e91c22cd3189c7221149e /asdc-controller/src/main | |
parent | 6df62b29490fa5119b6dfcb8fbe6092e2adadfef (diff) | |
parent | 419379c6c9ea13db0763519f51043c2c13a76abc (diff) |
Merge "update scheduled tasks to have mdc setup"
Diffstat (limited to 'asdc-controller/src/main')
-rw-r--r-- | asdc-controller/src/main/java/org/onap/so/asdc/ASDCControllerSingleton.java | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/ASDCControllerSingleton.java b/asdc-controller/src/main/java/org/onap/so/asdc/ASDCControllerSingleton.java index e00bb1eb36..ecffb683ca 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/ASDCControllerSingleton.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/ASDCControllerSingleton.java @@ -22,16 +22,21 @@ package org.onap.so.asdc; +import java.security.SecureRandom; import javax.annotation.PreDestroy; +import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.asdc.client.ASDCController; import org.onap.so.asdc.client.exceptions.ASDCControllerException; +import org.onap.so.logger.ErrorCode; +import org.onap.so.logger.ScheduledTasksMDCSetup; +import org.onap.so.utils.Components; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Profile; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; -import java.security.SecureRandom; @Component @@ -42,12 +47,16 @@ public class ASDCControllerSingleton { private final ASDCController asdcController; @Autowired + private ScheduledTasksMDCSetup scheduledMDCSetup; + + @Autowired public ASDCControllerSingleton(final ASDCController asdcController) { this.asdcController = asdcController; } @Scheduled(fixedRate = 50000) public void periodicControllerTask() { + scheduledMDCSetup.mdcSetup(Components.ASDC_CONTROLLER, "periodicControllerTask"); try { final int randomNumber = new SecureRandom().nextInt(Integer.MAX_VALUE); asdcController.setControllerName("mso-controller" + randomNumber); @@ -57,8 +66,11 @@ public class ASDCControllerSingleton { asdcController.initASDC(); } } catch (final ASDCControllerException controllerException) { + scheduledMDCSetup.errorMDCSetup(ErrorCode.UnknownError, controllerException.getMessage()); + MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.ERROR.toString()); logger.error("Exception occurred", controllerException); } + scheduledMDCSetup.exitAndClearMDC(); } @PreDestroy |