summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/main
diff options
context:
space:
mode:
authorsourabh_sourabh <sourabh.sourabh@est.tech>2022-09-02 09:40:35 +0100
committersourabh_sourabh <sourabh.sourabh@est.tech>2022-09-02 15:29:00 +0100
commit5c1c7a8f467c0c7e673aa81de9e39766c67eb20f (patch)
tree0f805f0436d2eb61bf8f9f3bc02709bc44dba58c /cps-ncmp-service/src/main
parent3c29b33cb1f9398106921e5d9510c62c34cc7694 (diff)
Performance Improvement: Use save batches of cmhandles
-Used cm handle batch to persist from state handler. Issue-ID: CPS-1230 Signed-off-by: sourabh_sourabh <sourabh.sourabh@est.tech> Change-Id: I68b7fde7dc85818b818f1af588344c26b549d87b
Diffstat (limited to 'cps-ncmp-service/src/main')
-rwxr-xr-xcps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java34
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncTasks.java13
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmHandleRegistrationResponse.java7
3 files changed, 31 insertions, 23 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
index c21c74bfb6..e8a64115a1 100755
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
@@ -300,14 +300,18 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
public List<CmHandleRegistrationResponse> parseAndCreateCmHandlesInDmiRegistrationAndSyncModules(
final DmiPluginRegistration dmiPluginRegistration) {
List<CmHandleRegistrationResponse> cmHandleRegistrationResponses = new ArrayList<>();
+ final Map<YangModelCmHandle, CmHandleState> cmHandleStatePerCmHandle = new HashMap<>();
try {
- cmHandleRegistrationResponses = dmiPluginRegistration.getCreatedCmHandles().stream()
- .map(cmHandle ->
- YangModelCmHandle.toYangModelCmHandle(
- dmiPluginRegistration.getDmiPlugin(),
- dmiPluginRegistration.getDmiDataPlugin(),
- dmiPluginRegistration.getDmiModelPlugin(),
- cmHandle)).map(this::registerNewCmHandle).collect(Collectors.toList());
+ dmiPluginRegistration.getCreatedCmHandles()
+ .forEach(cmHandle -> {
+ final YangModelCmHandle yangModelCmHandle = YangModelCmHandle.toYangModelCmHandle(
+ dmiPluginRegistration.getDmiPlugin(),
+ dmiPluginRegistration.getDmiDataPlugin(),
+ dmiPluginRegistration.getDmiModelPlugin(),
+ cmHandle);
+ cmHandleStatePerCmHandle.put(yangModelCmHandle, CmHandleState.ADVISED);
+ });
+ cmHandleRegistrationResponses = registerNewCmHandles(cmHandleStatePerCmHandle);
} catch (final DataValidationException dataValidationException) {
cmHandleRegistrationResponses.add(CmHandleRegistrationResponse.createFailureResponse(dmiPluginRegistration
.getCreatedCmHandles().stream()
@@ -356,15 +360,19 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
inventoryPersistence.deleteListOrListElement("/dmi-registry/cm-handles[@id='" + cmHandleId + "']");
}
- private CmHandleRegistrationResponse registerNewCmHandle(final YangModelCmHandle yangModelCmHandle) {
+ private List<CmHandleRegistrationResponse> registerNewCmHandles(final Map<YangModelCmHandle, CmHandleState>
+ cmHandleStatePerCmHandle) {
+ final List<String> cmHandleIds = cmHandleStatePerCmHandle.keySet().stream().map(YangModelCmHandle::getId)
+ .collect(Collectors.toList());
try {
- lcmEventsCmHandleStateHandler.updateCmHandleState(yangModelCmHandle, CmHandleState.ADVISED);
- return CmHandleRegistrationResponse.createSuccessResponse(yangModelCmHandle.getId());
+ lcmEventsCmHandleStateHandler.updateCmHandleStateBatch(cmHandleStatePerCmHandle);
+ return CmHandleRegistrationResponse.createSuccessResponses(cmHandleIds);
} catch (final AlreadyDefinedException alreadyDefinedException) {
- return CmHandleRegistrationResponse.createFailureResponse(
- yangModelCmHandle.getId(), RegistrationError.CM_HANDLE_ALREADY_EXIST);
+ return List.of(CmHandleRegistrationResponse.createFailureResponse(
+ String.join(",", cmHandleIds), RegistrationError.CM_HANDLE_ALREADY_EXIST));
} catch (final Exception exception) {
- return CmHandleRegistrationResponse.createFailureResponse(yangModelCmHandle.getId(), exception);
+ return List.of(CmHandleRegistrationResponse.createFailureResponse(String.join(",", cmHandleIds),
+ exception));
}
}
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncTasks.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncTasks.java
index 597e2ba8e5..ada3dc6744 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncTasks.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncTasks.java
@@ -78,7 +78,7 @@ public class ModuleSyncTasks {
}
log.debug("{} is now in {} state", cmHandleId, compositeState.getCmHandleState().name());
}
- updateCmHandlesStateBatch(cmHandelStatePerCmHandle);
+ lcmEventsCmHandleStateHandler.updateCmHandleStateBatch(cmHandelStatePerCmHandle);
} finally {
batchCounter.getAndDecrement();
}
@@ -98,11 +98,11 @@ public class ModuleSyncTasks {
final boolean isReadyForRetry = syncUtils.isReadyForRetry(compositeState);
if (isReadyForRetry) {
log.debug("Reset cm handle {} state to ADVISED to be re-attempted by module-sync watchdog",
- failedCmHandle.getId());
+ failedCmHandle.getId());
cmHandleStatePerCmHandle.put(failedCmHandle, CmHandleState.ADVISED);
}
}
- updateCmHandlesStateBatch(cmHandleStatePerCmHandle);
+ lcmEventsCmHandleStateHandler.updateCmHandleStateBatch(cmHandleStatePerCmHandle);
return COMPLETED_FUTURE;
}
@@ -111,11 +111,4 @@ public class ModuleSyncTasks {
advisedCmHandle.getCompositeState().setLockReason(lockReason);
}
- private void updateCmHandlesStateBatch(final Map<YangModelCmHandle, CmHandleState> cmHandleStatePerCmHandle) {
- // To be refactored as part of CPS-1231; Use state-save-batch capability (depends sub-task12, 13)
- for (final Map.Entry<YangModelCmHandle, CmHandleState> entry : cmHandleStatePerCmHandle.entrySet()) {
- lcmEventsCmHandleStateHandler.updateCmHandleState(entry.getKey(), entry.getValue());
- }
- }
-
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmHandleRegistrationResponse.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmHandleRegistrationResponse.java
index 1da2aa9430..b7faf09a9e 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmHandleRegistrationResponse.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/models/CmHandleRegistrationResponse.java
@@ -21,6 +21,8 @@
package org.onap.cps.ncmp.api.models;
+import java.util.List;
+import java.util.stream.Collectors;
import lombok.Builder;
import lombok.Data;
import lombok.RequiredArgsConstructor;
@@ -70,6 +72,11 @@ public class CmHandleRegistrationResponse {
.status(Status.SUCCESS).build();
}
+ public static List<CmHandleRegistrationResponse> createSuccessResponses(final List<String> cmHandleIds) {
+ return cmHandleIds.stream().map(CmHandleRegistrationResponse::createSuccessResponse)
+ .collect(Collectors.toList());
+ }
+
public enum Status {
SUCCESS, FAILURE;
}