Changed certain external task to use the long 00/110100/1
authorBoslet, Cory <cory.boslet@att.com>
Fri, 10 Jul 2020 20:01:27 +0000 (16:01 -0400)
committerBenjamin, Max (mb388a) <mb388a@att.com>
Fri, 10 Jul 2020 20:01:27 +0000 (16:01 -0400)
Changed certain external task to use the long lock time.

Issue-ID: SO-3049
Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com>
Change-Id: If074ee1467fe1bac79892a885c4efddf87415b8a

adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryService.java
adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/TaskServices.java
adapters/mso-openstack-adapters/src/test/resources/application-test.yaml
common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java

index 4d8c74d..4e5e880 100644 (file)
@@ -44,7 +44,7 @@ public class DeleteInventoryService {
     public void auditAAIInventory() throws Exception {
         for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) {
             externalTaskServiceUtils.createExternalTaskClient().subscribe("InventoryDelete")
-                    .lockDuration(Long.parseLong(env.getProperty("mso.audit.lock-time", "60000")))
+                    .lockDuration(externalTaskServiceUtils.getLockDurationMedium())
                     .handler(deleteInventory::executeExternalTask).open();
         }
     }
index db9a7ce..d4a4bb7 100644 (file)
@@ -70,7 +70,7 @@ public class TaskServices {
     public void auditAddAAIInventory() throws Exception {
         for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) {
             ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient();
-            client.subscribe("InventoryAddAudit").lockDuration(externalTaskServiceUtils.getLockDuration())
+            client.subscribe("InventoryAddAudit").lockDuration(externalTaskServiceUtils.getLockDurationLong())
                     .handler(auditCreateStack::executeExternalTask).open();
         }
     }
@@ -79,7 +79,7 @@ public class TaskServices {
     public void auditDeleteAAIInventory() throws Exception {
         for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) {
             ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient();
-            client.subscribe("InventoryDeleteAudit").lockDuration(externalTaskServiceUtils.getLockDuration())
+            client.subscribe("InventoryDeleteAudit").lockDuration(externalTaskServiceUtils.getLockDurationLong())
                     .handler(auditDeleteStack::executeExternalTask).open();
         }
     }
index 42955c3..ac45f85 100644 (file)
@@ -64,8 +64,6 @@ mso:
   adapters:
     requestDb:
       endpoint: http://localhost:${wiremock.server.port}
-  audit:
-    lock-time: 240000
   logPath: logs
   msb-ip: localhost
   msb-port: ${wiremock.server.port}
index 7ae7de2..fff82ea 100644 (file)
@@ -22,8 +22,16 @@ public class ExternalTaskServiceUtils {
     @Autowired
     public Environment env;
 
-    protected Set<ExternalTaskClient> taskClients = ConcurrentHashMap.newKeySet();
 
+    private static final long DEFAULT_LOCK_DURATION_LONG = 2700000;
+    private static final long DEFAULT_LOCK_DURATION_MEDIUM = 900000;
+    private static final long DEFAULT_LOCK_DURATION_SHORT = 300000;
+
+    private static final String LOCK_DURATION_LONG = "mso.workflow.topics.lockDurationLong";
+    private static final String LOCK_DURATION_MEDIUM = "mso.workflow.topics.lockDurationMedium";
+    private static final String LOCK_DURATION_SHORT = "mso.workflow.topics.lockDurationShort";
+
+    protected Set<ExternalTaskClient> taskClients = ConcurrentHashMap.newKeySet();
 
     private static final Logger logger = LoggerFactory.getLogger(ExternalTaskServiceUtils.class);
 
@@ -74,4 +82,16 @@ public class ExternalTaskServiceUtils {
         return taskClients;
     }
 
+    public long getLockDurationLong() {
+        return env.getProperty(LOCK_DURATION_LONG, Long.class, new Long(DEFAULT_LOCK_DURATION_LONG));
+    }
+
+    public long getLockDurationMedium() {
+        return env.getProperty(LOCK_DURATION_MEDIUM, Long.class, new Long(DEFAULT_LOCK_DURATION_MEDIUM));
+    }
+
+    public long getLockDurationShort() {
+        return env.getProperty(LOCK_DURATION_SHORT, Long.class, new Long(DEFAULT_LOCK_DURATION_SHORT));
+    }
+
 }