summaryrefslogtreecommitdiffstats
path: root/feature-lifecycle/src/main/java
diff options
context:
space:
mode:
authorjhh <jorge.hernandez-herrero@att.com>2020-01-07 12:09:47 -0600
committerjhh <jorge.hernandez-herrero@att.com>2020-01-07 15:22:50 -0600
commit38919c45aafa99d950eddf879b2bc25e95529378 (patch)
treef83af51e2c90cefeae5358e3cadc6171430a16e7 /feature-lifecycle/src/main/java
parent4112fecf3d65f1d5dd1eb99334061b2b17c6ad43 (diff)
Remove supported policy types from status message
Issue-ID: POLICY-2233 Signed-off-by: jhh <jorge.hernandez-herrero@att.com> Change-Id: I2168b9616d35ee3b9aa491aaa5d363b8609adb84 Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Diffstat (limited to 'feature-lifecycle/src/main/java')
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java31
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java8
2 files changed, 14 insertions, 25 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 27f375d0..805dfd01 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
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -45,8 +45,6 @@ import org.onap.policy.common.endpoints.listeners.ScoListener;
import org.onap.policy.common.gson.annotation.GsonJsonIgnore;
import org.onap.policy.common.utils.coder.StandardCoderObject;
import org.onap.policy.common.utils.network.NetworkUtil;
-import org.onap.policy.drools.controller.DroolsController;
-import org.onap.policy.drools.controller.DroolsControllerConstants;
import org.onap.policy.drools.persistence.SystemPersistenceConstants;
import org.onap.policy.drools.system.PolicyController;
import org.onap.policy.models.pdp.concepts.PdpResponseDetails;
@@ -70,7 +68,6 @@ 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;
protected static final String PDP_MESSAGE_NAME = "messageName";
@@ -112,6 +109,7 @@ public class LifecycleFsm implements Startable {
@Getter
protected String subgroup;
+ @Getter
protected final Map<ToscaPolicyTypeIdentifier, PolicyController> policyTypesMap = new HashMap<>();
protected final Map<ToscaPolicyIdentifier, ToscaPolicy> policiesMap = new HashMap<>();
@@ -150,7 +148,9 @@ public class LifecycleFsm implements Startable {
public synchronized void start(@NonNull PolicyController controller) {
logger.info("lifecycle event: start controller: {}", controller.getName());
for (ToscaPolicyTypeIdentifier id : controller.getPolicyTypes()) {
- policyTypesMap.put(id, controller);
+ if (isToscaPolicyType(id.getName())) {
+ policyTypesMap.put(id, controller);
+ }
}
}
@@ -342,7 +342,6 @@ public class LifecycleFsm implements Startable {
status.setState(state);
status.setHealthy(isAlive() ? PdpHealthStatus.HEALTHY : PdpHealthStatus.NOT_HEALTHY);
status.setPdpType("drools");
- status.setSupportedPolicyTypes(getCapabilities());
status.setPolicies(new ArrayList<>(policiesMap.keySet()));
return status;
}
@@ -379,23 +378,9 @@ public class LifecycleFsm implements Startable {
return this.client.getSink().start();
}
- private List<ToscaPolicyTypeIdentifier> getCapabilities() {
- List<ToscaPolicyTypeIdentifier> capabilities = new ArrayList<>();
- for (DroolsController dc : DroolsControllerConstants.getFactory().inventory()) {
- if (!dc.isBrained()) {
- continue;
- }
-
- for (String domain : dc.getBaseDomainNames()) {
- // HACK: until legacy controllers are removed
- if (StringUtils.countMatches(domain, ".") > 1) {
- capabilities.add(new ToscaPolicyTypeIdentifier(domain, POLICY_TYPE_VERSION));
- } else {
- logger.info("legacy controller {} with domain {}", dc.getCanonicalSessionNames(), domain);
- }
- }
- }
- return capabilities;
+ protected boolean isToscaPolicyType(String domain) {
+ // HACK: until legacy controllers support is removed
+ return StringUtils.countMatches(domain, ".") > 1;
}
protected boolean isItMe(String name, String group, String 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 78414fe8..a80c8853 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
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Bell Canada.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -80,7 +80,11 @@ public abstract class LifecycleStateRunning extends LifecycleStateDefault {
@Override
public boolean status() {
synchronized (fsm) {
- return fsm.statusAction();
+ if (fsm.getPolicyTypesMap().isEmpty()) {
+ return true;
+ } else {
+ return fsm.statusAction();
+ }
}
}