diff options
author | danielhanrahan <daniel.hanrahan@est.tech> | 2024-02-21 12:38:05 +0000 |
---|---|---|
committer | danielhanrahan <daniel.hanrahan@est.tech> | 2024-02-21 12:38:05 +0000 |
commit | a1ab76467ce2d096e3d51eaf144cfe043ef1c241 (patch) | |
tree | 6e6d1d5392cbdd2f246d3f9c0d75a1f0a8148fca /cps-ncmp-service/src/main/java/org/onap | |
parent | 18316c037509c4fddf382d8512c6af620019c7b8 (diff) |
Upgrade yang modules using module set tag
- New algorithm is implemented as per the pseudo code -> https://wiki.onap.org/display/DW/CPS-1733%3A+Upgrade+YANG+Schema-Set+for+CM+Handle+Using+a+Module+Set+Tag
Issue-ID: CPS-2027
Change-Id: I78fc1c8f927de1a1b814c3c1c62351dda58f2139
Signed-off-by: sourabh_sourabh <sourabh.sourabh@est.tech>
Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech>
Diffstat (limited to 'cps-ncmp-service/src/main/java/org/onap')
5 files changed, 93 insertions, 179 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 7622e7cb49..1f2748b4af 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 @@ -35,11 +35,9 @@ import static org.onap.cps.ncmp.api.impl.utils.RestQueryParametersValidator.vali import com.google.common.collect.Lists; import com.hazelcast.map.IMap; -import java.text.MessageFormat; import java.time.OffsetDateTime; import java.util.ArrayList; import java.util.Collection; -import java.util.EnumMap; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -48,8 +46,8 @@ import java.util.Set; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.onap.cps.api.CpsDataService; -import org.onap.cps.ncmp.api.NcmpResponseStatus; import org.onap.cps.ncmp.api.NetworkCmProxyCmHandleQueryService; import org.onap.cps.ncmp.api.NetworkCmProxyDataService; import org.onap.cps.ncmp.api.impl.events.lcm.LcmEventsCmHandleStateHandler; @@ -106,7 +104,6 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService private final Map<String, TrustLevel> trustLevelPerDmiPlugin; private final TrustLevelManager trustLevelManager; private final AlternateIdChecker alternateIdChecker; - private final Map<String, Collection<ModuleReference>> moduleSetTagCache; @Override public DmiPluginRegistrationResponse updateDmiRegistrationAndSyncModule( @@ -344,16 +341,12 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService new ArrayList<>(tobeRemovedCmHandles.size()); final Collection<YangModelCmHandle> yangModelCmHandles = inventoryPersistence.getYangModelCmHandles(tobeRemovedCmHandles); - final Set<String> moduleSetTags = yangModelCmHandles.stream().map(YangModelCmHandle::getModuleSetTag) - .collect(Collectors.toSet()); updateCmHandleStateBatch(yangModelCmHandles, CmHandleState.DELETING); final Set<String> notDeletedCmHandles = new HashSet<>(); for (final List<String> tobeRemovedCmHandleBatch : Lists.partition(tobeRemovedCmHandles, DELETE_BATCH_SIZE)) { try { batchDeleteCmHandlesFromDbAndModuleSyncMap(tobeRemovedCmHandleBatch); - moduleSetTags.forEach(moduleSetTagCache::remove); - log.debug("Removed module set tags: {}", moduleSetTags); tobeRemovedCmHandleBatch.forEach(cmHandleId -> cmHandleRegistrationResponses.add(CmHandleRegistrationResponse.createSuccessResponse(cmHandleId))); @@ -417,53 +410,55 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService final DmiPluginRegistration dmiPluginRegistration) { final List<String> upgradedCmHandleIds = dmiPluginRegistration.getUpgradedCmHandles().getCmHandles(); - + final String upgradedModuleSetTag = dmiPluginRegistration.getUpgradedCmHandles().getModuleSetTag(); final Map<YangModelCmHandle, CmHandleState> acceptedCmHandleStatePerCmHandle = new HashMap<>(upgradedCmHandleIds.size()); + final List<CmHandleRegistrationResponse> cmHandleUpgradeResponses = new ArrayList<>(upgradedCmHandleIds.size()); - final Map<NcmpResponseStatus, List<String>> failedCmHandlesPerResponseStatus - = new EnumMap<>(NcmpResponseStatus.class); - final List<String> nonExistingCmHandleIds = new ArrayList<>(); - final List<String> nonReadyCmHandleIds = new ArrayList<>(); - final List<String> invalidCmHandleIds = new ArrayList<>(); - - upgradedCmHandleIds.forEach(cmHandleId -> { + for (final String cmHandleId : upgradedCmHandleIds) { try { - if (cmHandleQueries.cmHandleHasState(cmHandleId, CmHandleState.READY)) { - final YangModelCmHandle yangModelCmHandleWithUpgradeDetails - = createYangModelCmHandle(dmiPluginRegistration, cmHandleId); - acceptedCmHandleStatePerCmHandle.put(yangModelCmHandleWithUpgradeDetails, CmHandleState.LOCKED); + final YangModelCmHandle yangModelCmHandle = inventoryPersistence.getYangModelCmHandle(cmHandleId); + if (yangModelCmHandle.getCompositeState().getCmHandleState() == CmHandleState.READY) { + if (moduleUpgradeCanBeSkipped(yangModelCmHandle, upgradedModuleSetTag)) { + cmHandleUpgradeResponses.add(CmHandleRegistrationResponse.createSuccessResponse(cmHandleId)); + } else { + updateYangModelCmHandleForUpgrade(yangModelCmHandle, upgradedModuleSetTag); + acceptedCmHandleStatePerCmHandle.put(yangModelCmHandle, CmHandleState.LOCKED); + } } else { - nonReadyCmHandleIds.add(cmHandleId); + cmHandleUpgradeResponses.add( + CmHandleRegistrationResponse.createFailureResponse(cmHandleId, CM_HANDLES_NOT_READY)); } } catch (final DataNodeNotFoundException dataNodeNotFoundException) { log.error("Unable to find data node for cm handle id : {} , caused by : {}", cmHandleId, dataNodeNotFoundException.getMessage()); - nonExistingCmHandleIds.add(cmHandleId); + cmHandleUpgradeResponses.add( + CmHandleRegistrationResponse.createFailureResponse(cmHandleId, CM_HANDLES_NOT_FOUND)); } catch (final DataValidationException dataValidationException) { log.error("Unable to upgrade cm handle id: {}, caused by : {}", cmHandleId, dataValidationException.getMessage()); - invalidCmHandleIds.add(cmHandleId); + cmHandleUpgradeResponses.add( + CmHandleRegistrationResponse.createFailureResponse(cmHandleId, CM_HANDLE_INVALID_ID)); } - }); - failedCmHandlesPerResponseStatus.put(CM_HANDLES_NOT_READY, nonReadyCmHandleIds); - failedCmHandlesPerResponseStatus.put(CM_HANDLES_NOT_FOUND, nonExistingCmHandleIds); - failedCmHandlesPerResponseStatus.put(CM_HANDLE_INVALID_ID, invalidCmHandleIds); - return mergeAllCmHandleResponses(acceptedCmHandleStatePerCmHandle, failedCmHandlesPerResponseStatus); - } - - private static YangModelCmHandle createYangModelCmHandle(final DmiPluginRegistration dmiPluginRegistration, - final String cmHandleId) { - final NcmpServiceCmHandle ncmpServiceCmHandle = new NcmpServiceCmHandle(); - ncmpServiceCmHandle.setCmHandleId(cmHandleId); - final String moduleSetTag = dmiPluginRegistration.getUpgradedCmHandles().getModuleSetTag(); - final String lockReasonWithModuleSetTag = MessageFormat.format( - ModuleOperationsUtils.MODULE_SET_TAG_MESSAGE_FORMAT, moduleSetTag); - ncmpServiceCmHandle.setCompositeState(new CompositeStateBuilder().withCmHandleState(CmHandleState.READY) + } + cmHandleUpgradeResponses.addAll(upgradeCmHandles(acceptedCmHandleStatePerCmHandle)); + return cmHandleUpgradeResponses; + } + + private static boolean moduleUpgradeCanBeSkipped(final YangModelCmHandle yangModelCmHandle, + final String upgradedModuleSetTag) { + if (StringUtils.isBlank(upgradedModuleSetTag)) { + return false; + } + return yangModelCmHandle.getModuleSetTag().equals(upgradedModuleSetTag); + } + + private static void updateYangModelCmHandleForUpgrade(final YangModelCmHandle yangModelCmHandle, + final String upgradedModuleSetTag) { + final String lockReasonWithModuleSetTag = String.format(ModuleOperationsUtils.MODULE_SET_TAG_MESSAGE_FORMAT, + upgradedModuleSetTag); + yangModelCmHandle.setCompositeState(new CompositeStateBuilder().withCmHandleState(CmHandleState.READY) .withLockReason(MODULE_UPGRADE, lockReasonWithModuleSetTag).build()); - return YangModelCmHandle.toYangModelCmHandle(dmiPluginRegistration.getDmiPlugin(), - dmiPluginRegistration.getDmiDataPlugin(), dmiPluginRegistration.getDmiModelPlugin(), - ncmpServiceCmHandle, moduleSetTag, ncmpServiceCmHandle.getAlternateId()); } private CmHandleRegistrationResponse deleteCmHandleAndGetCmHandleRegistrationResponse(final String cmHandleId) { @@ -533,17 +528,6 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService } } - private List<CmHandleRegistrationResponse> mergeAllCmHandleResponses( - final Map<YangModelCmHandle, CmHandleState> acceptedCmHandleStatePerCmHandle, - final Map<NcmpResponseStatus, List<String>> failedCmHandlesPerResponseStatus) { - final List<CmHandleRegistrationResponse> cmHandleUpgradeResponses - = upgradeCmHandles(acceptedCmHandleStatePerCmHandle); - failedCmHandlesPerResponseStatus.forEach((ncmpResponseStatus, cmHandleIds) -> - cmHandleIds.forEach(cmHandleId -> cmHandleUpgradeResponses.add(CmHandleRegistrationResponse - .createFailureResponse(cmHandleId, ncmpResponseStatus)))); - return cmHandleUpgradeResponses; - } - private List<CmHandleRegistrationResponse> upgradeCmHandles(final Map<YangModelCmHandle, CmHandleState> cmHandleStatePerCmHandle) { final List<String> cmHandleIds = getCmHandleIds(cmHandleStatePerCmHandle); diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/config/embeddedcache/ModuleSetTagCacheConfig.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/config/embeddedcache/ModuleSetTagCacheConfig.java deleted file mode 100644 index a791a3bbd1..0000000000 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/config/embeddedcache/ModuleSetTagCacheConfig.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2023 Nordix Foundation - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.cps.ncmp.api.impl.config.embeddedcache; - -import com.hazelcast.config.MapConfig; -import java.util.Collection; -import java.util.Map; -import org.onap.cps.cache.HazelcastCacheConfig; -import org.onap.cps.spi.model.ModuleReference; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class ModuleSetTagCacheConfig extends HazelcastCacheConfig { - - private static final MapConfig moduleSetTagCacheMapConfig = createMapConfig("moduleSetTagCacheMapConfig"); - - /** - * Map instance for cached ModulesSetTags. - * - * @return configured map of ModuleSetTags - */ - @Bean - public Map<String, Collection<ModuleReference>> moduleSetTagCache() { - return createHazelcastInstance("moduleSetTags", moduleSetTagCacheMapConfig) - .getMap("moduleSetTagCache"); - } -} diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleOperationsUtils.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleOperationsUtils.java index 7b2e3d589f..9f95131cf1 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleOperationsUtils.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleOperationsUtils.java @@ -62,9 +62,9 @@ public class ModuleOperationsUtils { private final JsonObjectMapper jsonObjectMapper; private static final String RETRY_ATTEMPT_KEY = "attempt"; private static final String MODULE_SET_TAG_KEY = "moduleSetTag"; - public static final String MODULE_SET_TAG_MESSAGE_FORMAT = "Upgrade to ModuleSetTag: {0}"; - private static final String UPGRADE_FORMAT = "Upgrade to ModuleSetTag: %s"; - private static final String LOCK_REASON_DETAILS_MSG_FORMAT = UPGRADE_FORMAT + " Attempt #%d failed: %s"; + public static final String MODULE_SET_TAG_MESSAGE_FORMAT = "Upgrade to ModuleSetTag: %s"; + private static final String LOCK_REASON_DETAILS_MSG_FORMAT = + MODULE_SET_TAG_MESSAGE_FORMAT + " Attempt #%d failed: %s"; private static final Pattern retryAttemptPattern = Pattern.compile("Attempt #(\\d+) failed:.+"); private static final Pattern moduleSetTagPattern = Pattern.compile("Upgrade to ModuleSetTag: (\\S+)"); private static final String CPS_PATH_CM_HANDLES_MODEL_SYNC_FAILED_OR_UPGRADE = """ @@ -220,7 +220,7 @@ public class ModuleOperationsUtils { * @param compositeState current lock reason of cm handle * @return true or false based on lock reason category */ - public static boolean isInUpgradeOrUpgradeFailed(final CompositeState compositeState) { + public static boolean inUpgradeOrUpgradeFailed(final CompositeState compositeState) { return compositeState.getLockReason() != null && (LockReasonCategory.MODULE_UPGRADE.equals(compositeState.getLockReason().getLockReasonCategory()) || LockReasonCategory.MODULE_UPGRADE_FAILED.equals(compositeState.getLockReason() diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncService.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncService.java index d4ef5c612a..8b70798eb1 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncService.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncService.java @@ -35,12 +35,12 @@ import java.util.Optional; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.tuple.ImmutableTriple; import org.onap.cps.api.CpsAnchorService; import org.onap.cps.api.CpsDataService; import org.onap.cps.api.CpsModuleService; import org.onap.cps.ncmp.api.impl.inventory.CmHandleQueries; import org.onap.cps.ncmp.api.impl.inventory.CmHandleState; -import org.onap.cps.ncmp.api.impl.inventory.CompositeState; import org.onap.cps.ncmp.api.impl.operations.DmiModelOperations; import org.onap.cps.ncmp.api.impl.utils.YangDataConverter; import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle; @@ -63,7 +63,6 @@ public class ModuleSyncService { private final CpsDataService cpsDataService; private final CpsAnchorService cpsAnchorService; private final JsonObjectMapper jsonObjectMapper; - private final Map<String, Collection<ModuleReference>> moduleSetTagCache; private static final Map<String, String> NO_NEW_MODULES = Collections.emptyMap(); /** @@ -73,44 +72,27 @@ public class ModuleSyncService { */ public void syncAndCreateOrUpgradeSchemaSetAndAnchor(final YangModelCmHandle yangModelCmHandle) { + final boolean inUpgrade = ModuleOperationsUtils.inUpgradeOrUpgradeFailed(yangModelCmHandle.getCompositeState()); + + final ImmutableTriple<String, Map<String, String>, Collection<ModuleReference>> + allModuleReferencesAndNewModuleNameByModuleSetTag + = getAllModuleReferencesAndNewYangResourcesByModuleSetTag(yangModelCmHandle, inUpgrade); + + final String moduleSetTag = allModuleReferencesAndNewModuleNameByModuleSetTag.getLeft(); + final Map<String, String> newYangResources = allModuleReferencesAndNewModuleNameByModuleSetTag.getMiddle(); + final Collection<ModuleReference> allModuleReferences + = allModuleReferencesAndNewModuleNameByModuleSetTag.getRight(); final String cmHandleId = yangModelCmHandle.getId(); - final CompositeState compositeState = yangModelCmHandle.getCompositeState(); - final boolean inUpgrade = ModuleOperationsUtils.isInUpgradeOrUpgradeFailed(compositeState); - final String moduleSetTag = getModuleSetTag(yangModelCmHandle, compositeState, inUpgrade); - - final Collection<ModuleReference> moduleReferencesFromCache = moduleSetTagCache.get(moduleSetTag); - - if (moduleReferencesFromCache == null) { - final Optional<DataNode> existingCmHandleWithSameModuleSetTag - = getFirstReadyDataNodeWithModuleSetTag(moduleSetTag); - - if (existingCmHandleWithSameModuleSetTag.isPresent()) { - final String existingAnchorName = existingCmHandleWithSameModuleSetTag.get().getAnchorName(); - final Collection<ModuleReference> moduleReferencesFromExistingCmHandle = - upgradeOrCreateSchemaSetUsingModuleSetTag(yangModelCmHandle.getId(), moduleSetTag, - existingAnchorName, inUpgrade); - updateModuleSetTagCache(moduleSetTag, moduleReferencesFromExistingCmHandle); - } else { - if (inUpgrade) { - deleteSchemaSetIfExists(cmHandleId); - } - final Collection<ModuleReference> allModuleReferencesFromCmHandle - = syncAndCreateSchemaSet(yangModelCmHandle); - updateModuleSetTagCache(moduleSetTag, allModuleReferencesFromCmHandle); - } + + if (inUpgrade) { + cpsModuleService.upgradeSchemaSetFromModules(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, cmHandleId, + newYangResources, allModuleReferences); + setCmHandleModuleSetTag(yangModelCmHandle, moduleSetTag); } else { - if (inUpgrade) { - cpsModuleService.upgradeSchemaSetFromModules(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, cmHandleId, - NO_NEW_MODULES, moduleReferencesFromCache); - } else { - cpsModuleService.createSchemaSetFromModules(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, - cmHandleId, NO_NEW_MODULES, moduleReferencesFromCache); - } - } - if (!inUpgrade) { + cpsModuleService.createSchemaSetFromModules(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, cmHandleId, + newYangResources, allModuleReferences); cpsAnchorService.createAnchor(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, cmHandleId, cmHandleId); } - setCmHandleModuleSetTag(yangModelCmHandle, moduleSetTag); } /** @@ -128,7 +110,30 @@ public class ModuleSyncService { } } - private Optional<DataNode> getFirstReadyDataNodeWithModuleSetTag(final String moduleSetTag) { + private ImmutableTriple<String, Map<String, String>, Collection<ModuleReference>> + getAllModuleReferencesAndNewYangResourcesByModuleSetTag(final YangModelCmHandle yangModelCmHandle, + final boolean inUpgrade) { + + final String moduleSetTag = getModuleSetTag(yangModelCmHandle, inUpgrade); + final Collection<ModuleReference> allModuleReferences; + Map<String, String> newYangResources = Collections.emptyMap(); + + final Optional<DataNode> optionalDataNode = getFirstReadyDataNodeByModuleSetTagProvidedInDb(moduleSetTag); + + if (optionalDataNode.isPresent()) { + log.info("Found other cm handle having same module set tag: {}", moduleSetTag); + final String otherAnchorWithSameModuleSetTag + = YangDataConverter.extractCmHandleIdFromXpath(optionalDataNode.get().getXpath()); + allModuleReferences = cpsModuleService.getYangResourcesModuleReferences( + NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, otherAnchorWithSameModuleSetTag); + } else { + allModuleReferences = dmiModelOperations.getModuleReferences(yangModelCmHandle); + newYangResources = getNewModuleNameToContentMap(yangModelCmHandle, allModuleReferences); + } + return ImmutableTriple.of(moduleSetTag, newYangResources, allModuleReferences); + } + + private Optional<DataNode> getFirstReadyDataNodeByModuleSetTagProvidedInDb(final String moduleSetTag) { final List<DataNode> dataNodes = StringUtils.isNotBlank(moduleSetTag) ? cmHandleQueries .queryNcmpRegistryByCpsPath("//cm-handles[@module-set-tag='" + moduleSetTag + "']", FetchDescendantsOption.OMIT_DESCENDANTS) : Collections.emptyList(); @@ -148,55 +153,26 @@ public class ModuleSyncService { jsonObjectMapper.asJsonString(dmiRegistryProperties), OffsetDateTime.now()); } - private Collection<ModuleReference> syncAndCreateSchemaSet(final YangModelCmHandle yangModelCmHandle) { - final Collection<ModuleReference> allModuleReferencesFromCmHandle = - dmiModelOperations.getModuleReferences(yangModelCmHandle); - final Collection<ModuleReference> identifiedNewModuleReferencesFromCmHandle = cpsModuleService - .identifyNewModuleReferences(allModuleReferencesFromCmHandle); + private Map<String, String> getNewModuleNameToContentMap(final YangModelCmHandle yangModelCmHandle, + final Collection<ModuleReference> moduleReferences) { + final Collection<ModuleReference> identifiedNewModuleReferences = cpsModuleService + .identifyNewModuleReferences(moduleReferences); final Map<String, String> newModuleNameToContentMap; - if (identifiedNewModuleReferencesFromCmHandle.isEmpty()) { + if (identifiedNewModuleReferences.isEmpty()) { newModuleNameToContentMap = NO_NEW_MODULES; } else { newModuleNameToContentMap = dmiModelOperations.getNewYangResourcesFromDmi(yangModelCmHandle, - identifiedNewModuleReferencesFromCmHandle); - } - cpsModuleService.createSchemaSetFromModules(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, - yangModelCmHandle.getId(), newModuleNameToContentMap, allModuleReferencesFromCmHandle); - return allModuleReferencesFromCmHandle; - } - - private Collection<ModuleReference> upgradeOrCreateSchemaSetUsingModuleSetTag(final String schemaSetName, - final String moduleSetTag, - final String existingAnchorName, - final boolean inUpgrade) { - log.info("Found cm handle having module set tag: {}", moduleSetTag); - final Collection<ModuleReference> moduleReferencesFromExistingCmHandle = - cpsModuleService.getYangResourcesModuleReferences(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, - existingAnchorName); - if (inUpgrade) { - cpsModuleService.upgradeSchemaSetFromModules(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, schemaSetName, - NO_NEW_MODULES, moduleReferencesFromExistingCmHandle); - } else { - cpsModuleService.createSchemaSetFromModules(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, - schemaSetName, NO_NEW_MODULES, moduleReferencesFromExistingCmHandle); + identifiedNewModuleReferences); } - return moduleReferencesFromExistingCmHandle; + return newModuleNameToContentMap; } - private String getModuleSetTag(final YangModelCmHandle yangModelCmHandle, - final CompositeState compositeState, - final boolean inUpgrade) { + private String getModuleSetTag(final YangModelCmHandle yangModelCmHandle, final boolean inUpgrade) { if (inUpgrade) { - return ModuleOperationsUtils.getUpgradedModuleSetTagFromLockReason(compositeState.getLockReason()); + return ModuleOperationsUtils.getUpgradedModuleSetTagFromLockReason( + yangModelCmHandle.getCompositeState().getLockReason()); } return yangModelCmHandle.getModuleSetTag(); } - private void updateModuleSetTagCache(final String moduleSetTag, - final Collection<ModuleReference> allModuleReferencesFromCmHandle) { - if (StringUtils.isNotBlank(moduleSetTag)) { - moduleSetTagCache.putIfAbsent(moduleSetTag, allModuleReferencesFromCmHandle); - } - } - } diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncTasks.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncTasks.java index e214044189..804653a168 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncTasks.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/inventory/sync/ModuleSyncTasks.java @@ -67,7 +67,7 @@ public class ModuleSyncTasks { final YangModelCmHandle yangModelCmHandle = YangDataConverter.convertCmHandleToYangModel(cmHandleAsDataNode, cmHandleId); final CompositeState compositeState = inventoryPersistence.getCmHandleState(cmHandleId); - final boolean inUpgrade = ModuleOperationsUtils.isInUpgradeOrUpgradeFailed(compositeState); + final boolean inUpgrade = ModuleOperationsUtils.inUpgradeOrUpgradeFailed(compositeState); try { if (!inUpgrade) { moduleSyncService.deleteSchemaSetIfExists(cmHandleId); |