summaryrefslogtreecommitdiffstats
path: root/dmaap-listener/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'dmaap-listener/src/main')
-rw-r--r--dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/DmaapListener.java165
-rw-r--r--dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/DummyDmaapConsumer.java37
-rw-r--r--dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/InvalidMessageException.java37
-rw-r--r--dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/SdncDmaapConsumer.java146
-rw-r--r--dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/SdncFlatJsonDmaapConsumer.java196
-rw-r--r--dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/SdncOdlConnection.java159
-rw-r--r--dmaap-listener/src/main/resources/edgeRouterStatusChange.map23
-rw-r--r--dmaap-listener/src/main/resources/log4j.properties37
-rw-r--r--dmaap-listener/src/main/resources/preferredRoute.txt1
-rw-r--r--dmaap-listener/src/main/scripts/start-dmaap-listener.sh69
-rw-r--r--dmaap-listener/src/main/scripts/stop-dmaap-listener.sh52
11 files changed, 922 insertions, 0 deletions
diff --git a/dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/DmaapListener.java b/dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/DmaapListener.java
new file mode 100644
index 000000000..7096d83bf
--- /dev/null
+++ b/dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/DmaapListener.java
@@ -0,0 +1,165 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 ONAP 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.dmaapclient;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DmaapListener {
+
+ private static final String DMAAP_LISTENER_PROPERTIES = "dmaap-listener.properties";
+ private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR";
+ private static final Logger LOG = LoggerFactory
+ .getLogger(DmaapListener.class);
+
+ public static void main(String[] args) {
+
+ Properties properties = new Properties();
+
+
+ String propFileName = DMAAP_LISTENER_PROPERTIES;
+
+ if (args.length > 0) {
+ propFileName = args[0];
+ }
+
+ String propPath = null;
+ String propDir = System.getenv(SDNC_CONFIG_DIR);
+
+ List<SdncDmaapConsumer> consumers = new LinkedList();
+
+ if (propDir == null) {
+
+ propDir = "/opt/sdnc/data/properties";
+ }
+
+ if (!propFileName.startsWith("/")) {
+ propPath = propDir + "/" + propFileName;
+ }
+
+ File propFile = new File(propPath);
+
+ if (!propFile.canRead()) {
+ LOG.error("Cannot read properties file "+propPath);
+ System.exit(1);
+ }
+
+ try {
+ properties.load(new FileInputStream(propFile));
+ } catch (Exception e) {
+ LOG.error("Caught exception loading properties from "+propPath, e);
+ System.exit(1);
+ }
+
+ String subscriptionStr = properties.getProperty("subscriptions");
+
+ boolean threadsRunning = false;
+
+ LOG.debug("Dmaap subscriptions : "+subscriptionStr);
+
+ if (subscriptionStr != null) {
+ String[] subscriptions = subscriptionStr.split(";");
+
+ for (int i = 0; i < subscriptions.length; i++) {
+ String[] subscription = subscriptions[i].split(":");
+ String consumerClassName = subscription[0];
+ String propertyPath = subscription[1];
+
+ LOG.debug("Handling subscription [" + consumerClassName + "," + propertyPath + "]");
+
+ if (propertyPath == null) {
+ LOG.error("Invalid subscription (" + subscriptions[i] + ") property file missing");
+ continue;
+ }
+
+ if (!propertyPath.startsWith("/")) {
+ propertyPath = propDir + "/" + propertyPath;
+ }
+
+ Class<?> consumerClass = null;
+
+ try {
+ consumerClass = Class.forName(consumerClassName);
+ } catch (Exception e) {
+ LOG.error("Could not find DMaap consumer class " + consumerClassName);
+ }
+
+ if (consumerClass != null) {
+
+ SdncDmaapConsumer consumer = null;
+
+ try {
+ consumer = (SdncDmaapConsumer) consumerClass.newInstance();
+ } catch (Exception e) {
+ LOG.error("Could not create consumer from class " + consumerClassName, e);
+ }
+
+ if (consumer != null) {
+ LOG.debug("Initializing consumer " + consumerClassName + "(" + propertyPath + ")");
+ consumer.init(properties, propertyPath);
+
+ if (consumer.isReady()) {
+ Thread consumerThread = new Thread(consumer);
+ consumerThread.start();
+ consumers.add(consumer);
+ threadsRunning = true;
+ LOG.info("Started consumer thread (" + consumerClassName + " : " + propertyPath + ")");
+ } else {
+ LOG.debug("Consumer " + consumerClassName + " is not ready");
+ }
+ }
+
+ }
+
+ }
+ }
+
+ while (threadsRunning) {
+
+ threadsRunning = false;
+ for (SdncDmaapConsumer consumer : consumers) {
+ if (consumer.isRunning()) {
+ threadsRunning = true;
+ }
+ }
+
+ if (!threadsRunning) {
+ break;
+ }
+
+ try {
+ Thread.sleep(10000);
+ } catch (InterruptedException e) {
+
+ }
+ }
+
+ LOG.info("No listener threads running - exitting");
+
+ }
+}
diff --git a/dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/DummyDmaapConsumer.java b/dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/DummyDmaapConsumer.java
new file mode 100644
index 000000000..5edc1c908
--- /dev/null
+++ b/dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/DummyDmaapConsumer.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 ONAP 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.dmaapclient;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DummyDmaapConsumer extends SdncDmaapConsumer {
+
+ private static final Logger LOG = LoggerFactory
+ .getLogger(DummyDmaapConsumer.class);
+
+ @Override
+ public void processMsg(String msg) {
+ LOG.info("Consumed message: \n"+msg);
+ }
+
+}
diff --git a/dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/InvalidMessageException.java b/dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/InvalidMessageException.java
new file mode 100644
index 000000000..3de5df6c2
--- /dev/null
+++ b/dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/InvalidMessageException.java
@@ -0,0 +1,37 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 ONAP 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.dmaapclient;
+
+public class InvalidMessageException extends Exception {
+
+ public InvalidMessageException() {
+ super();
+ }
+
+ public InvalidMessageException(String msg) {
+ super(msg);
+ }
+
+ public InvalidMessageException(String msg, Throwable t) {
+ super(msg, t);
+ }
+}
diff --git a/dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/SdncDmaapConsumer.java b/dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/SdncDmaapConsumer.java
new file mode 100644
index 000000000..5b55bda5b
--- /dev/null
+++ b/dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/SdncDmaapConsumer.java
@@ -0,0 +1,146 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 ONAP 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.dmaapclient;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.Properties;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.att.nsa.mr.client.MRClientFactory;
+import com.att.nsa.mr.client.MRConsumer;
+import com.att.nsa.mr.client.response.MRConsumerResponse;
+
+public abstract class SdncDmaapConsumer implements Runnable {
+
+ private static final Logger LOG = LoggerFactory
+ .getLogger(SdncDmaapConsumer.class);
+
+ private String propertiesPath = "";
+ private Properties properties = null;
+ MRConsumer consumer = null;
+ MRConsumerResponse consumerResponse = null;
+ boolean running = false;
+ boolean ready = false;
+ int fetchPause = 5000; // Default pause between fetchs - 5 seconds
+
+ public boolean isReady() {
+ return ready;
+ }
+
+ int timeout = 15000; // Default timeout - 15 seconds
+
+ public boolean isRunning() {
+ return running;
+ }
+
+ public SdncDmaapConsumer() {
+
+ }
+
+ public SdncDmaapConsumer(Properties properties, String propertiesPath) {
+ init(properties, propertiesPath);
+ }
+
+ public String getProperty(String name) {
+ return(properties.getProperty(name, ""));
+ }
+
+ public void init(Properties properties, String propertiesPath) {
+
+ this.propertiesPath = propertiesPath;
+
+ try {
+
+ this.properties = (Properties) properties.clone();
+
+ this.properties.load(new FileInputStream(new File(propertiesPath)));
+
+ String timeoutStr = properties.getProperty("timeout");
+
+ if ((timeoutStr != null) && (timeoutStr.length() > 0)) {
+ try {
+ timeout = Integer.parseInt(timeoutStr);
+ } catch (NumberFormatException e) {
+ LOG.error("Non-numeric value specified for timeout ("+timeoutStr+")");
+ }
+ }
+
+ String fetchPauseStr = properties.getProperty("fetchPause");
+ if ((fetchPauseStr != null) && (fetchPauseStr.length() > 0)) {
+ try {
+ fetchPause = Integer.parseInt(fetchPauseStr);
+ } catch (NumberFormatException e) {
+ LOG.error("Non-numeric valud specified for fetchPause ("+fetchPauseStr+")");
+ }
+ }
+
+ this.consumer = MRClientFactory.createConsumer(propertiesPath);
+ ready = true;
+ } catch (Exception e) {
+ LOG.error("Error initializing DMaaP consumer from file "+propertiesPath, e);
+ }
+ }
+
+
+ @Override
+ public void run() {
+ if (ready) {
+
+ running = true;
+
+ while (running) {
+
+ try {
+ boolean noData = true;
+ consumerResponse = consumer.fetchWithReturnConsumerResponse(timeout, -1);
+ for (String msg : consumerResponse.getActualMessages()) {
+ noData = false;
+ LOG.info("Received message from DMaaP:\n"+msg);
+ processMsg(msg);
+ }
+
+ if (noData) {
+ if (fetchPause > 0) {
+
+ LOG.info("No data received from fetch. Pausing "+fetchPause+" ms before retry");
+ Thread.sleep(fetchPause);
+ } else {
+
+ LOG.info("No data received from fetch. No fetch pause specified - retrying immediately");
+ }
+ }
+ } catch (Exception e) {
+ LOG.error("Caught exception reading from DMaaP", e);
+ running = false;
+ }
+
+
+ }
+ }
+
+ }
+
+ abstract public void processMsg(String msg) throws InvalidMessageException;
+}
diff --git a/dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/SdncFlatJsonDmaapConsumer.java b/dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/SdncFlatJsonDmaapConsumer.java
new file mode 100644
index 000000000..7e9c069ac
--- /dev/null
+++ b/dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/SdncFlatJsonDmaapConsumer.java
@@ -0,0 +1,196 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 ONAP 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.dmaapclient;
+
+import java.io.BufferedReader;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.Authenticator;
+import java.net.HttpURLConnection;
+import java.net.PasswordAuthentication;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLSession;
+
+import org.apache.commons.codec.binary.Base64;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+
+public class SdncFlatJsonDmaapConsumer extends SdncDmaapConsumer {
+
+ private static final Logger LOG = LoggerFactory
+ .getLogger(SdncFlatJsonDmaapConsumer.class);
+
+ private static final String DMAAPLISTENERROOT = "DMAAPLISTENERROOT";
+ private static final String SDNC_ENDPOINT = "SDNC.endpoint";
+
+
+
+ @Override
+ public void processMsg(String msg) throws InvalidMessageException {
+
+ processMsg(msg, null);
+ }
+
+ public void processMsg(String msg, String mapDirName) throws InvalidMessageException {
+
+ if (msg == null) {
+ throw new InvalidMessageException("Null message");
+ }
+
+ ObjectMapper oMapper = new ObjectMapper();
+ JsonNode instarRootNode = null;
+ ObjectNode sdncRootNode = null;
+
+ String instarMsgName = null;
+
+ try {
+ instarRootNode = oMapper.readTree(msg);
+ } catch (Exception e) {
+ throw new InvalidMessageException("Cannot parse json object", e);
+ }
+
+ Iterator<Map.Entry<String, JsonNode>> instarFields = instarRootNode.fields();
+
+ while (instarFields.hasNext()) {
+ Map.Entry<String, JsonNode> entry = instarFields.next();
+
+ instarMsgName = entry.getKey();
+ instarRootNode = entry.getValue();
+ break;
+ }
+
+ Map<String,String> fieldMap = loadMap(instarMsgName, mapDirName);
+
+ if (fieldMap == null) {
+ throw new InvalidMessageException("Unable to process message - cannot load field mappings");
+ }
+
+ if (!fieldMap.containsKey(SDNC_ENDPOINT)) {
+ throw new InvalidMessageException("No SDNC endpoint known for message "+instarMsgName);
+ }
+
+ String sdncEndpoint = fieldMap.get(SDNC_ENDPOINT);
+
+ sdncRootNode = oMapper.createObjectNode();
+ ObjectNode inputNode = oMapper.createObjectNode();
+
+
+ for (String fromField : fieldMap.keySet()) {
+
+ if (!SDNC_ENDPOINT.equals(fromField)) {
+ JsonNode curNode = instarRootNode.get(fromField);
+ if (curNode != null) {
+ String fromValue = curNode.textValue();
+
+ inputNode.put(fieldMap.get(fromField), fromValue);
+ }
+ }
+ }
+ sdncRootNode.put("input", inputNode);
+
+ try {
+ String rpcMsgbody = oMapper.writeValueAsString(sdncRootNode);
+ String odlUrlBase = getProperty("sdnc.odl.url-base");
+ String odlUser = getProperty("sdnc.odl.user");
+ String odlPassword = getProperty("sdnc.odl.password");
+
+ if ((odlUrlBase != null) && (odlUrlBase.length() > 0)) {
+ SdncOdlConnection conn = SdncOdlConnection.newInstance(odlUrlBase + sdncEndpoint, odlUser, odlPassword);
+
+ conn.send("POST", "application/json", rpcMsgbody);
+ } else {
+ LOG.info("POST message body would be:\n"+rpcMsgbody);
+ }
+ } catch (Exception e) {
+
+ }
+
+ }
+
+ private Map<String,String> loadMap(String msgType, String mapDirName) {
+ Map<String, String> results = new HashMap<String, String>();
+
+
+ if (mapDirName == null) {
+ String rootdir = System.getenv(DMAAPLISTENERROOT);
+
+ if ((rootdir == null) || (rootdir.length() == 0)) {
+ rootdir = "/opt/app/dmaap-listener";
+ }
+
+ mapDirName = rootdir + "/lib";
+
+ }
+
+ String mapFilename = mapDirName + "/" + msgType + ".map";
+
+ File mapFile = new File(mapFilename);
+
+ if (!mapFile.canRead()) {
+ LOG.error("Cannot read map file ("+mapFilename+")");
+ return(null);
+ }
+
+ try {
+ BufferedReader mapReader = new BufferedReader(new FileReader(mapFile));
+
+ String curLine = null;
+
+ while ((curLine = mapReader.readLine()) != null) {
+ curLine = curLine.trim();
+
+ if ((curLine.length() > 0) && (!curLine.startsWith("#"))) {
+
+ if (curLine.contains("=>")) {
+ String[] entry = curLine.split("=>");
+ if (entry.length == 2) {
+ results.put(entry[0].trim(), entry[1].trim());
+ }
+ }
+ }
+ }
+ mapReader.close();
+ } catch (Exception e) {
+ LOG.error("Caught exception reading map "+mapFilename, e);
+ return(null);
+ }
+
+ return(results);
+ }
+
+
+
+}
diff --git a/dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/SdncOdlConnection.java b/dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/SdncOdlConnection.java
new file mode 100644
index 000000000..6c6f308fb
--- /dev/null
+++ b/dmaap-listener/src/main/java/org/openecomp/sdnc/dmaapclient/SdncOdlConnection.java
@@ -0,0 +1,159 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 ONAP 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.
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.dmaapclient;
+
+import java.io.BufferedReader;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.Authenticator;
+import java.net.HttpURLConnection;
+import java.net.PasswordAuthentication;
+import java.net.ProtocolException;
+import java.net.URL;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLSession;
+
+import org.apache.commons.codec.binary.Base64;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class SdncOdlConnection {
+
+ private static final Logger LOG = LoggerFactory
+ .getLogger(SdncOdlConnection.class);
+
+ private HttpURLConnection httpConn = null;
+
+ private String url = null;
+ private String user = null;
+ private String password = null;
+
+ private class SdncAuthenticator extends Authenticator {
+
+ private String user;
+ private String passwd;
+
+ SdncAuthenticator(String user, String passwd) {
+ this.user = user;
+ this.passwd = passwd;
+ }
+ @Override
+ protected PasswordAuthentication getPasswordAuthentication() {
+ return new PasswordAuthentication(user, passwd.toCharArray());
+ }
+
+ }
+
+ private SdncOdlConnection() {
+
+ }
+
+ private SdncOdlConnection(String url, String user, String password) {
+ this.url = url;
+ this.user = user;
+ this.password = password;
+
+ try {
+ URL sdncUrl = new URL(url);
+ Authenticator.setDefault(new SdncAuthenticator(user, password));
+
+ this.httpConn = (HttpURLConnection) sdncUrl.openConnection();
+ } catch (Exception e) {
+ LOG.error("Unable to create http connection", e);
+ }
+ }
+
+ public static SdncOdlConnection newInstance(String url, String user, String password) throws IOException
+ {
+ return (new SdncOdlConnection(url, user, password));
+ }
+
+
+
+ public String send(String method, String contentType, String msg) throws IOException {
+
+ LOG.info("Sending REST " + method + " to " + url);
+ LOG.info("Message body:\n" + msg);
+ String authStr = user + ":" + password;
+ String encodedAuthStr = new String(Base64.encodeBase64(authStr.getBytes()));
+
+ httpConn.addRequestProperty("Authentication", "Basic " + encodedAuthStr);
+
+ httpConn.setRequestMethod(method);
+ httpConn.setRequestProperty("Content-Type", contentType);
+ httpConn.setRequestProperty("Accept", contentType);
+
+ httpConn.setDoInput(true);
+ httpConn.setDoOutput(true);
+ httpConn.setUseCaches(false);
+
+ if (httpConn instanceof HttpsURLConnection) {
+ HostnameVerifier hostnameVerifier = new HostnameVerifier() {
+ @Override
+ public boolean verify(String hostname, SSLSession session) {
+ return true;
+ }
+ };
+ ((HttpsURLConnection) httpConn).setHostnameVerifier(hostnameVerifier);
+ }
+
+ // Write message
+ httpConn.setRequestProperty("Content-Length", "" + msg.length());
+ DataOutputStream outStr = new DataOutputStream(httpConn.getOutputStream());
+ outStr.write(msg.getBytes());
+ outStr.close();
+
+ // Read response
+ BufferedReader respRdr;
+
+ LOG.info("Response: " + httpConn.getResponseCode() + " " + httpConn.getResponseMessage());
+
+ if (httpConn.getResponseCode() < 300) {
+
+ respRdr = new BufferedReader(new InputStreamReader(httpConn.getInputStream()));
+ } else {
+ respRdr = new BufferedReader(new InputStreamReader(httpConn.getErrorStream()));
+ }
+
+ StringBuffer respBuff = new StringBuffer();
+
+ String respLn;
+
+ while ((respLn = respRdr.readLine()) != null) {
+ respBuff.append(respLn + "\n");
+ }
+ respRdr.close();
+
+ String respString = respBuff.toString();
+
+ LOG.info("Response body :\n" + respString);
+
+ return (respString);
+
+ }
+
+
+}
diff --git a/dmaap-listener/src/main/resources/edgeRouterStatusChange.map b/dmaap-listener/src/main/resources/edgeRouterStatusChange.map
new file mode 100644
index 000000000..57644bbd5
--- /dev/null
+++ b/dmaap-listener/src/main/resources/edgeRouterStatusChange.map
@@ -0,0 +1,23 @@
+# SDN-C URL
+SDNC.endpoint => FLOWRED-API:process-edge-router-status-change
+
+# Field mapping
+equip_id => equip_id
+ptnii_equip_name => equip-name
+equip_type.equip_type => equip-type
+ip_addr => loopback0
+router_prov_status => prov-status
+country.region => region
+country_abbr => country
+equip_name_code => equip-name-code
+as_number => as-number
+loopback1 => loopback1
+loopback2 => loopback2
+loopback3 => loopback3
+loopback40 => loopback40
+loopback65535 => loopback65535
+inms_list => inms-list
+encrypted_access_flag => encrypted-access-flag
+sw_name => sw-name
+nmipaddr => nm-addr
+function_code => function-code \ No newline at end of file
diff --git a/dmaap-listener/src/main/resources/log4j.properties b/dmaap-listener/src/main/resources/log4j.properties
new file mode 100644
index 000000000..ba815871b
--- /dev/null
+++ b/dmaap-listener/src/main/resources/log4j.properties
@@ -0,0 +1,37 @@
+###
+# ============LICENSE_START=======================================================
+# openECOMP : SDN-C
+# ================================================================================
+# Copyright (C) 2017 ONAP 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.
+# 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.
+# ============LICENSE_END=========================================================
+###
+
+log4j.rootLogger=DEBUG,CONSOLE,LOGFILE
+
+# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.Threshold=ERROR
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
+
+# LOGFILE is set to be a File appender using a PatternLayout.
+log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender
+log4j.appender.LOGFILE.File=/opt/app/dmaap-listener/logs/dmaap-listener.log
+log4j.appender.LOGFILE.Append=true
+log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
+log4j.appender.LOGFILE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n
+log4j.appender.LOGFILE.MaxFileSize=10MB
+log4j.appender.LOGFILE.MaxBackupIndex=10
diff --git a/dmaap-listener/src/main/resources/preferredRoute.txt b/dmaap-listener/src/main/resources/preferredRoute.txt
new file mode 100644
index 000000000..662b0aa7d
--- /dev/null
+++ b/dmaap-listener/src/main/resources/preferredRoute.txt
@@ -0,0 +1 @@
+preferredRouteKey=MR1 \ No newline at end of file
diff --git a/dmaap-listener/src/main/scripts/start-dmaap-listener.sh b/dmaap-listener/src/main/scripts/start-dmaap-listener.sh
new file mode 100644
index 000000000..5eeb62bbf
--- /dev/null
+++ b/dmaap-listener/src/main/scripts/start-dmaap-listener.sh
@@ -0,0 +1,69 @@
+#!/bin/bash
+
+###
+# ============LICENSE_START=======================================================
+# openECOMP : SDN-C
+# ================================================================================
+# Copyright (C) 2017 ONAP 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.
+# 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.
+# ============LICENSE_END=========================================================
+###
+
+PROPERTY_DIR=${PROPERTY_DIR:-/opt/sdnc/data/properties}
+
+LISTENER=dmaap-listener
+
+
+
+PIDFILE=/tmp/.${LISTENER}-pid
+UEBLISTENERROOT=${UEBLISTENERROOT:-/opt/app/dmaap-listener}
+JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-7-oracle}
+JAVA_OPTS=${JAVA_OPTS:--Dhttps.protocols=TLSv1.1,TLSv1.2}
+JAVA=${JAVA:-${JAVA_HOME}/bin/java}
+
+# Redirect output from script to $LISTENER.out
+exec >> ${UEBLISTENERROOT}/logs/$LISTENER.out
+exec 2>&1
+
+if [ -f $PIDFILE ]
+then
+ pid=$(cat $PIDFILE)
+ if [ "$pid" != "" ]
+ then
+ if kill -0 $pid
+ then
+ echo "$LISTENER already running"
+ exit 0
+ fi
+ fi
+fi
+
+if [ ! -d ${UEBLISTENERROOT}/logs ]
+then
+ mkdir ${UEBLISTENERROOT}/logs
+fi
+
+for file in ${UEBLISTENERROOT}/lib/*.jar
+do
+ LISTENERCLASSPATH=$LISTENERCLASSPATH:$file
+done
+
+${JAVA} ${JAVA_OPTS} -Dlog4j.configuration=file:${UEBLISTENERROOT}/lib/log4j.properties -cp ${LISTENERCLASSPATH} com.att.sdnctl.dmaapclient.DmaapListener &
+
+
+echo $! > $PIDFILE
+
+echo "$LISTENER started!"
+exit 0
diff --git a/dmaap-listener/src/main/scripts/stop-dmaap-listener.sh b/dmaap-listener/src/main/scripts/stop-dmaap-listener.sh
new file mode 100644
index 000000000..42de474fb
--- /dev/null
+++ b/dmaap-listener/src/main/scripts/stop-dmaap-listener.sh
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+###
+# ============LICENSE_START=======================================================
+# openECOMP : SDN-C
+# ================================================================================
+# Copyright (C) 2017 ONAP 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.
+# 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.
+# ============LICENSE_END=========================================================
+###
+
+PROPERTY_DIR=${PROPERTY_DIR:-/opt/sdnc/data/properties}
+
+LISTENER=dmaap-listener
+
+
+PIDFILE=/tmp/.${LISTENER}-pid
+UEBLISTENERROOT=${UEBLISTENERROOT:-/opt/app/dmaap-listener}
+
+if [ -f $PIDFILE ]
+then
+ pid=$(cat $PIDFILE)
+ if [ "$pid" != "" ]
+ then
+ if kill -0 $pid
+ then
+ echo "Stopping $LISTENER"
+ kill $pid && rm $PIDFILE
+ exit 0
+ else
+ echo "$LISTENER not running"
+ exit 1
+ fi
+ else
+ echo "$LISTENER not running"
+ exit 1
+ fi
+fi
+
+