summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/CoordinationGuardTranslator.java1
-rw-r--r--applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/LegacyGuardTranslator.java1
-rw-r--r--applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/CoordinationTest.java1
-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
9 files changed, 38 insertions, 5 deletions
diff --git a/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/CoordinationGuardTranslator.java b/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/CoordinationGuardTranslator.java
index 41c1428e..a93e2811 100644
--- a/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/CoordinationGuardTranslator.java
+++ b/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/CoordinationGuardTranslator.java
@@ -72,6 +72,7 @@ public class CoordinationGuardTranslator implements ToscaPolicyTranslator {
Map<String, Object> policyProps = toscaPolicy.getProperties();
LOGGER.debug("path = {}", coordinationFunctionPath);
LOGGER.debug("props = {}", policyProps);
+ @SuppressWarnings("unchecked")
List<String> controlLoop = (List<String>) policyProps.get("controlLoop");
CoordinationDirective cd = new CoordinationDirective();
cd.setCoordinationFunction(type);
diff --git a/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/LegacyGuardTranslator.java b/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/LegacyGuardTranslator.java
index 2917aab2..932db959 100644
--- a/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/LegacyGuardTranslator.java
+++ b/applications/guard/src/main/java/org/onap/policy/xacml/pdp/application/guard/LegacyGuardTranslator.java
@@ -766,6 +766,7 @@ public class LegacyGuardTranslator implements ToscaPolicyTranslator {
return theInt;
}
+ @SuppressWarnings("unused")
private static AdviceExpressionsType generateRequestIdAdvice() {
AdviceExpressionType adviceExpression = new AdviceExpressionType();
adviceExpression.setAppliesTo(EffectType.PERMIT);
diff --git a/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/CoordinationTest.java b/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/CoordinationTest.java
index 9edf11dd..ee992907 100644
--- a/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/CoordinationTest.java
+++ b/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/CoordinationTest.java
@@ -70,6 +70,7 @@ public class CoordinationTest {
private static File propertiesFile;
private static XacmlApplicationServiceProvider service;
private static DecisionRequest requestCl1Node1;
+ @SuppressWarnings("unused")
private static DecisionRequest requestCl1Node2;
private static DecisionRequest requestCl2Node1;
private static DecisionRequest requestCl2Node2;
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());