Merge "NCMP : Replacing the word 'Batch' as 'DataOperation'."
authorSourabh Sourabh <sourabh.sourabh@est.tech>
Fri, 23 Jun 2023 10:15:25 +0000 (10:15 +0000)
committerGerrit Code Review <gerrit@onap.org>
Fri, 23 Jun 2023 10:15:25 +0000 (10:15 +0000)
cps-ncmp-events/src/main/resources/schemas/subscription/dmi-subscription-response-event-schema-1.0.0.json [new file with mode: 0644]
cps-ri/src/main/java/org/onap/cps/spi/impl/CpsDataPersistenceServiceImpl.java
integration-test/src/test/groovy/org/onap/cps/integration/performance/cps/UpdatePerfTest.groovy

diff --git a/cps-ncmp-events/src/main/resources/schemas/subscription/dmi-subscription-response-event-schema-1.0.0.json b/cps-ncmp-events/src/main/resources/schemas/subscription/dmi-subscription-response-event-schema-1.0.0.json
new file mode 100644 (file)
index 0000000..527d6e5
--- /dev/null
@@ -0,0 +1,69 @@
+{
+  "$schema": "https://json-schema.org/draft/2019-09/schema",
+  "$id": "urn:cps:org.onap.cps.ncmp.events:dmi-subscription-response-event-schema:1.0.0",
+  "$ref": "#/definitions/SubscriptionEventResponse",
+  "definitions": {
+    "SubscriptionStatus": {
+      "description": "The subscription status information",
+      "type": "object",
+      "properties": {
+        "id": {
+          "type": "string"
+        },
+        "status" : {
+          "type": "string",
+          "enum": [
+            "ACCEPTED",
+            "REJECTED",
+            "PENDING"
+          ]
+        },
+        "details" : {
+          "type": "string"
+        }
+      },
+      "required": [
+        "id",
+        "status"
+      ],
+      "additionalProperties": false
+    },
+    "SubscriptionEventResponse" : {
+      "description": "The payload for subscription response event.",
+      "type": "object",
+      "javaType": "org.onap.cps.ncmp.events.subscription1_0_0.SubscriptionEventResponse",
+      "properties": {
+        "data": {
+          "type": "object",
+          "properties": {
+            "clientId": {
+              "type": "string"
+            },
+            "subscriptionName": {
+              "type": "string"
+            },
+            "dmiName": {
+              "type": "string"
+            },
+            "subscriptionStatus": {
+              "type": "array",
+              "items": {
+                "$ref": "#/definitions/SubscriptionStatus"
+              }
+            }
+          },
+          "required": [
+            "clientId",
+            "subscriptionName",
+            "dmiName",
+            "subscriptionStatus"
+          ],
+          "additionalProperties": false
+        },
+        "required": [
+          "data"
+        ]
+      }
+    }
+  }
+}
\ No newline at end of file
index e6e250f..7fed534 100644 (file)
@@ -243,14 +243,14 @@ public class CpsDataPersistenceServiceImpl implements CpsDataPersistenceService
                                                               final Collection<String> xpaths,
                                                               final FetchDescendantsOption fetchDescendantsOption) {
         final AnchorEntity anchorEntity = getAnchorEntity(dataspaceName, anchorName);
-        final Collection<FragmentEntity> fragmentEntities =
-            getFragmentEntities(anchorEntity, xpaths, fetchDescendantsOption);
+        Collection<FragmentEntity> fragmentEntities = getFragmentEntities(anchorEntity, xpaths);
+        fragmentEntities = fragmentRepository.prefetchDescendantsOfFragmentEntities(fetchDescendantsOption,
+                fragmentEntities);
         return createDataNodesFromFragmentEntities(fetchDescendantsOption, fragmentEntities);
     }
 
     private Collection<FragmentEntity> getFragmentEntities(final AnchorEntity anchorEntity,
-                                                           final Collection<String> xpaths,
-                                                           final FetchDescendantsOption fetchDescendantsOption) {
+                                                           final Collection<String> xpaths) {
         final Collection<String> nonRootXpaths = new HashSet<>(xpaths);
         final boolean haveRootXpath = nonRootXpaths.removeIf(CpsDataPersistenceServiceImpl::isRootXpath);
 
@@ -266,10 +266,7 @@ public class CpsDataPersistenceServiceImpl implements CpsDataPersistenceService
             normalizedXpaths.addAll(fragmentRepository.findAllXpathByAnchorAndParentIdIsNull(anchorEntity));
         }
 
