summaryrefslogtreecommitdiffstats
path: root/feature-lifecycle/src/main/java/org/onap
diff options
context:
space:
mode:
authorjhh <jorge.hernandez-herrero@att.com>2019-05-13 23:31:44 -0500
committerjhh <jorge.hernandez-herrero@att.com>2019-05-13 23:40:58 -0500
commit9d93b8b4c3577a381e9b5181965d2ceb31e446ed (patch)
tree9f381d2201ed436c4374f1db5aa419ffe5e97f45 /feature-lifecycle/src/main/java/org/onap
parent6615d0388a27266a0487ed1b334e613e4e80cc6d (diff)
Ensure passive policies are injected when active
Add vim package for testing support Change-Id: Icefcf8a57eea80b4fed97d4c63080f6159d8167a Issue-ID: POLICY-1748 Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Diffstat (limited to 'feature-lifecycle/src/main/java/org/onap')
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java6
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleState.java9
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateDefault.java8
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStatePassive.java6
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java3
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateUnsupported.java7
6 files changed, 33 insertions, 6 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 7431097a..0e853e80 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
@@ -288,11 +288,15 @@ public class LifecycleFsm implements Startable {
}
protected List<ToscaPolicy> resetPoliciesAction() {
- ArrayList<ToscaPolicy> policies = new ArrayList<>(policiesMap.values());
+ List<ToscaPolicy> policies = new ArrayList<>(policiesMap.values());
policiesMap.clear();
return policies;
}
+ protected boolean updatePoliciesAction(List<ToscaPolicy> toscaPolicies) {
+ return (this.scheduler.submit( () -> state.updatePolicies(toscaPolicies)) != null);
+ }
+
/* ** Action Helpers ** */
private boolean startIo() {
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleState.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleState.java
index 2976732e..726e1d46 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleState.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleState.java
@@ -20,12 +20,14 @@
package org.onap.policy.drools.lifecycle;
+import java.util.List;
import lombok.NonNull;
import org.onap.policy.common.capabilities.Startable;
import org.onap.policy.common.gson.annotation.GsonJsonIgnore;
import org.onap.policy.models.pdp.concepts.PdpStateChange;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.models.pdp.enums.PdpState;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -67,7 +69,12 @@ public abstract class LifecycleState implements Startable {
public abstract boolean update(@NonNull PdpUpdate update);
/**
- * state change event .
+ * state change event.
*/
public abstract boolean stateChange(@NonNull PdpStateChange change);
+
+ /**
+ * update policies with the current list.
+ */
+ public abstract boolean updatePolicies(List<ToscaPolicy> toscaPolicies);
} \ No newline at end of file
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateDefault.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateDefault.java
index 330d02f4..db5d610a 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateDefault.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateDefault.java
@@ -20,9 +20,11 @@
package org.onap.policy.drools.lifecycle;
+import java.util.List;
import lombok.NonNull;
import org.onap.policy.models.pdp.concepts.PdpStateChange;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -90,4 +92,10 @@ public abstract class LifecycleStateDefault extends LifecycleStateUnsupported {
public boolean isAlive() {
return false;
}
+
+ @Override
+ public boolean updatePolicies(List<ToscaPolicy> toscaPolicies) {
+ logger.warn("{}: updatePolicies", this);
+ return false;
+ }
}
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStatePassive.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStatePassive.java
index 98829eeb..b88a200c 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStatePassive.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStatePassive.java
@@ -49,8 +49,8 @@ public class LifecycleStatePassive extends LifecycleStateRunning {
@Override
protected boolean stateChangeToActive(@NonNull PdpStateChange change) {
fsm.transitionToAction(new LifecycleStateActive(fsm));
- super.updatePolicies(fsm.resetPoliciesAction());
- return fsm.statusAction(response(change.getRequestId(), PdpResponseStatus.SUCCESS,null));
+ fsm.statusAction(response(change.getRequestId(), PdpResponseStatus.SUCCESS,null));
+ return fsm.updatePoliciesAction(fsm.resetPoliciesAction());
}
@Override
@@ -60,7 +60,7 @@ public class LifecycleStatePassive extends LifecycleStateRunning {
@Override
protected boolean deployPolicy(@NonNull PolicyController controller, @NonNull ToscaPolicy policy) {
- logger.info("{}: deploy {} from {}", this, policy.getIdentifier(), controller.getName());
+ logger.info("{}: deploy {} to {}", this, policy.getIdentifier(), controller.getName());
fsm.deployedPolicyAction(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 fcff4904..f50eab51 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
@@ -127,7 +127,8 @@ public abstract class LifecycleStateRunning extends LifecycleStateDefault {
}
}
- protected boolean updatePolicies(List<ToscaPolicy> policies) {
+ @Override
+ public boolean updatePolicies(List<ToscaPolicy> policies) {
if (policies == null) {
return true;
}
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateUnsupported.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateUnsupported.java
index 11ce7f34..f37cf68d 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateUnsupported.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateUnsupported.java
@@ -20,8 +20,10 @@
package org.onap.policy.drools.lifecycle;
+import java.util.List;
import org.onap.policy.models.pdp.concepts.PdpStateChange;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
/**
* Support class for those unsupported states not yet implemented.
@@ -75,4 +77,9 @@ public abstract class LifecycleStateUnsupported extends LifecycleState {
public boolean stateChange(PdpStateChange change) {
throw new UnsupportedOperationException("stateChange: " + this);
}
+
+ @Override
+ public boolean updatePolicies(List<ToscaPolicy> toscaPolicies) {
+ throw new UnsupportedOperationException("updatePolicies: " + this);
+ }
}