diff options
author | xg353y <xg353y@intl.att.com> | 2017-08-17 14:10:26 +0200 |
---|---|---|
committer | xg353y <xg353y@intl.att.com> | 2017-08-17 15:55:26 +0200 |
commit | be0219b3b7f239bc5bba6d659c223a267ec4c0f5 (patch) | |
tree | beb5c5d5e47e10f9bd175a272b5a03fde32c58c7 /src/main/java | |
parent | d5d079cc1966ddb4274ef8d2d059b5780828d79e (diff) |
Code improvement
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>
Diffstat (limited to 'src/main/java')
6 files changed, 32 insertions, 22 deletions
diff --git a/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java b/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java index 343391eb..e5144bfe 100644 --- a/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java +++ b/src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java @@ -129,25 +129,26 @@ public class DcaeDispatcherServices { */
public String getOperationStatus(String statusUrl) throws Exception {
- String opStatus = null;
+ //Assigning processing status to monitor operation status further
+ String opStatus = "processing";
InputStream in = null;
try {
URL obj = new URL(statusUrl);
HttpsURLConnection conn = (HttpsURLConnection) obj.openConnection();
conn.setRequestMethod("GET");
int responseCode = conn.getResponseCode();
- logger.debug("response code " + responseCode);
- in = conn.getInputStream();
- String res = new BufferedReader(new InputStreamReader(in)).lines().collect(Collectors.joining("\n"));
- JSONParser parser = new JSONParser();
- Object obj0 = parser.parse(res);
- JSONObject jsonObj = (JSONObject) obj0;
- String operationType = (String) jsonObj.get("operationType");
- String status = (String) jsonObj.get("status");
- logger.debug("Operation Type " + operationType);
- logger.debug("Status " + status);
- opStatus = status;
-
+ logger.debug("Deployment operation status response code - " + responseCode);
+ if(responseCode == 200){
+ in = conn.getInputStream();
+ String res = new BufferedReader(new InputStreamReader(in)).lines().collect(Collectors.joining("\n"));
+ JSONParser parser = new JSONParser();
+ Object obj0 = parser.parse(res);
+ JSONObject jsonObj = (JSONObject) obj0;
+ String operationType = (String) jsonObj.get("operationType");
+ String status = (String) jsonObj.get("status");
+ logger.debug("Operation Type - " + operationType + ", Status " + status);
+ opStatus = status;
+ }
} catch (Exception e) {
logger.debug(e.getClass().getName() + " " + e.getMessage());
logger.debug(e.getMessage()
diff --git a/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java b/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java index a009f06f..df86977c 100644 --- a/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java +++ b/src/main/java/org/onap/clamp/clds/client/SdcCatalogServices.java @@ -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"); diff --git a/src/main/java/org/onap/clamp/clds/client/req/SdcReq.java b/src/main/java/org/onap/clamp/clds/client/req/SdcReq.java index 8a31a3b9..08e196b7 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/SdcReq.java +++ b/src/main/java/org/onap/clamp/clds/client/req/SdcReq.java @@ -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); diff --git a/src/main/java/org/onap/clamp/clds/model/CldsModel.java b/src/main/java/org/onap/clamp/clds/model/CldsModel.java index e34f47d9..59db9b58 100644 --- a/src/main/java/org/onap/clamp/clds/model/CldsModel.java +++ b/src/main/java/org/onap/clamp/clds/model/CldsModel.java @@ -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)) { diff --git a/src/main/java/org/onap/clamp/clds/service/CldsService.java b/src/main/java/org/onap/clamp/clds/service/CldsService.java index aaeb03f6..509535c5 100644 --- a/src/main/java/org/onap/clamp/clds/service/CldsService.java +++ b/src/main/java/org/onap/clamp/clds/service/CldsService.java @@ -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")) { diff --git a/src/main/java/org/onap/clamp/clds/util/LoggingUtils.java b/src/main/java/org/onap/clamp/clds/util/LoggingUtils.java index c4740068..8ceaa3d8 100644 --- a/src/main/java/org/onap/clamp/clds/util/LoggingUtils.java +++ b/src/main/java/org/onap/clamp/clds/util/LoggingUtils.java @@ -35,21 +35,21 @@ public class LoggingUtils { /**
* Set request related logging variables in thread local data via MDC
- *
+ *
* @param service
* Service Name of API (ex. "PUT template")
* @param partner
* Partner name (client or user invoking API)
*/
public static void setRequestContext(String service, String partner) {
- MDC.put("RequestId", "clds-" + UUID.randomUUID().toString());
+ MDC.put("RequestId", UUID.randomUUID().toString());
MDC.put("ServiceName", service);
MDC.put("PartnerName", partner);
}
/**
* Set time related logging variables in thread local data via MDC
- *
+ *
* @param beginTimeStamp
* Start time
* @param endTimeStamp
|