diff options
Diffstat (limited to 'cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/dmiavailability')
-rw-r--r-- | cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/dmiavailability/DmiPluginStatus.java | 25 | ||||
-rw-r--r-- | cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/dmiavailability/DmiPluginWatchDog.java (renamed from cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/dmiavailability/DMiPluginWatchDog.java) | 26 |
2 files changed, 11 insertions, 40 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/dmiavailability/DmiPluginStatus.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/dmiavailability/DmiPluginStatus.java deleted file mode 100644 index 352d36f94..000000000 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/dmiavailability/DmiPluginStatus.java +++ /dev/null @@ -1,25 +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.trustlevel.dmiavailability; - -public enum DmiPluginStatus { - UP, DOWN; -} diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/dmiavailability/DMiPluginWatchDog.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/dmiavailability/DmiPluginWatchDog.java index 39f880257..b073f1bc3 100644 --- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/dmiavailability/DMiPluginWatchDog.java +++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/trustlevel/dmiavailability/DmiPluginWatchDog.java @@ -31,28 +31,24 @@ import org.springframework.stereotype.Service; @Slf4j @RequiredArgsConstructor @Service -public class DMiPluginWatchDog { - - private final Map<String, TrustLevel> trustLevelPerDmiPlugin; +public class DmiPluginWatchDog { private final DmiRestClient dmiRestClient; + private final Map<String, TrustLevel> trustLevelPerDmiPlugin; /** - * Monitors the aliveness of DMI plugins by this watchdog. - * This method periodically checks the health and status of each DMI plugin to ensure that - * they are functioning properly. If a plugin is found to be unresponsive or in an - * unhealthy state, the cache will be updated with the latest status. - * The @fixedDelayString is the time interval, in milliseconds, between consecutive aliveness checks. + * 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 @fixedDelayString is the time interval, in milliseconds, between consecutive checks. */ @Scheduled(fixedDelayString = "${ncmp.timers.trust-evel.dmi-availability-watchdog-ms:30000}") - public void watchDmiPluginAliveness() { - trustLevelPerDmiPlugin.keySet().forEach(dmiPluginName -> { - final DmiPluginStatus dmiPluginStatus = dmiRestClient.getDmiPluginStatus(dmiPluginName); - log.debug("Trust level for dmi-plugin: {} is {}", dmiPluginName, dmiPluginStatus.toString()); - if (DmiPluginStatus.UP.equals(dmiPluginStatus)) { - trustLevelPerDmiPlugin.put(dmiPluginName, TrustLevel.COMPLETE); + public void watchDmiPluginTrustLevel() { + trustLevelPerDmiPlugin.keySet().forEach(dmiKey -> { + final String dmiHealthStatus = dmiRestClient.getDmiHealthStatus(dmiKey); + if ("UP".equals(dmiHealthStatus)) { + trustLevelPerDmiPlugin.put(dmiKey, TrustLevel.COMPLETE); } else { - trustLevelPerDmiPlugin.put(dmiPluginName, TrustLevel.NONE); + trustLevelPerDmiPlugin.put(dmiKey, TrustLevel.NONE); } }); } |