aboutsummaryrefslogtreecommitdiffstats
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.java8
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStatePassive.java3
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java12
3 files changed, 11 insertions, 12 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 ada29ede..7431097a 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
@@ -67,7 +67,7 @@ public class LifecycleFsm implements Startable {
protected static final String CONFIGURATION_PROPERTIES_NAME = "feature-lifecycle";
protected static final String POLICY_TYPE_VERSION = "1.0.0";
- protected static final long DEFAULT_STATUS_TIMER_SECONDS = 60L;
+ protected static final long DEFAULT_STATUS_TIMER_SECONDS = 120L;
protected static final long MIN_STATUS_INTERVAL_SECONDS = 5L;
protected static final String PDP_MESSAGE_NAME = "messageName";
@@ -287,6 +287,12 @@ public class LifecycleFsm implements Startable {
policiesMap.remove(policy.getIdentifier());
}
+ protected List<ToscaPolicy> resetPoliciesAction() {
+ ArrayList<ToscaPolicy> policies = new ArrayList<>(policiesMap.values());
+ policiesMap.clear();
+ return policies;
+ }
+
/* ** Action Helpers ** */
private boolean startIo() {
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 e9f4b9bf..98829eeb 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,6 +49,7 @@ 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));
}
@@ -60,12 +61,14 @@ public class LifecycleStatePassive extends LifecycleStateRunning {
@Override
protected boolean deployPolicy(@NonNull PolicyController controller, @NonNull ToscaPolicy policy) {
logger.info("{}: deploy {} from {}", this, policy.getIdentifier(), controller.getName());
+ fsm.deployedPolicyAction(policy);
return true;
}
@Override
protected boolean undeployPolicy(@NonNull PolicyController controller, @NonNull ToscaPolicy policy) {
logger.info("{}: undeploy {} from {}", this, policy.getIdentifier(), controller.getName());
+ 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 ed200ea6..fcff4904 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
@@ -92,12 +92,10 @@ public abstract class LifecycleStateRunning extends LifecycleStateDefault {
public boolean stateChange(@NonNull PdpStateChange change) {
synchronized (fsm) {
if (change.getState() == PdpState.PASSIVE) {
- group(change.getPdpGroup(), change.getPdpSubgroup());
return stateChangeToPassive(change);
}
if (change.getState() == PdpState.ACTIVE) {
- group(change.getPdpGroup(), change.getPdpSubgroup());
return stateChangeToActive(change);
}
@@ -118,7 +116,7 @@ public abstract class LifecycleStateRunning extends LifecycleStateDefault {
return false;
}
- group(update.getPdpGroup(), update.getPdpSubgroup());
+ fsm.setGroupAction(update.getPdpGroup(), update.getPdpSubgroup());
if (!updatePolicies(update.getPolicies())) {
fsm.statusAction(response(update.getRequestId(), PdpResponseStatus.FAIL, "cannot process policies"));
@@ -187,12 +185,4 @@ public abstract class LifecycleStateRunning extends LifecycleStateDefault {
return response;
}
-
- protected void group(String group, String subgroup) {
- if (group == null || subgroup == null) {
- return;
- }
-
- fsm.setGroupAction(group, subgroup);
- }
}