summaryrefslogtreecommitdiffstats
path: root/feature-lifecycle/src/main/java
diff options
context:
space:
mode:
authoradheli.tavares <adheli.tavares@est.tech>2021-07-07 16:21:51 +0100
committeradheli.tavares <adheli.tavares@est.tech>2021-07-08 21:20:14 +0100
commit1dbf657c3138a9026bb20f9da0412eee53499f44 (patch)
tree14eae08d610d97cb58fb9c2972e576c071a5bd3a /feature-lifecycle/src/main/java
parent62597d6fcdea939c5fdbbc3d870023f1458c8704 (diff)
Update pdp statistics to count deploy/undeploy separately.
Issue-ID: POLICY-3383 Change-Id: If8f1555aa0c509a35f4dd1821ddc5dd2f7294d2f Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'feature-lifecycle/src/main/java')
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java28
1 files changed, 19 insertions, 9 deletions
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
index 3cec7451..1326c3b0 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
@@ -53,7 +53,6 @@ import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher;
import org.onap.policy.common.endpoints.listeners.ScoListener;
import org.onap.policy.common.gson.annotation.GsonJsonIgnore;
import org.onap.policy.common.utils.coder.StandardCoderObject;
-import org.onap.policy.drools.metrics.Metric;
import org.onap.policy.drools.persistence.SystemPersistenceConstants;
import org.onap.policy.drools.policies.DomainMaker;
import org.onap.policy.drools.system.PolicyController;
@@ -446,8 +445,8 @@ public class LifecycleFsm implements Startable {
policiesMap.computeIfPresent(policy.getIdentifier(), (key, value) -> {
// avoid counting reapplies in a second pass when a mix of native and non-native
// policies are present.
- getStats().setPolicyDeployCount(getStats().getPolicyDeployCount() + 1);
- getStats().setPolicyDeploySuccessCount(getStats().getPolicyDeploySuccessCount() + 1);
+ getStats().setPolicyUndeployCount(getStats().getPolicyUndeployCount() + 1);
+ getStats().setPolicyUndeploySuccessCount(getStats().getPolicyUndeploySuccessCount() + 1);
return null;
});
}
@@ -458,7 +457,8 @@ public class LifecycleFsm implements Startable {
}
protected void failedUndeployPolicyAction(ToscaPolicy failedPolicy) {
- failedDeployPolicyAction(failedPolicy);
+ getStats().setPolicyUndeployCount(getStats().getPolicyUndeployCount() + 1);
+ getStats().setPolicyUndeployFailCount(getStats().getPolicyUndeployFailCount() + 1);
policiesMap.remove(failedPolicy.getIdentifier());
}
@@ -477,14 +477,24 @@ public class LifecycleFsm implements Startable {
}
}
- protected void resetDeployCountsAction() {
- getStats().setPolicyDeployCount(0);
- getStats().setPolicyDeployFailCount(0);
- getStats().setPolicyDeploySuccessCount(0);
+ protected void updateUndeployCountsAction(Long undeployCount, Long undeploySuccesses, Long undeployFailures) {
+ PdpStatistics statistics = getStats();
+ if (undeployCount != null) {
+ statistics.setPolicyUndeployCount(undeployCount);
+ }
+
+ if (undeploySuccesses != null) {
+ statistics.setPolicyUndeploySuccessCount(undeploySuccesses);
+ }
+
+ if (undeployFailures != null) {
+ statistics.setPolicyUndeployFailCount(undeployFailures);
+ }
}
protected List<ToscaPolicy> resetPoliciesAction() {
- resetDeployCountsAction();
+ updateDeployCountsAction(0L, 0L, 0L);
+ updateUndeployCountsAction(0L, 0L, 0L);
List<ToscaPolicy> policies = new ArrayList<>(getActivePolicies());
policiesMap.clear();
return policies;