summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'cps-ncmp-service/src/main/java')
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyCmHandleQueryService.java29
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java7
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/SubscriptionModelLoader.java38
3 files changed, 43 insertions, 31 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyCmHandleQueryService.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyCmHandleQueryService.java
index 91e98e866b..f29fd687b0 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyCmHandleQueryService.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyCmHandleQueryService.java
@@ -26,26 +26,39 @@ import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle;
public interface NetworkCmProxyCmHandleQueryService {
/**
- * Query and return cm handles that match the given query parameters.
+ * Query and return cm handle ids that match the given query parameters.
+ * Supported query types:
+ * public properties
+ * modules
+ * cps-path
*
* @param cmHandleQueryServiceParameters the cm handle query parameters
- * @return collection of cm handles
+ * @return collection of cm handle ids
*/
- Collection<NcmpServiceCmHandle> queryCmHandles(CmHandleQueryServiceParameters cmHandleQueryServiceParameters);
+ Collection<String> queryCmHandleIds(CmHandleQueryServiceParameters cmHandleQueryServiceParameters);
/**
- * Query and return cm handles that match the given query parameters.
+ * Query and return cm handle ids that match the given query parameters.
+ * Supported query types:
+ * public properties
+ * private (additional) properties
+ * dmi-names
+ * The inventory interface also allows conditions on private (additional) properties and dmi names
*
* @param cmHandleQueryServiceParameters the cm handle query parameters
* @return collection of cm handle ids
*/
- Collection<String> queryCmHandleIds(CmHandleQueryServiceParameters cmHandleQueryServiceParameters);
+ Collection<String> queryCmHandleIdsForInventory(CmHandleQueryServiceParameters cmHandleQueryServiceParameters);
/**
- * Query and return cm handles that match the given query parameters.
+ * Query and return cm handle objects that match the given query parameters.
+ * Supported query types:
+ * public properties
+ * modules
+ * cps-path
*
* @param cmHandleQueryServiceParameters the cm handle query parameters
- * @return collection of cm handle ids
+ * @return collection of cm handles
*/
- Collection<String> queryCmHandleIdsForInventory(CmHandleQueryServiceParameters cmHandleQueryServiceParameters);
+ Collection<NcmpServiceCmHandle> queryCmHandles(CmHandleQueryServiceParameters cmHandleQueryServiceParameters);
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java
index 8acaa0abe3..e2330a7135 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/inventory/sync/ModuleSyncWatchdog.java
@@ -69,7 +69,7 @@ public class ModuleSyncWatchdog {
while (!moduleSyncWorkQueue.isEmpty()) {
if (batchCounter.get() <= asyncTaskParallelismLevel) {
final Collection<DataNode> nextBatch = prepareNextBatch();
- log.debug("Processing module sync batch of {}. {} batch(es) active.",
+ log.info("Processing module sync batch of {}. {} batch(es) active.",
nextBatch.size(), batchCounter.get());
asyncTaskExecutor.executeTask(() ->
moduleSyncTasks.performModuleSync(nextBatch, batchCounter),
@@ -118,15 +118,16 @@ public class ModuleSyncWatchdog {
final Collection<DataNode> nextBatchCandidates = new HashSet<>(MODULE_SYNC_BATCH_SIZE);
final Collection<DataNode> nextBatch = new HashSet<>(MODULE_SYNC_BATCH_SIZE);
moduleSyncWorkQueue.drainTo(nextBatchCandidates, MODULE_SYNC_BATCH_SIZE);
- log.debug("nextBatchCandidates size : {}", nextBatchCandidates.size());
+ log.info("nextBatchCandidates size : {}", nextBatchCandidates.size());
for (final DataNode batchCandidate : nextBatchCandidates) {
final String cmHandleId = String.valueOf(batchCandidate.getLeaves().get("id"));
final boolean alreadyAddedToInProgressMap = VALUE_FOR_HAZELCAST_IN_PROGRESS_MAP.equals(
moduleSyncStartedOnCmHandles.putIfAbsent(cmHandleId, VALUE_FOR_HAZELCAST_IN_PROGRESS_MAP,
SynchronizationCacheConfig.MODULE_SYNC_STARTED_TTL_SECS, TimeUnit.SECONDS));
if (alreadyAddedToInProgressMap) {
- log.debug("module sync for {} already in progress by other instance", cmHandleId);
+ log.info("module sync for {} already in progress by other instance", cmHandleId);
} else {
+ log.info("Adding cmHandle : {} to current batch", cmHandleId);
nextBatch.add(batchCandidate);
}
}
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/SubscriptionModelLoader.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/SubscriptionModelLoader.java
index 705c9d2664..231ba75b5d 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/SubscriptionModelLoader.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/init/SubscriptionModelLoader.java
@@ -24,7 +24,6 @@ import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.time.OffsetDateTime;
import java.util.Map;
-import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.onap.cps.api.CpsAdminService;
@@ -45,6 +44,8 @@ public class SubscriptionModelLoader implements ModelLoader {
private final CpsAdminService cpsAdminService;
private final CpsModuleService cpsModuleService;
private final CpsDataService cpsDataService;
+ private static final String SUBSCRIPTION_MODEL_FILENAME = "subscription.yang";
+ private static final String SUBSCRIPTION_MODEL_RESOURCE_PATH = "model/" + SUBSCRIPTION_MODEL_FILENAME;
private static final String SUBSCRIPTION_DATASPACE_NAME = "NCMP-Admin";
private static final String SUBSCRIPTION_ANCHOR_NAME = "AVC-Subscriptions";
private static final String SUBSCRIPTION_SCHEMASET_NAME = "subscriptions";
@@ -59,10 +60,10 @@ public class SubscriptionModelLoader implements ModelLoader {
* @param applicationReadyEvent the event to respond to
*/
@Override
- public void onApplicationEvent(@NonNull final ApplicationReadyEvent applicationReadyEvent) {
+ public void onApplicationEvent(final ApplicationReadyEvent applicationReadyEvent) {
try {
if (subscriptionModelLoaderEnabled) {
- onboardSubscriptionModel();
+ onboardSubscriptionModel(createYangResourceToContentMap());
} else {
log.info("Subscription Model Loader is disabled");
}
@@ -75,21 +76,18 @@ public class SubscriptionModelLoader implements ModelLoader {
/**
* Method to onboard subscription model for NCMP.
*/
- private void onboardSubscriptionModel() {
- final Map<String, String> yangResourceContentMap = createYangResourceToContentMap();
- if (!yangResourceContentMap.get("subscription.yang").isEmpty()) {
- createSchemaSet(SUBSCRIPTION_DATASPACE_NAME, SUBSCRIPTION_SCHEMASET_NAME, yangResourceContentMap);
- createAnchor(SUBSCRIPTION_DATASPACE_NAME, SUBSCRIPTION_SCHEMASET_NAME, SUBSCRIPTION_ANCHOR_NAME);
- createTopLevelDataNode(SUBSCRIPTION_DATASPACE_NAME, SUBSCRIPTION_ANCHOR_NAME,
- SUBSCRIPTION_REGISTRY_DATANODE_NAME);
- }
+ private void onboardSubscriptionModel(final Map<String, String> yangResourceContentMap) {
+ createSchemaSet(SUBSCRIPTION_DATASPACE_NAME, SUBSCRIPTION_SCHEMASET_NAME, yangResourceContentMap);
+ createAnchor(SUBSCRIPTION_DATASPACE_NAME, SUBSCRIPTION_SCHEMASET_NAME, SUBSCRIPTION_ANCHOR_NAME);
+ createTopLevelDataNode(SUBSCRIPTION_DATASPACE_NAME, SUBSCRIPTION_ANCHOR_NAME,
+ SUBSCRIPTION_REGISTRY_DATANODE_NAME);
}
@Override
public boolean createSchemaSet(final String dataspaceName,
- final String schemaSetName,
- final Map<String, String> yangResourceContentMap) {
+ final String schemaSetName,
+ final Map<String, String> yangResourceContentMap) {
try {
cpsModuleService.createSchemaSet(dataspaceName, schemaSetName, yangResourceContentMap);
} catch (final AlreadyDefinedException exception) {
@@ -129,24 +127,24 @@ public class SubscriptionModelLoader implements ModelLoader {
try {
cpsDataService.saveData(dataspaceName, anchorName, nodeData, OffsetDateTime.now());
} catch (final AlreadyDefinedException exception) {
- log.info("Creating new data node {} failed as data node already exists", dataNodeName);
+ log.info("Creating new data node '{}' failed as data node already exists", dataNodeName);
} catch (final Exception exception) {
log.debug("Creating data node for subscription model failed: {}", exception.getMessage());
throw new NcmpStartUpException("Creating data node failed", exception.getMessage());
}
}
- private String getFileContentAsString() {
- try (InputStream inputStream = getClass().getClassLoader()
- .getResourceAsStream("model/subscription.yang")) {
+ private String getFileContentAsString(final String fileName) {
+ try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(fileName)) {
return new String(inputStream.readAllBytes(), StandardCharsets.UTF_8);
} catch (final Exception exception) {
- log.debug("Onboarding failed as unable to read file: {}", exception.getCause().toString());
- throw new NcmpStartUpException("Onboarding failed as unable to read file: {}", exception.getMessage());
+ final String message = String.format("Onboarding failed as unable to read file: %s", fileName);
+ log.debug(message);
+ throw new NcmpStartUpException(message, exception.getMessage());
}
}
private Map<String, String> createYangResourceToContentMap() {
- return Map.of("subscription.yang", getFileContentAsString());
+ return Map.of(SUBSCRIPTION_MODEL_FILENAME, getFileContentAsString(SUBSCRIPTION_MODEL_RESOURCE_PATH));
}
}