Hazelcast related code update 27/139727/1
authoremaclee <lee.anjella.macabuhay@est.tech>
Thu, 19 Dec 2024 09:31:43 +0000 (09:31 +0000)
committeremaclee <lee.anjella.macabuhay@est.tech>
Thu, 19 Dec 2024 09:39:45 +0000 (09:39 +0000)
- this patch answers comments from 'Hazelcast Optimization'
  patch that was merged

Issue-ID: CPS-2420
Change-Id: Ic5cf005730f2a45eba553a7f6d32e9af6676821d
Signed-off-by: emaclee <lee.anjella.macabuhay@est.tech>
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/CmHandleQueryServiceImpl.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/CmHandleRegistrationService.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/sync/ModuleSyncTasks.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/trustlevel/DmiPluginTrustLevelWatchDog.java
cps-ncmp-service/src/main/java/org/onap/cps/ncmp/impl/inventory/trustlevel/TrustLevelCacheConfig.java
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/CmHandleQueryServiceImplSpec.groovy
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/CmHandleRegistrationServiceSpec.groovy
cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/impl/inventory/sync/ModuleSyncTasksSpec.groovy

index c129163..5610013 100644 (file)
@@ -26,7 +26,6 @@ import static org.onap.cps.ncmp.impl.inventory.NcmpPersistence.NCMP_DATASPACE_NA
 import static org.onap.cps.ncmp.impl.inventory.NcmpPersistence.NCMP_DMI_REGISTRY_ANCHOR;
 import static org.onap.cps.ncmp.impl.inventory.NcmpPersistence.NCMP_DMI_REGISTRY_PARENT;
 
