diff options
author | danielhanrahan <daniel.hanrahan@est.tech> | 2023-08-04 11:22:43 +0100 |
---|---|---|
committer | danielhanrahan <daniel.hanrahan@est.tech> | 2024-01-09 10:47:51 +0000 |
commit | 926d40875fecb3c11e4103dfdaf00ac615de3cdc (patch) | |
tree | 3dd976137922160419ef781ac6be34cd00441e1f /cps-service/src/main | |
parent | 8e617d64a7725f5fb0f0f31a5c551ff3e1e484de (diff) |
Remove inefficient saveListElementsBatch API
CpsDataService::saveListElementsBatch method is not needed as
saveListElements supports saving multiple list elements in a single
operation. This both simplifies implementation and greatly improves
performance when saving list elements, as the Yang parser need only
run once for the whole batch.
- Change InventoryPersistence to save CM-handles in batches of 100
using existing CpsDataService::saveListElements method.
- Remove not needed CpsDataService::saveListElementBatch.
Issue-ID: CPS-2019
Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech>
Change-Id: I8b74dda2917e094d064b42f2c0e4d57029b90395
Diffstat (limited to 'cps-service/src/main')
3 files changed, 6 insertions, 51 deletions
diff --git a/cps-service/src/main/java/org/onap/cps/api/CpsDataService.java b/cps-service/src/main/java/org/onap/cps/api/CpsDataService.java index c9879595a8..0abcc05f9c 100644 --- a/cps-service/src/main/java/org/onap/cps/api/CpsDataService.java +++ b/cps-service/src/main/java/org/onap/cps/api/CpsDataService.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2020-2023 Nordix Foundation + * Copyright (C) 2020-2024 Nordix Foundation * Modifications Copyright (C) 2021 Pantheon.tech * Modifications Copyright (C) 2021-2022 Bell Canada * Modifications Copyright (C) 2022 Deutsche Telekom AG @@ -100,19 +100,6 @@ public interface CpsDataService { OffsetDateTime observedTimestamp); /** - * Persists child data fragment representing one or more list elements under existing data node for the - * given anchor and dataspace. - * - * @param dataspaceName dataspace name - * @param anchorName anchor name - * @param parentNodeXpath parent node xpath - * @param jsonDataList collection of json data representing list element(s) - * @param observedTimestamp observedTimestamp - */ - void saveListElementsBatch(String dataspaceName, String anchorName, String parentNodeXpath, - Collection<String> jsonDataList, OffsetDateTime observedTimestamp); - - /** * Retrieves all the datanodes by XPath for given dataspace and anchor. * * @param dataspaceName dataspace name diff --git a/cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java b/cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java index a1bae6a441..e49714b66d 100755..100644 --- a/cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java +++ b/cps-service/src/main/java/org/onap/cps/api/impl/CpsDataServiceImpl.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2021-2023 Nordix Foundation + * Copyright (C) 2021-2024 Nordix Foundation * Modifications Copyright (C) 2020-2022 Bell Canada. * Modifications Copyright (C) 2021 Pantheon.tech * Modifications Copyright (C) 2022-2023 TechMahindra Ltd. @@ -105,9 +105,9 @@ public class CpsDataServiceImpl implements CpsDataService { @Override @Timed(value = "cps.data.service.list.element.save", - description = "Time taken to save a list element") - public void saveListElements(final String dataspaceName, final String anchorName, - final String parentNodeXpath, final String jsonData, final OffsetDateTime observedTimestamp) { + description = "Time taken to save list elements") + public void saveListElements(final String dataspaceName, final String anchorName, final String parentNodeXpath, + final String jsonData, final OffsetDateTime observedTimestamp) { cpsValidator.validateNameCharacters(dataspaceName, anchorName); final Anchor anchor = cpsAnchorService.getAnchor(dataspaceName, anchorName); final Collection<DataNode> listElementDataNodeCollection = @@ -121,19 +121,6 @@ public class CpsDataServiceImpl implements CpsDataService { } @Override - @Timed(value = "cps.data.service.list.element.batch.save", - description = "Time taken to save a batch of list elements") - public void saveListElementsBatch(final String dataspaceName, final String anchorName, final String parentNodeXpath, - final Collection<String> jsonDataList, final OffsetDateTime observedTimestamp) { - cpsValidator.validateNameCharacters(dataspaceName, anchorName); - final Anchor anchor = cpsAnchorService.getAnchor(dataspaceName, anchorName); - final Collection<Collection<DataNode>> listElementDataNodeCollections = - buildDataNodes(anchor, parentNodeXpath, jsonDataList, ContentType.JSON); - cpsDataPersistenceService.addMultipleLists(dataspaceName, anchorName, parentNodeXpath, - listElementDataNodeCollections); - } - - @Override @Timed(value = "cps.data.service.datanode.get", description = "Time taken to get data nodes for an xpath") public Collection<DataNode> getDataNodes(final String dataspaceName, final String anchorName, @@ -347,14 +334,6 @@ public class CpsDataServiceImpl implements CpsDataService { return dataNodes; } - private Collection<Collection<DataNode>> buildDataNodes(final Anchor anchor, final String parentNodeXpath, - final Collection<String> nodeDataList, - final ContentType contentType) { - return nodeDataList.stream() - .map(nodeData -> buildDataNodes(anchor, parentNodeXpath, nodeData, contentType)) - .collect(Collectors.toList()); - } - private SchemaContext getSchemaContext(final Anchor anchor) { return yangTextSchemaSourceSetCache .get(anchor.getDataspaceName(), anchor.getSchemaSetName()).getSchemaContext(); diff --git a/cps-service/src/main/java/org/onap/cps/spi/CpsDataPersistenceService.java b/cps-service/src/main/java/org/onap/cps/spi/CpsDataPersistenceService.java index 1baca4ea7d..bc819163bc 100644 --- a/cps-service/src/main/java/org/onap/cps/spi/CpsDataPersistenceService.java +++ b/cps-service/src/main/java/org/onap/cps/spi/CpsDataPersistenceService.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2020-2023 Nordix Foundation. + * Copyright (C) 2020-2024 Nordix Foundation. * Modifications Copyright (C) 2021 Pantheon.tech * Modifications Copyright (C) 2022 Bell Canada * Modifications Copyright (C) 2022-2023 TechMahindra Ltd. @@ -67,17 +67,6 @@ public interface CpsDataPersistenceService { Collection<DataNode> listElementsCollection); /** - * Add multiple lists of data nodes to a parent node at the same time. - * - * @param dataspaceName dataspace name - * @param anchorName anchor name - * @param parentNodeXpath parent node xpath - * @param newLists collections of lists of data nodes representing list elements - */ - void addMultipleLists(String dataspaceName, String anchorName, String parentNodeXpath, - Collection<Collection<DataNode>> newLists); - - /** * Retrieves multiple datanodes for a single XPath for given dataspace and anchor. * Multiple data nodes are returned when xPath is set to root '/', otherwise single data node * is returned when a specific xpath is used (Example: /bookstore). |