summaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisher.java7
-rw-r--r--main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManager.java9
-rw-r--r--main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpStatisticsManager.java9
-rw-r--r--main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpActivator.java1
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/rest/TestXacmlPdpRestServer.java7
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/rest/TestXacmlPdpStatistics.java7
6 files changed, 35 insertions, 5 deletions
diff --git a/main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisher.java b/main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisher.java
index a26f4b11..686a8edc 100644
--- a/main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisher.java
+++ b/main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisher.java
@@ -29,6 +29,7 @@ import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.onap.policy.pdpx.main.XacmlState;
import org.onap.policy.pdpx.main.rest.XacmlPdpApplicationManager;
+import org.onap.policy.pdpx.main.rest.XacmlPdpStatisticsManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -80,6 +81,12 @@ public class XacmlPdpUpdatePublisher {
}
}
+ // update the policy count statistic
+ XacmlPdpStatisticsManager stats = XacmlPdpStatisticsManager.getCurrent();
+ if (stats != null) {
+ stats.setTotalPolicyCount(appManager.getPolicyCount());
+ }
+
sendPdpUpdate(state.updateInternalState(message));
}
diff --git a/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManager.java b/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManager.java
index 6a5555be..52b4e00d 100644
--- a/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManager.java
+++ b/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManager.java
@@ -212,6 +212,15 @@ public class XacmlPdpApplicationManager {
return types;
}
+ /**
+ * Gets the number of policies currently deployed.
+ *
+ * @return the number of policies currently deployed
+ */
+ public int getPolicyCount() {
+ return mapLoadedPolicies.size();
+ }
+
private void initializeApplicationPath(Path basePath, XacmlApplicationServiceProvider application)
throws XacmlApplicationException {
//
diff --git a/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpStatisticsManager.java b/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpStatisticsManager.java
index 6d043052..a696ea43 100644
--- a/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpStatisticsManager.java
+++ b/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpStatisticsManager.java
@@ -53,12 +53,15 @@ public class XacmlPdpStatisticsManager {
}
/**
- * Method to update the xacml pdp total policies count.
+ * Method to set the xacml pdp total policies count. This
+ * doesn't really increment, it depends on the applications
+ * that are loaded. Which can be dynamic.
*
* @return the total
*/
- public long updateTotalPoliciesCount() {
- return ++totalPoliciesCount;
+ public long setTotalPolicyCount(long newCount) {
+ totalPoliciesCount = newCount;
+ return totalPoliciesCount;
}
/**
diff --git a/main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpActivator.java b/main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpActivator.java
index 5f014a12..8af412d5 100644
--- a/main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpActivator.java
+++ b/main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpActivator.java
@@ -100,6 +100,7 @@ public class XacmlPdpActivator extends ServiceManagerContainer {
XacmlPdpStatisticsManager stats = new XacmlPdpStatisticsManager();
XacmlPdpStatisticsManager.setCurrent(stats);
stats.setTotalPolicyTypesCount(appmgr.getPolicyTypeCount());
+ stats.setTotalPolicyCount(appmgr.getPolicyCount());
state = new XacmlState(appmgr);
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/rest/TestXacmlPdpRestServer.java b/main/src/test/java/org/onap/policy/pdpx/main/rest/TestXacmlPdpRestServer.java
index ba8f0044..7865851d 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/rest/TestXacmlPdpRestServer.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/rest/TestXacmlPdpRestServer.java
@@ -44,6 +44,8 @@ public class TestXacmlPdpRestServer extends CommonRest {
private static final String HEALTHCHECK_ENDPOINT = "healthcheck";
private static final String STATISTICS_ENDPOINT = "statistics";
+ private int nupdates = 0;
+
@Test
public void testHealthCheckSuccess() throws Exception {
LOGGER.info("***************************** Running testHealthCheckSuccess *****************************");
@@ -111,7 +113,9 @@ public class TestXacmlPdpRestServer extends CommonRest {
private void updateXacmlPdpStatistics() {
XacmlPdpStatisticsManager stats = XacmlPdpStatisticsManager.getCurrent();
- stats.updateTotalPoliciesCount();
+ ++nupdates;
+ stats.setTotalPolicyCount(nupdates);
+ stats.setTotalPolicyTypesCount(nupdates);
stats.updatePermitDecisionsCount();
stats.updateDenyDecisionsCount();
stats.updateIndeterminantDecisionsCount();
@@ -121,6 +125,7 @@ public class TestXacmlPdpRestServer extends CommonRest {
private void validateStatisticsReport(final StatisticsReport report, final int count, final int code) {
assertEquals(code, report.getCode());
assertEquals(count, report.getTotalPoliciesCount());
+ assertEquals(count, report.getTotalPolicyTypesCount());
assertEquals(count, report.getPermitDecisionsCount());
assertEquals(count, report.getDenyDecisionsCount());
assertEquals(count, report.getIndeterminantDecisionsCount());
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/rest/TestXacmlPdpStatistics.java b/main/src/test/java/org/onap/policy/pdpx/main/rest/TestXacmlPdpStatistics.java
index 250f21e6..030b9075 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/rest/TestXacmlPdpStatistics.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/rest/TestXacmlPdpStatistics.java
@@ -37,6 +37,8 @@ public class TestXacmlPdpStatistics extends CommonRest {
private static final Logger LOGGER = LoggerFactory.getLogger(TestXacmlPdpStatistics.class);
+ private int nupdates = 0;
+
@Test
public void testXacmlPdpStatistics_200() throws Exception {
LOGGER.info("*************************** Running testXacmlPdpStatistics_200 ***************************");
@@ -64,7 +66,9 @@ public class TestXacmlPdpStatistics extends CommonRest {
private void updateXacmlPdpStatistics() {
XacmlPdpStatisticsManager stats = XacmlPdpStatisticsManager.getCurrent();
- stats.updateTotalPoliciesCount();
+ ++nupdates;
+ stats.setTotalPolicyCount(nupdates);
+ stats.setTotalPolicyTypesCount(nupdates);
stats.updatePermitDecisionsCount();
stats.updateDenyDecisionsCount();
stats.updateIndeterminantDecisionsCount();
@@ -74,6 +78,7 @@ public class TestXacmlPdpStatistics extends CommonRest {
private void validateReport(final StatisticsReport report, final int count, final int code) {
assertEquals(code, report.getCode());
assertEquals(count, report.getTotalPoliciesCount());
+ assertEquals(count, report.getTotalPolicyTypesCount());
assertEquals(count, report.getPermitDecisionsCount());
assertEquals(count, report.getDenyDecisionsCount());
assertEquals(count, report.getIndeterminantDecisionsCount());