Fix DCAE deploy/undeploy 21/46621/1
authorDeterme, Sebastien (sd378r) <sd378r@intl.att.com>
Tue, 8 May 2018 14:30:12 +0000 (16:30 +0200)
committerDeterme, Sebastien (sd378r) <sd378r@intl.att.com>
Tue, 8 May 2018 14:30:12 +0000 (16:30 +0200)
Add configurable timer and attempt for the DCAE GetOperation Status

Issue-ID: CLAMP-159
Change-Id: I537961af135d0197330ec89da12dcff467153311
Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java
src/main/java/org/onap/clamp/clds/service/CldsService.java
src/main/resources/application.properties
src/test/resources/application.properties

index 2ba910a..0ca2850 100644 (file)
@@ -90,6 +90,22 @@ public class DcaeDispatcherServices {
         }\r
     }\r
 \r
+    public String getOperationStatusWithRetry(String operationStatusUrl) throws InterruptedException {\r
+        String operationStatus = "";\r
+        for (int i = 0; i < Integer.valueOf(refProp.getStringValue("dcae.dispatcher.retry.limit")); i++) {\r
+            logger.info("Trying to get Operation status on DCAE for url:" + operationStatusUrl);\r
+            operationStatus = getOperationStatus(operationStatusUrl);\r
+            logger.info("Current Status is:" + operationStatus);\r
+            if (!"processing".equalsIgnoreCase(operationStatus)) {\r
+                return operationStatus;\r
+            } else {\r
+                Thread.sleep(Integer.valueOf(refProp.getStringValue("dcae.dispatcher.retry.interval")));\r
+            }\r
+        }\r
+        logger.warn("Number of attempts on DCAE is over, stopping the getOperationStatus method");\r
+        return operationStatus;\r
+    }\r
+\r
     /**\r
      * Get the Operation Status from a specified URL.\r
      * \r
index 1b76067..592a945 100644 (file)
@@ -849,17 +849,7 @@ public class CldsService extends SecureServiceBase {
             }
             String createNewDeploymentStatusUrl = dcaeDispatcherServices.createNewDeployment(deploymentId,
                     model.getTypeId(), modelProp.getGlobal().getDeployParameters());
-            String operationStatus = "processing";
-            long waitingTime = System.nanoTime() + DCAE_DEPLOY_WAITING_TIME;
-            while ("processing".equalsIgnoreCase(operationStatus)) {
-                if (waitingTime < System.nanoTime()) {
-                    logger.info("Waiting is over for DCAE deployment");
-                    break;
-                }
-                logger.info("Waiting 5s before sending query to DCAE");
-                Thread.sleep(5000);
-                operationStatus = dcaeDispatcherServices.getOperationStatus(createNewDeploymentStatusUrl);
-            }
+            String operationStatus = dcaeDispatcherServices.getOperationStatusWithRetry(createNewDeploymentStatusUrl);
             if ("succeeded".equalsIgnoreCase(operationStatus)) {
                 String artifactName = model.getControlName();
                 if (artifactName != null) {
@@ -904,14 +894,7 @@ public class CldsService extends SecureServiceBase {
         try {
             String operationStatusUndeployUrl = dcaeDispatcherServices.deleteExistingDeployment(model.getDeploymentId(),
                     model.getTypeId());
-            String operationStatus = "processing";
-            long waitingTime = System.nanoTime() + TimeUnit.MINUTES.toNanos(10);
-            while ("processing".equalsIgnoreCase(operationStatus)) {
-                if (waitingTime < System.nanoTime()) {
-                    break;
-                }
-                operationStatus = dcaeDispatcherServices.getOperationStatus(operationStatusUndeployUrl);
-            }
+            String operationStatus = dcaeDispatcherServices.getOperationStatusWithRetry(operationStatusUndeployUrl);
             if ("succeeded".equalsIgnoreCase(operationStatus)) {
                 String artifactName = model.getControlName();
                 if (artifactName != null) {
index d9d69c7..1724818 100644 (file)
@@ -201,6 +201,8 @@ clamp.config.dcae.intentory.retry.limit=3
 \r
 #DCAE Dispatcher Url Properties\r
 clamp.config.dcae.dispatcher.url=http://dcae.api.simpledemo.onap.org:8188\r
+clamp.config.dcae.dispatcher.retry.interval=10000\r
+clamp.config.dcae.dispatcher.retry.limit=10\r
 clamp.config.dcae.header.requestId = X-ECOMP-RequestID\r
 \r
 #Define user permission related parameters, the permission type can be changed but MUST be redefined in clds-users.properties in that case !\r
index 0d206cf..b543af1 100644 (file)
@@ -194,9 +194,13 @@ clamp.config.clds.service.cache.invalidate.after.seconds=120
 \r
 #DCAE Inventory Url Properties\r
 clamp.config.dcae.inventory.url=http://localhost:${docker.http-cache.port.host}\r
+clamp.config.dcae.intentory.retry.interval=10000\r
+clamp.config.dcae.intentory.retry.limit=3\r
 \r
 #DCAE Dispatcher Url Properties\r
 clamp.config.dcae.dispatcher.url=http://localhost:${docker.http-cache.port.host}\r
+clamp.config.dcae.dispatcher.retry.interval=10000\r
+clamp.config.dcae.dispatcher.retry.limit=10\r
 clamp.config.dcae.header.requestId = X-ECOMP-RequestID\r
 \r
 #Define user permission related parameters, the permission type can be changed but MUST be redefined in clds-users.properties in that case !\r