summaryrefslogtreecommitdiffstats
path: root/appc-sdc-listener/appc-sdc-listener-bundle
diff options
context:
space:
mode:
authorRamya Balaji <rb111y@att.com>2018-01-02 21:58:59 -0500
committerSkip Wonnell <skip@att.com>2018-01-04 21:10:36 +0000
commit13b9505921e2cbbd4b155a78bfdaa5caa3375ec0 (patch)
tree7c661f5c3c8b7895cad1d4c3c90b9077ba74c1fd /appc-sdc-listener/appc-sdc-listener-bundle
parent9ebb5ddcb60345dea668049c73f5f2d9c3cdf731 (diff)
Updated SDC listener and dependent bundles
Changes related to SDC adapter.Also includes sequence generator changes and changes to appc-dg-shared. Issue-ID: APPC-355 Change-Id: Ib8a0b1d304199db6d2595291539b266885842d63 Signed-off-by: Ramya Balaji <rb111y@att.com>
Diffstat (limited to 'appc-sdc-listener/appc-sdc-listener-bundle')
-rw-r--r--appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/helper/DependencyModelGenerator.java9
-rw-r--r--appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/ConfigArtifactProcessor.java13
-rw-r--r--appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/ToscaCsarArtifactProcessor.java19
-rw-r--r--appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/listener/SdcCallback.java14
-rw-r--r--appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/listener/SdcConfig.java45
-rw-r--r--appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/listener/SdcConfigTest.java46
6 files changed, 132 insertions, 14 deletions
diff --git a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/helper/DependencyModelGenerator.java b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/helper/DependencyModelGenerator.java
index 295ee47c8..62212d74c 100644
--- a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/helper/DependencyModelGenerator.java
+++ b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/helper/DependencyModelGenerator.java
@@ -32,6 +32,7 @@ import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import org.onap.appc.dg.dependencymanager.helper.DependencyModelParser;
+import org.onap.appc.dg.flowbuilder.exception.InvalidDependencyModelException;
import org.onap.appc.dg.objects.Node;
import org.onap.appc.dg.objects.VnfcDependencyModel;
import org.onap.appc.domainmodel.Vnfc;
@@ -58,7 +59,13 @@ public class DependencyModelGenerator {
logger.debug(String.format("Generating dependency model for vnfType : %s , TOSCA: %s ", vnfType ,tosca));
String dependencyJson;
DependencyModelParser dependencyModelParser = new DependencyModelParser();
- VnfcDependencyModel vnfcDependencyModel = dependencyModelParser.generateDependencyModel(tosca, vnfType);
+ VnfcDependencyModel vnfcDependencyModel = null;
+ try {
+ vnfcDependencyModel = dependencyModelParser.generateDependencyModel(tosca, vnfType);
+ } catch (InvalidDependencyModelException e) {
+ logger.error("Error generating dependency model");
+ throw new APPCException(e.getMessage(),e);
+ }
if (vnfcDependencyModel != null && !vnfcDependencyModel.getDependencies().isEmpty()) {
logger.debug(String.format("Dependency Model generated : %s ", vnfcDependencyModel.toString()));
diff --git a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/ConfigArtifactProcessor.java b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/ConfigArtifactProcessor.java
index 41230ea30..b9eedc466 100644
--- a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/ConfigArtifactProcessor.java
+++ b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/ConfigArtifactProcessor.java
@@ -24,6 +24,7 @@
package org.onap.appc.sdc.artifacts.impl;
+import org.apache.commons.lang.StringUtils;
import org.onap.appc.adapter.message.EventSender;
import org.onap.appc.sdc.listener.ProviderOperations;
import org.onap.appc.sdc.listener.ProviderResponse;
@@ -63,11 +64,21 @@ public class ConfigArtifactProcessor extends AbstractArtifactProcessor {
@Override
public void processArtifact(SDCArtifact artifact) throws APPCException {
String postData = Util.toSdcStoreDocumentInput(notification, resource, super.artifact, artifact.getArtifactContent());
+ logger.debug("ConfigArtifactProcessor::processArtifact::postData="+postData);
try {
- ProviderResponse result = ProviderOperations.post(storeUri.toURL(), postData, null);
+ ProviderOperations providerOperations = new ProviderOperations();
+ if (null != storeUri)
+ logger.debug("ConfigArtifactProcessor::processArtifact::URI is"+storeUri.toString());
+ ProviderResponse result = providerOperations.post(storeUri.toURL(), postData, null);
if (result.getStatus() == 200) {
+ logger.debug("ConfigArtifactProcessor::processArtifact::post request success!!");
Util.parseResponse(result.getBody());
}
+ else {
+ logger.debug("ConfigArtifactProcessor::processArtifact()::post request failed!! Returned :"
+ +result.getStatus()+"-Result body- "+result.getBody());
+ throw new APPCException("ConfigArtifactProcessor::processArtifact: Invalid status retrurned from post "+result.getStatus());
+ }
} catch (MalformedURLException | APPCException e) {
logger.error("Error processing artifact : " + this.artifact.toString(),e);
throw new APPCException(e.getMessage(),e);
diff --git a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/ToscaCsarArtifactProcessor.java b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/ToscaCsarArtifactProcessor.java
index 46a37273f..4cc4cfbdb 100644
--- a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/ToscaCsarArtifactProcessor.java
+++ b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/artifacts/impl/ToscaCsarArtifactProcessor.java
@@ -42,7 +42,16 @@ import org.openecomp.sdc.api.notification.INotificationData;
import org.openecomp.sdc.api.notification.IResourceInstance;
import org.openecomp.sdc.api.results.IDistributionClientDownloadResult;
-import java.io.*;
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
import java.net.URI;
import java.util.*;
import java.util.zip.ZipEntry;
@@ -54,8 +63,12 @@ public class ToscaCsarArtifactProcessor extends AbstractArtifactProcessor{
private DependencyModelGenerator dependencyModelGenerator;
- public ToscaCsarArtifactProcessor(IDistributionClient client, EventSender eventSender, INotificationData notification, IResourceInstance resource,
- IArtifactInfo artifact, URI storeUri){
+ public ToscaCsarArtifactProcessor(IDistributionClient client,
+ EventSender eventSender,
+ INotificationData notification,
+ IResourceInstance resource,
+ IArtifactInfo artifact,
+ URI storeUri){
super(client,eventSender,notification,resource,artifact,storeUri);
dependencyModelGenerator = new DependencyModelGenerator();
}
diff --git a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/listener/SdcCallback.java b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/listener/SdcCallback.java
index 8be458200..a3d82a703 100644
--- a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/listener/SdcCallback.java
+++ b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/listener/SdcCallback.java
@@ -49,7 +49,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
public class SdcCallback implements INotificationCallback {
private final EELFLogger logger = EELFManager.getInstance().getLogger(SdcCallback.class);
- private ArtifactProcessorFactory artifactProcessorFactory=new ArtifactProcessorFactory();
+ private ArtifactProcessorFactory artifactProcessorFactory = new ArtifactProcessorFactory();
private URI storeUri;
private IDistributionClient client;
@@ -92,7 +92,8 @@ public class SdcCallback implements INotificationCallback {
if (isRunning.get()) {
for(IArtifactInfo artifact:data.getServiceArtifacts()){
- ArtifactProcessor artifactProcessor = artifactProcessorFactory.getArtifactProcessor(client, eventSender, data, null, artifact, storeUri);
+ ArtifactProcessor artifactProcessor = artifactProcessorFactory.getArtifactProcessor(
+ client, eventSender, data, null, artifact, storeUri);
if(artifactProcessor!=null){
executor.submit(artifactProcessor);
}
@@ -102,9 +103,11 @@ public class SdcCallback implements INotificationCallback {
for (IArtifactInfo artifact : resource.getArtifacts()) {
logger.info(Util.toSdcStoreDocumentInput(data, resource, artifact, "abc"));
if (executor.getQueue().size() >= threadCount) {
- // log warning about job backlog
+ logger.warn(String.format("excuter queue size (%d) is exceeding thread count (%s).",
+ executor.getQueue().size(), threadCount));
}
- ArtifactProcessor artifactProcessor = artifactProcessorFactory.getArtifactProcessor(client, eventSender, data, resource, artifact, storeUri);
+ ArtifactProcessor artifactProcessor = artifactProcessorFactory.getArtifactProcessor(
+ client, eventSender, data, resource, artifact, storeUri);
if(artifactProcessor != null){
executor.submit(artifactProcessor);
}
@@ -115,7 +118,8 @@ public class SdcCallback implements INotificationCallback {
we are sending the download status as positive just to have the same behaviour as before
refactoring.
*/
- client.sendDownloadStatus(Util.buildDistributionStatusMessage(client, data, artifact, DistributionStatusEnum.DOWNLOAD_OK));
+ client.sendDownloadStatus(Util.buildDistributionStatusMessage(
+ client, data, artifact, DistributionStatusEnum.DOWNLOAD_OK));
logger.error("Artifact type not supported : " + artifact.getArtifactType());
}
}
diff --git a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/listener/SdcConfig.java b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/listener/SdcConfig.java
index 86ba9e1f5..2acb2e625 100644
--- a/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/listener/SdcConfig.java
+++ b/appc-sdc-listener/appc-sdc-listener-bundle/src/main/java/org/onap/appc/sdc/listener/SdcConfig.java
@@ -34,6 +34,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
+import org.apache.commons.lang.StringUtils;
public class SdcConfig implements IConfiguration {
@@ -50,11 +51,8 @@ public class SdcConfig implements IConfiguration {
private List<String> types = new ArrayList<>();
private String user;
private String pass;
-
private URI storeOp;
-
private Properties props;
-
private final EELFLogger logger = EELFManager.getInstance().getLogger(SdcConfig.class);
SdcConfig(Properties props) throws Exception {
@@ -67,7 +65,6 @@ public class SdcConfig implements IConfiguration {
logger.error("SdcConfig init is skipped due to properties is null");
return;
}
-
// Keystore for ca cert
keystorePath = props.getProperty("appc.sdc.keystore.path");
keystorePass = props.getProperty("appc.sdc.keystore.pass");
@@ -181,6 +178,31 @@ public class SdcConfig implements IConfiguration {
return true;
}
+ @Override
+ public List <String> getMsgBusAddress() {
+ return (getMsgBusProperties());
+ }
+
+ public List<String> getMsgBusProperties() {
+ List<String> uebAddresses = new ArrayList<String>();
+ String uebAddressesList=null;
+ if (null != this.props)
+ uebAddressesList = this.props.getProperty("appc.ClosedLoop.poolMembers");
+ else {
+ logger.info("SdcConfig:SdcConfig:getMsgBusProperties()::props is null for SdcConfig");
+ return null;
+ }
+ if (null == uebAddressesList) {
+ logger.info("SdcConfig:SdcConfig:getMsgBusProperties()::uebAddressesList is null for SdcConfig");
+ return null;
+ }
+ logger.debug("SdcConfig:SdcConfig:getMsgBusProperties()::uebAddressesList is="+ uebAddressesList);
+ String[] sList = uebAddressesList.split(",");
+ uebAddresses= formatAddresses(sList);
+ logger.debug("SdcConfig:getMsgBusProperties:::Returning addresses as "+uebAddresses.toString());
+ return uebAddresses;
+ }
+
URI getStoreOpURI() {
return storeOp;
}
@@ -199,4 +221,19 @@ public class SdcConfig implements IConfiguration {
logger.info(String.format("SDC Params: %s", params));
}
+
+ protected List<String> formatAddresses(String[] sList) {
+ List<String> uebAddresses = new ArrayList<String>();
+ for (String fqdnPort:sList) {
+ if (fqdnPort.startsWith("http")) {
+ fqdnPort=StringUtils.substringAfter(fqdnPort, "://");
+ }
+ if (null != fqdnPort && fqdnPort.contains(":")) {
+ fqdnPort=StringUtils.substringBefore(fqdnPort,":");
+ }
+ logger.debug("SdcConfig:formatAddresses:: "+fqdnPort);
+ uebAddresses.add(fqdnPort);
+ }
+ return uebAddresses;
+ }
}
diff --git a/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/listener/SdcConfigTest.java b/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/listener/SdcConfigTest.java
new file mode 100644
index 000000000..f799db5e1
--- /dev/null
+++ b/appc-sdc-listener/appc-sdc-listener-bundle/src/test/java/org/onap/appc/sdc/listener/SdcConfigTest.java
@@ -0,0 +1,46 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.sdc.listener;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.List;
+import java.util.Properties;
+
+import org.junit.Test;
+
+public class SdcConfigTest {
+
+ @Test
+ public void testGetMsgBusProperties() throws Exception {
+ Properties properties = new Properties();
+ properties.setProperty("appc.sdc.provider.url",
+ "http://localhost:8181/restconf/operations/SdcMessage:configuration-document-request");
+ properties.setProperty("appc.ClosedLoop.poolMembers","uebsb91bodc.it.att.com:3905,uebsb92bodc.it.att.com:3905,uebsb93bodc.it.att.com:3905");
+ SdcConfig sdc = new SdcConfig(properties);
+ List<String> uebAddresses = sdc.getMsgBusProperties();
+ assertNotNull(uebAddresses);
+ }
+}