-import com.hazelcast.map.IMap;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -60,10 +59,10 @@ public class CmHandleQueryServiceImpl implements CmHandleQueryService {
     private final CpsQueryService cpsQueryService;
 
     @Qualifier(TrustLevelCacheConfig.TRUST_LEVEL_PER_DMI_PLUGIN)
-    private final IMap<String, TrustLevel> trustLevelPerDmiPlugin;
+    private final Map<String, TrustLevel> trustLevelPerDmiPlugin;
 
     @Qualifier(TrustLevelCacheConfig.TRUST_LEVEL_PER_CM_HANDLE)
-    private final IMap<String, TrustLevel> trustLevelPerCmHandleId;
+    private final Map<String, TrustLevel> trustLevelPerCmHandleId;
 
     private final CpsValidator cpsValidator;
 
index 281d64e..fed8cc7 100644 (file)
@@ -321,7 +321,7 @@ public class CmHandleRegistrationService {
     private void removeDeletedCmHandleFromModuleSyncMap(final String cmHandleId) {
         if (moduleSyncStartedOnCmHandles.containsKey(cmHandleId)) {
             moduleSyncStartedOnCmHandles.removeAsync(cmHandleId);
-            log.debug("{} removed from in progress map", cmHandleId);
+            log.debug("{} will be removed asynchronously from in progress map", cmHandleId);
         }
     }
 
index 0d618cf..fd8a994 100644 (file)
@@ -127,7 +127,7 @@ public class ModuleSyncTasks {
     private void removeResetCmHandleFromModuleSyncMap(final String resetCmHandleId) {
         if (moduleSyncStartedOnCmHandles.containsKey(resetCmHandleId)) {
             moduleSyncStartedOnCmHandles.removeAsync(resetCmHandleId);
-            log.info("{} removed from in progress map", resetCmHandleId);
+            log.info("{} will be removed asynchronously from in progress map", resetCmHandleId);
         }
     }
 
index 044e2b5..aca485f 100644 (file)
@@ -20,8 +20,8 @@
 
 package org.onap.cps.ncmp.impl.inventory.trustlevel;
 
-import com.hazelcast.map.IMap;
 import java.util.Collection;
+import java.util.Map;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.onap.cps.ncmp.api.inventory.models.TrustLevel;
@@ -43,7 +43,7 @@ public class DmiPluginTrustLevelWatchDog {
     private final TrustLevelManager trustLevelManager;
 
     @Qualifier(TrustLevelCacheConfig.TRUST_LEVEL_PER_DMI_PLUGIN)
-    private final IMap<String, TrustLevel> trustLevelPerDmiPlugin;
+    private final Map<String, TrustLevel> trustLevelPerDmiPlugin;
 
     /**
      * This class monitors the trust level of all DMI plugin by checking the health status
index a11dec7..779024b 100644 (file)
@@ -33,7 +33,7 @@ public class TrustLevelCacheConfig extends HazelcastCacheConfig {
     public static final String TRUST_LEVEL_PER_DMI_PLUGIN = "trustLevelPerDmiPlugin";
 
     public static final String TRUST_LEVEL_PER_CM_HANDLE = "trustLevelPerCmHandle";
-    private static final MapConfig trustLevelPerCmHandleIdCacheConfig =
+    private static final MapConfig trustLevelPerCmHandleIdNearCacheConfig =
             createNearCacheMapConfig("trustLevelPerCmHandleCacheConfig");
 
     private static final MapConfig trustLevelPerDmiPluginCacheConfig =
@@ -46,7 +46,7 @@ public class TrustLevelCacheConfig extends HazelcastCacheConfig {
      */
     @Bean(TRUST_LEVEL_PER_CM_HANDLE)
     public IMap<String, TrustLevel> trustLevelPerCmHandleId() {
-        return getOrCreateHazelcastInstance(trustLevelPerCmHandleIdCacheConfig).getMap(TRUST_LEVEL_PER_CM_HANDLE);
+        return getOrCreateHazelcastInstance(trustLevelPerCmHandleIdNearCacheConfig).getMap(TRUST_LEVEL_PER_CM_HANDLE);
     }
 
     /**
index 7ac2b2c..1c8a19a 100644 (file)
@@ -42,18 +42,11 @@ class CmHandleQueryServiceImplSpec extends Specification {
 
     def mockCpsQueryService = Mock(CpsQueryService)
     def mockCpsDataService = Mock(CpsDataService)
-    def trustLevelPerDmiPlugin = HazelcastInstanceFactory
-        .getOrCreateHazelcastInstance(new Config('hazelcastInstanceName'))
-        .getMap('trustLevelPerDmiPlugin')
-    def trustLevelPerCmHandleId = HazelcastInstanceFactory
-        .getOrCreateHazelcastInstance(new Config('hazelcastInstanceName'))
-        .getMap('trustLevelPerCmHandleId')
+    def trustLevelPerDmiPlugin = HazelcastInstanceFactory.getOrCreateHazelcastInstance(new Config('hazelcastInstanceName')).getMap('trustLevelPerDmiPlugin')
+    def trustLevelPerCmHandleId = HazelcastInstanceFactory.getOrCreateHazelcastInstance(new Config('hazelcastInstanceName')).getMap('trustLevelPerCmHandleId')
     def mockCpsValidator = Mock(CpsValidator)
 
-
-    def objectUnderTest = new CmHandleQueryServiceImpl(mockCpsDataService, mockCpsQueryService,
-        trustLevelPerDmiPlugin, trustLevelPerCmHandleId, mockCpsValidator)
-
+    def objectUnderTest = new CmHandleQueryServiceImpl(mockCpsDataService, mockCpsQueryService, trustLevelPerDmiPlugin, trustLevelPerCmHandleId, mockCpsValidator)
     def static sampleDataNodes = [new DataNode(xpath: "/dmi-registry/cm-handles[@id='ch-1']"),
                                   new DataNode(xpath: "/dmi-registry/cm-handles[@id='ch-2']")]
 
index faa193e..0706a1e 100644 (file)
@@ -86,7 +86,7 @@ class CmHandleRegistrationServiceSpec extends Specification {
             mockInventoryPersistence.getYangModelCmHandle('cmhandle-3') >> new YangModelCmHandle(id: 'cmhandle-3', moduleSetTag: '', compositeState: new CompositeState(cmHandleState: CmHandleState.READY))
         and: 'cm handle is in READY state'
             mockCmHandleQueries.cmHandleHasState('cmhandle-3', CmHandleState.READY) >> true
-        and: 'cm handle to be removed is in progress map'
+        and: 'cm handles is present in in-progress map'
             mockModuleSyncStartedOnCmHandles.containsKey('cmhandle-2') >> true
         when: 'registration is processed'
             objectUnderTest.updateDmiRegistration(dmiRegistration)
@@ -328,7 +328,6 @@ class CmHandleRegistrationServiceSpec extends Specification {
         and: 'successfully de-registered cm handle 3 is removed from in progress map even though it was already being removed'
             1 * mockModuleSyncStartedOnCmHandles.removeAsync('cmhandle3')
         and: 'failed de-registered cm handle entries should NOT be removed from in progress map'
-            0 * mockModuleSyncStartedOnCmHandles.containsKey('cmhandle2')
             0 * mockModuleSyncStartedOnCmHandles.removeAsync('cmhandle2')
         and: '1st and 3rd cm-handle deletes successfully'
             with(response.removedCmHandles[0]) {
index 97c2488..02d50c2 100644 (file)
@@ -194,7 +194,7 @@ class ModuleSyncTasksSpec extends Specification {
             def loggingEvent = getLoggingEvent()
             assert loggingEvent.level == Level.INFO
         and: 'the log indicates the cm handle entry is removed successfully'
-            assert loggingEvent.formattedMessage == 'ch-1 removed from in progress map'
+            assert loggingEvent.formattedMessage == 'ch-1 will be removed asynchronously from in progress map'
     }
 
     def 'Sync and upgrade CM handle if in upgrade state for #scenario'() {