diff options
Diffstat (limited to 'participant')
5 files changed, 28 insertions, 8 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; diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/ControlLoopElementHandler.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/ControlLoopElementHandler.java index f6d616dac..901fb682b 100644 --- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/ControlLoopElementHandler.java +++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/main/handler/ControlLoopElementHandler.java @@ -102,7 +102,7 @@ public class ControlLoopElementHandler implements ControlLoopElementListener { break; case PASSIVE: try { - undeployPolicies(controlLoopElementId, orderedState); + undeployPolicies(controlLoopElementId); } catch (PfModelRuntimeException e) { LOGGER.debug("Undeploying policies failed - no policies to undeploy {}", controlLoopElementId); } @@ -157,7 +157,7 @@ public class ControlLoopElementHandler implements ControlLoopElementListener { ParticipantMessageType.CONTROL_LOOP_STATE_CHANGE); } - private void undeployPolicies(UUID controlLoopElementId, ControlLoopOrderedState newState) { + private void undeployPolicies(UUID controlLoopElementId) { // Undeploy all policies of this controlloop from Policy Framework if (policyMap.entrySet() != null) { for (Entry<String, String> policy : policyMap.entrySet()) { diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java index 43ac3464c..bbafc4678 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java @@ -89,7 +89,7 @@ public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryAp @Override public void updateParticipantStatistics(ParticipantStatistics participantStatistics) { - // TODO Auto-generated method stub + participantHandler.updateParticipantStatistics(participantStatistics); } @Override diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java index d7537e3d8..89a13a84b 100644 --- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java +++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java @@ -190,6 +190,19 @@ public class ParticipantHandler { } /** + * Method to update participant statistics. + * + * @param statistics participant statistics + */ + public void updateParticipantStatistics(ParticipantStatistics statistics) { + participantStatistics.setState(statistics.getState()); + participantStatistics.setHealthStatus(statistics.getHealthStatus()); + participantStatistics.setTimeStamp(statistics.getTimeStamp()); + participantStatistics.setAverageExecutionTime(statistics.getAverageExecutionTime()); + participantStatistics.setEventCount(statistics.getEventCount()); + } + + /** * Get participants as a {@link Participant} class. * * @param name the participant name to get |