diff options
author | jhh <jorge.hernandez-herrero@att.com> | 2020-02-26 18:30:18 -0600 |
---|---|---|
committer | jhh <jorge.hernandez-herrero@att.com> | 2020-02-26 18:30:18 -0600 |
commit | fe4f6e1c9a4ee06c21ccee51af9eaf654e56281e (patch) | |
tree | b1a2e9c5178171e3ed6a405c4fded94c2739fbfa /policy-management/src/main | |
parent | 9f75b598b3e0946cf4065bced39f9ea77a9dc3d7 (diff) |
Undeploy support for native rules PDP-D policies.
Issue-ID: POLICY-2388
Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Change-Id: Iaaf5e13a5db286928952bcb3e4cc0f526b0b133c
Diffstat (limited to 'policy-management/src/main')
3 files changed, 16 insertions, 9 deletions
diff --git a/policy-management/src/main/java/org/onap/policy/drools/controller/IndexedDroolsControllerFactory.java b/policy-management/src/main/java/org/onap/policy/drools/controller/IndexedDroolsControllerFactory.java index a4c546f8..e5128bb5 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/controller/IndexedDroolsControllerFactory.java +++ b/policy-management/src/main/java/org/onap/policy/drools/controller/IndexedDroolsControllerFactory.java @@ -95,7 +95,6 @@ class IndexedDroolsControllerFactory implements DroolsControllerFactory { } List<TopicCoderFilterConfiguration> topics2DecodedClasses2Filters = codersAndFilters(properties, eventSources); - List<TopicCoderFilterConfiguration> topics2EncodedClasses2Filters = codersAndFilters(properties, eventSinks); return this.build(groupId, artifactId, version, topics2DecodedClasses2Filters, topics2EncodedClasses2Filters); diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/IndexedPolicyControllerFactory.java b/policy-management/src/main/java/org/onap/policy/drools/system/IndexedPolicyControllerFactory.java index 0d7806c6..528f1e0d 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/system/IndexedPolicyControllerFactory.java +++ b/policy-management/src/main/java/org/onap/policy/drools/system/IndexedPolicyControllerFactory.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -122,7 +122,7 @@ class IndexedPolicyControllerFactory implements PolicyControllerFactory { * {@inheritDoc}. */ @Override - public void patch(PolicyController controller, DroolsConfiguration droolsConfig) { + public synchronized void patch(PolicyController controller, DroolsConfiguration droolsConfig) { if (controller == null) { throw new IllegalArgumentException("Not a valid controller: null"); @@ -132,20 +132,22 @@ class IndexedPolicyControllerFactory implements PolicyControllerFactory { throw new IllegalArgumentException("Invalid Drools Configuration"); } + if (controller.getDrools().isBrained()) { + this.coordinates2Controller.remove( + toKey(controller.getDrools().getGroupId(), controller.getDrools().getArtifactId())); + } + if (!controller.updateDrools(droolsConfig)) { logger.warn("Cannot update drools configuration: {} on {}", droolsConfig, this); throw new IllegalArgumentException("Cannot update drools configuration Drools Configuration"); } logger.info("UPDATED drools configuration: {} on {}", droolsConfig, this); - - String coordinates = toKey(controller.getDrools().getGroupId(), - controller.getDrools().getArtifactId()); + String coordinates = toKey(controller.getDrools().getGroupId(), controller.getDrools().getArtifactId()); if (controller.getDrools().isBrained()) { this.coordinates2Controller.put(coordinates, controller); } - } /** diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java b/policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java index aa57abaf..1fd42546 100644 --- a/policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java +++ b/policy-management/src/main/java/org/onap/policy/drools/system/internal/AggregatedPolicyController.java @@ -1,8 +1,8 @@ /* * ============LICENSE_START======================================================= - * policy-management + * ONAP * ================================================================================ - * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -226,6 +226,12 @@ public class AggregatedPolicyController implements PolicyController, TopicListen return true; } + if (droolsController.isBrained() + && (newDroolsConfiguration.getArtifactId() == null + || DroolsControllerConstants.NO_ARTIFACT_ID.equals(newDroolsConfiguration.getArtifactId()))) { + DroolsControllerConstants.getFactory().destroy(this.droolsController); + } + try { /* Drools Controller created, update initialization properties for restarts */ |