diff options
Diffstat (limited to 'services/services-onappf/src/main')
2 files changed, 30 insertions, 6 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 4044a4903..134b45c14 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 @@ -141,6 +141,11 @@ public class PdpMessageHandler { 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()); diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java index e6c2c399a..09fb92dd3 100644 --- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java +++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java @@ -168,6 +168,7 @@ public class PdpUpdateMessageHandler { pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpUpdateMsg.getRequestId(), PdpResponseStatus.FAIL, "Pdp update failed as the policies couldn't be undeployed."); } + updateDeploymentCounts(pdpUpdateMsg, pdpResponseDetails); } return pdpResponseDetails; } @@ -196,12 +197,7 @@ public class PdpUpdateMessageHandler { pdpResponseDetails = pdpMessageHandler.createPdpResonseDetails(pdpUpdateMsg.getRequestId(), PdpResponseStatus.FAIL, "Apex engine service running failed. " + e.getMessage()); } - final ApexPolicyStatisticsManager apexPolicyStatisticsManager = - ApexPolicyStatisticsManager.getInstanceFromRegistry(); - if (apexPolicyStatisticsManager != null) { - apexPolicyStatisticsManager - .updatePolicyDeployCounter(pdpResponseDetails.getResponseStatus() == PdpResponseStatus.SUCCESS); - } + updateDeploymentCounts(pdpUpdateMsg, pdpResponseDetails); return pdpResponseDetails; } @@ -284,4 +280,27 @@ public class PdpUpdateMessageHandler { List<ToscaConceptIdentifier> listToCheckAgainst) { return listToCheckAgainst.stream().anyMatch(listToCheckWith::contains); } + + /** + * Update count values for deployment actions (deploy and undeploy) when applicable. + * @param pdpUpdateMsg the pdp update message from pap + * @param pdpResponseDetails the pdp response + */ + private void updateDeploymentCounts(final PdpUpdate pdpUpdateMsg, PdpResponseDetails pdpResponseDetails) { + final ApexPolicyStatisticsManager statisticsManager = + ApexPolicyStatisticsManager.getInstanceFromRegistry(); + + if (statisticsManager != null) { + if (pdpUpdateMsg.getPoliciesToBeDeployed() != null && !pdpUpdateMsg.getPoliciesToBeDeployed().isEmpty()) { + statisticsManager.updatePolicyDeployCounter( + pdpResponseDetails.getResponseStatus() == PdpResponseStatus.SUCCESS); + } + + if (pdpUpdateMsg.getPoliciesToBeUndeployed() != null + && !pdpUpdateMsg.getPoliciesToBeUndeployed().isEmpty()) { + statisticsManager.updatePolicyUndeployCounter( + pdpResponseDetails.getResponseStatus() == PdpResponseStatus.SUCCESS); + } + } + } } |