-        final List<FragmentEntity> fragmentEntities = fragmentRepository.findByAnchorAndXpathIn(anchorEntity,
-                normalizedXpaths);
-
-        return fragmentRepository.prefetchDescendantsOfFragmentEntities(fetchDescendantsOption, fragmentEntities);
+        return fragmentRepository.findByAnchorAndXpathIn(anchorEntity, normalizedXpaths);
     }
 
     private FragmentEntity getFragmentEntity(final AnchorEntity anchorEntity, final String xpath) {
@@ -407,8 +404,7 @@ public class CpsDataPersistenceServiceImpl implements CpsDataPersistenceService
         final AnchorEntity anchorEntity = getAnchorEntity(dataspaceName, anchorName);
 
         final Collection<String> xpathsOfUpdatedLeaves = updatedLeavesPerXPath.keySet();
-        final Collection<FragmentEntity> fragmentEntities = getFragmentEntities(anchorEntity, xpathsOfUpdatedLeaves,
-                FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS);
+        final Collection<FragmentEntity> fragmentEntities = getFragmentEntities(anchorEntity, xpathsOfUpdatedLeaves);
 
         for (final FragmentEntity fragmentEntity : fragmentEntities) {
             final Map<String, Serializable> updatedLeaves = updatedLeavesPerXPath.get(fragmentEntity.getXpath());
@@ -432,8 +428,9 @@ public class CpsDataPersistenceServiceImpl implements CpsDataPersistenceService
             .collect(Collectors.toMap(DataNode::getXpath, dataNode -> dataNode));
 
         final Collection<String> xpaths = xpathToUpdatedDataNode.keySet();
-        final Collection<FragmentEntity> existingFragmentEntities =
-            getFragmentEntities(anchorEntity, xpaths, FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS);
+        Collection<FragmentEntity> existingFragmentEntities = getFragmentEntities(anchorEntity, xpaths);
+        existingFragmentEntities = fragmentRepository.prefetchDescendantsOfFragmentEntities(
+                FetchDescendantsOption.INCLUDE_ALL_DESCENDANTS, existingFragmentEntities);
 
         for (final FragmentEntity existingFragmentEntity : existingFragmentEntities) {
             final DataNode updatedDataNode = xpathToUpdatedDataNode.get(existingFragmentEntity.getXpath());
index b3c8841..6d856cc 100644 (file)
@@ -70,8 +70,8 @@ class UpdatePerfTest extends CpsPerfTestBase {
             objectUnderTest.updateNodeLeaves(CPS_PERFORMANCE_TEST_DATASPACE, 'openroadm3', "/openroadm-devices", jsonDataOriginal, now)
             stopWatch.stop()
             def updateDurationInMillis = stopWatch.getTotalTimeMillis()
-        then: 'update duration is under 750 milliseconds'
-            recordAndAssertPerformance('Update leaves for 1 data node', 750, updateDurationInMillis)
+        then: 'update duration is under 650 milliseconds'
+            recordAndAssertPerformance('Update leaves for 1 data node', 650, updateDurationInMillis)
     }
 
     def 'Batch update leaves for 50 data nodes'() {
@@ -84,8 +84,8 @@ class UpdatePerfTest extends CpsPerfTestBase {
             objectUnderTest.updateNodeLeaves(CPS_PERFORMANCE_TEST_DATASPACE, 'openroadm4', "/openroadm-devices", jsonDataOriginal, now)
             stopWatch.stop()
             def updateDurationInMillis = stopWatch.getTotalTimeMillis()
-        then: 'update duration is under 3500 milliseconds'
-            recordAndAssertPerformance('Batch update leaves for 50 data nodes', 3500, updateDurationInMillis)
+        then: 'update duration is under 700 milliseconds'
+            recordAndAssertPerformance('Batch update leaves for 50 data nodes', 700, updateDurationInMillis)
     }
 
 }