diff options
Diffstat (limited to 'policy-management/src')
7 files changed, 22 insertions, 23 deletions
diff --git a/policy-management/src/main/java/org/onap/policy/drools/stats/PolicyStats.java b/policy-management/src/main/java/org/onap/policy/drools/stats/PolicyStats.java index add4c18c..03ab2268 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/stats/PolicyStats.java +++ b/policy-management/src/main/java/org/onap/policy/drools/stats/PolicyStats.java @@ -30,7 +30,7 @@ import lombok.NonNull; import lombok.Setter; import lombok.Synchronized; import lombok.ToString; -import org.onap.policy.drools.metrics.TransMetric; +import org.onap.policy.drools.metrics.Metric; import org.slf4j.Logger; /** @@ -91,7 +91,7 @@ public class PolicyStats { */ @Synchronized - public void stat(@NonNull TransMetric trans) { + public void stat(@NonNull Metric trans) { policyExecutedCount++; if (trans.isSuccess()) { policyExecutedSuccessCount++; diff --git a/policy-management/src/main/java/org/onap/policy/drools/stats/PolicyStatsManager.java b/policy-management/src/main/java/org/onap/policy/drools/stats/PolicyStatsManager.java index bb1b2679..c8066484 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/stats/PolicyStatsManager.java +++ b/policy-management/src/main/java/org/onap/policy/drools/stats/PolicyStatsManager.java @@ -27,7 +27,7 @@ import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import lombok.NonNull; import lombok.ToString; -import org.onap.policy.drools.metrics.TransMetric; +import org.onap.policy.drools.metrics.Metric; /** * Policy Stats Manager that manages PDP-D statistics. @@ -45,7 +45,7 @@ public class PolicyStatsManager { /** * stat a new transaction. */ - public synchronized void stat(@NonNull String subGroupName, @NonNull TransMetric transaction) { + public synchronized void stat(@NonNull String subGroupName, @NonNull Metric transaction) { groupStat.stat(transaction); subgroupStats.computeIfAbsent(subGroupName, key -> new PolicyStats()).stat(transaction); } diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java index ef641f31..10623c50 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java +++ b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngine.java @@ -34,7 +34,6 @@ import org.onap.policy.drools.core.lock.Lock; import org.onap.policy.drools.core.lock.LockCallback; import org.onap.policy.drools.features.PolicyEngineFeatureApi; import org.onap.policy.drools.metrics.Metric; -import org.onap.policy.drools.metrics.TransMetric; import org.onap.policy.drools.policies.DomainMaker; import org.onap.policy.drools.protocol.configuration.ControllerConfiguration; import org.onap.policy.drools.protocol.configuration.PdpdConfiguration; @@ -362,5 +361,5 @@ public interface PolicyEngine extends Startable, Lockable, TopicListener { * @param policyName policy name * @param transaction transaction */ - void transaction(String controllerName, String policyName, TransMetric transaction); + void transaction(String controllerName, String policyName, Metric transaction); } diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java index e20986cb..1b2c13a1 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java +++ b/policy-management/src/main/java/org/onap/policy/drools/system/PolicyEngineManager.java @@ -68,7 +68,6 @@ import org.onap.policy.drools.features.PolicyControllerFeatureApiConstants; import org.onap.policy.drools.features.PolicyEngineFeatureApi; import org.onap.policy.drools.features.PolicyEngineFeatureApiConstants; import org.onap.policy.drools.metrics.Metric; -import org.onap.policy.drools.metrics.TransMetric; import org.onap.policy.drools.persistence.SystemPersistence; import org.onap.policy.drools.persistence.SystemPersistenceConstants; import org.onap.policy.drools.policies.DomainMaker; @@ -255,13 +254,15 @@ class PolicyEngineManager implements PolicyEngine { } @Override - public void transaction(@NonNull String controllerName, - @NonNull String policyName, @NonNull TransMetric transaction) { + public void transaction(@NonNull String controllerName, // NOSONAR placeholder + @NonNull String controlLoopName, @NonNull Metric transaction) { - // will stat on a per policy name that for an admin would - // be more significant than a controller name. + // keeping stats on a per control loop name, + // applications must report the controller name too + // for completeness and to avoid being modified when/if + // the controller name is used for tracking purposes - getStats().stat(controllerName + "[" + policyName + "]", transaction); + getStats().stat(controlLoopName, transaction); } @Override diff --git a/policy-management/src/test/java/org/onap/policy/drools/stats/PolicyStatsManagerTest.java b/policy-management/src/test/java/org/onap/policy/drools/stats/PolicyStatsManagerTest.java index 9ab23979..a12fb50a 100644 --- a/policy-management/src/test/java/org/onap/policy/drools/stats/PolicyStatsManagerTest.java +++ b/policy-management/src/test/java/org/onap/policy/drools/stats/PolicyStatsManagerTest.java @@ -23,7 +23,7 @@ package org.onap.policy.drools.stats; import static org.junit.Assert.assertEquals; import org.junit.Test; -import org.onap.policy.drools.metrics.TransMetric; +import org.onap.policy.drools.metrics.Metric; public class PolicyStatsManagerTest { @@ -32,7 +32,7 @@ public class PolicyStatsManagerTest { PolicyStatsManager stats = new PolicyStatsManager(); assertEquals(0, stats.getGroupStat().getPolicyExecutedCount()); - TransMetric trans = new TransMetric(); + Metric trans = new Metric(); stats.stat("foo", trans); stats.stat("blah", trans); stats.stat("blah", trans); diff --git a/policy-management/src/test/java/org/onap/policy/drools/stats/PolicyStatsTest.java b/policy-management/src/test/java/org/onap/policy/drools/stats/PolicyStatsTest.java index 29518e93..631e85b8 100644 --- a/policy-management/src/test/java/org/onap/policy/drools/stats/PolicyStatsTest.java +++ b/policy-management/src/test/java/org/onap/policy/drools/stats/PolicyStatsTest.java @@ -24,13 +24,13 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; import org.junit.Test; -import org.onap.policy.drools.metrics.TransMetric; +import org.onap.policy.drools.metrics.Metric; public class PolicyStatsTest { @Test public void testStat() { - TransMetric trans1 = createTrans(); + Metric trans1 = createTrans(); trans1.setSuccess(true); PolicyStats stats = new PolicyStats(); @@ -44,7 +44,7 @@ public class PolicyStatsTest { assertEquals(1, stats.getPolicyExecutedSuccessCount()); assertThat(stats.getBirthTime()).isGreaterThanOrEqualTo(trans1.getStartTime().toEpochMilli()); - TransMetric trans2 = createTrans(); + Metric trans2 = createTrans(); trans2.setSuccess(false); trans2.setEndTime(trans2.getStartTime().plusMillis(5)); trans2.setElapsedTime(null); @@ -58,7 +58,7 @@ public class PolicyStatsTest { assertEquals(1, stats.getPolicyExecutedSuccessCount()); assertThat(stats.getBirthTime()).isLessThanOrEqualTo(trans2.getStartTime().toEpochMilli()); - TransMetric trans3 = createTrans(); + Metric trans3 = createTrans(); trans3.setSuccess(false); trans3.setEndTime(trans3.getStartTime().plusMillis(9)); trans3.setElapsedTime(null); @@ -73,8 +73,8 @@ public class PolicyStatsTest { assertThat(stats.getBirthTime()).isLessThanOrEqualTo(trans2.getStartTime().toEpochMilli()); } - private TransMetric createTrans() { - TransMetric trans = new TransMetric(); + private Metric createTrans() { + Metric trans = new Metric(); trans.setStartTime(null); trans.setEndTime(trans.getStartTime().plusMillis(1)); diff --git a/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineManagerTest.java b/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineManagerTest.java index f9b101c3..1930dfb8 100644 --- a/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineManagerTest.java +++ b/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineManagerTest.java @@ -65,7 +65,6 @@ import org.onap.policy.drools.core.lock.PolicyResourceLockManager; import org.onap.policy.drools.features.PolicyControllerFeatureApi; import org.onap.policy.drools.features.PolicyEngineFeatureApi; import org.onap.policy.drools.metrics.Metric; -import org.onap.policy.drools.metrics.TransMetric; import org.onap.policy.drools.persistence.SystemPersistence; import org.onap.policy.drools.properties.DroolsPropertyConstants; import org.onap.policy.drools.protocol.coders.EventProtocolCoder; @@ -1365,10 +1364,10 @@ public class PolicyEngineManagerTest { assertEquals(0, mgr.getStats().getGroupStat().getPolicyExecutedCount()); assertEquals(0, mgr.getStats().getSubgroupStats().size()); - mgr.transaction("foo", "bar", new TransMetric()); + mgr.transaction("foo", "bar", new Metric()); assertEquals(1, mgr.getStats().getGroupStat().getPolicyExecutedCount()); assertEquals(1, mgr.getStats().getSubgroupStats().size()); - assertEquals(1, mgr.getStats().getSubgroupStats().get("foo[bar]").getPolicyExecutedFailCount()); + assertEquals(1, mgr.getStats().getSubgroupStats().get("bar").getPolicyExecutedFailCount()); } @Test |