Uplift Spring boot 3.2.4
[cps.git] / cps-ncmp-service / src / main / java / org / onap / cps / ncmp / api / impl / trustlevel / dmiavailability / DmiPluginWatchDog.java
index 9fd096d..d6d6fd6 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2023 Nordix Foundation
+ *  Copyright (C) 2023-2024 Nordix Foundation
  *  ================================================================================
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -26,8 +26,10 @@ import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.onap.cps.ncmp.api.NetworkCmProxyDataService;
 import org.onap.cps.ncmp.api.impl.client.DmiRestClient;
+import org.onap.cps.ncmp.api.impl.config.embeddedcache.TrustLevelCacheConfig;
 import org.onap.cps.ncmp.api.impl.trustlevel.TrustLevel;
 import org.onap.cps.ncmp.api.impl.trustlevel.TrustLevelManager;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 
@@ -39,14 +41,16 @@ public class DmiPluginWatchDog {
     private final DmiRestClient dmiRestClient;
     private final NetworkCmProxyDataService networkCmProxyDataService;
     private final TrustLevelManager trustLevelManager;
+
+    @Qualifier(TrustLevelCacheConfig.TRUST_LEVEL_PER_DMI_PLUGIN)
     private final Map<String, TrustLevel> trustLevelPerDmiPlugin;
 
     /**
      * This class monitors the trust level of all DMI plugin by checking the health status
-     * the resulting trustlevel wil be stored in the relevant cache.
+     * the resulting trust level wil be stored in the relevant cache.
      * The @fixedDelayString is the time interval, in milliseconds, between consecutive checks.
      */
-    @Scheduled(fixedDelayString = "${ncmp.timers.trust-evel.dmi-availability-watchdog-ms:30000}")
+    @Scheduled(fixedDelayString = "${ncmp.timers.trust-level.dmi-availability-watchdog-ms:30000}")
     public void checkDmiAvailability() {
         trustLevelPerDmiPlugin.entrySet().forEach(entry -> {
             final TrustLevel newDmiTrustLevel;
@@ -60,18 +64,12 @@ public class DmiPluginWatchDog {
             } else {
                 newDmiTrustLevel = TrustLevel.NONE;
             }
-
             if (oldDmiTrustLevel.equals(newDmiTrustLevel)) {
-                log.debug("The Dmi Plugin: {} has already the same trust level: {}", dmiServiceName,
-                        newDmiTrustLevel);
+                log.debug("The Dmi Plugin: {} has already the same trust level: {}", dmiServiceName, newDmiTrustLevel);
             } else {
-                trustLevelPerDmiPlugin.put(dmiServiceName, newDmiTrustLevel);
-
-                final Collection<String> notificationCandidateCmHandleIds =
+                final Collection<String> cmHandleIds =
                     networkCmProxyDataService.getAllCmHandleIdsByDmiPluginIdentifier(dmiServiceName);
-                for (final String cmHandleId: notificationCandidateCmHandleIds) {
-                    trustLevelManager.handleUpdateOfTrustLevels(cmHandleId, newDmiTrustLevel.name());
-                }
+                trustLevelManager.handleUpdateOfDmiTrustLevel(dmiServiceName, cmHandleIds, newDmiTrustLevel);
             }
         });
     }