diff options
author | hetengjiao <hetengjiao@chinamobile.com> | 2020-11-20 10:11:12 +0800 |
---|---|---|
committer | hetengjiao <hetengjiao@chinamobile.com> | 2020-11-23 12:17:12 +0800 |
commit | a3761511f6343eba0a478116f958881b6925c4cf (patch) | |
tree | 3ad74c60c1bf7e0810e159e66ceb04f674a1aed1 /adapters/mso-nssmf-adapter/src/main | |
parent | a65f924438cda21350682c24e17cba9c493e2192 (diff) |
add serializable to fixed cn nssi processing error
Issue-ID: SO-2963
Signed-off-by: hetengjiao <hetengjiao@chinamobile.com>
Change-Id: I0c50d7ea14298aa7b7a261faef9d01c811363633
Diffstat (limited to 'adapters/mso-nssmf-adapter/src/main')
4 files changed, 37 insertions, 6 deletions
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/consts/NssmfAdapterConsts.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/consts/NssmfAdapterConsts.java index 84e1eb2acc..1e3c76cdde 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/consts/NssmfAdapterConsts.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/consts/NssmfAdapterConsts.java @@ -91,8 +91,7 @@ public class NssmfAdapterConsts { private final static String INTERNAL_MODIFY_URL = "/onap/so/infra/3gppservices/{apiVersion}/modify"; // - private final static String EXTERNAL_QUERY_JOB_STATUS = - "/api/rest/provMns/{apiVersion}/NSS/jobs/{jobId}?responseId={responseId}"; + private final static String EXTERNAL_QUERY_JOB_STATUS = "/api/rest/provMns/{apiVersion}/NSS/jobs/{jobId}"; private final static String INTERNAL_QUERY_SUB_NET_CAPABILITY = "/onap/so/infra/3gppservices/{apiVersion}/subnetCapabilityQuery"; diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/ActionType.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/ActionType.java index 9df20bac1c..530cc1be0d 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/ActionType.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/enums/ActionType.java @@ -24,6 +24,9 @@ import lombok.Getter; @Getter public enum ActionType { + /** + * allocate + */ ALLOCATE("allocate"), DEALLOCATE("deallocate"), @@ -52,4 +55,13 @@ public enum ActionType { ActionType(String type) { this.type = type; } + + public static ActionType getActionType(String value) { + for (ActionType actionType : ActionType.values()) { + if (actionType.type.equalsIgnoreCase(value)) { + return actionType; + } + } + return null; + } } diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java index 2de6e01693..fb880a91e3 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/BaseNssmfManager.java @@ -31,14 +31,19 @@ import org.onap.so.adapters.nssmf.util.RestUtil; import org.onap.so.beans.nsmf.*; import org.onap.so.db.request.beans.ResourceOperationStatus; import org.onap.so.db.request.data.repository.ResourceOperationStatusRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.data.domain.Example; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Optional; import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal; public abstract class BaseNssmfManager implements NssmfManager { + private static final Logger logger = LoggerFactory.getLogger(BaseNssmfManager.class); + protected RestUtil restUtil; protected ResourceOperationStatusRepository repository; @@ -152,6 +157,7 @@ public abstract class BaseNssmfManager implements NssmfManager { ResourceOperationStatus status = getOperationStatus(serviceInfo.getNsiId(), jobId, serviceInfo.getServiceUuid()); + logger.info("ResourceOperationStatus = {}", status); this.restResponse = doQueryJobStatus(status); afterQueryJobStatus(status); @@ -165,11 +171,18 @@ public abstract class BaseNssmfManager implements NssmfManager { private ResourceOperationStatus getOperationStatus(String nsiId, String jobId, String serviceUuid) { + logger.info("Query operations: nsiId = [{}], jobId = [{}], serviceUuid = [{}]", nsiId, jobId, serviceUuid); + ResourceOperationStatus status = new ResourceOperationStatus(nsiId, jobId, serviceUuid); - Optional<ResourceOperationStatus> optional = repository.findOne(Example.of(status)); + List<ResourceOperationStatus> resourceOperationStatuses = + repository.findByServiceIdAndOperationId(nsiId, jobId); - return optional.orElse(null); + logger.info("resourceOperationStatuses = {}", resourceOperationStatuses); + if (resourceOperationStatuses.size() == 0) { + return null; + } + return resourceOperationStatuses.get(0); } @Override diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java index 3c5be7eb39..4b0e98e8ec 100644 --- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java +++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/ExternalNssmfManager.java @@ -75,8 +75,9 @@ public abstract class ExternalNssmfManager extends BaseNssmfManager { @Override protected void afterQueryJobStatus(ResourceOperationStatus status) { + logger.info("afterQueryJobStatus = " + status); if (Integer.parseInt(status.getProgress()) == 100) { - + logger.info("after query finished = " + status); ActionType jobOperType = ActionType.valueOf(status.getOperType()); if (ActionType.ALLOCATE.equals(jobOperType)) { @@ -118,6 +119,8 @@ public abstract class ExternalNssmfManager extends BaseNssmfManager { JobStatusResponse jobStatusResponse = unMarshal(restResponse.getResponseContent(), JobStatusResponse.class); ResponseDescriptor rspDesc = jobStatusResponse.getResponseDescriptor(); + + logger.info("status = {}", status); rspDesc.setNssiId(status.getResourceInstanceID()); jobStatusResponse.setResponseDescriptor(rspDesc); @@ -152,7 +155,7 @@ public abstract class ExternalNssmfManager extends BaseNssmfManager { protected void updateRequestDbJobStatus(ResponseDescriptor rspDesc, ResourceOperationStatus status, RestResponse rsp) throws ApplicationException { - + status.setProgress(Integer.toString(rspDesc.getProgress())); switch (fromString(rspDesc.getStatus())) { case STARTED: updateDbStatus(status, rsp.getStatus(), STARTED, QUERY_JOB_STATUS_SUCCESS); @@ -168,6 +171,8 @@ public abstract class ExternalNssmfManager extends BaseNssmfManager { case ERROR: updateDbStatus(status, rsp.getStatus(), ERROR, QUERY_JOB_STATUS_FAILED); throw new ApplicationException(500, QUERY_JOB_STATUS_FAILED); + default: + throw new ApplicationException(500, QUERY_JOB_STATUS_FAILED); } } @@ -227,6 +232,8 @@ public abstract class ExternalNssmfManager extends BaseNssmfManager { ResourceOperationStatus status = new ResourceOperationStatus(serviceInfo.getNsiId(), response.getJobId(), serviceInfo.getServiceUuid()); status.setResourceInstanceID(response.getNssiId()); + status.setOperType(actionType.toString()); + status.setProgress("0"); updateDbStatus(status, restResponse.getStatus(), STARTED, NssmfAdapterUtil.getStatusDesc(actionType)); } |