summaryrefslogtreecommitdiffstats
path: root/participant/participant-impl/participant-impl-kubernetes
diff options
context:
space:
mode:
authorSirisha_Manchikanti <sirisha.manchikanti@est.tech>2021-11-02 05:35:12 +0000
committerSirisha_Manchikanti <sirisha.manchikanti@est.tech>2021-11-02 06:05:15 +0000
commita48252db26e2ccd031ddb2046d87737d47c248a6 (patch)
tree69c6a7e25f1a5b67d0c1d598949d0b6ad815f41a /participant/participant-impl/participant-impl-kubernetes
parent9a49920ac001f76d796cbffce823abd7c0c7d9e2 (diff)
Remove code smells in controlloop runtime
Remove code-smells reported by sonar cloud https://sonarcloud.io/project/issues?id=onap_policy-clamp&resolved=false Issue-ID: POLICY-3540 Signed-off-by: Sirisha_Manchikanti <sirisha.manchikanti@est.tech> Change-Id: I8ed1c4599e7eeebbc3a31e74cea4148eb0435847
Diffstat (limited to 'participant/participant-impl/participant-impl-kubernetes')
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandler.java14
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java3
2 files changed, 12 insertions, 5 deletions
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandler.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandler.java
index e1e9195eb..3f2113d98 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandler.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/handler/ControlLoopElementHandler.java
@@ -20,9 +20,9 @@
package org.onap.policy.clamp.controlloop.participant.kubernetes.handler;
-
import java.io.IOException;
import java.lang.invoke.MethodHandles;
+import java.time.Instant;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@@ -30,6 +30,7 @@ import java.util.concurrent.ConcurrentHashMap;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
@@ -51,7 +52,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-
/**
* This class handles implementation of controlLoopElement updates.
*/
@@ -170,10 +170,16 @@ public class ControlLoopElementHandler implements ControlLoopElementListener {
* Overridden method.
*
* @param controlLoopElementId controlLoopElement id
- * @throws PfModelException incase of error
+ * @throws PfModelException in case of error
*/
@Override
public synchronized void handleStatistics(UUID controlLoopElementId) throws PfModelException {
- // TODO Implement statistics functionality
+ var clElement = intermediaryApi.getControlLoopElement(controlLoopElementId);
+ if (clElement != null) {
+ var clElementStatistics = new ClElementStatistics();
+ clElementStatistics.setControlLoopState(clElement.getState());
+ clElementStatistics.setTimeStamp(Instant.now());
+ intermediaryApi.updateControlLoopElementStatistics(controlLoopElementId, clElementStatistics);
+ }
}
}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java
index 1c405539b..31fa62f1f 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java
@@ -47,6 +47,7 @@ public class HelmClient {
private ChartStore chartStore;
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ private static final String PATH_DELIMITER = "/";
/**
* Install a chart.
@@ -100,7 +101,7 @@ public class HelmClient {
}
var localHelmChartDir = chartStore.getAppPath(chart.getChartId()).toString();
logger.info("Chart not found in helm repositories, verifying local repo {} ", localHelmChartDir);
- if (verifyLocalHelmRepo(new File(localHelmChartDir + "/" + chart.getChartId().getName()))) {
+ if (verifyLocalHelmRepo(new File(localHelmChartDir + PATH_DELIMITER + chart.getChartId().getName()))) {
repository = localHelmChartDir;
}
return repository;