summaryrefslogtreecommitdiffstats
path: root/adapters
diff options
context:
space:
mode:
authorPlummer, Brittany <brittany.plummer@att.com>2019-10-11 09:06:55 -0400
committerBenjamin, Max (mb388a) <mb388a@att.com>2019-10-14 09:06:42 -0400
commit419379c6c9ea13db0763519f51043c2c13a76abc (patch)
tree40bdd37c7d3cf37c83d08453771f101867877abf /adapters
parent621dd5b5b4f0e5058c86fe84926deb11e883b36c (diff)
update scheduled tasks to have mdc setup
Added MDCSetup for Scheduled Tasks Added tests for ScheduledTasksMDCSetup Added required fields for audit log and markers Issue-ID: SO-2444 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: I05e8032ed934abd76d898559c51230761d36b78c
Diffstat (limited to 'adapters')
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/CatalogDBApplication.java2
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java13
2 files changed, 13 insertions, 2 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/CatalogDBApplication.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/CatalogDBApplication.java
index 6fb65ca87e..e5b51f72c9 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/CatalogDBApplication.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/CatalogDBApplication.java
@@ -28,7 +28,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication(scanBasePackages = {"org.onap.so.adapters.catalogdb", "org.onap.so.db.catalog.client",
"org.onap.so.logging.jaxrs.filter", "org.onap.so.logging.spring.interceptor", "org.onap.so.client",
- "org.onap.so.configuration", "org.onap.so.db", "org.onap.logging.filter"})
+ "org.onap.so.configuration", "org.onap.so.db", "org.onap.logging.filter", "org.onap.so.logger"})
@EnableJpaRepositories("org.onap.so.db.catalog.data.repository")
@EntityScan("org.onap.so.db.catalog.beans")
@EnableScheduling
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java
index 8c4150cd50..4ec4cc7eb5 100644
--- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/ArchiveInfraRequestsScheduler.java
@@ -27,15 +27,19 @@ import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
-import org.onap.so.logger.LoggingAnchor;
+import org.onap.logging.filter.base.ONAPComponents;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.db.request.beans.ArchivedInfraRequests;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.data.repository.ArchivedInfraRequestsRepository;
import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository;
import org.onap.so.logger.ErrorCode;
+import org.onap.so.logger.LoggingAnchor;
import org.onap.so.logger.MessageEnum;
+import org.onap.so.logger.ScheduledTasksMDCSetup;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.PageRequest;
@@ -52,6 +56,9 @@ public class ArchiveInfraRequestsScheduler {
private InfraActiveRequestsRepository infraActiveRepo;
@Autowired
private ArchivedInfraRequestsRepository archivedInfraRepo;
+ @Autowired
+ private ScheduledTasksMDCSetup scheduledMDCSetup;
+
@Value("${mso.infra-requests.archived.period}")
private int archivedPeriod;
@@ -62,6 +69,7 @@ public class ArchiveInfraRequestsScheduler {
@Scheduled(cron = "0 0 1 * * ?")
@SchedulerLock(name = "archiveInfraRequestsScheduler")
public void infraRequestsScheduledTask() {
+ scheduledMDCSetup.mdcSetup(ONAPComponents.REQUEST_DB, "infraRequestsScheduledTask");
logger.debug("Start of archiveInfraRequestsScheduler");
Date currentDate = new Date();
@@ -89,6 +97,7 @@ public class ArchiveInfraRequestsScheduler {
} while (!requestsByStartTime.isEmpty());
logger.debug("End of archiveInfraRequestsScheduler");
+ scheduledMDCSetup.exitAndClearMDC();
}
protected void archiveInfraRequests(List<InfraActiveRequests> requests) {
@@ -146,6 +155,8 @@ public class ArchiveInfraRequestsScheduler {
newArchivedReqs.add(archivedInfra);
oldInfraReqs.add(iar);
} catch (Exception e) {
+ scheduledMDCSetup.errorMDCSetup(ErrorCode.UnknownError, e.getMessage());
+ MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.ERROR.toString());
logger.error(LoggingAnchor.TWO, MessageEnum.RA_GENERAL_EXCEPTION.toString(),
ErrorCode.UnknownError.getValue(), e);
}