diff options
author | halil.cakal <halil.cakal@est.tech> | 2022-10-28 14:51:46 +0100 |
---|---|---|
committer | halil.cakal <halil.cakal@est.tech> | 2022-11-01 15:05:56 +0000 |
commit | c08690c4904d70f867c8d5b24aac2bb76f3dfbb0 (patch) | |
tree | 68744fa3d7ecd43a2aa83242371e41b4ec994cfb /a1-policy-management/src/main/java/org | |
parent | 6b99dcc7dc6b8b0eb66fbefe2a7e5470cdb6c92e (diff) |
sonarcloud fixes
Sonarqube fixes
Issue-ID: CCSDK-3766
Change-Id: Ib03463a13194c18b00ed0d99754d7884af0d805f
Signed-off-by: halil.cakal <halil.cakal@est.tech>
Diffstat (limited to 'a1-policy-management/src/main/java/org')
-rw-r--r-- | a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshCounterTask.java | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshCounterTask.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshCounterTask.java index 8eb8fbcb..95999a04 100644 --- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshCounterTask.java +++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/tasks/RefreshCounterTask.java @@ -22,37 +22,37 @@ package org.onap.ccsdk.oran.a1policymanagementservice.tasks; import io.micrometer.core.instrument.MeterRegistry; import java.lang.invoke.MethodHandles; -import java.util.concurrent.atomic.AtomicLong; +import lombok.AccessLevel; +import lombok.Getter; import org.onap.ccsdk.oran.a1policymanagementservice.repository.Policies; import org.onap.ccsdk.oran.a1policymanagementservice.repository.PolicyTypes; import org.onap.ccsdk.oran.a1policymanagementservice.repository.Rics; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.annotation.EnableScheduling; -import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; /** * The aim is to collect statistical values from the A1 Policy Management Service. - * The counters are being updated every minute. */ -@EnableScheduling @Component public class RefreshCounterTask { private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + @Autowired private final Rics rics; + + @Autowired private final PolicyTypes policyTypes; + + @Autowired private final Policies policies; + @Autowired + @Getter(AccessLevel.PUBLIC) private final MeterRegistry meterRegistry; - private final AtomicLong ricCount; - private final AtomicLong policyTypeCount; - private final AtomicLong policyCount; - @Autowired public RefreshCounterTask(Rics rics, PolicyTypes policyTypes, Policies policies, MeterRegistry meterRegistry) { this.rics = rics; @@ -60,19 +60,10 @@ public class RefreshCounterTask { this.policies = policies; this.meterRegistry = meterRegistry; - ricCount = meterRegistry.gauge("total_ric_count", new AtomicLong(0)); - policyTypeCount = meterRegistry.gauge("total_policy_type_count", new AtomicLong(0)); - policyCount = meterRegistry.gauge("total_policy_count", new AtomicLong(0)); + logger.trace("Counters have been initialized."); + meterRegistry.gauge("total_ric_count", rics, Rics::size); + meterRegistry.gauge("total_policy_type_count", policyTypes, PolicyTypes::size); + meterRegistry.gauge("total_policy_count", policies, Policies::size); } - /** - * Every minute, updates counters for statistical purposes. - */ - @Scheduled(fixedRate = 1000 * 60) - public void checkAllCounters() { - logger.trace("Checking counters starting..."); - ricCount.set(rics.size()); - policyCount.set(policies.size()); - policyTypeCount.set(policyTypes.size()); - } } |