diff options
author | adheli.tavares <adheli.tavares@est.tech> | 2021-07-08 15:36:25 +0100 |
---|---|---|
committer | adheli.tavares <adheli.tavares@est.tech> | 2021-07-12 14:10:10 +0100 |
commit | d58200919584dfa7f45a1c3ae94061aa91d341d8 (patch) | |
tree | 39a3dca977bc0768606acf3736749081cc7942d4 /services/services-onappf/src/main/java | |
parent | 7ec6f6a88b3a90a0f865f2798ff70f13278e40c2 (diff) |
Update pdp statistics to count deploy/undeploy separately.
Issue-ID: POLICY-3383
Change-Id: Ie9c5c7178c4c4302a0ba63ab42732f7157d302f8
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'services/services-onappf/src/main/java')
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); + } + } + } } |