summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
Diffstat (limited to 'services')
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpMessageHandler.java91
1 files changed, 1 insertions, 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,89 +98,10 @@ 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<PdpEngineWorkerStatistics> getEngineWorkerStats(@NonNull final ApexEngineHandler apexEngineHandler) {
- List<PdpEngineWorkerStatistics> pdpEngineWorkerStats = new ArrayList<>();
- List<AxEngineModel> 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.
*
* @return PdpStatus the pdp status message