From 342703276a0b5e1a031890010dfae5b5a8ab0d66 Mon Sep 17 00:00:00 2001 From: "Boslet, Cory" Date: Thu, 22 Oct 2020 13:43:15 -0400 Subject: Fixed the lock times and populated error variable Fixed the lock times and populated error variable only on error so it doesnt over write Issue-ID: SO-3330 Signed-off-by: Benjamin, Max (mb388a) Change-Id: I2d9bd05329a2a4c752cd9fc6f740891adb6d8251 --- .../src/main/java/org/onap/so/adapters/tasks/TaskServices.java | 10 +++++----- .../org/onap/so/adapters/tasks/orchestration/PollService.java | 6 +++--- .../onap/so/adapters/tasks/orchestration/RollbackService.java | 2 +- .../org/onap/so/adapters/tasks/orchestration/StackService.java | 2 +- .../main/java/org/onap/so/utils/ExternalTaskServiceUtils.java | 10 ---------- 5 files changed, 10 insertions(+), 20 deletions(-) diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/TaskServices.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/TaskServices.java index b176892192..4e0c4ad8a6 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/TaskServices.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/TaskServices.java @@ -62,13 +62,13 @@ public class TaskServices { public void createtAAIInventory() throws Exception { for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) { ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient(); - client.subscribe("InventoryCreate").lockDuration(externalTaskServiceUtils.getLongLockDuration()) + client.subscribe("InventoryCreate").lockDuration(externalTaskServiceUtils.getLockDurationMedium()) .handler(createInventory::executeExternalTask).open(); } } @PostConstruct - public void auditAAIInventory() throws Exception { + public void deleteAAIInventory() throws Exception { for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) { externalTaskServiceUtils.createExternalTaskClient().subscribe("InventoryDelete") .lockDuration(externalTaskServiceUtils.getLockDurationMedium()) @@ -80,7 +80,7 @@ public class TaskServices { public void openstackInvoker() throws Exception { for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) { ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient(); - client.subscribe("OpenstackAdapterInvoke").lockDuration(externalTaskServiceUtils.getLockDuration()) + client.subscribe("OpenstackAdapterInvoke").lockDuration(externalTaskServiceUtils.getLockDurationShort()) .handler(stackService::executeExternalTask).open(); } } @@ -89,7 +89,7 @@ public class TaskServices { public void openstackPoller() throws Exception { for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) { ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient(); - client.subscribe("OpenstackAdapterPolling").lockDuration(externalTaskServiceUtils.getLockDuration()) + client.subscribe("OpenstackAdapterPolling").lockDuration(externalTaskServiceUtils.getLockDurationMedium()) .handler(pollService::executeExternalTask).open(); } } @@ -98,7 +98,7 @@ public class TaskServices { public void openstackRollback() throws Exception { for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) { ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient(); - client.subscribe("OpenstackAdapterRollback").lockDuration(externalTaskServiceUtils.getLockDuration()) + client.subscribe("OpenstackAdapterRollback").lockDuration(externalTaskServiceUtils.getLockDurationShort()) .handler(rollbackService::executeExternalTask).open(); } } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/PollService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/PollService.java index 9ff50e8644..6a5381cf3e 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/PollService.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/PollService.java @@ -68,7 +68,7 @@ public class PollService extends ExternalTaskUtils { public void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) { mdcSetup.setupMDC(externalTask); - logger.trace("Executing External Task Poll Service"); + logger.debug("Starting External Task Poll Service"); Map variables = new HashMap<>(); MutableBoolean success = new MutableBoolean(); String errorMessage = null; @@ -103,11 +103,11 @@ public class PollService extends ExternalTaskUtils { } } catch (Exception e) { logger.error("Error during External Task Poll Service", e); - errorMessage = e.getMessage(); + errorMessage = e.toString(); + variables.put("openstackAdapterErrorMessage", errorMessage); } variables.put("OpenstackPollSuccess", success.booleanValue()); - variables.put("openstackAdapterErrorMessage", errorMessage); if (success.isTrue()) { externalTaskService.complete(externalTask, variables); logger.debug("The External Task Id: {} Successful", externalTask.getId()); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/RollbackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/RollbackService.java index 15e6ff581d..c25d752cc4 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/RollbackService.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/RollbackService.java @@ -39,7 +39,7 @@ public class RollbackService extends ExternalTaskUtils { public void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) { mdcSetup.setupMDC(externalTask); - logger.trace("Executing External Task Rollback Service"); + logger.debug("Starting External Task Rollback Service"); Map variables = new HashMap<>(); boolean success = false; boolean pollRollbackStatus = false; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/StackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/StackService.java index 5196ffffda..c9fa30d949 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/StackService.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/StackService.java @@ -91,7 +91,7 @@ public class StackService extends ExternalTaskUtils { Map variables = new HashMap<>(); mdcSetup.setupMDC(externalTask); String xmlRequest = externalTask.getVariable("openstackAdapterTaskRequest"); - logger.debug("Executing External Task Stack Service. {}", xmlRequest); + logger.debug("Starting External Task Stack Service. {}", xmlRequest); MutableBoolean success = new MutableBoolean(); MutableBoolean backout = new MutableBoolean(); String response = ""; diff --git a/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java b/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java index c601b88ae5..1a8307e8bc 100644 --- a/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java +++ b/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java @@ -64,16 +64,6 @@ public class ExternalTaskServiceUtils { return Integer.parseInt(env.getProperty("workflow.topics.maxClients", "10")); } - public Long getLockDuration() { - Long lockDuration = Long.parseLong(env.getProperty("mso.audit.lock-time", "60000")); - return lockDuration; - } - - public Long getLongLockDuration() { - Long lockDuration = Long.parseLong(env.getProperty("mso.long.lock-time", "600000")); - return lockDuration; - } - @ScheduledLogging @Scheduled(fixedDelay = 30000) public void checkAllClientsActive() { -- cgit 1.2.3-korg