From 097618956f681eee12a23d7d9dc4f4f22f5347cc Mon Sep 17 00:00:00 2001 From: Ram Krishna Verma Date: Mon, 17 Jul 2023 11:00:41 -0400 Subject: Remove db based statistics from apex-pdp Removing the db based statistics feature from apex-pdp in lieu of Prometheus based one. Issue-ID: POLICY-4109 Change-Id: Ia20adf5b59c56681669d55c98e409269cd4f53c1 Signed-off-by: Ram Krishna Verma --- .../services/onappf/handler/PdpMessageHandler.java | 91 +--------------------- 1 file changed, 1 insertion(+), 90 deletions(-) diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpMessageHandler.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpMessageHandler.java index 97feba152..328bb3003 100644 --- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpMessageHandler.java +++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpMessageHandler.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,29 +22,19 @@ package org.onap.policy.apex.services.onappf.handler; -import java.time.Instant; import java.util.ArrayList; import java.util.List; -import lombok.NonNull; -import org.onap.policy.apex.model.enginemodel.concepts.AxEngineModel; -import org.onap.policy.apex.model.enginemodel.concepts.AxEngineState; -import org.onap.policy.apex.service.engine.main.ApexPolicyStatisticsManager; import org.onap.policy.apex.services.onappf.ApexStarterConstants; import org.onap.policy.apex.services.onappf.parameters.PdpStatusParameters; import org.onap.policy.apex.services.onappf.parameters.ToscaPolicyTypeIdentifierParameters; import org.onap.policy.common.utils.services.Registry; -import org.onap.policy.models.pdp.concepts.PdpEngineWorkerStatistics; import org.onap.policy.models.pdp.concepts.PdpResponseDetails; -import org.onap.policy.models.pdp.concepts.PdpStatistics; import org.onap.policy.models.pdp.concepts.PdpStatus; -import org.onap.policy.models.pdp.enums.PdpEngineWorkerState; import org.onap.policy.models.pdp.enums.PdpHealthStatus; import org.onap.policy.models.pdp.enums.PdpResponseStatus; import org.onap.policy.models.pdp.enums.PdpState; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** @@ -52,7 +43,6 @@ import org.slf4j.LoggerFactory; * @author Ajith Sreekumar (ajith.sreekumar@est.tech) */ public class PdpMessageHandler { - private static final Logger LOGGER = LoggerFactory.getLogger(PdpMessageHandler.class); /** * Method to create PdpStatus message from the parameters which will be saved to the context. @@ -108,88 +98,9 @@ public class PdpMessageHandler { pdpStatus.setPolicies(pdpStatusContext.getPolicies()); pdpStatus.setPdpGroup(pdpStatusContext.getPdpGroup()); pdpStatus.setPdpSubgroup(pdpStatusContext.getPdpSubgroup()); - - ApexEngineHandler apexEngineHandler = null; - try { - apexEngineHandler = Registry.get(ApexStarterConstants.REG_APEX_ENGINE_HANDLER); - } catch (IllegalArgumentException e) { - LOGGER.warn(e.getMessage()); - } - - pdpStatus.setStatistics(getStatistics(pdpStatus, apexEngineHandler)); - - return pdpStatus; } - /** - * Method to get the statistics. - * - * @return PdpStatistics the pdp status message - */ - - private PdpStatistics getStatistics(final PdpStatus pdpStatusContext, final ApexEngineHandler apexEngineHandler) { - var pdpStatistics = new PdpStatistics(); - pdpStatistics.setPdpInstanceId(pdpStatusContext.getName()); - pdpStatistics.setTimeStamp(Instant.now()); - pdpStatistics.setPdpGroupName(pdpStatusContext.getPdpGroup()); - pdpStatistics.setPdpSubGroupName(pdpStatusContext.getPdpSubgroup()); - if (apexEngineHandler != null) { - pdpStatistics.setEngineStats(getEngineWorkerStats(apexEngineHandler)); - } - final var apexPolicyCounter = ApexPolicyStatisticsManager.getInstanceFromRegistry(); - if (apexPolicyCounter != null) { - pdpStatistics.setPolicyDeploySuccessCount(apexPolicyCounter.getPolicyDeploySuccessCount()); - pdpStatistics.setPolicyDeployFailCount(apexPolicyCounter.getPolicyDeployFailCount()); - pdpStatistics.setPolicyDeployCount(apexPolicyCounter.getPolicyDeployCount()); - - pdpStatistics.setPolicyUndeploySuccessCount(apexPolicyCounter.getPolicyUndeploySuccessCount()); - pdpStatistics.setPolicyUndeployFailCount(apexPolicyCounter.getPolicyUndeployFailCount()); - pdpStatistics.setPolicyUndeployCount(apexPolicyCounter.getPolicyUndeployCount()); - - pdpStatistics.setPolicyExecutedCount(apexPolicyCounter.getPolicyExecutedCount()); - pdpStatistics.setPolicyExecutedSuccessCount(apexPolicyCounter.getPolicyExecutedSuccessCount()); - pdpStatistics.setPolicyExecutedFailCount(apexPolicyCounter.getPolicyExecutedFailCount()); - } - return pdpStatistics; - } - - private List getEngineWorkerStats(@NonNull final ApexEngineHandler apexEngineHandler) { - List pdpEngineWorkerStats = new ArrayList<>(); - List engineModels = apexEngineHandler.getEngineStats(); - if (engineModels != null) { - engineModels.forEach(engineModel -> { - var workerStatistics = new PdpEngineWorkerStatistics(); - workerStatistics.setEngineWorkerState(transferEngineState(engineModel.getState())); - workerStatistics.setEngineId(engineModel.getId()); - workerStatistics.setEventCount(engineModel.getStats().getEventCount()); - workerStatistics.setAverageExecutionTime(engineModel.getStats().getAverageExecutionTime()); - workerStatistics.setEngineTimeStamp(engineModel.getStats().getTimeStamp()); - workerStatistics.setLastEnterTime(engineModel.getStats().getLastEnterTime()); - workerStatistics.setLastExecutionTime(engineModel.getStats().getLastExecutionTime()); - workerStatistics.setLastStart(engineModel.getStats().getLastStart()); - workerStatistics.setUpTime(engineModel.getStats().getUpTime()); - pdpEngineWorkerStats.add(workerStatistics); - }); - } - return pdpEngineWorkerStats; - } - - private PdpEngineWorkerState transferEngineState(@NonNull final AxEngineState state) { - switch (state) { - case STOPPING: - return PdpEngineWorkerState.STOPPING; - case STOPPED: - return PdpEngineWorkerState.STOPPED; - case READY: - return PdpEngineWorkerState.READY; - case EXECUTING: - return PdpEngineWorkerState.EXECUTING; - default: - return PdpEngineWorkerState.UNDEFINED; - } - } - /** * Method to get a final pdp status when the apex started is shutting down. * -- cgit 1.2.3-korg