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);
return theInt;
}
+ @SuppressWarnings("unused")
private static AdviceExpressionsType generateRequestIdAdvice() {
AdviceExpressionType adviceExpression = new AdviceExpressionType();
adviceExpression.setAppliesTo(EffectType.PERMIT);
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;
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;
}
}
+ // update the policy count statistic
+ XacmlPdpStatisticsManager stats = XacmlPdpStatisticsManager.getCurrent();
+ if (stats != null) {
+ stats.setTotalPolicyCount(appManager.getPolicyCount());
+ }
+
sendPdpUpdate(state.updateInternalState(message));
}
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 {
//
}
/**
- * 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;
}
/**
XacmlPdpStatisticsManager stats = new XacmlPdpStatisticsManager();
XacmlPdpStatisticsManager.setCurrent(stats);
stats.setTotalPolicyTypesCount(appmgr.getPolicyTypeCount());
+ stats.setTotalPolicyCount(appmgr.getPolicyCount());
state = new XacmlState(appmgr);
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 *****************************");
private void updateXacmlPdpStatistics() {
XacmlPdpStatisticsManager stats = XacmlPdpStatisticsManager.getCurrent();
- stats.updateTotalPoliciesCount();
+ ++nupdates;
+ stats.setTotalPolicyCount(nupdates);
+ stats.setTotalPolicyTypesCount(nupdates);
stats.updatePermitDecisionsCount();
stats.updateDenyDecisionsCount();
stats.updateIndeterminantDecisionsCount();
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());
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 ***************************");
private void updateXacmlPdpStatistics() {
XacmlPdpStatisticsManager stats = XacmlPdpStatisticsManager.getCurrent();
- stats.updateTotalPoliciesCount();
+ ++nupdates;
+ stats.setTotalPolicyCount(nupdates);
+ stats.setTotalPolicyTypesCount(nupdates);
stats.updatePermitDecisionsCount();
stats.updateDenyDecisionsCount();
stats.updateIndeterminantDecisionsCount();
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());