aboutsummaryrefslogtreecommitdiffstats
path: root/feature-lifecycle
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2019-11-15 10:58:03 -0500
committerJim Hahn <jrh3@att.com>2019-11-17 08:29:40 -0500
commit1e70699a0e388071c09e15e358188e1c76936a39 (patch)
treef68477a0e24364bdf5090d69fc7b141b2e9f7f25 /feature-lifecycle
parent58c3811bfba7e421af8c9d2d72f55e95b4b01a50 (diff)
Set drools-pdp Pdp Group from the property file
Modified drools-pdp to get its Pdp Group from a property file instead of getting it from the PDP-UPDATE or PDP-STATE-CHANGE requests. Modified property files to use envd, per review comment. Issue-ID: POLICY-2232 Change-Id: Ibf024a476b2216074819dda7a66dcbfba811e278 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'feature-lifecycle')
-rw-r--r--feature-lifecycle/src/main/feature/config/feature-lifecycle.properties2
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java10
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java2
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java10
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java18
-rw-r--r--feature-lifecycle/src/test/resources/feature-lifecycle.properties2
6 files changed, 25 insertions, 19 deletions
diff --git a/feature-lifecycle/src/main/feature/config/feature-lifecycle.properties b/feature-lifecycle/src/main/feature/config/feature-lifecycle.properties
index 7fd6599c..1bb32169 100644
--- a/feature-lifecycle/src/main/feature/config/feature-lifecycle.properties
+++ b/feature-lifecycle/src/main/feature/config/feature-lifecycle.properties
@@ -16,6 +16,8 @@
# limitations under the License.
# ============LICENSE_END=========================================================
+lifecycle.pdp.group=${envd:POLICY_PDP_PAP_GROUP:defaultGroup}
+
dmaap.source.topics=POLICY-PDP-PAP
dmaap.sink.topics=POLICY-PDP-PAP
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 5b4bd1ec..27f375d0 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
@@ -68,6 +68,8 @@ import org.slf4j.LoggerFactory;
public class LifecycleFsm implements Startable {
protected static final String CONFIGURATION_PROPERTIES_NAME = "feature-lifecycle";
+ protected static final String GROUP_NAME = "lifecycle.pdp.group";
+ protected static final String DEFAULT_PDP_GROUP = "defaultGroup";
protected static final String POLICY_TYPE_VERSION = "1.0.0";
protected static final long DEFAULT_STATUS_TIMER_SECONDS = 120L;
protected static final long MIN_STATUS_INTERVAL_SECONDS = 5L;
@@ -92,7 +94,7 @@ public class LifecycleFsm implements Startable {
protected ScheduledFuture<?> statusTask;
@GsonJsonIgnore
- protected MessageTypeDispatcher sourceDispatcher = new MessageTypeDispatcher(new String[]{PDP_MESSAGE_NAME});
+ protected MessageTypeDispatcher sourceDispatcher = new MessageTypeDispatcher(PDP_MESSAGE_NAME);
@GsonJsonIgnore
protected PdpStateChangeFeed stateChangeFeed = new PdpStateChangeFeed(PdpStateChange.class, this);
@@ -105,7 +107,7 @@ public class LifecycleFsm implements Startable {
protected long statusTimerSeconds = DEFAULT_STATUS_TIMER_SECONDS;
@Getter
- protected String group;
+ private final String group;
@Getter
protected String subgroup;
@@ -119,6 +121,7 @@ public class LifecycleFsm implements Startable {
*/
public LifecycleFsm() {
this.properties = SystemPersistenceConstants.getManager().getProperties(CONFIGURATION_PROPERTIES_NAME);
+ this.group = this.properties.getProperty(GROUP_NAME, DEFAULT_PDP_GROUP);
}
@Override
@@ -238,8 +241,7 @@ public class LifecycleFsm implements Startable {
return client.send(status);
}
- protected void setGroupAction(String group, String subgroup) {
- this.group = group;
+ protected void setSubGroupAction(String subgroup) {
this.subgroup = subgroup;
}
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 c5ea44b2..78414fe8 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
@@ -117,7 +117,7 @@ public abstract class LifecycleStateRunning extends LifecycleStateDefault {
return false;
}
- fsm.setGroupAction(update.getPdpGroup(), update.getPdpSubgroup());
+ fsm.setSubGroupAction(update.getPdpSubgroup());
if (!updatePolicies(update.getPolicies())) {
fsm.statusAction(response(update.getRequestId(), PdpResponseStatus.FAIL, "cannot process policies"));
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java
index 71245335..bb8e4940 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStateActiveTest.java
@@ -74,7 +74,7 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
change.setState(PdpState.ACTIVE);
change.setName(fsm.getName());
- fsm.setGroupAction("A", "a");
+ fsm.setSubGroupAction("a");
fsm.source.offer(new StandardCoder().encode(change));
controllerSupport.getController().start();
}
@@ -96,7 +96,7 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
private void assertActive() {
assertEquals(PdpState.ACTIVE, fsm.state());
- assertEquals("A", fsm.getGroup());
+ assertEquals(LifecycleFsm.DEFAULT_PDP_GROUP, fsm.getGroup());
assertEquals("a", fsm.getSubgroup());
assertTrue(fsm.isAlive());
waitUntil(fsm.getStatusTimerSeconds() + 1, TimeUnit.SECONDS, isStatus(PdpState.ACTIVE));
@@ -164,13 +164,13 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
fsm.source.offer(new StandardCoder().encode(change));
assertEquals(PdpState.ACTIVE, fsm.state());
- assertNotEquals("B", fsm.getGroup());
+ assertEquals(LifecycleFsm.DEFAULT_PDP_GROUP, fsm.getGroup());;
assertNotEquals("b", fsm.getSubgroup());
change.setName(fsm.getName());
fsm.source.offer(new StandardCoder().encode(change));
assertEquals(PdpState.ACTIVE, fsm.state());
- assertEquals("A", fsm.getGroup());
+ assertEquals(LifecycleFsm.DEFAULT_PDP_GROUP, fsm.getGroup());
assertEquals("a", fsm.getSubgroup());
change.setState(PdpState.SAFE);
@@ -204,7 +204,7 @@ public class LifecycleStateActiveTest extends LifecycleStateRunningTest {
assertTrue(fsm.update(update));
assertEquals(PdpState.ACTIVE, fsm.state());
- assertEquals("W", fsm.getGroup());
+ assertEquals(LifecycleFsm.DEFAULT_PDP_GROUP, fsm.getGroup());
assertEquals("w", fsm.getSubgroup());
String restartV1 =
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java
index 9ecabbe8..341d9857 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/LifecycleStatePassiveTest.java
@@ -176,7 +176,7 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
assertEquals(PdpState.PASSIVE, fsm.state());
assertEquals(interval, fsm.getStatusTimerSeconds());
- assertEquals("Z", fsm.getGroup());
+ assertEquals(LifecycleFsm.DEFAULT_PDP_GROUP, fsm.getGroup());
assertEquals("z", fsm.getSubgroup());
assertBasicPassive();
@@ -189,7 +189,7 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
assertEquals(PdpState.PASSIVE, fsm.state());
assertEquals(interval, fsm.getStatusTimerSeconds());
- assertEquals("Z", fsm.getGroup());
+ assertEquals(LifecycleFsm.DEFAULT_PDP_GROUP, fsm.getGroup());
assertEquals("z", fsm.getSubgroup());
assertBasicPassive();
@@ -203,7 +203,7 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
assertEquals(PdpState.PASSIVE, fsm.state());
assertEquals(interval, fsm.getStatusTimerSeconds());
- assertNull(fsm.getGroup());
+ assertEquals(LifecycleFsm.DEFAULT_PDP_GROUP, fsm.getGroup());
assertNull(fsm.getSubgroup());
assertBasicPassive();
assertTrue(fsm.policyTypesMap.isEmpty());
@@ -216,7 +216,7 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
assertEquals(PdpState.PASSIVE, fsm.state());
assertEquals(interval, fsm.getStatusTimerSeconds());
- assertEquals("A", fsm.getGroup());
+ assertEquals(LifecycleFsm.DEFAULT_PDP_GROUP, fsm.getGroup());
assertEquals("a", fsm.getSubgroup());
assertBasicPassive();
assertTrue(fsm.policyTypesMap.isEmpty());
@@ -232,7 +232,7 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
assertEquals(fsm.policiesMap.get(toscaPolicy.getIdentifier()), toscaPolicy);
assertEquals(PdpState.PASSIVE, fsm.state());
assertEquals(interval, fsm.getStatusTimerSeconds());
- assertEquals("A", fsm.getGroup());
+ assertEquals(LifecycleFsm.DEFAULT_PDP_GROUP, fsm.getGroup());
assertEquals("a", fsm.getSubgroup());
assertBasicPassive();
assertEquals(0, controllerSupport.getController().getDrools().factCount("junits"));
@@ -245,7 +245,7 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
assertEquals(0, fsm.policiesMap.size());
assertEquals(PdpState.PASSIVE, fsm.state());
assertEquals(interval, fsm.getStatusTimerSeconds());
- assertNull(fsm.getGroup());
+ assertEquals(LifecycleFsm.DEFAULT_PDP_GROUP, fsm.getGroup());
assertNull(fsm.getSubgroup());
assertBasicPassive();
assertEquals(0, controllerSupport.getController().getDrools().factCount("junits"));
@@ -266,7 +266,7 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
fsm.source.offer(new StandardCoder().encode(change));
assertEquals(PdpState.PASSIVE, fsm.state());
- assertNull(fsm.getGroup());
+ assertEquals(LifecycleFsm.DEFAULT_PDP_GROUP, fsm.getGroup());
assertNull(fsm.getSubgroup());
PdpUpdate update = new PdpUpdate();
@@ -289,7 +289,7 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
assertEquals(1, fsm.policiesMap.size());
assertEquals(fsm.policiesMap.get(toscaPolicy.getIdentifier()), toscaPolicy);
assertEquals(PdpState.PASSIVE, fsm.state());
- assertEquals("A", fsm.getGroup());
+ assertEquals(LifecycleFsm.DEFAULT_PDP_GROUP, fsm.getGroup());
assertEquals("a", fsm.getSubgroup());
assertBasicPassive();
assertEquals(0, controllerSupport.getController().getDrools().factCount("junits"));
@@ -299,7 +299,7 @@ public class LifecycleStatePassiveTest extends LifecycleStateRunningTest {
fsm.source.offer(new StandardCoder().encode(change));
assertEquals(PdpState.ACTIVE, fsm.state());
- assertEquals("A", fsm.getGroup());
+ assertEquals(LifecycleFsm.DEFAULT_PDP_GROUP, fsm.getGroup());
assertEquals("a", fsm.getSubgroup());
waitUntil(5, TimeUnit.SECONDS, () -> controllerSupport.getController().getDrools().factCount("junits") == 1);
diff --git a/feature-lifecycle/src/test/resources/feature-lifecycle.properties b/feature-lifecycle/src/test/resources/feature-lifecycle.properties
index a972016f..0c80ed45 100644
--- a/feature-lifecycle/src/test/resources/feature-lifecycle.properties
+++ b/feature-lifecycle/src/test/resources/feature-lifecycle.properties
@@ -16,6 +16,8 @@
# limitations under the License.
# ============LICENSE_END=========================================================
+lifecycle.pdp.group=${envd:POLICY_PDP_PAP_GROUP:defaultGroup}
+
noop.source.topics=POLICY-PDP-PAP
noop.sink.topics=POLICY-PDP-PAP