Code improvement 31/7831/5
authorxg353y <xg353y@intl.att.com>
Thu, 17 Aug 2017 12:10:26 +0000 (14:10 +0200)
committerxg353y <xg353y@intl.att.com>
Thu, 17 Aug 2017 13:55:26 +0000 (15:55 +0200)
Improve logging message; Introduce timeout for deploy/undeploy CL;
Update allowed actions for deploy/undeploy/update action.

Issue-id: CLAMP-43
Change-Id: Ic876e835447cc495d4ca42d9401ee4bd503d5db7
Signed-off-by: xg353y <xg353y@intl.att.com>
src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java
src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java
src/main/java/org/onap/clamp/clds/client/req/SdcReq.java
src/main/java/org/onap/clamp/clds/model/CldsModel.java
src/main/java/org/onap/clamp/clds/service/CldsService.java
src/main/java/org/onap/clamp/clds/util/LoggingUtils.java
src/main/resources/META-INF/processes.xml
src/main/resources/clds/globalClds.properties

index 343391e..e5144bf 100644 (file)
@@ -129,25 +129,26 @@ public class DcaeDispatcherServices {
      */\r
     public String getOperationStatus(String statusUrl) throws Exception {\r
 \r
-        String opStatus = null;\r
+        //Assigning processing status to monitor operation status further\r
+        String opStatus = "processing";\r
         InputStream in = null;\r
         try {\r
             URL obj = new URL(statusUrl);\r
             HttpsURLConnection conn = (HttpsURLConnection) obj.openConnection();\r
             conn.setRequestMethod("GET");\r
             int responseCode = conn.getResponseCode();\r
-            logger.debug("response code " + responseCode);\r
-            in = conn.getInputStream();\r
-            String res = new BufferedReader(new InputStreamReader(in)).lines().collect(Collectors.joining("\n"));\r
-            JSONParser parser = new JSONParser();\r
-            Object obj0 = parser.parse(res);\r
-            JSONObject jsonObj = (JSONObject) obj0;\r
-            String operationType = (String) jsonObj.get("operationType");\r
-            String status = (String) jsonObj.get("status");\r
-            logger.debug("Operation Type " + operationType);\r
-            logger.debug("Status " + status);\r
-            opStatus = status;\r
-\r
+            logger.debug("Deployment operation status response code - " + responseCode);\r
+            if(responseCode == 200){\r
+                in = conn.getInputStream();\r
+                String res = new BufferedReader(new InputStreamReader(in)).lines().collect(Collectors.joining("\n"));\r
+                JSONParser parser = new JSONParser();\r
+                Object obj0 = parser.parse(res);\r
+                JSONObject jsonObj = (JSONObject) obj0;\r
+                String operationType = (String) jsonObj.get("operationType");\r
+                String status = (String) jsonObj.get("status");\r
+                logger.debug("Operation Type - " + operationType + ", Status " + status);\r
+                opStatus = status;\r
+            }\r
         } catch (Exception e) {\r
             logger.debug(e.getClass().getName() + " " + e.getMessage());\r
             logger.debug(e.getMessage()\r
index a009f06..df86977 100644 (file)
@@ -108,7 +108,7 @@ public class SdcCatalogServices {
         } catch (Exception e) {
             LoggingUtils.setResponseContext("900", "Get sdc services failed", this.getClass().getName());
             LoggingUtils.setErrorContext("900", "Get sdc services error");
-            logger.error("not able to get any service information from sdc for uuid:" + uuid);
+            logger.error("not able to get any service information from sdc for uuid:" + uuid + " , exception is - " + e.getMessage());
         }
         LoggingUtils.setTimeContext(startTime, new Date());
         LoggingUtils.setTargetContext("SDC", "Get Services");
index 8a31a3b..08e196b 100644 (file)
@@ -143,6 +143,7 @@ public class SdcReq {
 
         // "closedLoopControlName":"ClosedLoop-FRWL-SIG-0538e6f2-8c1b-4656-9999-3501b3c59ad7",
         configurationObjectNode.put("closedLoopControlName", prop.getControlName());
+        configurationObjectNode.put("messageReaderConsumerGroup", prop.getModelName());
         configurationObjectNode.set("serviceConfigurations", serviceConf);
         propsObject.put("deployment_JSON", deployJsonNode.toString());
         String blueprint = yaml.dump(loadedYaml);
index e34f47d..59db9b5 100644 (file)
@@ -243,17 +243,15 @@ public class CldsModel {
                 permittedActionCd = Arrays.asList(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_RESUBMIT);
                 break;
             case CldsEvent.ACTION_UNDEPLOY:
-                permittedActionCd = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_DEPLOY);
+                permittedActionCd = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_RESUBMIT);
                 break;
             case CldsEvent.ACTION_DEPLOY:
-                permittedActionCd = Arrays.asList(CldsEvent.ACTION_UNDEPLOY, CldsEvent.ACTION_UPDATE,
-                        CldsEvent.ACTION_STOP);
+                permittedActionCd = Arrays.asList(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_UNDEPLOY, CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_STOP);
                 break;
             case CldsEvent.ACTION_RESTART:
             case CldsEvent.ACTION_UPDATE:
                 // for 1702 delete is not currently implemented
-                permittedActionCd = Arrays.asList(CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_STOP,
-                        CldsEvent.ACTION_UNDEPLOY);
+                permittedActionCd = Arrays.asList(CldsEvent.ACTION_DEPLOY, CldsEvent.ACTION_UPDATE, CldsEvent.ACTION_STOP, CldsEvent.ACTION_UNDEPLOY);
                 break;
             case CldsEvent.ACTION_DELETE:
                 if (getCurrentActionStateCd().equals(CldsEvent.ACTION_STATE_SENT)) {
index aaeb03f..509535c 100644 (file)
@@ -32,6 +32,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 import java.util.UUID;
+import java.util.concurrent.TimeUnit;
 
 import javax.annotation.PostConstruct;
 import javax.ws.rs.Consumes;
@@ -916,7 +917,12 @@ public class CldsService extends SecureServiceBase {
         String createNewDeploymentStatusUrl = dcaeDispatcherServices.createNewDeployment(deploymentId,
                 model.getTypeId());
         String operationStatus = "processing";
+        long waitingTime = System.nanoTime() + TimeUnit.MINUTES.toNanos(10);
         while (operationStatus.equalsIgnoreCase("processing")) {
+            //Break the loop if waiting for more than 10 mins
+            if(waitingTime < System.nanoTime()){
+                break;
+            }
             operationStatus = dcaeDispatcherServices.getOperationStatus(createNewDeploymentStatusUrl);
         }
         if (operationStatus != null && operationStatus.equalsIgnoreCase("succeeded")) {
@@ -956,7 +962,11 @@ public class CldsService extends SecureServiceBase {
         String operationStatusUndeployUrl = dcaeDispatcherServices.deleteExistingDeployment(model.getDeploymentId(),
                 model.getTypeId());
         String operationStatus = "processing";
+        long waitingTime = System.nanoTime() + TimeUnit.MINUTES.toNanos(10);
         while (operationStatus.equalsIgnoreCase("processing")) {
+            if(waitingTime < System.nanoTime()){
+                break;
+            }
             operationStatus = dcaeDispatcherServices.getOperationStatus(operationStatusUndeployUrl);
         }
         if (operationStatus != null && operationStatus.equalsIgnoreCase("succeeded")) {
index c474006..8ceaa3d 100644 (file)
@@ -35,21 +35,21 @@ public class LoggingUtils {
 \r
     /**\r
      * Set request related logging variables in thread local data via MDC\r
-     * \r
+     *\r
      * @param service\r
      *            Service Name of API (ex. "PUT template")\r
      * @param partner\r
      *            Partner name (client or user invoking API)\r
      */\r
     public static void setRequestContext(String service, String partner) {\r
-        MDC.put("RequestId", "clds-" + UUID.randomUUID().toString());\r
+        MDC.put("RequestId",  UUID.randomUUID().toString());\r
         MDC.put("ServiceName", service);\r
         MDC.put("PartnerName", partner);\r
     }\r
 \r
     /**\r
      * Set time related logging variables in thread local data via MDC\r
-     * \r
+     *\r
      * @param beginTimeStamp\r
      *            Start time\r
      * @param endTimeStamp\r
index fddc60d..bd3547d 100644 (file)
                        <property name="isScanForProcessDefinitions">false</property>
                </properties>
        </process-archive>
+       <process-archive name="clds-process-archive">
+               <process-engine>default</process-engine>
+               <resource>bpmn/clds-process-action.bpmn</resource>
+               <properties>
+                       <property name="isDeleteUponUndeploy">true</property>
+                       <property name="isScanForProcessDefinitions">false</property>
+               </properties>
+       </process-archive>
 
 </process-application>
index 3402db3..f6607cb 100644 (file)
@@ -21,4 +21,4 @@
 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
 ###
 
-globalCldsProps ={"collector":{"topicPublishes":{"DCAE-COLLECTOR-UCSNMP":"DCAE-COLLECTOR-UCSNMP"}},"string_match":{"topicPublishes":{"DCAE-CL-EVENT":"DCAE-CL-EVENT"},"aaiMatchingFields":{"cloud-region.identity-url":"cloud-region.identity-url","complex.city":"complex.city","complex.physical-location-id":"complex.physical-location-id","complex.state":"complex.state","generic-vnf.service-id":"generic-vnf.service-id","generic-vnf.vnf-name":"generic-vnf.vnf-name","generic-vnf.vnf-type":"generic-vnf.vnf-type","tenant.tenant-id":"tenant.tenant-id","vserver.in-maint":"vserver.in-maint","vserver.is-closed-loop-disabled":"vserver.is-closed-loop-disabled","vserver.l-interface.interface-name":"vserver.l-interface.interface-name","vserver.l-interface.l3-interface-ipv4-address-list.l3-inteface-ipv4-address":"vserver.l-interface.l3-interface-ipv4-address-list.l3-inteface-ipv4-address","vserver.l-interface.l3-interface-ipv6-address-list.l3-inteface-ipv6-address":"vserver.l-interface.l3-interface-ipv6-address-list.l3-inteface-ipv6-address","vserver.l-interface.network-name":"vserver.l-interface.network-name","vserver.prov-status":"vserver.prov-status","vserver.selflink":"vserver.selflink","vserver.vserver-id":"vserver.vserver-id","vserver.vserver-name":"vserver.vserver-name"},"aaiSendFields":{"cloud-region.identity-url":"cloud-region.identity-url","complex.city":"complex.city","complex.physical-location-id":"complex.physical-location-id","complex.state":"complex.state","generic-vnf.service-id":"generic-vnf.service-id","generic-vnf.vnf-name":"generic-vnf.vnf-name","generic-vnf.vnf-type":"generic-vnf.vnf-type","tenant.tenant-id":"tenant.tenant-id","vserver.in-maint":"vserver.in-maint","vserver.is-closed-loop-disabled":"vserver.is-closed-loop-disabled","vserver.l-interface.interface-name":"vserver.l-interface.interface-name","vserver.l-interface.l3-interface-ipv4-address-list.l3-inteface-ipv4-address":"vserver.l-interface.l3-interface-ipv4-address-list.l3-inteface-ipv4-address","vserver.l-interface.l3-interface-ipv6-address-list.l3-inteface-ipv6-address":"vserver.l-interface.l3-interface-ipv6-address-list.l3-inteface-ipv6-address","vserver.l-interface.network-name":"vserver.l-interface.network-name","vserver.prov-status":"vserver.prov-status","vserver.selflink":"vserver.selflink","vserver.vserver-id":"vserver.vserver-id","vserver.vserver-name":"vserver.vserver-name"},"eventSourceType":{"f5BigIP":"f5BigIP","vSBG_Alarms":"vSBG_Alarms","vCTS_Alarms":"vCTS_Alarms"},"eventSeverity":{"NORMAL":"NORMAL","not-NORMAL":"not-NORMAL","OK":"OK","WARNING":"WARNING","MINOR":"MINOR","MAJOR":"MAJOR","CRITICAL":"CRITICAL"},"timeWindow":0,"ageLimit":1600,"outputEventName":{"":"","ONSET":"ONSET","ABATED":"ABATED"},"createClosedLoopEventId":{"Initial":"Initial","Close":"Close"}},"tca":{"tname":"New_Set","tcaInt":"1","tcaVio":"1","tcaSev":{"Normal":"Normal","Critical":"Critical","Major":"Major","Minor":"Minor","Warning":"Warning"},"fieldPath":{"FIELDPATH_test_1":"FIELDPATH_test_1","FIELDPATH_test_2":"FIELDPATH_test_2"},"operator":{">":"GREATER","=":"EQUAL","<":"LESS"},"opsPolicy":{"POLICY_test_X":"POLICY_test_X","POLICY_test_Y":"POLICY_test_Y"}},"global":{"actionSet":{"vnfRecipe":"VNF", "enbRecipe":"eNodeB"},"location":{"SNDGCA64":"San Diego SAN3","ALPRGAED":"Alpharetta PDK1","LSLEILAA":"Lisle DPA3","MDTWNJC1":"FTL_C_location1","MDTWNJC2":"FTL_C_location2","MDTWNJ21":"FTL_L_location1","MDTWNJ22":"FTL_L_location2","RDM2WAGPLCP":"ISTFTL_location","RDM3":"RDM3WAGPLCP"}},"policy":{"pname":"0","timeout":345,"vnfRecipe":{"":"","restart":"Restart","rebuild":"Rebuild","migrate":"Migrate","healthCheck":"Health Check"},"enbRecipe":{"":"","reset":"Reset"},"maxRetries":"3","retryTimeLimit":180,"resource":{"vCTS":"vCTS","v3CDB":"v3CDB","vUDR":"vUDR","vCOM":"vCOM","vRAR":"vRAR","vLCS":"vLCS","vUDR-BE":"vUDR-BE","vDBE":"vDBE"},"parentPolicyConditions":{"Failure_Retries":"Failure: Max Retries Exceeded","Failure_Timeout":"Failure: Time Limit Exceeded","Failure_Guard":"Failure: Guard","Failure_Exception":"Failure: Exception","Failure":"Failure: Other","Success":"Success"}},"shared":{"byService":{"":{"vf":{"":""},"location":{"":""},"alarmCondition":{"":""}}},"byVf":{"":{"vfc":{"":""}}}}}
\ No newline at end of file
+globalCldsProps ={"collector":{"topicPublishes":{"DCAE-COLLECTOR-UCSNMP":"DCAE-COLLECTOR-UCSNMP"}},"string_match":{"topicPublishes":{"DCAE-CL-EVENT":"DCAE-CL-EVENT"},"aaiMatchingFields":{"cloud-region.identity-url":"cloud-region.identity-url","complex.city":"complex.city","complex.physical-location-id":"complex.physical-location-id","complex.state":"complex.state","generic-vnf.service-id":"generic-vnf.service-id","generic-vnf.vnf-name":"generic-vnf.vnf-name","generic-vnf.vnf-type":"generic-vnf.vnf-type","tenant.tenant-id":"tenant.tenant-id","vserver.in-maint":"vserver.in-maint","vserver.is-closed-loop-disabled":"vserver.is-closed-loop-disabled","vserver.l-interface.interface-name":"vserver.l-interface.interface-name","vserver.l-interface.l3-interface-ipv4-address-list.l3-inteface-ipv4-address":"vserver.l-interface.l3-interface-ipv4-address-list.l3-inteface-ipv4-address","vserver.l-interface.l3-interface-ipv6-address-list.l3-inteface-ipv6-address":"vserver.l-interface.l3-interface-ipv6-address-list.l3-inteface-ipv6-address","vserver.l-interface.network-name":"vserver.l-interface.network-name","vserver.prov-status":"vserver.prov-status","vserver.selflink":"vserver.selflink","vserver.vserver-id":"vserver.vserver-id","vserver.vserver-name":"vserver.vserver-name"},"aaiSendFields":{"cloud-region.identity-url":"cloud-region.identity-url","complex.city":"complex.city","complex.physical-location-id":"complex.physical-location-id","complex.state":"complex.state","generic-vnf.service-id":"generic-vnf.service-id","generic-vnf.vnf-name":"generic-vnf.vnf-name","generic-vnf.vnf-type":"generic-vnf.vnf-type","tenant.tenant-id":"tenant.tenant-id","vserver.in-maint":"vserver.in-maint","vserver.is-closed-loop-disabled":"vserver.is-closed-loop-disabled","vserver.l-interface.interface-name":"vserver.l-interface.interface-name","vserver.l-interface.l3-interface-ipv4-address-list.l3-inteface-ipv4-address":"vserver.l-interface.l3-interface-ipv4-address-list.l3-inteface-ipv4-address","vserver.l-interface.l3-interface-ipv6-address-list.l3-inteface-ipv6-address":"vserver.l-interface.l3-interface-ipv6-address-list.l3-inteface-ipv6-address","vserver.l-interface.network-name":"vserver.l-interface.network-name","vserver.prov-status":"vserver.prov-status","vserver.selflink":"vserver.selflink","vserver.vserver-id":"vserver.vserver-id","vserver.vserver-name":"vserver.vserver-name"},"eventSourceType":{"f5BigIP":"f5BigIP","vSBG_Alarms":"vSBG_Alarms","vCTS_Alarms":"vCTS_Alarms"},"eventSeverity":{"NORMAL":"NORMAL","not-NORMAL":"not-NORMAL","OK":"OK","WARNING":"WARNING","MINOR":"MINOR","MAJOR":"MAJOR","CRITICAL":"CRITICAL"},"timeWindow":0,"ageLimit":1600,"outputEventName":{"":"","ONSET":"ONSET","ABATED":"ABATED"},"createClosedLoopEventId":{"Initial":"Initial","Close":"Close"}},"tca":{"tname":"New_Set","tcaInt":"1","tcaVio":"1","tcaSev":{"NORMAL":"NORMAL","CRITICAL":"CRITICAL","MAJOR":"MAJOR","MINOR":"MINOR","WARNING":"WARNING"},"fieldPath":{"FIELDPATH_test_1":"FIELDPATH_test_1","FIELDPATH_test_2":"FIELDPATH_test_2"},"operator":{">":"GREATER","=":"EQUAL","<":"LESS"},"opsPolicy":{"POLICY_test_X":"POLICY_test_X","POLICY_test_Y":"POLICY_test_Y"}},"global":{"actionSet":{"vnfRecipe":"VNF", "enbRecipe":"eNodeB"},"location":{"SNDGCA64":"San Diego SAN3","ALPRGAED":"Alpharetta PDK1","LSLEILAA":"Lisle DPA3","MDTWNJC1":"FTL_C_location1","MDTWNJC2":"FTL_C_location2","MDTWNJ21":"FTL_L_location1","MDTWNJ22":"FTL_L_location2","RDM2WAGPLCP":"ISTFTL_location","RDM3":"RDM3WAGPLCP"}},"policy":{"pname":"0","timeout":345,"vnfRecipe":{"":"","restart":"Restart","rebuild":"Rebuild","migrate":"Migrate","healthCheck":"Health Check"},"enbRecipe":{"":"","reset":"Reset"},"maxRetries":"3","retryTimeLimit":180,"resource":{"vCTS":"vCTS","v3CDB":"v3CDB","vUDR":"vUDR","vCOM":"vCOM","vRAR":"vRAR","vLCS":"vLCS","vUDR-BE":"vUDR-BE","vDBE":"vDBE"},"parentPolicyConditions":{"Failure_Retries":"Failure: Max Retries Exceeded","Failure_Timeout":"Failure: Time Limit Exceeded","Failure_Guard":"Failure: Guard","Failure_Exception":"Failure: Exception","Failure":"Failure: Other","Success":"Success"}},"shared":{"byService":{"":{"vf":{"":""},"location":{"":""},"alarmCondition":{"":""}}},"byVf":{"":{"vfc":{"":""}}}}}
\ No newline at end of file