From 88b6b1fe6db0c107362670520b8437b1e163eec4 Mon Sep 17 00:00:00 2001 From: Ram Krishna Verma Date: Mon, 7 Aug 2023 15:40:30 -0400 Subject: Remove db based statistics from xacml-pdp Removing the db based statistics from xacml-pdp, in favour of the prometheus based option. Issue-ID: POLICY-4109 Change-Id: Ibd2dfe27aa53fc486585d182985cf743801a1de7 Signed-off-by: Ram Krishna Verma --- .../java/org/onap/policy/pdpx/main/XacmlState.java | 36 ---------------------- .../org/onap/policy/pdpx/main/XacmlStateTest.java | 21 ------------- 2 files changed, 57 deletions(-) (limited to 'main') diff --git a/main/src/main/java/org/onap/policy/pdpx/main/XacmlState.java b/main/src/main/java/org/onap/policy/pdpx/main/XacmlState.java index 3635a21a..7f40532d 100644 --- a/main/src/main/java/org/onap/policy/pdpx/main/XacmlState.java +++ b/main/src/main/java/org/onap/policy/pdpx/main/XacmlState.java @@ -20,21 +20,18 @@ package org.onap.policy.pdpx.main; -import java.time.Instant; import java.util.Collections; import org.apache.commons.lang3.StringUtils; import org.onap.policy.common.utils.network.NetworkUtil; import org.onap.policy.models.pdp.concepts.PdpMessage; import org.onap.policy.models.pdp.concepts.PdpResponseDetails; import org.onap.policy.models.pdp.concepts.PdpStateChange; -import org.onap.policy.models.pdp.concepts.PdpStatistics; import org.onap.policy.models.pdp.concepts.PdpStatus; import org.onap.policy.models.pdp.concepts.PdpUpdate; import org.onap.policy.models.pdp.enums.PdpHealthStatus; import org.onap.policy.models.pdp.enums.PdpResponseStatus; import org.onap.policy.models.pdp.enums.PdpState; import org.onap.policy.pdpx.main.rest.XacmlPdpApplicationManager; -import org.onap.policy.pdpx.main.rest.XacmlPdpStatisticsManager; import org.onap.policy.pdpx.main.startstop.XacmlPdpActivator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -96,42 +93,9 @@ public class XacmlState { : PdpHealthStatus.NOT_HEALTHY); PdpStatus heartbeat = new PdpStatus(status); - heartbeat.setStatistics(getStatistics()); return heartbeat; } - /** - * Generates statistics to be used in a heart beat message. - * - * @return statistics for heart beat message - */ - protected PdpStatistics getStatistics() { - XacmlPdpStatisticsManager stats = XacmlPdpStatisticsManager.getCurrent(); - if (stats == null) { - LOGGER.warn("XacmlPdpStatisticsManager is null"); - return null; - } - stats.setTotalPolicyCount(appManager.getPolicyCount()); - - PdpStatistics pdpStats = new PdpStatistics(); - pdpStats.setPdpGroupName(this.status.getPdpGroup()); - pdpStats.setPdpSubGroupName(this.status.getPdpSubgroup()); - pdpStats.setTimeStamp(Instant.ofEpochSecond(this.status.getTimestampMs())); - - pdpStats.setPolicyExecutedCount(stats.getPermitDecisionsCount() + stats.getDenyDecisionsCount()); - pdpStats.setPolicyExecutedSuccessCount(stats.getPermitDecisionsCount()); - pdpStats.setPolicyExecutedFailCount(stats.getDenyDecisionsCount()); - - pdpStats.setPolicyDeployCount(stats.getDeploySuccessCount() + stats.getDeployFailureCount()); - pdpStats.setPolicyDeploySuccessCount(stats.getDeploySuccessCount()); - pdpStats.setPolicyDeployFailCount(stats.getDeployFailureCount()); - - pdpStats.setPolicyUndeployCount(stats.getUndeploySuccessCount() + stats.getUndeployFailureCount()); - pdpStats.setPolicyUndeploySuccessCount(stats.getUndeploySuccessCount()); - pdpStats.setPolicyUndeployFailCount(stats.getUndeployFailureCount()); - return pdpStats; - } - /** * Updates the internal state based on the given message. * diff --git a/main/src/test/java/org/onap/policy/pdpx/main/XacmlStateTest.java b/main/src/test/java/org/onap/policy/pdpx/main/XacmlStateTest.java index a1f1b8a7..a16f3a8f 100644 --- a/main/src/test/java/org/onap/policy/pdpx/main/XacmlStateTest.java +++ b/main/src/test/java/org/onap/policy/pdpx/main/XacmlStateTest.java @@ -42,7 +42,6 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient; import org.onap.policy.models.pdp.concepts.PdpResponseDetails; import org.onap.policy.models.pdp.concepts.PdpStateChange; -import org.onap.policy.models.pdp.concepts.PdpStatistics; import org.onap.policy.models.pdp.concepts.PdpStatus; import org.onap.policy.models.pdp.concepts.PdpUpdate; import org.onap.policy.models.pdp.enums.PdpHealthStatus; @@ -132,26 +131,6 @@ public class XacmlStateTest { TopicSinkClient client = Mockito.mock(TopicSinkClient.class); XacmlPdpUpdatePublisher publisher = new XacmlPdpUpdatePublisher(client, state, appmgr); publisher.handlePdpUpdate(message); - - PdpStatistics stats = state.getStatistics(); - assertNotNull(stats); - assertEquals(GROUP, stats.getPdpGroupName()); - assertEquals(1, stats.getPolicyDeployCount()); - assertEquals(1, stats.getPolicyDeploySuccessCount()); - assertEquals(0, stats.getPolicyDeployFailCount()); - assertEquals(1, stats.getPolicyUndeployCount()); - assertEquals(1, stats.getPolicyUndeployFailCount()); - assertEquals(0, stats.getPolicyUndeploySuccessCount()); - - PdpStatistics test = new PdpStatistics(); - test.setTimeStamp(stats.getTimeStamp()); - test.setPdpGroupName(GROUP); - test.setPolicyDeployCount(1); - test.setPolicyDeploySuccessCount(1); - test.setPolicyUndeployCount(1); - test.setPolicyUndeployFailCount(1); - - assertEquals(stats.toString(), test.toString()); } @Test -- cgit 1.2.3-korg