summaryrefslogtreecommitdiffstats
path: root/feature-lifecycle/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'feature-lifecycle/src/main/java')
-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);
+ }
}