summaryrefslogtreecommitdiffstats
path: root/feature-lifecycle/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'feature-lifecycle/src/main')
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java4
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateActive.java8
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java11
3 files changed, 18 insertions, 5 deletions
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
index b99953ed..97f3574e 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
@@ -283,6 +283,10 @@ public class LifecycleFsm implements Startable {
policiesMap.put(policy.getIdentifier(), policy);
}
+ protected void undeployedPolicyAction(@NonNull ToscaPolicy policy) {
+ policiesMap.remove(policy.getIdentifier());
+ }
+
/* ** Action Helpers ** */
private boolean startIo() {
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateActive.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateActive.java
index d481b8bd..38ea0917 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateActive.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateActive.java
@@ -61,8 +61,6 @@ public class LifecycleStateActive extends LifecycleStateRunning {
protected boolean deployPolicy(@NonNull PolicyController controller, @NonNull ToscaPolicy policy) {
logger.info("{}: deploy {} into {}", this, policy.getIdentifier(), controller.getName());
- // TODO: This is the latest version - retract policy with same id but different version
-
if (!controller.offer(policy)) {
return false;
}
@@ -75,8 +73,12 @@ public class LifecycleStateActive extends LifecycleStateRunning {
protected boolean undeployPolicy(@NonNull PolicyController controller, @NonNull ToscaPolicy policy) {
logger.info("{}: undeploy {} from {}", this, policy.getIdentifier(), controller.getName());
- // TODO: retract policy.
+ if (!controller.getDrools().delete(policy)) {
+ logger.warn("Policy {}:{}:{}:{} was not deployed.",
+ policy.getType(), policy.getTypeVersion(), policy.getName(), policy.getVersion());
+ }
+ fsm.undeployedPolicyAction(policy);
return true;
}
}
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java
index 405dbeba..ed200ea6 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java
@@ -134,8 +134,15 @@ public abstract class LifecycleStateRunning extends LifecycleStateDefault {
return true;
}
- boolean success = deployPolicies(policies);
- return undeployPolicies(policies) && success;
+ // Note that PAP sends the list of all ACTIVE policies with every
+ // UPDATE message. First, we will undeploy all policies that are
+ // running but are not present in this list. This will include
+ // policies that are overridden by a different version. Second,
+ // we will deploy those policies that are not installed but
+ // resent in this list.
+
+ boolean success = undeployPolicies(policies);
+ return deployPolicies(policies) && success;
}
protected boolean deployPolicies(List<ToscaPolicy> policies) {