diff options
author | jhh <jorge.hernandez-herrero@att.com> | 2019-05-07 20:51:34 -0500 |
---|---|---|
committer | jhh <jorge.hernandez-herrero@att.com> | 2019-05-08 21:59:33 -0500 |
commit | c3351f687be075d91908d04dfc4e7e9da243f395 (patch) | |
tree | 8845bb8f411bc212a466b1b98efd02f65290af97 /policy-management/src/main/java/org | |
parent | 6da702fafb473a08efd112cdc38cef1cfdef2f7a (diff) |
Track policies when active.
Do not honor group/subgroup changes with status messages.
When no present group/subgroups in update messages, assume that
they have to be reset.
Keep the policy cache of non-installed policies tracking them
when in passive state besides active. Wait until go active
to enable them.
Remove legacy PAP and PDP-X healtchecks as it was basically
testing reachability. There are conflicts with maintaining
2 different sets of PAPs and PDPs, trying to avoid it.
Alternative healtchecks are being placed on the robot test
framework. What to healtcheck should be considered more
carefully in the near future.
Change-Id: I574f30bb5899faf521123c79046793d16b4a46e0
Issue-ID: POLICY-1748
Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Diffstat (limited to 'policy-management/src/main/java/org')
4 files changed, 51 insertions, 3 deletions
diff --git a/policy-management/src/main/java/org/onap/policy/drools/controller/DroolsController.java b/policy-management/src/main/java/org/onap/policy/drools/controller/DroolsController.java index 78a2f4e8..4347614f 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/controller/DroolsController.java +++ b/policy-management/src/main/java/org/onap/policy/drools/controller/DroolsController.java @@ -243,6 +243,16 @@ public interface DroolsController extends Startable, Lockable { <T> boolean delete(@NonNull T fact); /** + * Deletes all facts from a given class from a session. + */ + <T> boolean delete(@NonNull String sessionName, @NonNull Class<T> fact); + + /** + * Deletes all facts from a given class from all sessions. + */ + <T> boolean delete(@NonNull Class<T> fact); + + /** * halts and permanently releases all resources. * */ diff --git a/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java b/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java index a9ab212b..140d6769 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java +++ b/policy-management/src/main/java/org/onap/policy/drools/controller/internal/MavenDroolsController.java @@ -920,6 +920,30 @@ public class MavenDroolsController implements DroolsController { } @Override + public <T> boolean delete(@NonNull String sessionName, @NonNull Class<T> fact) { + PolicySession session = getSession(sessionName); + KieSession kieSession = session.getKieSession(); + + boolean success = true; + Collection<FactHandle> factHandles = kieSession.getFactHandles(new ClassObjectFilter(fact)); + for (FactHandle factHandle : factHandles) { + try { + kieSession.delete(factHandle); + } catch (Exception e) { + logger.warn("Object cannot be retrieved from fact {}", factHandle, e); + success = false; + } + } + return success; + } + + @Override + public <T> boolean delete(@NonNull Class<T> fact) { + return this.getSessionNames().stream().map((ss) -> delete(ss, fact)).reduce(false, Boolean::logicalOr); + } + + + @Override public Class<?> fetchModelClass(String className) { return ReflectionUtil.fetchClass(this.policyContainer.getClassLoader(), className); } diff --git a/policy-management/src/main/java/org/onap/policy/drools/controller/internal/NullDroolsController.java b/policy-management/src/main/java/org/onap/policy/drools/controller/internal/NullDroolsController.java index 5bf51efa..3595f91a 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/controller/internal/NullDroolsController.java +++ b/policy-management/src/main/java/org/onap/policy/drools/controller/internal/NullDroolsController.java @@ -203,6 +203,16 @@ public class NullDroolsController implements DroolsController { return false; } + @Override + public <T> boolean delete(@NonNull String sessionName, @NonNull Class<T> fact) { + return false; + } + + @Override + public <T> boolean delete(@NonNull Class<T> fact) { + return false; + } + private String makeInvokeMsg() { return this.getClass().getCanonicalName() + " invoked"; } diff --git a/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java b/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java index aac92505..d926bed6 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java +++ b/policy-management/src/main/java/org/onap/policy/drools/server/restful/RestManager.java @@ -1699,6 +1699,7 @@ public class RestManager { @ApiParam(value = "Communication Mechanism", required = true) @PathParam("comm") String comm ) { List<TopicSource> sources = new ArrayList<>(); + Status status = Status.OK; switch (CommInfrastructure.valueOf(comm.toUpperCase())) { case UEB: sources.addAll(TopicEndpoint.manager.getUebTopicSources()); @@ -1710,10 +1711,11 @@ public class RestManager { sources.addAll(TopicEndpoint.manager.getNoopTopicSources()); break; default: + status = Status.BAD_REQUEST; logger.debug("Invalid communication mechanism parameter: {}", comm); break; } - return Response.status(Response.Status.OK).entity(sources).build(); + return Response.status(status).entity(sources).build(); } /** @@ -1727,6 +1729,7 @@ public class RestManager { @ApiParam(value = "Communication Mechanism", required = true) @PathParam("comm") String comm ) { List<TopicSink> sinks = new ArrayList<>(); + Status status = Status.OK; switch (CommInfrastructure.valueOf(comm.toUpperCase())) { case UEB: sinks.addAll(TopicEndpoint.manager.getUebTopicSinks()); @@ -1738,10 +1741,11 @@ public class RestManager { sinks.addAll(TopicEndpoint.manager.getNoopTopicSinks()); break; default: + status = Status.BAD_REQUEST; logger.debug("Invalid communication mechanism parameter: {}", comm); break; } - return Response.status(Response.Status.OK).entity(sinks).build(); + return Response.status(status).entity(sinks).build(); } @@ -1992,7 +1996,7 @@ public class RestManager { } /** - * Offers and event to a topic in a communication infrastructure. + * Offers an event to a topic in a communication infrastructure. * * @return response object */ |