summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/main/java/org
diff options
context:
space:
mode:
authorkissand <andras.zoltan.kiss@est.tech>2022-06-30 12:14:56 +0200
committerkissand <andras.zoltan.kiss@est.tech>2022-07-01 10:24:59 +0200
commit50585e9b0affad604f92f737da1296c06e03d76d (patch)
treefb0d07cf115a312df42df13245de5b60cffa07e9 /cps-ncmp-service/src/main/java/org
parentf7c7848d4cd7654ab94d9c31b62a71ed2bc4b9e8 (diff)
use separated get methods for every cmHandle instead of one "get all"
query Issue-ID: CPS-1085 Change-Id: Ifac152f606b25b7a7d143315dba6d73698ef914e Signed-off-by: kissand <andras.zoltan.kiss@est.tech>
Diffstat (limited to 'cps-ncmp-service/src/main/java/org')
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyCmHandlerQueryServiceImpl.java31
1 files changed, 17 insertions, 14 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyCmHandlerQueryServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyCmHandlerQueryServiceImpl.java
index d64dfb4a63..000627bec9 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyCmHandlerQueryServiceImpl.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyCmHandlerQueryServiceImpl.java
@@ -55,7 +55,7 @@ public class NetworkCmProxyCmHandlerQueryServiceImpl implements NetworkCmProxyCm
private static final String PROPERTY_QUERY_NAME = "hasAllProperties";
private static final String MODULE_QUERY_NAME = "hasAllModules";
- private static final Object NO_QUERY_EXECUTED = null;
+ private static final Map<String, NcmpServiceCmHandle> NO_QUERY_EXECUTED = null;
private final CpsDataPersistenceService cpsDataPersistenceService;
private final CpsAdminPersistenceService cpsAdminPersistenceService;
@@ -80,7 +80,7 @@ public class NetworkCmProxyCmHandlerQueryServiceImpl implements NetworkCmProxyCm
combineWithModuleNameQuery(cmHandleQueryServiceParameters, publicPropertyQueryResult);
return combinedQueryResult == NO_QUERY_EXECUTED
- ? Collections.emptySet() : new HashSet<NcmpServiceCmHandle>(combinedQueryResult.values());
+ ? Collections.emptySet() : new HashSet<>(combinedQueryResult.values());
}
/**
@@ -121,14 +121,14 @@ public class NetworkCmProxyCmHandlerQueryServiceImpl implements NetworkCmProxyCm
final Map<String, String> publicPropertyQueryPairs =
getPublicPropertyPairs(cmHandleQueryServiceParameters.getCmHandleQueryParameters());
if (publicPropertyQueryPairs.isEmpty()) {
- return null;
+ return NO_QUERY_EXECUTED;
}
Map<String, NcmpServiceCmHandle> cmHandleIdToNcmpServiceCmHandles = null;
for (final Map.Entry<String, String> entry : publicPropertyQueryPairs.entrySet()) {
- final String cmHandlePath = "//public-properties[@name='" + entry.getKey() + "' and @value='"
+ final String cpsPath = "//public-properties[@name='" + entry.getKey() + "' and @value='"
+ entry.getValue() + "']/ancestor::cm-handles";
- final Collection<DataNode> dataNodes = queryDataNodes(cmHandlePath);
+ final Collection<DataNode> dataNodes = queryDataNodes(cpsPath);
if (cmHandleIdToNcmpServiceCmHandles == NO_QUERY_EXECUTED) {
cmHandleIdToNcmpServiceCmHandles = collectDataNodesToNcmpServiceCmHandles(dataNodes);
} else {
@@ -157,12 +157,10 @@ public class NetworkCmProxyCmHandlerQueryServiceImpl implements NetworkCmProxyCm
}
final Map<String, NcmpServiceCmHandle> queryResult = new HashMap<>(cmHandleIdsByModuleName.size());
if (previousQueryResult == NO_QUERY_EXECUTED) {
- //TODO Discuss performance/scaling of getting ALL cmHandles here
- getAllCmHandles().forEach(ncmpServiceCmHandle -> {
- if (cmHandleIdsByModuleName.contains(ncmpServiceCmHandle.getCmHandleId())) {
- queryResult.put(ncmpServiceCmHandle.getCmHandleId(), ncmpServiceCmHandle);
- }
- });
+ cmHandleIdsByModuleName.forEach(cmHandleId ->
+ queryResult.put(cmHandleId, createNcmpServiceCmHandle(
+ getDataNode("/dmi-registry/cm-handles[@id='" + cmHandleId + "']")))
+ );
return queryResult;
}
previousQueryResult.keySet().retainAll(cmHandleIdsByModuleName);
@@ -214,7 +212,7 @@ public class NetworkCmProxyCmHandlerQueryServiceImpl implements NetworkCmProxyCm
}
private Set<NcmpServiceCmHandle> getAllCmHandles() {
- return queryDataNodes("/dmi-registry/cm-handles").stream()
+ return getDataNode("/dmi-registry").getChildDataNodes().stream()
.map(this::createNcmpServiceCmHandle).collect(Collectors.toSet());
}
@@ -223,9 +221,14 @@ public class NetworkCmProxyCmHandlerQueryServiceImpl implements NetworkCmProxyCm
.parallelStream().map(Anchor::getName).collect(Collectors.toSet());
}
- private List<DataNode> queryDataNodes(final String cmHandlePath) {
+ private List<DataNode> queryDataNodes(final String cpsPath) {
return cpsDataPersistenceService.queryDataNodes(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR,
- cmHandlePath, INCLUDE_ALL_DESCENDANTS);
+ cpsPath, INCLUDE_ALL_DESCENDANTS);
+ }
+
+ private DataNode getDataNode(final String cpsPath) {
+ return cpsDataPersistenceService.getDataNode(NCMP_DATASPACE_NAME, NCMP_DMI_REGISTRY_ANCHOR,
+ cpsPath, INCLUDE_ALL_DESCENDANTS);
}
private NcmpServiceCmHandle createNcmpServiceCmHandle(final DataNode dataNode) {