summaryrefslogtreecommitdiffstats
path: root/services/services-onappf/src
diff options
context:
space:
mode:
Diffstat (limited to 'services/services-onappf/src')
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpMessageHandler.java5
-rw-r--r--services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/PdpUpdateMessageHandler.java31
-rw-r--r--services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpUpdateListener.java3
3 files changed, 33 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);
+ }
+ }
+ }
}
diff --git a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpUpdateListener.java b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpUpdateListener.java
index 9d314b41a..3716e043f 100644
--- a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpUpdateListener.java
+++ b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/comm/TestPdpUpdateListener.java
@@ -38,6 +38,7 @@ import java.util.stream.Collectors;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.onap.policy.apex.service.engine.main.ApexPolicyStatisticsManager;
import org.onap.policy.apex.services.onappf.ApexStarterActivator;
import org.onap.policy.apex.services.onappf.ApexStarterCommandLineArguments;
import org.onap.policy.apex.services.onappf.ApexStarterConstants;
@@ -101,6 +102,8 @@ public class TestPdpUpdateListener {
activator.initialize();
pdpUpdateMessageListener = new PdpUpdateListener();
pdpStateChangeListener = new PdpStateChangeListener();
+ Registry.register(ApexPolicyStatisticsManager.REG_APEX_PDP_POLICY_COUNTER,
+ new ApexPolicyStatisticsManager());
}
/**