summaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src/main/java/org/openecomp
diff options
context:
space:
mode:
authorRob Daugherty <rd472p@att.com>2018-04-24 13:53:25 -0400
committerRob Daugherty <rd472p@att.com>2018-04-24 14:26:12 -0400
commitbb34137b85575dd36121d8cfc63b469e9a2ebf08 (patch)
tree33b7aba21b0db8bf9511488c10ffa0718c94d42a /bpmn/MSOCommonBPMN/src/main/java/org/openecomp
parent4e40f1186d6dac2bf112ee21dccf5b6a463c00b8 (diff)
Create VF Module Error
There are multiple issues here. 1) The LCM healthcheck and config-scale-out should be made conditional upon the VNF orchestration status being Active or Activated. I'm not going to do that with this commit, since the logic will probably need to be moved to the DoCreateVfModule flow. What I will do is bypass the LCM operations to unblock testing. Another ticket will need to address the real solution. 2) APP-C gave us an API where the controller type is configured in their client object, which is NOT what we wanted. As a result, we have to keep a client object for each controller type. Our implementation did not do this. 3) Need to support the APP-C client configuration properties for specifying the SDN-C topic names. I'm refactoring the APP-C client urn mapping names to make it clear that they are for configuring the APP-C *client* and not necessarily for APP-C itself. Change-Id: I588f3b98b4ee44ba53b4931f9f1a7938ee70bebf Issue-ID: SO-577 Signed-off-by: Rob Daugherty <rd472p@att.com>
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/main/java/org/openecomp')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerClient.java99
1 files changed, 69 insertions, 30 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerClient.java
index 8c57b9255c..3cd26be631 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerClient.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerClient.java
@@ -26,9 +26,7 @@ import java.time.Instant;
import java.util.Map;
import java.util.Properties;
import java.util.UUID;
-
-import org.openecomp.mso.bpmn.core.PropertyConfiguration;
-import org.springframework.beans.factory.annotation.Autowired;
+import java.util.concurrent.ConcurrentHashMap;
import org.onap.appc.client.lcm.api.AppcClientServiceFactoryProvider;
import org.onap.appc.client.lcm.api.AppcLifeCycleManagerServiceFactory;
@@ -44,11 +42,16 @@ import org.onap.appc.client.lcm.model.Flags.Mode;
import org.onap.appc.client.lcm.model.Payload;
import org.onap.appc.client.lcm.model.Status;
import org.onap.appc.client.lcm.model.ZULU;
+import org.openecomp.mso.bpmn.core.PropertyConfiguration;
+import org.springframework.beans.factory.annotation.Autowired;
+
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFLogger.Level;
import com.att.eelf.configuration.EELFManager;
public class ApplicationControllerClient {
+
+ public static final String DEFAULT_CONTROLLER_TYPE = "appc";
private static final String CLIENT_NAME = "MSO";
@@ -60,18 +63,68 @@ public class ApplicationControllerClient {
@Autowired
public ApplicationControllerSupport appCSupport;
- private static LifeCycleManagerStateful client;
+ // APPC gave us an API where the controllerType is configured in the
+ // client object, which is not what we asked for. We asked for an API
+ // in which the client would have additional methods that could take
+ // the controllerType as a parameter, so that we would not need to
+ // maintain multiple client objects. This map should be removed when
+ // the (hopefully short-term) controllerType becomes obsolete.
+
+ private final String controllerType;
+
+ private static ConcurrentHashMap<String, LifeCycleManagerStateful> appCClients = new ConcurrentHashMap<>();
+ /**
+ * Creates an ApplicationControllerClient for communication with APP-C.
+ */
+ public ApplicationControllerClient() {
+ this(DEFAULT_CONTROLLER_TYPE);
+ }
+
+ /**
+ * Creates an ApplicationControllerClient for the specified controller type.
+ * @param controllerType the controller type: "appc" or "sndnc".
+ */
public ApplicationControllerClient(String controllerType) {
+ this.controllerType = controllerType;
appCSupport = new ApplicationControllerSupport();
- client = this.getAppCClient(controllerType);
+ }
+
+ /**
+ * Gets the controller type.
+ * @return the controllertype
+ */
+ public String getControllerType() {
+ return controllerType;
}
- public Status runCommand(Action action, org.onap.appc.client.lcm.model.ActionIdentifiers actionIdentifiers, org.onap.appc.client.lcm.model.Payload payload, String requestID)
+ /**
+ * Returns the AppC client object associated with this ApplicationControllerClient.
+ * AppC client objects are shared objects. One is created if it does not exist.
+ * @return the client object, or null if creation failed
+ */
+ public LifeCycleManagerStateful getAppCClient() {
+ return appCClients.computeIfAbsent(controllerType, k -> createAppCClient(k));
+ }
+
+ protected LifeCycleManagerStateful createAppCClient(String controllerType) {
+ try {
+ return AppcClientServiceFactoryProvider.getFactory(AppcLifeCycleManagerServiceFactory.class)
+ .createLifeCycleManagerStateful(new ApplicationContext(), getLCMProperties());
+ } catch (AppcClientException e) {
+ auditLogger.log(Level.ERROR, "Error in getting LifeCycleManagerStateful: ", e, e.getMessage());
+ // This null value will cause NullPointerException when used later.
+ // Error handling could certainly be improved here.
+ return null;
+ }
+ }
+
+ public Status runCommand(Action action, org.onap.appc.client.lcm.model.ActionIdentifiers actionIdentifiers,
+ org.onap.appc.client.lcm.model.Payload payload, String requestID)
throws ApplicationControllerOrchestratorException {
- Object requestObject;
- requestObject = createRequest(action, actionIdentifiers, payload, requestID);
+ Object requestObject = createRequest(action, actionIdentifiers, payload, requestID);
appCSupport.logLCMMessage(requestObject);
+ LifeCycleManagerStateful client = getAppCClient();
Method lcmMethod = appCSupport.getAPIMethod(action.name(), client, false);
try {
Object response = lcmMethod.invoke(client, requestObject);
@@ -81,35 +134,21 @@ public class ApplicationControllerClient {
}
}
- public LifeCycleManagerStateful getAppCClient(String controllerType) {
- if (client == null)
- try {
- client = AppcClientServiceFactoryProvider.getFactory(AppcLifeCycleManagerServiceFactory.class)
- .createLifeCycleManagerStateful(new ApplicationContext(), getLCMProperties(controllerType));
- } catch (AppcClientException e) {
- auditLogger.log(Level.ERROR, "Error in getting LifeCycleManagerStateful: ", e, e.getMessage());
- }
- return client;
- }
-
- protected Properties getLCMProperties(String controllerType) {
+ protected Properties getLCMProperties() {
Properties properties = new Properties();
Map<String, String> globalProperties = PropertyConfiguration.getInstance()
.getProperties("mso.bpmn.urn.properties");
- String controllerTypeValue = controllerType;
- if (controllerType == null) {
- controllerTypeValue = "";
- }
- properties.put("topic.read", globalProperties.get("appc.topic.read"));
- properties.put("topic.read.timeout", globalProperties.get("appc.topic.read.timeout"));
+ properties.put("topic.read", globalProperties.get("appc.client.topic.read"));
+ properties.put("topic.write", globalProperties.get("appc.client.topic.write"));
+ properties.put("topic.sdnc.read", globalProperties.get("appc.client.topic.sdnc.read"));
+ properties.put("topic.sdnc.write", globalProperties.get("appc.client.topic.sdnc.write"));
+ properties.put("topic.read.timeout", globalProperties.get("appc.client.topic.read.timeout"));
properties.put("client.response.timeout", globalProperties.get("appc.client.response.timeout"));
- properties.put("topic.write", globalProperties.get("appc.topic.write"));
- properties.put("poolMembers", globalProperties.get("appc.poolMembers"));
- properties.put("client.controllerType", controllerTypeValue);
+ properties.put("poolMembers", globalProperties.get("appc.client.poolMembers"));
properties.put("client.key", globalProperties.get("appc.client.key"));
properties.put("client.secret", globalProperties.get("appc.client.secret"));
properties.put("client.name", CLIENT_NAME);
- properties.put("service", globalProperties.get("appc.service"));
+ properties.put("service", globalProperties.get("appc.client.service"));
return properties;
}