diff options
author | jhh <jorge.hernandez-herrero@att.com> | 2021-02-18 13:32:16 -0600 |
---|---|---|
committer | jhh <jorge.hernandez-herrero@att.com> | 2021-02-19 08:24:29 -0600 |
commit | d6083133bac5c1a54681a004468d416993d47d7f (patch) | |
tree | e99be71f5346b634150eebd2875f4f79b640a988 | |
parent | dd8c5ad785a19c3af7249808aa01fe4f04abc61e (diff) |
remove TransMetric - not needed
Issue-ID: POLICY-3033
Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Change-Id: I626de45b528bb891c79900085bfe783fe248b3fa
Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
9 files changed, 22 insertions, 129 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 diff --git a/policy-utils/src/main/java/org/onap/policy/drools/metrics/TransMetric.java b/policy-utils/src/main/java/org/onap/policy/drools/metrics/TransMetric.java deleted file mode 100644 index 21f3fadd..00000000 --- a/policy-utils/src/main/java/org/onap/policy/drools/metrics/TransMetric.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - * ================================================================================ - * Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.drools.metrics; - -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.ToString; - -/** - * Transaction Metric that models a complete policy transaction. - */ - -@Data -@NoArgsConstructor -@ToString(callSuper = true) -@EqualsAndHashCode(callSuper = true) -public class TransMetric extends Metric { -} diff --git a/policy-utils/src/test/java/org/onap/policy/drools/metrics/TransMetricTest.java b/policy-utils/src/test/java/org/onap/policy/drools/metrics/TransMetricTest.java deleted file mode 100644 index e3e8fb79..00000000 --- a/policy-utils/src/test/java/org/onap/policy/drools/metrics/TransMetricTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.drools.metrics; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; - -import com.openpojo.reflection.PojoClass; -import com.openpojo.reflection.impl.PojoClassFactory; -import com.openpojo.validation.Validator; -import com.openpojo.validation.ValidatorBuilder; -import com.openpojo.validation.rule.impl.GetterMustExistRule; -import com.openpojo.validation.rule.impl.SetterMustExistRule; -import com.openpojo.validation.test.impl.GetterTester; -import com.openpojo.validation.test.impl.SetterTester; -import org.junit.Test; - -public class TransMetricTest { - - @Test - public void testPojo() { - PojoClass metric = PojoClassFactory.getPojoClass(TransMetric.class); - Validator val = ValidatorBuilder - .create() - .with(new SetterMustExistRule()) - .with(new GetterMustExistRule()) - .with(new SetterTester()) - .with(new GetterTester()) - .build(); - val.validate(metric); - } - - @Test - public void testEqualsToString() { - TransMetric trans1 = new TransMetric(); - TransMetric trans2 = new TransMetric(); - - assertEquals(trans1, trans2); - - trans1.setRequestId(null); - assertNotEquals(trans1, trans2); - - trans1.setRequestId("a"); - trans2.setRequestId("a"); - assertEquals(trans1, trans2); - - assertThat(trans1.toString()).startsWith("TransMetric"); - } - -}
\ No newline at end of file |