summaryrefslogtreecommitdiffstats
path: root/services/appc-dmaap-service/appc-event-listener-bundle/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'services/appc-dmaap-service/appc-event-listener-bundle/src/main')
-rw-r--r--services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/AbstractListener.java158
-rw-r--r--services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/AppcEventListenerActivator.java196
-rw-r--r--services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/Controller.java57
-rw-r--r--services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/EventHandler.java208
-rw-r--r--services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/conv/Converter.java139
-rw-r--r--services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/impl/ListenerImpl.java156
-rw-r--r--services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/impl/WorkerImpl.java136
-rw-r--r--services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/ActionIdentifiers.java83
-rw-r--r--services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/CommonHeader.java116
-rw-r--r--services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/DmaapIncomingMessage.java52
-rw-r--r--services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/DmaapMessage.java116
-rw-r--r--services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/DmaapOutgoingMessage.java51
-rw-r--r--services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/InputBody.java89
-rw-r--r--services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/OutputBody.java100
-rw-r--r--services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/ResponseStatus.java72
-rw-r--r--services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/operation/GenericProviderOperationRequestFormatter.java85
-rw-r--r--services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/operation/ProviderOperationRequestFormatter.java44
-rw-r--r--services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/operation/ProviderOperations.java281
-rw-r--r--services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/Listener.java74
-rw-r--r--services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/ListenerProperties.java305
-rw-r--r--services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/impl/ListenerImpl.java131
-rw-r--r--services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/impl/ProviderOperations.java195
-rw-r--r--services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/impl/WorkerImpl.java84
-rw-r--r--services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/model/Action.java57
-rw-r--r--services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/model/CommonMessage.java313
-rw-r--r--services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/model/IncomingMessage.java90
-rw-r--r--services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/model/OutgoingMessage.java202
-rw-r--r--services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/model/Status.java71
-rw-r--r--services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/impl/ControllerImpl.java146
-rw-r--r--services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/impl/EventHandlerImpl.java400
-rw-r--r--services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/util/HttpClientUtil.java126
-rw-r--r--services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/util/Mapper.java136
-rw-r--r--services/appc-dmaap-service/appc-event-listener-bundle/src/main/resources/org/onap/appc/default.properties113
33 files changed, 4582 insertions, 0 deletions
diff --git a/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/AbstractListener.java b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/AbstractListener.java
new file mode 100644
index 000000000..b9e8a6c84
--- /dev/null
+++ b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/AbstractListener.java
@@ -0,0 +1,158 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * Modifications Copyright (C) 2019 IBM
+ * =============================================================================
+ * 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.onap.appc.listener;
+
+import java.security.SecureRandom;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.RejectedExecutionHandler;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.apache.commons.lang3.concurrent.BasicThreadFactory;
+import org.onap.appc.listener.impl.EventHandlerImpl;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+public abstract class AbstractListener implements Listener {
+
+ private final EELFLogger LOG = EELFManager.getInstance().getLogger(AbstractListener.class);
+
+ protected AtomicBoolean run = new AtomicBoolean(false);
+ protected int QUEUED_MIN = 1;
+ protected int QUEUED_MAX = 10;
+ protected int THREAD_MIN = 4;
+ protected int THREAD_MAX = THREAD_MIN; // Fixed thread pool
+ protected int THREAD_SCALE_DOWN_SEC = 10; // Number of seconds to wait until we remove idle threads
+ protected ThreadPoolExecutor executor;
+ protected EventHandler dmaap;
+ protected ListenerProperties props;
+
+ private String listenerId;
+
+ public AbstractListener(ListenerProperties props) {
+ updateProperties(props);
+
+ dmaap = new EventHandlerImpl(props);
+ if (dmaap.getClientId().equals("0")) {
+ dmaap.setClientId(String.valueOf(new SecureRandom().nextInt(1000)));
+ }
+
+ BlockingQueue<Runnable> threadQueue = new ArrayBlockingQueue<Runnable>(QUEUED_MAX + QUEUED_MIN + 1);
+ executor = new ThreadPoolExecutor(THREAD_MIN, THREAD_MAX, THREAD_SCALE_DOWN_SEC, TimeUnit.SECONDS, threadQueue,
+ new JobRejectionHandler());
+
+ // Custom Named thread factory
+ BasicThreadFactory threadFactory = new BasicThreadFactory.Builder().namingPattern("DMaaP-Worker-%d").build();
+ executor.setThreadFactory(threadFactory);
+
+ run.set(true);
+ }
+
+ /**
+ * Starts a loop that will only end after stop() or stopNow() are called. The loop will read messages off the DMaaP
+ * topic and perform some action on them while writing messages back to DMaaP at critical points in the execution.
+ * Inherited from Runnable.
+ *
+ * @see java.lang.Runnable#run()
+ */
+ @Override
+ public void run() {
+ LOG.error("Listener.run() has not been implemented");
+ }
+
+ @Override
+ public void stop() {
+ run.set(false);
+ LOG.info(String.format("Stopping with %d messages in queue", executor.getQueue().size()));
+ executor.shutdown();
+ try {
+ executor.awaitTermination(10, TimeUnit.SECONDS);
+ } catch (InterruptedException e) {
+ LOG.error("Listener graceful stop() failed", e);
+ Thread.currentThread().interrupt();
+ }
+
+ // close DMaaP clients
+ if (dmaap != null) {
+ dmaap.closeClients();
+ }
+ LOG.info("Listener Thread Pool Finished");
+ }
+
+ @Override
+ public void stopNow() {
+ run.set(false);
+ LOG.info(String.format("StopNow called. Orphaning %d messages in the queue", executor.getQueue().size()));
+ executor.getQueue().clear();
+ stop();
+ }
+
+ @Override
+ public String getBenchmark() {
+ return String.format("%s - No benchmarking implemented.", getListenerId());
+ }
+
+ @Override
+ public String getListenerId() {
+ return listenerId;
+ }
+
+ // Sets the id of the listener in
+ @Override
+ public void setListenerId(String id) {
+ listenerId = id;
+ }
+
+ private void updateProperties(ListenerProperties properties) {
+ this.props = properties;
+ QUEUED_MIN =
+ Integer.valueOf(props.getProperty(ListenerProperties.KEYS.THREADS_MIN_QUEUE, String.valueOf(QUEUED_MIN)));
+ QUEUED_MAX =
+ Integer.valueOf(props.getProperty(ListenerProperties.KEYS.THREADS_MAX_QUEUE, String.valueOf(QUEUED_MAX)));
+ THREAD_MIN =
+ Integer.valueOf(props.getProperty(ListenerProperties.KEYS.THREADS_MIN_POOL, String.valueOf(THREAD_MIN)));
+ THREAD_MAX =
+ Integer.valueOf(props.getProperty(ListenerProperties.KEYS.THREADS_MAX_POOL, String.valueOf(THREAD_MAX)));
+
+ listenerId = props.getPrefix();
+ }
+
+ /**
+ * This class will be used to handle what happens when we cannot add a job because of a ThreadPool issue. It does
+ * not get invoked if there is any fault with the job. NOTE: So far, this has only been seen when doing a
+ * {@link Listener#stopNow}
+ *
+ */
+ class JobRejectionHandler implements RejectedExecutionHandler {
+ @Override
+ public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
+ LOG.error(String.format("A job was rejected. [%s]", r));
+ }
+ }
+}
diff --git a/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/AppcEventListenerActivator.java b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/AppcEventListenerActivator.java
new file mode 100644
index 000000000..5c6fd4c67
--- /dev/null
+++ b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/AppcEventListenerActivator.java
@@ -0,0 +1,196 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2018 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.
+ *
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.listener;
+
+import org.onap.appc.configuration.Configuration;
+import org.onap.appc.configuration.ConfigurationFactory;
+import org.onap.appc.listener.impl.ControllerImpl;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+
+/**
+ * This activator is used to initialize and terminate the dmaap listener controller and pool(s)
+ * <p>
+ * The DMaaP listener is responsible for listening to a topic on the Universal Event Bus and reading in messages that
+ * conform to the DCAE message format for APPC. These messages will then be parsed and passed along to the APPC Provider
+ * to take action on. The listener will also send messages out on DMaaP during critical phases. The messages sent out
+ * will have a status of:
+ * <ul>
+ * <li><i>PENDING</i> - The listener has read the message off of DMaaP and has put it in the queue to be processed</li>
+ * <li><i>ACTIVE</i> - The listener has begun actually processing the request and is waiting on the appc provider to
+ * complete the request</li>
+ * <li><i>SUCCESS</i> or <i>FAILURE</i> - The listener has gotten a response back from the appc provider. If it is a
+ * FAILURE, a message should also be included</li>
+ * </ul>
+ * </p>
+ * <p>
+ * Activation of the bundle will provision 1 controller that in turn will provision 1 (or in the future more) listener
+ * to interact with DMaaP. Each listener will have a queue of messages read off of DMaaP and a thread pool of workers to
+ * process them. This worker is responsible for contacting appc provider to perform the action
+ * </p>
+ * <p>
+ * When the bundle is deactivated, the stopNow() method is called and the thread pool is emptied and all remaining jobs
+ * are orphaned. Alternatively stop() could be called which would allow all remaining jobs in the queue to complete at
+ * the cost of longer run time.
+ * </p>
+ *
+ * @since Aug 30, 2015
+ * @version $Id$
+ */
+public class AppcEventListenerActivator {
+
+
+ /**
+ * The configuration object
+ */
+ private Configuration configuration;
+
+ /**
+ * The reference to the actual implementation object that implements the services
+ */
+ private Controller adapter;
+
+ /**
+ * The logger to be used
+ */
+ private final EELFLogger LOG = EELFManager.getInstance().getLogger(AppcEventListenerActivator.class);
+
+ /**
+ * Called when this bundle is started so the Framework can perform the bundle-specific activities necessary to start
+ * this bundle. This method can be used to register services or to allocate any resources that this bundle needs.
+ * <p>
+ * This method must complete and return to its caller in a timely manner.
+ * </p>
+ *
+ * @param ctx
+ * The execution context of the bundle being started.
+ * @throws java.lang.Exception
+ * If this method throws an exception, this bundle is marked as stopped and the Framework will remove
+ * this bundle's listeners, unregister all services registered by this bundle, and release all services
+ * used by this bundle.
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start() throws Exception {
+ LOG.info("Starting Bundle " + getName());
+
+ Properties props = getProperties();
+
+ Set<ListenerProperties> listeners = new HashSet<>();
+
+ // Configure event listener for the demo use case
+ ListenerProperties demoProps = new ListenerProperties("appc.demo", props);
+ // Only add the listener if properties are set
+ if (!demoProps.getProperties().isEmpty()) {
+ demoProps.setListenerClass(org.onap.appc.listener.demo.impl.ListenerImpl.class);
+ listeners.add(demoProps);
+ }
+
+
+ ListenerProperties clLCMProps = new ListenerProperties("appc.LCM", props);
+ // Only add the listener if properties are set
+ if (!clLCMProps.getProperties().isEmpty()) {
+ clLCMProps.setListenerClass(org.onap.appc.listener.LCM.impl.ListenerImpl.class);
+ listeners.add(clLCMProps);
+ }
+
+
+ // Configure the OAM properties
+ String oamPropKeyPrefix = "appc.OAM";
+ ListenerProperties oamProps = new ListenerProperties(oamPropKeyPrefix, props);
+ // Only add the listener if properties are set and enabled is true
+ if (!oamProps.getProperties().isEmpty() && isAppcOamPropsListenerEnabled(oamProps)) {
+ oamProps.setListenerClass(org.onap.appc.listener.LCM.impl.ListenerImpl.class);
+ listeners.add(oamProps);
+ } else {
+ LOG.warn(String.format("The listener %s is disabled and will not be run", oamPropKeyPrefix));
+ }
+
+ adapter = new ControllerImpl(listeners);
+ adapter.start();
+
+ LOG.info("DMaaP Listener started successfully");
+ }
+
+ /**
+ * Called when this bundle is stopped so the Framework can perform the bundle-specific activities necessary to stop
+ * the bundle. In general, this method should undo the work that the BundleActivator.start method started. There
+ * should be no active threads that were started by this bundle when this bundle returns. A stopped bundle must not
+ * call any Framework objects.
+ * <p>
+ * This method must complete and return to its caller in a timely manner.
+ * </p>
+ *
+ * @param ctx
+ * The execution context of the bundle being stopped.
+ * @throws java.lang.Exception
+ * If this method throws an exception, the bundle is still marked as stopped, and the Framework will
+ * remove the bundle's listeners, unregister all services registered by the bundle, and release all
+ * services used by the bundle. *
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop() throws Exception {
+ boolean stopNow = true;
+ LOG.info("Stopping DMaaP Listener. StopNow=" + stopNow);
+ adapter.stop(stopNow);
+ LOG.info("DMaaP Listener stopped successfully");
+ }
+
+ public String getName() {
+ return "DMaaP Listener";
+ }
+
+ /**
+ * Check if AppcOam props disable listener or not
+ *
+ * @param listenerProperties of ListenerProperties objext
+ * @return false only if AppcOam disabled key is defined and equal to true. Otherwise, return true.
+ */
+ private boolean isAppcOamPropsListenerEnabled(ListenerProperties listenerProperties) {
+ final Properties appcOamProperties = listenerProperties.getProperties();
+
+ boolean result;
+ if (appcOamProperties == null) {
+ result = true;
+ } else {
+ result = !Boolean.parseBoolean(appcOamProperties.getProperty(
+ ListenerProperties.KEYS.DISABLED.getPropertySuffix()));
+ }
+
+ return result;
+ }
+
+ /**
+ * Get properties from configuration
+ */
+ Properties getProperties() {
+ configuration = ConfigurationFactory.getConfiguration();
+ return configuration.getProperties();
+ }
+
+}
diff --git a/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/Controller.java b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/Controller.java
new file mode 100644
index 000000000..25f4735a2
--- /dev/null
+++ b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/Controller.java
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2018 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.
+ *
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.listener;
+
+import java.util.Map;
+
+/**
+ * A controller is responsible for creating a listener for each ListenerProperties object that is passed in to it on
+ * instantiation. The controller will create a thread pool that will contain all of the listener threads so no listener
+ * can crash the controller.
+ *
+ */
+public interface Controller {
+
+ /**
+ * Creates a new thread in the thread pool for an implementation of the {@see #Listener} class set in the
+ * ListenerProperties. This thread is run immediately after it is created.
+ */
+ public void start();
+
+ /**
+ * Stops each of the listeners known by this controller. Takes an optional parameter that indicates the the listener
+ * should stop immediately rather than waiting for all threads to complete.
+ *
+ * @param stopNow
+ * Determines what method the listeners should use to shutdown. If true, listeners will use the stopNow()
+ * method. Otherwise they will use the stop() method.
+ */
+ public void stop(boolean stopNow);
+
+ /**
+ * @return A Map of ListenerProperties and the Listener object that is running in the controllers thread pool.
+ */
+ public Map<ListenerProperties, Listener> getListeners();
+
+}
diff --git a/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/EventHandler.java b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/EventHandler.java
new file mode 100644
index 000000000..35052a085
--- /dev/null
+++ b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/EventHandler.java
@@ -0,0 +1,208 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2019 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.
+ *
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.listener;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * EventHandler defines a class that wraps DMaaP operations (most notably Get Message and Post Message) to make them
+ * easier to use.
+ *
+ */
+public interface EventHandler {
+
+ /**
+ * Gets a list of messages as Strings on the read topic.
+ *
+ * @return A list of String messages. Never returns null.
+ */
+ public List<String> getIncomingEvents();
+
+ /**
+ * Gets a list of messages as String on the read topic.
+ *
+ * @param limit
+ * The maximum amount of entries to return
+ * @return A list of String messages. Never returns null.
+ */
+ public List<String> getIncomingEvents(int limit);
+
+ /**
+ * Gets a list of messages Mapped to the given Class. If a message cannot be mapped to that class, it is discarded.
+ *
+ * @param cls
+ * The class to map the message to.
+ * @return A list of objects of the provided class. Never returns null.
+ */
+ public <T> List<T> getIncomingEvents(Class<T> cls);
+
+ /**
+ * Gets a list of messages Mapped to the given Class. If a message cannot be mapped to that class, it is discarded.
+ *
+ * @param cls
+ * The class to map the message to.
+ * @param limit
+ * The maximum amount of entries to return
+ * @return A list of objects of the provided class. Never returns null.
+ */
+ public <T> List<T> getIncomingEvents(Class<T> cls, int limit);
+
+ /**
+ * Posts the String message to the write topic(s).
+ *
+ * @param event
+ * The String to post.
+ */
+ public void postStatus(String event);
+
+ /**
+ * Posts the String message to the write topic(s) on the specified partition. Partitions are only used to guarantee
+ * ordering and do not impact if data is retreived.
+ *
+ * @param partition
+ * The partition to post to or null if no partition should be used.
+ * @param event
+ * The String to post.
+ */
+ public void postStatus(String partition, String event);
+
+ /**
+ * @return The client/group id used to read messages
+ */
+ public String getClientId();
+
+ /**
+ * Set the client/group id used to read messages
+ *
+ * @param clientId
+ * The new clientId to use
+ */
+ public void setClientId(String clientId);
+
+ /**
+ * @return The client/group name to use.
+ */
+ public String getClientName();
+
+ /**
+ * Set the client/group name used to read messages.
+ *
+ * @param clientName
+ * The new clientName to use
+ */
+ public void setClientName(String clientName);
+
+ /**
+ * @return The name of the topic to read from
+ */
+ public String getReadTopic();
+
+ /**
+ * Set the name of the topic to read from.
+ *
+ * @param topic
+ * The new topic to read from
+ */
+ public void setReadTopic(String topic);
+
+ /**
+ * @return The name of the topic to write to
+ */
+ public String getWriteTopic();
+
+ /**
+ * Set the name of the topic to write to
+ *
+ * @param topic
+ * The new topic to write to
+ */
+ public void setWriteTopic(String topic);
+
+ /**
+ * Adds a DMaaP host to the host pool
+ *
+ * @param host
+ * The host to add to the pool in &lt;host&gt;:&lt;port&gt; format
+ */
+ public void addToPool(String host);
+
+ /**
+ * Remove the host name from the pool if it exists
+ *
+ * @param host
+ * The host to add to the pool in &lt;host&gt;:&lt;port&gt; format
+ */
+ public void removeFromPool(String host);
+
+ /**
+ * Get all of the hosts in the DMaaP pool
+ *
+ * @return A collection of host in &lt;host&gt;:&lt;port&gt; format
+ */
+ public Collection<String> getPool();
+
+ /**
+ * Clear any provided api credentials and make future requests as an unauthenticated user
+ */
+ public void clearCredentials();
+
+ /**
+ * Sets Blacklist time for a server with response problem in seconds
+ */
+ void setResponseProblemBlacklistTime(String duration);
+
+ /**
+ * Sets Blacklist time for a server with server problem in seconds
+ */
+ void setServerProblemBlacklistTime(String duration);
+
+ /**
+ * Sets Blacklist time for a server with DNS problem in seconds
+ */
+ void setDnsIssueBlacklistTime(String duration);
+
+ /**
+ * Sets Blacklist time for a server with IO Exception problem in seconds
+ */
+ void setIOExceptionBlacklistTime(String duration);
+ /**
+ * Set the api credentials and make future requests as an authenticated user
+ *
+ * @param access
+ * The access portion of the credentials (either user name or api key)
+ * @param secret
+ * The secret portion of the credentials (either password or api secret)
+ */
+
+
+ public void setCredentials(String access, String secret);
+
+ /**
+ * Close consumer/producer DMaaP clients
+ */
+ public void closeClients();
+
+}
diff --git a/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/conv/Converter.java b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/conv/Converter.java
new file mode 100644
index 000000000..8222af13f
--- /dev/null
+++ b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/conv/Converter.java
@@ -0,0 +1,139 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2018 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.
+ *
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.listener.LCM.conv;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.MapperFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectWriter;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import org.apache.commons.lang3.StringUtils;
+import org.json.JSONObject;
+import org.onap.appc.listener.LCM.model.DmaapMessage;
+import org.onap.appc.listener.LCM.model.DmaapOutgoingMessage;
+import org.onap.appc.listener.util.Mapper;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+
+public class Converter {
+
+ private Converter() {
+ }
+
+ public static DmaapOutgoingMessage convertJsonNodeToDmaapOutgoingMessage(DmaapMessage event, JsonNode inObj){
+
+ if (event == null || inObj == null) {
+ throw new IllegalArgumentException("One of given arguments is null");
+ }
+
+ DmaapOutgoingMessage outObj = new DmaapOutgoingMessage();
+ outObj.setBody(inObj);
+ outObj.setRpcName(event.getRpcName());
+ outObj.setVersion(event.getVersion());
+ outObj.setType("response");
+ outObj.setCorrelationID(event.getCorrelationID());
+ return outObj;
+ }
+
+ public static String convertDmaapOutgoingMessageToJsonString(DmaapMessage inObj) throws JsonProcessingException {
+
+ if (inObj == null)
+ throw new IllegalArgumentException("Input message is null");
+
+
+ ObjectMapper objectMapper = new ObjectMapper();
+ ObjectWriter writer = objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL)
+ .configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true)
+ .writer().withFeatures(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS);
+ return writer.writeValueAsString(inObj);
+
+ }
+
+ public static DmaapOutgoingMessage buildDmaapOutgoingMessageWithUnexpectedError(DmaapMessage event,
+ Exception inputException) {
+
+ if (event == null || inputException == null) {
+ throw new IllegalArgumentException("One of given arguments is null");
+ }
+
+ DmaapOutgoingMessage dmaapOutgoingMessage;
+ String errMsg =
+ StringUtils.isEmpty(inputException.getMessage()) ? inputException.toString() : inputException.getMessage();
+ JSONObject commonHeaderJsonObject = Mapper.toJsonObject(event.getBody().get("input").get("common-header"));
+ JSONObject jsonObjectOutput = new JSONObject().accumulate("common-header", commonHeaderJsonObject)
+ .accumulate("status", new JSONObject().accumulate("code", 200).accumulate("value", errMsg));
+ dmaapOutgoingMessage = new DmaapOutgoingMessage();
+ dmaapOutgoingMessage.setRpcName(event.getRpcName());
+ dmaapOutgoingMessage.setCorrelationID(event.getCorrelationID());
+ dmaapOutgoingMessage.setType("error");
+ dmaapOutgoingMessage.setVersion(event.getVersion());
+ JSONObject jsonObjectBody = new JSONObject().accumulate("output", jsonObjectOutput);
+ JsonNode jsonNodeBody = Mapper.toJsonNodeFromJsonString(jsonObjectBody.toString());
+ dmaapOutgoingMessage.setBody(jsonNodeBody);
+ return dmaapOutgoingMessage;
+ }
+
+ public static String extractRequestIdWithSubId(JsonNode dmaapBody) {
+
+ if (dmaapBody == null) {
+ throw new IllegalArgumentException("Dmaap body is null");
+ }
+
+ JsonNode commonHeaderJsonNode = dmaapBody.get("input").get("common-header");
+ String requestId = getValue(commonHeaderJsonNode, "request-id", "");
+ String subRequestId = getValue(commonHeaderJsonNode, "sub-request-id", "");
+ if (!StringUtils.isEmpty(subRequestId)) {
+ requestId = requestId + "-" + subRequestId;
+ }
+ return requestId;
+ }
+
+ public static Integer extractStatusCode(JsonNode event) {
+
+ if (event == null){
+ throw new IllegalArgumentException("Input event is null");
+ }
+
+ Integer statusCode;
+ statusCode = event.get("output").get("status").get("code").asInt();
+ return statusCode;
+ }
+
+ private static String getValue(JsonNode jsonNode, String name, String defaultValue) {
+ if (jsonNode == null) {
+ return defaultValue;
+ }
+ JsonNode childJsonNode = jsonNode.get(name);
+ if (childJsonNode == null) {
+ return defaultValue;
+ }
+ String value = childJsonNode.asText();
+ if (value == null) {
+ return defaultValue;
+ }
+ return value;
+ }
+
+}
diff --git a/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/impl/ListenerImpl.java b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/impl/ListenerImpl.java
new file mode 100644
index 000000000..761d65231
--- /dev/null
+++ b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/impl/ListenerImpl.java
@@ -0,0 +1,156 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2018 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.
+ *
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.listener.LCM.impl;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.att.eelf.i18n.EELFResourceManager;
+import com.fasterxml.jackson.databind.JsonNode;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.TimeZone;
+import java.util.concurrent.RejectedExecutionException;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.appc.listener.AbstractListener;
+import org.onap.appc.listener.LCM.conv.Converter;
+import org.onap.appc.listener.LCM.model.DmaapIncomingMessage;
+import org.onap.appc.listener.LCM.operation.ProviderOperations;
+import org.onap.appc.listener.ListenerProperties;
+
+public class ListenerImpl extends AbstractListener {
+
+ private final EELFLogger LOG = EELFManager.getInstance().getLogger(ListenerImpl.class);
+
+ private long startTime = 0;
+
+ private final ProviderOperations providerOperations;
+
+ public ListenerImpl(ListenerProperties props) {
+ super(props);
+
+ String url = props.getProperty("provider.url");
+ String user = props.getProperty("provider.user");
+ String pass = props.getProperty("provider.pass");
+ providerOperations = new ProviderOperations(url, user, pass);
+ LOG.info("DMaaP Provider Endpoint: " + url);
+ }
+
+ @Override
+ public void run() {
+ // Some vars for benchmarking
+ startTime = System.currentTimeMillis();
+
+ LOG.info("Running DMaaP Listener");
+
+ while (run.get()) {
+ // Only update if the queue is low. otherwise we read in more
+ // messages than we need
+ try {
+ if (executor.getQueue().size() <= QUEUED_MIN) {
+ LOG.debug("DMaaP queue running low. Querying for more jobs");
+
+ List<DmaapIncomingMessage> messages = dmaap
+ .getIncomingEvents(DmaapIncomingMessage.class, QUEUED_MAX);
+ LOG.debug(String.format("Read %d messages from dmaap", messages.size()));
+ for (DmaapIncomingMessage incoming : messages) {
+ // Acknowledge that we read the event
+ if (isValid(incoming)) {
+ String requestIdWithSubId = getRequestIdWithSubId(incoming.getBody());
+ LOG.info("Acknowledging Message: " + requestIdWithSubId);
+ }
+ }
+ for (DmaapIncomingMessage incoming : messages) {
+ String requestIdWithSubId = getRequestIdWithSubId(incoming.getBody());
+ // Add to pool if still running
+ if (run.get()) {
+ if (isValid(incoming)) {
+ LOG.info(String.format("Adding DMaaP message to pool queue [%s]", requestIdWithSubId));
+ try {
+ executor.execute(new WorkerImpl(incoming, dmaap, providerOperations));
+ } catch (RejectedExecutionException rejectEx) {
+ LOG.error("Task Rejected: ", rejectEx);
+ }
+ } else {
+ // Badly formed message
+ LOG.error("Message was not valid. Rejecting message: " + incoming);
+ }
+ } else {
+ if (isValid(incoming)) {
+ LOG.info("Run stopped. Orphaning Message: " + requestIdWithSubId);
+ } else {
+ // Badly formed message
+ LOG.error("Message was not valid. Rejecting message: " + incoming);
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ LOG.error("Exception " + e.getClass().getSimpleName() + " caught in DMaaP listener");
+ LOG.error(EELFResourceManager.format(e));
+ LOG.error("DMaaP Listener logging and ignoring the exception, continue...");
+ }
+ }
+
+ LOG.info("Stopping DMaaP Listener thread");
+
+ // We've told the listener to stop
+ // TODO - Should we:
+ // 1) Put a message back on the queue indicating that APP-C never got to
+ // the message
+ // or
+ // 2) Let downstream figure it out after timeout between PENDING and
+ // ACTIVE messages
+ }
+
+ private boolean isValid(DmaapIncomingMessage incoming) {
+ return ((incoming != null) &&
+ incoming.getBody() != null
+ && !StringUtils.isEmpty(incoming.getRpcName()));
+ }
+
+ @Override
+ public String getBenchmark() {
+ long time = System.currentTimeMillis();
+ DateFormat df = new SimpleDateFormat("HH:mm:ss");
+ df.setTimeZone(TimeZone.getTimeZone("UTC"));
+ String runningTime = df.format(new Date(time - startTime));
+
+ String out = String.format("Running for %s and completed %d jobs using %d threads.", runningTime,
+ executor.getCompletedTaskCount(), executor.getPoolSize());
+ LOG.info("***BENCHMARK*** " + out);
+ return out;
+ }
+
+ private String getRequestIdWithSubId(JsonNode event) {
+ String requestId = "";
+ try {
+ requestId = Converter.extractRequestIdWithSubId(event);
+ } catch (Exception e) {
+ LOG.error("failed to parse request-id and sub-request-id. Json not in expected format", e);
+ }
+ return requestId;
+ }
+}
diff --git a/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/impl/WorkerImpl.java b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/impl/WorkerImpl.java
new file mode 100644
index 000000000..870871da3
--- /dev/null
+++ b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/impl/WorkerImpl.java
@@ -0,0 +1,136 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2018 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.
+ *
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.listener.LCM.impl;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import org.onap.appc.exceptions.APPCException;
+import org.onap.appc.listener.EventHandler;
+import org.onap.appc.listener.LCM.conv.Converter;
+import org.onap.appc.listener.LCM.model.DmaapMessage;
+import org.onap.appc.listener.LCM.model.DmaapOutgoingMessage;
+import org.onap.appc.listener.LCM.operation.ProviderOperations;
+
+public class WorkerImpl implements Runnable {
+
+ private final EELFLogger LOG = EELFManager.getInstance().getLogger(WorkerImpl.class);
+
+ // Should have all of the data we need for processing
+ private DmaapMessage event;
+
+ // So we can post messages from inside the worker.
+ private EventHandler dmaap;
+
+ //so we know were to post the messages
+ private final ProviderOperations providerOperations;
+
+
+ public WorkerImpl(DmaapMessage message, EventHandler dmaap, ProviderOperations providerOperations) {
+ this.event = message;
+ this.dmaap = dmaap;
+ this.providerOperations = providerOperations;
+ }
+
+ @Override
+ public void run() {
+
+ if (checkParametersForNull(event, dmaap, providerOperations)) {
+ throw new IllegalStateException("Cannot run worker. One of its parameters is null");
+ }
+
+ String requestIdWithSubId = extractRequestIdWithSubId(event.getBody());
+ LOG.debug(String.format("Started working on %s", requestIdWithSubId));
+
+ // Run the dg in a try catch to handle all exceptions and update the message at the end
+ try {
+
+ JsonNode outputJsonNode = doDG(event.getRpcName(), event.getBody());
+ DmaapOutgoingMessage dmaapOutgoingMessage = Converter
+ .convertJsonNodeToDmaapOutgoingMessage(event, outputJsonNode);
+ postMessageToDMaaP(dmaapOutgoingMessage, requestIdWithSubId);
+ Integer statusCode = extractStatusCode(dmaapOutgoingMessage.getBody());
+ if (ProviderOperations.isSucceeded(statusCode)) {
+ LOG.debug(String.format("Event %s finished successfully", requestIdWithSubId));
+ } else {
+ LOG.warn(String.format("Event %s failed", requestIdWithSubId));
+ }
+
+ } catch (Exception e) {
+ // Unknown exception from DG method. Fail and pass the exception along
+ String msg = "Exception: " + e.getMessage();
+ LOG.error(String.format("Event %s finished with failure. %s", requestIdWithSubId, msg));
+ DmaapOutgoingMessage dmaapOutgoingMessage = Converter
+ .buildDmaapOutgoingMessageWithUnexpectedError(event, e);
+ postMessageToDMaaP(dmaapOutgoingMessage, requestIdWithSubId);
+ }
+
+ LOG.debug("Done working on " + requestIdWithSubId);
+ }
+
+ private boolean checkParametersForNull(DmaapMessage message, EventHandler dmaap,
+ ProviderOperations providerOperations) {
+
+ return message == null || dmaap == null || providerOperations == null;
+ }
+
+ private Integer extractStatusCode(JsonNode event) {
+ Integer statusCode = null;
+ try {
+ statusCode = Converter.extractStatusCode(event);
+ } catch (Exception e) {
+ LOG.error("failed to parse statusCode. Json not in expected format", e);
+ }
+ return statusCode;
+ }
+
+
+ private String extractRequestIdWithSubId(JsonNode event) {
+ String requestId = "";
+ try {
+ requestId = Converter.extractRequestIdWithSubId(event);
+ } catch (Exception e) {
+ LOG.error("failed to parse request-id and sub-request-id. Json not in expected format", e);
+ }
+ return requestId;
+ }
+
+
+ private void postMessageToDMaaP(DmaapOutgoingMessage dmaapOutgoingMessage, String requestIdWithSubId) {
+ String dmaapOutgoingMessageJsonString;
+ try {
+ dmaapOutgoingMessageJsonString = Converter.convertDmaapOutgoingMessageToJsonString(dmaapOutgoingMessage);
+ dmaap.postStatus(dmaapOutgoingMessage.getCambriaPartition(), dmaapOutgoingMessageJsonString);
+ } catch (JsonProcessingException e) {
+ LOG.error(
+ "failed to postMessageToDMaaP requestIdWithSubId: " + requestIdWithSubId + " dmaapOutgoingMessage: "
+ + dmaapOutgoingMessage, e);
+ }
+ }
+
+ private JsonNode doDG(String rpcName, JsonNode msg) throws APPCException {
+ return providerOperations.topologyDG(rpcName, msg);
+ }
+}
diff --git a/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/ActionIdentifiers.java b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/ActionIdentifiers.java
new file mode 100644
index 000000000..a7a2795d4
--- /dev/null
+++ b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/ActionIdentifiers.java
@@ -0,0 +1,83 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2018 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.
+ *
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.listener.LCM.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.io.Serializable;
+
+
+public class ActionIdentifiers implements Serializable {
+
+ @JsonProperty("service-instance-id")
+ private String serviceInstanceId;
+ @JsonProperty("vnf-id")
+ private String vnfID;
+ @JsonProperty("vnfc-name")
+ private String vnfcName;
+ @JsonProperty("vserver-id")
+ private String vserverId;
+
+ public ActionIdentifiers() {
+ }
+
+ public ActionIdentifiers(ActionIdentifiers actionIdentifiers) {
+ this.serviceInstanceId=actionIdentifiers.getServiceInstanceId();
+ this.vnfID=actionIdentifiers.getVnfID();
+ this.vnfcName=actionIdentifiers.getVnfcName();
+ this.vserverId=actionIdentifiers.getVserverId();
+ }
+
+ public String getServiceInstanceId() {
+ return serviceInstanceId;
+ }
+
+ public void setServiceInstanceId(String serviceInstanceId) {
+ this.serviceInstanceId = serviceInstanceId;
+ }
+
+ public String getVnfID() {
+ return vnfID;
+ }
+
+ public void setVnfID(String vnfID) {
+ this.vnfID = vnfID;
+ }
+
+ public String getVnfcName() {
+ return vnfcName;
+ }
+
+ public void setVnfcName(String vnfcName) {
+ this.vnfcName = vnfcName;
+ }
+
+ public String getVserverId() {
+ return vserverId;
+ }
+
+ public void setVserverId(String vserverId) {
+ this.vserverId = vserverId;
+ }
+}
diff --git a/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/CommonHeader.java b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/CommonHeader.java
new file mode 100644
index 000000000..b7933184c
--- /dev/null
+++ b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/CommonHeader.java
@@ -0,0 +1,116 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * Modification Copyright (C) 2019 IBM
+ * =============================================================================
+ * 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.onap.appc.listener.LCM.model;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import java.io.Serializable;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Map;
+
+import org.onap.appc.util.Time;
+
+public class CommonHeader implements Serializable {
+ @JsonProperty("timestamp")
+ private String timeStamp;
+ @JsonProperty("api-ver")
+ private String apiVer;
+ @JsonProperty("originator-id")
+ private String originatorId;
+ @JsonProperty("request-id")
+ private String requestID;
+ @JsonProperty("sub-request-id")
+ private String subRequestId;
+ @JsonProperty("flags")
+ private Map<String, String> flags;
+
+ private final DateFormat ZULU_FORMATTER = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SS'Z'");
+
+ public CommonHeader() {
+ }
+
+ public CommonHeader(CommonHeader commonHeader) {
+ // changed to current system time
+ timeStamp = ZULU_FORMATTER.format(Time.utcDate());
+
+ apiVer = commonHeader.getApiVer();
+ originatorId = commonHeader.getOriginatorId();
+ requestID = commonHeader.getRequestID();
+ subRequestId = commonHeader.getSubRequestId();
+ flags = commonHeader.getFlags();
+ }
+
+
+
+ public String getTimeStamp() {
+ return timeStamp;
+ }
+
+ public void setTimeStamp(String timeStamp) {
+ this.timeStamp = timeStamp;
+ }
+
+ public String getApiVer() {
+ return apiVer;
+ }
+
+ public void setApiVer(String apiVer) {
+ this.apiVer = apiVer;
+ }
+
+ public String getRequestID() {
+ return requestID;
+ }
+
+ public void setRequestID(String requestID) {
+ this.requestID = requestID;
+ }
+
+ public String getOriginatorId() {
+ return originatorId;
+ }
+
+ public void setOriginatorId(String originatorId) {
+ this.originatorId = originatorId;
+ }
+
+ public String getSubRequestId() {
+ return subRequestId;
+ }
+
+ public void setSubRequestId(String subRequestId) {
+ this.subRequestId = subRequestId;
+ }
+
+ public Map<String, String> getFlags() {
+ return flags;
+ }
+
+ public void setFlags(Map<String, String> flags) {
+ this.flags = flags;
+ }
+}
diff --git a/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/DmaapIncomingMessage.java b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/DmaapIncomingMessage.java
new file mode 100644
index 000000000..3607fd719
--- /dev/null
+++ b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/DmaapIncomingMessage.java
@@ -0,0 +1,52 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2018 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.
+ *
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.listener.LCM.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import org.json.JSONObject;
+import org.onap.appc.listener.util.Mapper;
+
+/**
+ * This class represents a message being sent out to DMaaP by APPC to update listeners on the status of a request
+ *
+ */
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class DmaapIncomingMessage extends DmaapMessage{
+ private final static String defaultCambriaPartition = "APP-C";
+
+ public DmaapIncomingMessage() {
+ super();
+ setCambriaPartition(defaultCambriaPartition);
+ }
+
+
+ @Override
+ public String toString() {
+ return "DmaapIncomingMessage{"+super.toString()+"}";
+ }
+}
+
diff --git a/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/DmaapMessage.java b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/DmaapMessage.java
new file mode 100644
index 000000000..8703b0d75
--- /dev/null
+++ b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/DmaapMessage.java
@@ -0,0 +1,116 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2018 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.
+ *
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.listener.LCM.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+
+
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class DmaapMessage {
+
+ @JsonProperty("version")
+ private String version;
+
+ @JsonProperty("type")
+ private String type;
+
+ @JsonProperty("correlation-id")
+ private String correlationID;
+
+ @JsonProperty("cambria.partition")
+ private String cambriaPartition;
+
+ @JsonProperty("rpc-name")
+ private String rpcName;
+
+ @JsonProperty("body")
+ private JsonNode body;
+
+ public String getVersion() {
+ return version;
+ }
+
+
+ public String getType() {
+ return type;
+ }
+
+ public String getCorrelationID() {
+ return correlationID;
+ }
+
+ public String getCambriaPartition() {
+ return cambriaPartition;
+ }
+
+ public String getRpcName() {
+ return rpcName;
+ }
+
+ public JsonNode getBody() {
+ return body;
+ }
+
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public void setCorrelationID(String correlationID) {
+ this.correlationID = correlationID;
+ }
+
+ public void setCambriaPartition(String cambriaPartition) {
+ this.cambriaPartition = cambriaPartition;
+ }
+
+ public void setRpcName(String rpcName) {
+ this.rpcName = rpcName;
+ }
+
+ public void setBody(JsonNode body) {
+ this.body = body;
+ }
+
+ @Override
+ public String toString() {
+ return "DmaapMessage{" +
+ "version='" + version + '\'' +
+ ", type='" + type + '\'' +
+ ", correlationId='" + correlationID + '\'' +
+ ", cambriaPartition='" + cambriaPartition + '\'' +
+ ", rpcName='" + rpcName + '\'' +
+ ", body=" + body +
+ '}';
+ }
+}
+
diff --git a/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/DmaapOutgoingMessage.java b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/DmaapOutgoingMessage.java
new file mode 100644
index 000000000..b24043971
--- /dev/null
+++ b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/DmaapOutgoingMessage.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2018 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.
+ *
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.listener.LCM.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import org.json.JSONObject;
+import org.onap.appc.listener.util.Mapper;
+
+/**
+ * This class represents a message being sent out to DMaaP by APPC to update listeners on the status of a request
+ *
+ */
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class DmaapOutgoingMessage extends DmaapMessage{
+ private final static String defaultCambriaPartition = "MSO";
+
+ public DmaapOutgoingMessage() {
+ super();
+ setCambriaPartition(defaultCambriaPartition);
+ }
+
+
+ @Override
+ public String toString() {
+ return "DmaapOutgoingMessage{"+super.toString()+"}";
+ }
+}
+
diff --git a/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/InputBody.java b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/InputBody.java
new file mode 100644
index 000000000..0c70d643c
--- /dev/null
+++ b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/InputBody.java
@@ -0,0 +1,89 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2018 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.
+ *
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.listener.LCM.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class InputBody {
+
+ @JsonProperty("common-header")
+ private CommonHeader commonHeader;
+
+ @JsonProperty("action-identifiers")
+ private ActionIdentifiers actionIdentifiers;
+
+ @JsonProperty("action")
+ private String action;
+
+ @JsonProperty("payload")
+ private Object payload;
+
+
+ public Object getPayload() {
+ return payload;
+ }
+
+ public String getAction() {
+ return action;
+ }
+
+ public ActionIdentifiers getActionIdentifiers() {
+ return actionIdentifiers;
+ }
+
+ public CommonHeader getCommonHeader() {
+ return commonHeader;
+ }
+
+ @JsonIgnore
+ public void setPayloadAsString(String payload) {
+ this.payload = payload;
+ }
+
+ public void setPayload(Object payload) {
+ this.payload = payload;
+ }
+
+ public void setAction(String action) {
+ this.action = action;
+ }
+
+ public void setActionIdentifiers(ActionIdentifiers actionIdentifiers) {
+ this.actionIdentifiers = actionIdentifiers;
+ }
+
+ public void setCommonHeader(CommonHeader commonHeader) {
+ this.commonHeader = commonHeader;
+ }
+
+ @JsonIgnore
+ public boolean isValid() {
+ return getCommonHeader() != null;
+ }
+}
diff --git a/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/OutputBody.java b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/OutputBody.java
new file mode 100644
index 000000000..a42174dc2
--- /dev/null
+++ b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/OutputBody.java
@@ -0,0 +1,100 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2018 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.
+ *
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.listener.LCM.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import org.json.JSONObject;
+import org.onap.appc.listener.util.Mapper;
+
+/**
+ * This class represents a message being sent out to DMaaP by APPC to update listeners on the status of a request
+ */
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class OutputBody {
+
+ @JsonProperty("common-header")
+ private CommonHeader header;
+
+ @JsonProperty("status")
+ private ResponseStatus status;
+
+ @JsonProperty("payload")
+ private String payload;
+
+ @JsonProperty("locked")
+ private String locked;
+
+ public OutputBody() {
+ }
+
+ public OutputBody(InputBody msg) {
+ this.header = new CommonHeader(msg.getCommonHeader());
+ }
+
+
+ public JSONObject toResponse() {
+ return Mapper.toJsonObject(this);
+ }
+
+ public String getLocked() {
+ return locked;
+ }
+
+ public String getPayload() {
+ return payload;
+ }
+
+ public CommonHeader getHeader() {
+ return header;
+ }
+
+ public ResponseStatus getStatus() {
+ return status;
+ }
+
+ public void setStatus(ResponseStatus status) {
+ this.status = status;
+ }
+
+ public void setLocked(String locked) {
+ this.locked = locked;
+ }
+
+ public void setHeader(CommonHeader header) {
+ this.header = header;
+ }
+
+ public void setPayload(String payload) {
+ this.payload = payload;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("%s - %s(%s)", getHeader().getRequestID(), getStatus().getCode(), getStatus().getValue());
+ }
+}
+
diff --git a/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/ResponseStatus.java b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/ResponseStatus.java
new file mode 100644
index 000000000..6562bf9db
--- /dev/null
+++ b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/model/ResponseStatus.java
@@ -0,0 +1,72 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2018 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.
+ *
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.listener.LCM.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+
+
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ResponseStatus {
+
+ @JsonProperty("code")
+ private Integer code;
+ @JsonProperty("message")
+ private String value;
+
+ public ResponseStatus() {
+ }
+
+ public ResponseStatus(Integer code, String value) {
+ this.code = code;
+ this.value = value;
+ }
+
+ public Integer getCode() {
+ return code;
+ }
+
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setCode(Integer code) {
+ this.code = code;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ return "ResponseStatus{" +
+ "code=" + code +
+ ", value='" + value + '\'' +
+ '}';
+ }
+}
diff --git a/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/operation/GenericProviderOperationRequestFormatter.java b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/operation/GenericProviderOperationRequestFormatter.java
new file mode 100644
index 000000000..ca0f52ac7
--- /dev/null
+++ b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/operation/GenericProviderOperationRequestFormatter.java
@@ -0,0 +1,85 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
+ * =============================================================================
+ * 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.onap.appc.listener.LCM.operation;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import org.json.JSONObject;
+import org.onap.appc.exceptions.APPCException;
+import org.onap.appc.listener.LCM.model.InputBody;
+import org.onap.appc.listener.LCM.model.ResponseStatus;
+import org.onap.appc.listener.util.Mapper;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+import java.net.URL;
+
+public class GenericProviderOperationRequestFormatter implements ProviderOperationRequestFormatter {
+
+ private final EELFLogger LOG = EELFManager.getInstance().getLogger(GenericProviderOperationRequestFormatter.class);
+
+ //@formatter:off
+ @SuppressWarnings("nls")
+ private final static String TEMPLATE = "{\"input\": %s}";
+ //@formatter:on
+
+ @Override
+ public String buildPath(URL url, String rpcName) {
+ return url.getPath() + ":" + rpcName;
+ }
+
+ @Override
+ public String buildRequest(InputBody msg) {
+ JSONObject jsonObject = Mapper.toJsonObject(msg);
+ return String.format(TEMPLATE, jsonObject.toString());
+ }
+
+ @Override
+ public ResponseStatus getResponseStatus(JsonNode responseBody)throws APPCException{
+ try {
+ JsonNode status = responseBody.get("output").get("status");
+ return new ResponseStatus(status.get("code").asInt(), status.get("message").asText());
+ } catch (Exception e) {
+ LOG.error("Unknown error processing failed response from provider. Json not in expected format", e);
+ throw new APPCException("APPC has an unknown RPC error");
+ }
+ }
+
+ @Override
+ public String getLocked(JSONObject responseBody) throws APPCException {
+ try {
+ JSONObject outputObject=responseBody.getJSONObject("output");
+ if(outputObject.has("locked")){
+ return outputObject.getString("locked");
+ }else{
+ return null;
+ }
+ } catch (Exception e) {
+ LOG.error("Unknown error processing failed response from provider. Json not in expected format", e);
+ throw new APPCException("APPC has an unknown RPC error");
+ }
+ }
+}
diff --git a/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/operation/ProviderOperationRequestFormatter.java b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/operation/ProviderOperationRequestFormatter.java
new file mode 100644
index 000000000..e8a6ecbeb
--- /dev/null
+++ b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/operation/ProviderOperationRequestFormatter.java
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2018 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.
+ *
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.listener.LCM.operation;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import org.json.JSONObject;
+import org.onap.appc.exceptions.APPCException;
+import org.onap.appc.listener.LCM.model.InputBody;
+import org.onap.appc.listener.LCM.model.ResponseStatus;
+
+import java.net.URL;
+
+
+public interface ProviderOperationRequestFormatter {
+
+ String buildPath(URL url, String rpcName);
+
+ String buildRequest(InputBody msg);
+
+ ResponseStatus getResponseStatus(JsonNode json)throws APPCException;
+
+ String getLocked(JSONObject json)throws APPCException;
+}
diff --git a/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/operation/ProviderOperations.java b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/operation/ProviderOperations.java
new file mode 100644
index 000000000..42206ec2e
--- /dev/null
+++ b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/LCM/operation/ProviderOperations.java
@@ -0,0 +1,281 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
+ * =============================================================================
+ * 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.onap.appc.listener.LCM.operation;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.fasterxml.jackson.databind.JsonNode;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.Socket;
+import java.net.URL;
+import java.security.KeyManagementException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.io.IOUtils;
+import org.apache.http.HttpHeaders;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpVersion;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.conn.scheme.PlainSocketFactory;
+import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.scheme.SchemeRegistry;
+import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
+import org.apache.http.params.BasicHttpParams;
+import org.apache.http.params.HttpParams;
+import org.apache.http.params.HttpProtocolParams;
+import org.apache.http.protocol.HTTP;
+import org.onap.appc.exceptions.APPCException;
+import org.onap.appc.listener.LCM.model.ResponseStatus;
+import org.onap.appc.listener.util.Mapper;
+
+public class ProviderOperations {
+
+ private final EELFLogger LOG = EELFManager.getInstance().getLogger(ProviderOperations.class);
+
+ private URL url;
+ private String basicAuth;
+
+ private static ProviderOperationRequestFormatter requestFormatter = new GenericProviderOperationRequestFormatter();
+
+
+ public ProviderOperations(String url, String username, String password){
+ setAuthentication(username, password);
+ try {
+ this.url = new URL(url);
+ } catch (MalformedURLException e) {
+ LOG.error("An error occurred while building url", e);
+ }
+ }
+
+ /**
+ * Calls the AppcProvider to run a topology directed graph
+ *
+ * @param message The incoming message to be run
+ * @return True if the result is success. Never returns false and throws an exception instead.
+ * @throws UnsupportedEncodingException
+ * @throws Exception if there was a failure processing the request. The exception message is the failure reason.
+ */
+ @SuppressWarnings("nls")
+ public JsonNode topologyDG(String rpcName, JsonNode message) throws APPCException {
+ if (message == null) {
+ throw new APPCException("Provided message was null");
+ }
+
+ HttpPost postRequest = buildPostRequest(rpcName, message);
+ return getJsonNode(message, postRequest);
+ }
+
+ private HttpPost buildPostRequest(String rpcName, JsonNode message) throws APPCException {
+ HttpPost post;
+ try {
+
+ // Concatenate the "action" on the end of the URL
+ String path = requestFormatter.buildPath(url, rpcName);
+ URL serviceUrl = new URL(url.getProtocol(), url.getHost(), url.getPort(), path);
+
+ post = new HttpPost(serviceUrl.toExternalForm());
+ post.setHeader(HttpHeaders.CONTENT_TYPE, "application/json");
+ post.setHeader(HttpHeaders.ACCEPT, "application/json");
+
+ // Set Auth
+ if (basicAuth != null) {
+ post.setHeader(HttpHeaders.AUTHORIZATION, "Basic " + basicAuth);
+ }
+
+ String body = Mapper.toJsonString(message);
+ StringEntity entity = new StringEntity(body);
+ entity.setContentType("application/json");
+ post.setEntity(entity);
+ } catch (UnsupportedEncodingException | MalformedURLException e) {
+ throw new APPCException(e);
+ }
+ return post;
+ }
+
+ private JsonNode getJsonNode(JsonNode message, HttpPost post) throws APPCException {
+ HttpClient client = getHttpClient();
+
+ int httpCode;
+ String respBody;
+ try {
+ HttpResponse response = client.execute(post);
+ httpCode = response.getStatusLine().getStatusCode();
+ respBody = IOUtils.toString(response.getEntity().getContent());
+ } catch (IOException e) {
+ throw new APPCException(e);
+ }
+
+ if (httpCode >= 200 && httpCode < 300 && respBody != null) {
+ JsonNode json;
+ try {
+ json = Mapper.toJsonNodeFromJsonString(respBody);
+ } catch (Exception e) {
+ LOG.error("Error processing response from provider. Could not map response to json", e);
+ throw new APPCException("APPC has an unknown RPC error");
+ }
+ ResponseStatus responseStatus = requestFormatter.getResponseStatus(json);
+ if (!isSucceeded(responseStatus.getCode())) {
+ LOG.warn(String.format("Operation failed [%s]", message.toString()));
+ }
+ return json;
+ }
+ throw new APPCException(String.format("Unexpected response from endpoint: [%d] - %s ", httpCode, respBody));
+ }
+
+ /**
+ * Updates the static var URL and returns the value;
+ *
+ * @return The new value of URL
+ */
+ public String getUrl() {
+ return url.toExternalForm();
+ }
+
+ public void setUrl(String newUrl) {
+ try {
+ url = new URL(newUrl);
+ } catch (MalformedURLException e) {
+ LOG.error("An error occurred while building url", e);
+ }
+ }
+
+ /**
+ * Sets the basic authentication header for the given user and password. If either entry is null then set basic auth
+ * to null
+ *
+ * @param user The user with optional domain name
+ * @param password The password for the user
+ * @return The new value of the basic auth string that will be used in the request headers
+ */
+ public String setAuthentication(String user, String password) {
+ if (user != null && password != null) {
+ String authStr = user + ":" + password;
+ basicAuth = new String(Base64.encodeBase64(authStr.getBytes()));
+ } else {
+ basicAuth = null;
+ }
+ return basicAuth;
+ }
+
+ @SuppressWarnings("deprecation")
+ protected HttpClient getHttpClient() throws APPCException {
+ HttpClient client;
+ switch (url.getProtocol()) {
+ case "https":
+ try {
+ KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
+ trustStore.load(null, null);
+ MySSLSocketFactory sf = new MySSLSocketFactory(trustStore);
+ sf.setHostnameVerifier(MySSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+
+ HttpParams params = new BasicHttpParams();
+ HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
+ HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
+
+ SchemeRegistry registry = new SchemeRegistry();
+ registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
+ registry.register(new Scheme("https", sf, 443));
+ registry.register(new Scheme("https", sf, 8443));
+ registry.register(new Scheme("http", sf, 8181));
+
+ ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry);
+ client = new DefaultHttpClient(ccm, params);
+ } catch (Exception e) {
+ LOG.error("Error getting HTTP Client", e);
+ client = new DefaultHttpClient();
+ }
+ break;
+ case "http":
+ client = new DefaultHttpClient();
+ break;
+ default:
+ throw new APPCException(
+ "The provider.topology.url property is invalid. The url did not start with http[s]");
+ }
+ return client;
+ }
+
+ @SuppressWarnings("deprecation")
+ public static class MySSLSocketFactory extends SSLSocketFactory {
+ private SSLContext sslContext = SSLContext.getInstance("TLS");
+
+ public MySSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException,
+ KeyStoreException, UnrecoverableKeyException {
+ super(truststore);
+
+ TrustManager tm = new X509TrustManager() {
+ @Override
+ public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
+ }
+
+ @Override
+ public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
+ }
+
+ @Override
+ public X509Certificate[] getAcceptedIssuers() {
+ return null;
+ }
+ };
+
+ sslContext.init(null, new TrustManager[]{
+ tm
+ }, null);
+ }
+
+ @Override
+ public Socket createSocket(Socket socket, String host, int port, boolean autoClose)
+ throws IOException {
+ return sslContext.getSocketFactory().createSocket(socket, host, port, autoClose);
+ }
+
+ @Override
+ public Socket createSocket() throws IOException {
+ return sslContext.getSocketFactory().createSocket();
+ }
+ }
+
+ public static boolean isSucceeded(Integer code) {
+
+ //FIXME is it working as intended?
+ return code != null && ((code == 100) || (code == 400));
+ }
+} \ No newline at end of file
diff --git a/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/Listener.java b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/Listener.java
new file mode 100644
index 000000000..f4b87bd25
--- /dev/null
+++ b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/Listener.java
@@ -0,0 +1,74 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2018 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.
+ *
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.listener;
+
+/**
+ * This interface defines a listener that subscribes to a DMaaP topic and continually polls for messages. The
+ * listener does all operations in the run() method and long running operations should be created in a separate worker
+ * thread.
+ *
+ */
+public interface Listener extends Runnable {
+
+ /**
+ * Should start a continuous poll to get messages from the message bus only ending when stop() or stopNow() are
+ * called.
+ *
+ * @see java.lang.Runnable#run()
+ */
+ @Override
+ public void run();
+
+ /**
+ * Signals the listener to stop accepting new messages to the queue and to cleanly finish processing all remaining
+ * messages in the queue. This can take a significant amount of time to complete depending on the thread pool
+ * characteristics. Similar to {@link #stopNow()}
+ */
+ public void stop();
+
+ /**
+ * Signals the listener to stop accepting new messages to the queue and to destroy all remaining messages in the
+ * queue. This will complete quicker than {@link #stop()} at the cost of discarded requests. Recovery of these
+ * requests would have to be caught downstream. Similar to {@link #stop()}
+ */
+ public void stopNow();
+
+ /**
+ * @return A string that shows various benchmarking data. Can be used by humans to tune the thread pool.
+ */
+ public String getBenchmark();
+
+ /**
+ * @return The listener's id when requesting messages from DMaaP. Also known as the group id.
+ */
+ public String getListenerId();
+
+ /**
+ * Sets the listener's id to use when requesting messages from DMaaP. Also known as the group id.
+ *
+ * @param idString
+ * The new listener id
+ */
+ public void setListenerId(String idString);
+}
diff --git a/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/ListenerProperties.java b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/ListenerProperties.java
new file mode 100644
index 000000000..74ead9485
--- /dev/null
+++ b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/ListenerProperties.java
@@ -0,0 +1,305 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2019 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.
+ *
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.listener;
+
+import java.util.Properties;
+
+/**
+ * A class for instantiating Listener objects. It is primarily used to hold properties that start with the given prefix.
+ * It also holds a class that implements {@see Listener} and will be used by the controller to spawn a new listener
+ * object.
+ *
+ * @since Apr 25, 2016
+ * @version $Id$
+ */
+public class ListenerProperties {
+
+ private String prefix;
+
+ private Class<? extends Listener> listenerClass;
+
+ private Properties props;
+
+ /**
+ * Creates a new listener object with the given prefix and properties. Any property starting with the prefix is
+ * added to the internal properties object with the prefix removed. All other properties are ignored.
+ * ListenerProperties constructor
+ *
+ * @param prefix
+ * The prefix of the properties to load
+ * @param allProps
+ * The properties object to load from.
+ */
+ public ListenerProperties(String prefix, Properties allProps) {
+ this.prefix = prefix;
+ props = new Properties();
+
+ String dottedPrefix = String.format("%s.", prefix);
+ for (String key : allProps.stringPropertyNames()) {
+ if (key.startsWith(dottedPrefix) && key.length() > dottedPrefix.length()) {
+ props.put(key.substring(dottedPrefix.length()), allProps.get(key));
+ }
+ }
+ }
+
+ /**
+ * @return The prefix of these properties
+ */
+ public String getPrefix() {
+ return prefix;
+ }
+
+ /**
+ * Sets the listener class. Will be used by {@see Controller} to instantiate the Listener thread for this object
+ *
+ * @param cls
+ * The class to be created. Implements {@see Listener}
+ */
+ public void setListenerClass(Class<? extends Listener> cls) {
+ this.listenerClass = cls;
+ }
+
+ /**
+ * @return The class that will be used by {@see Controller} to instantiate the Listener thread for this object
+ */
+ public Class<? extends Listener> getListenerClass() {
+ return listenerClass;
+ }
+
+ /**
+ * Returns a property matching a given KEYS
+ *
+ * @param key
+ * The KEYS object who's value to return.
+ * @return The value of the property or null if none exists
+ */
+ public String getProperty(KEYS key) {
+ return getProperty(key, null);
+ }
+
+ /**
+ * Returns a property matching a given string.
+ *
+ * @param key
+ * The key who's value to return.
+ * @return The value of the property or null if none exists
+ */
+ public String getProperty(String key) {
+ return getProperty(key, null);
+ }
+
+ /**
+ * Returns a property matching a given KEYS
+ *
+ * @param key
+ * The KEYS object who's value to return.
+ * @param defaultValue
+ * The value to return if the property is not found
+ * @return The value of the property or null if none exists
+ */
+ public String getProperty(KEYS key, String defaultValue) {
+ return getProperty(key.getPropertySuffix(), defaultValue);
+ }
+
+ /**
+ * Returns a property matching a given string.
+ *
+ * @param key
+ * The key who's value to return.
+ * @param defaultValue
+ * The value to return if the property is not found
+ * @return The value of the property or null if none exists
+ */
+ public String getProperty(String key, String defaultValue) {
+ return props.getProperty(key, defaultValue);
+ }
+
+ /**
+ * @return The properties object containing all properties
+ */
+ public Properties getProperties() {
+ return props;
+ }
+
+ /**
+ * Reads the <i>prefix</i>.disabled property to determine if the listener is disabled and should not be run by the
+ * controller. Defaults to false if property not set or value cannot be parsed.
+ *
+ * @return true if the listener is disabled and should not be started. false if the listener should be start
+ * normally (default).
+ */
+ public boolean isDisabled() {
+ return Boolean.valueOf(getProperty(KEYS.DISABLED, "false"));
+ }
+
+ @Override
+ public String toString() {
+ return String.format("%s", prefix);
+ }
+
+
+ /**
+ * Set of common properties that will be used by most systems. Primarily relating to DMaaP and ThreadPools
+ *
+ * @since Apr 25, 2016
+ * @version $Id$
+ */
+ public enum KEYS {
+ /**
+ * Property to determine if the listener should be disabled. If not set, defaults to false
+ */
+ DISABLED("disabled"),
+
+ /**
+ * Property for the message service type. Should be a lower case string. See MessageService.
+ */
+ MESSAGE_SERVICE("service"),
+
+ /**
+ * A hostname or comma separated list (no spaces) of hostnames of servers in a cluster. Can have ports included
+ * as well.<br>
+ * Examples:
+ * <ul>
+ * <li>server1.appc.onap.org</li>
+ * <li>server1.appc.onap.org:3904</li>
+ * <li>server1.appc.onap.org,server2.appc.onap.org</li>
+ * </ul>
+ */
+ HOSTS("poolMembers"),
+
+ /**
+ * The topic that will be used for DMaaP read operations. Can only support a single topic.
+ */
+ TOPIC_READ("topic.read"),
+
+ /**
+ * The topic or topics that will be used to write to. If multiple topics are provided, should be in a comma
+ * seperated list with no spaces.<br>
+ * Examples:
+ * <ul>
+ * <li>TOPIC-1</li>
+ * <li>TOPIC-1,TOPIC-2,ANOTHER-TOPIC</li>
+ * </ul>
+ */
+ TOPIC_WRITE("topic.write"),
+
+ /**
+ * The highland park filter to use on read requests. If you are reading and writing to the same topic this must
+ * be provided. Filter should be in JSON format (not url escaped).
+ */
+ TOPIC_READ_FILTER("topic.read.filter"),
+
+ /**
+ * The amount of time in seconds that the DMaaP polling connection should stay open for. Recommended to be set
+ * high (around 60 seconds) as most clients will return immediately and not wait until the timeout is up to
+ * return if they have data.
+ */
+ TOPIC_READ_TIMEOUT("topic.read.timeout"),
+
+ /**
+ * Blacklist time for a server with response problem in seconds
+ */
+
+ PROBLEM_WITH_RESPONSE_BLACKLIST_TIME("topic.responseProblem.blacklistTime"),
+ /**
+ * Blacklist time for a server with server problem in seconds
+ */
+
+ PROBLEM_SERVERSIDE_ERROR_BLACKLIST_TIME("topic.serverError.blacklistTime"),
+ /**
+ * Blacklist time for a server with DNS problem in seconds
+ */
+
+ PROBLEM_DNS_BLACKLIST_TIME("topic.dnsIssue.blacklistTime"),
+ /**
+ * Blacklist time for a server with IO Exception problem in seconds
+ */
+
+ PROBLEM_IO_EXCEPTION_BLACKLIST_TIME("topic.ioException.blacklistTime"),
+
+ /**
+ * The name of the client to use. Should be unique to the application.
+ */
+ CLIENT_NAME("client.name"),
+
+ /**
+ * The id of the client to use. Should be unique for each instance of the application in an environment.
+ */
+ CLIENT_ID("client.name.id"),
+
+ /**
+ * The User (DMaaP) to use for authentication. If a user is provided, you must include the
+ * domain name (e.g. example<b>@example.com</b>).
+ */
+ AUTH_USER_KEY("client.key"),
+
+ /**
+ * The password (DMaaP) to use for authentication.
+ */
+ AUTH_SECRET_KEY("client.secret"),
+
+ /**
+ * The minimum amount of size of the queue. A client should request new messages once the queue has dropped
+ * below this size.
+ */
+ THREADS_MIN_QUEUE("threads.queuesize.min"),
+
+ /**
+ * The maximum size of the queue. A client will request no new messages once this maximum size has been reached.
+ */
+ THREADS_MAX_QUEUE("threads.queuesize.max"),
+
+ /**
+ * The minimum size of the worker threads pool. This is the pool each listener will use to launch longer running
+ * operations.
+ */
+ THREADS_MIN_POOL("threads.poolsize.min"),
+
+ /**
+ * The maximum size of the worker threads pool. This is the pool each listener will use to launch longer running
+ * operations.
+ */
+ THREADS_MAX_POOL("threads.poolsize.max");
+
+ private String suffix;
+
+ private KEYS(String val) {
+ this.suffix = val;
+ }
+
+ /**
+ * @param prefix
+ * The prefix to prepend
+ * @return a fully property name that corroponds to what is used in the properties file. Format is PREFIX.KEY
+ */
+ public String getFullProp(String prefix) {
+ return String.format("%s.%s", prefix, suffix);
+ }
+
+ public String getPropertySuffix() {
+ return suffix;
+ }
+ }
+
+}
diff --git a/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/impl/ListenerImpl.java b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/impl/ListenerImpl.java
new file mode 100644
index 000000000..d6909abf3
--- /dev/null
+++ b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/impl/ListenerImpl.java
@@ -0,0 +1,131 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2018 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.
+ *
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.listener.demo.impl;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.TimeZone;
+import java.util.concurrent.RejectedExecutionException;
+
+import org.onap.appc.listener.AbstractListener;
+import org.onap.appc.listener.ListenerProperties;
+import org.onap.appc.listener.demo.model.IncomingMessage;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.att.eelf.i18n.EELFResourceManager;
+
+public class ListenerImpl extends AbstractListener {
+
+ private final EELFLogger LOG = EELFManager.getInstance().getLogger(ListenerImpl.class);
+
+ private long startTime = 0;
+
+ public ListenerImpl(ListenerProperties props) {
+ super(props);
+ String url = props.getProperty("provider.url");
+ LOG.info("DMaaP Provider Endpoint: " + url);
+ ProviderOperations.setUrl(url);
+
+ // Set Basic Auth
+ String user = props.getProperty("provider.user");
+ String pass = props.getProperty("provider.pass");
+ ProviderOperations.setAuthentication(user, pass);
+ }
+
+ @Override
+ public void run() {
+ // Some vars for benchmarking
+ startTime = System.currentTimeMillis();
+
+ LOG.info("Running DMaaP Listener");
+
+ while (run.get()) {
+ // Only update if the queue is low. otherwise we read in more
+ // messages than we need
+ try {
+ if (executor.getQueue().size() <= QUEUED_MIN) {
+ LOG.debug("DMaaP queue running low. Querying for more jobs");
+ List<IncomingMessage> messages = dmaap.getIncomingEvents(IncomingMessage.class, QUEUED_MAX);
+ LOG.debug(String.format("Read %d messages from dmaap", messages.size()));
+ for (IncomingMessage incoming : messages) {
+ // Acknowledge that we read the event
+ LOG.info("Acknowledging Message: " + incoming.getHeader().getRequestID());
+
+ //TODO: Should we post a pending status for 1607
+ //dmaap.postStatus(incoming.toOutgoing(Status.PENDING, null).toString());
+ }
+ for (IncomingMessage incoming : messages) {
+ // Add to pool if still running
+ if (run.get()) {
+ LOG.info(String.format("Adding DMaaP message to pool queue [%s]", incoming.getHeader().getRequestID()));
+ if (incoming.isValid()) {
+ try {
+ executor.execute(new WorkerImpl(incoming, dmaap));
+ } catch (RejectedExecutionException rejectEx) {
+ LOG.error("Task Rejected: ", rejectEx);
+ }
+ } else {
+ // Badly formed message
+ LOG.error("Message was not valid. Rejecting");
+ }
+ } else {
+ LOG.info("Run stopped. Orphaning Message: " + incoming.getHeader().getRequestID());
+ }
+ }
+ }
+ } catch (Exception e) {
+ LOG.error("Exception " + e.getClass().getSimpleName() + " caught in DMaaP listener");
+ LOG.error(EELFResourceManager.format(e));
+ LOG.error("DMaaP Listener logging and ignoring the exception, continue...");
+ }
+ }
+
+ LOG.info("Stopping DMaaP Listener thread");
+
+ // We've told the listener to stop
+ // TODO - Should we:
+ // 1) Put a message back on the queue indicating that APP-C never got to
+ // the message
+ // or
+ // 2) Let downstream figure it out after timeout between PENDING and
+ // ACTIVE messages
+ }
+
+ @Override
+ public String getBenchmark() {
+ long time = System.currentTimeMillis();
+ DateFormat df = new SimpleDateFormat("HH:mm:ss");
+ df.setTimeZone(TimeZone.getTimeZone("UTC"));
+ String runningTime = df.format(new Date(time - startTime));
+
+ String out = String.format("Running for %s and completed %d jobs using %d threads.", runningTime,
+ executor.getCompletedTaskCount(), executor.getPoolSize());
+ LOG.info("***BENCHMARK*** " + out);
+ return out;
+ }
+
+}
diff --git a/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/impl/ProviderOperations.java b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/impl/ProviderOperations.java
new file mode 100644
index 000000000..6cd2f2d76
--- /dev/null
+++ b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/impl/ProviderOperations.java
@@ -0,0 +1,195 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * Modifications Copyright (C) 2019 Ericsson
+ * Modifications Copyright (C) 2019 IBM
+ * =============================================================================
+ * 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.onap.appc.listener.demo.impl;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.io.IOUtils;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.json.JSONObject;
+import org.onap.appc.exceptions.APPCException;
+import org.onap.appc.listener.demo.model.IncomingMessage;
+import org.onap.appc.listener.util.HttpClientUtil;
+import org.onap.appc.listener.util.Mapper;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+public class ProviderOperations {
+
+ private static final EELFLogger LOG = EELFManager.getInstance().getLogger(ProviderOperations.class);
+
+ private static URL url;
+
+ private static String basic_auth;
+
+ //@formatter:off
+ @SuppressWarnings("nls")
+ private final static String TEMPLATE = "{\"input\": {\"common-request-header\": {\"service-request-id\": \"%s\"},\"config-payload\": {\"config-url\": \"%s\",\"config-json\":\"%s\"}}}";
+ //@formatter:on
+
+ /**
+ * Calls the AppcProvider to run a topology directed graph
+ *
+ * @param msg
+ * The incoming message to be run
+ * @return True if the result is success. Never returns false and throws an exception instead.
+ * @throws UnsupportedEncodingException
+ * @throws Exception
+ * if there was a failure processing the request. The exception message is the failure reason.
+ */
+ @SuppressWarnings("nls")
+ public static boolean topologyDG(IncomingMessage msg) throws APPCException {
+ if (msg == null) {
+ throw new APPCException("Provided message was null");
+ }
+
+ HttpPost post = null;
+ try {
+ // Concatenate the "action" on the end of the URL
+ String path = url.getPath() + ":" + msg.getAction().getValue();
+ URL serviceUrl = new URL(url.getProtocol(), url.getHost(), url.getPort(), path);
+
+ post = new HttpPost(serviceUrl.toExternalForm());
+ post.setHeader("Content-Type", "application/json");
+ post.setHeader("Accept", "application/json");
+
+ // Set Auth
+ if (basic_auth != null) {
+ post.setHeader("Authorization", "Basic " + basic_auth);
+ }
+
+ //String body = buildReqest(msg.getId(), msg.getUrl(), msg.getIdentityUrl());
+ String body = buildReqest(msg.getHeader().getRequestID(), msg.getPayload().getGenericVnfId(), msg.getPayload().getStreams());
+ StringEntity entity = new StringEntity(body);
+ entity.setContentType("application/json");
+ post.setEntity(new StringEntity(body));
+ } catch (UnsupportedEncodingException | MalformedURLException e) {
+ throw new APPCException(e);
+ }
+
+ HttpClient client = HttpClientUtil.getHttpClient(url.getProtocol());
+
+ int httpCode = 0;
+ String respBody = null;
+ try {
+ HttpResponse response = client.execute(post);
+ httpCode = response.getStatusLine().getStatusCode();
+ respBody = IOUtils.toString(response.getEntity().getContent());
+ } catch (IOException e) {
+ throw new APPCException(e);
+ }
+
+ if (httpCode == 200 && respBody != null) {
+ JSONObject json;
+ try {
+ json = Mapper.toJsonObject(respBody);
+ } catch (Exception e) {
+ LOG.error("Error prcoessing response from provider. Could not map response to json", e);
+ throw new APPCException("APPC has an unknown RPC error");
+ }
+ boolean success;
+ String reason;
+ try {
+ JSONObject header = json.getJSONObject("output").getJSONObject("common-response-header");
+ success = header.getBoolean("success");
+ reason = header.getString("reason");
+ } catch (Exception e) {
+ LOG.error("Unknown error prcoessing failed response from provider. Json not in expected format", e);
+ throw new APPCException("APPC has an unknown RPC error");
+ }
+ if (success) {
+ return true;
+ }
+ String reasonStr = reason == null ? "Unknown" : reason;
+ LOG.warn(String.format("Topology Operation [%s] failed. Reason: %s", msg.getHeader().getRequestID(), reasonStr));
+ throw new APPCException(reasonStr);
+
+ }
+ throw new APPCException(String.format("Unexpected response from endpoint: [%d] - %s ", httpCode, respBody));
+ }
+
+ /**
+ * Updates the static var URL and returns the value;
+ *
+ * @return The new value of URL
+ */
+ public static String getUrl() {
+ return url.toExternalForm();
+ }
+
+ public static void setUrl(String newUrl) {
+ try {
+ url = new URL(newUrl);
+ } catch (MalformedURLException e) {
+ LOG.error("Malformed URL", e);
+ }
+ }
+
+ /**
+ * Sets the basic authentication header for the given user and password. If either entry is null then set basic auth
+ * to null
+ *
+ * @param user
+ * The user with optional domain name
+ * @param password
+ * The password for the user
+ * @return The new value of the basic auth string that will be used in the request headers
+ */
+ public static String setAuthentication(String user, String password) {
+ if (user != null && password != null) {
+ String authStr = user + ":" + password;
+ basic_auth = new String(org.apache.commons.codec.binary.Base64.encodeBase64(authStr.getBytes()));
+ } else {
+ basic_auth = null;
+ }
+ return basic_auth;
+ }
+
+ /**
+ * Builds the request body for a topology operation
+ *
+ * @param id
+ * The request id
+ * @param url
+ * The vm's url
+ *
+ * @param pgstreams
+ * The streams to send to the traffic generator
+ *
+ * @return A String containing the request body
+ */
+ private static String buildReqest(String id, String url, String pgstreams) {
+
+ return String.format(TEMPLATE, id, url, pgstreams);
+ }
+}
diff --git a/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/impl/WorkerImpl.java b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/impl/WorkerImpl.java
new file mode 100644
index 000000000..d9bf6d358
--- /dev/null
+++ b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/impl/WorkerImpl.java
@@ -0,0 +1,84 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2018 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.
+ *
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.listener.demo.impl;
+
+import org.onap.appc.exceptions.APPCException;
+import org.onap.appc.listener.EventHandler;
+import org.onap.appc.listener.demo.model.IncomingMessage;
+import org.onap.appc.listener.demo.model.Status;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+public class WorkerImpl implements Runnable {
+
+ private final EELFLogger LOG = EELFManager.getInstance().getLogger(WorkerImpl.class);
+
+ // Should have all of the data we need for processing
+ private IncomingMessage event;
+
+ // So we can post messages from inside the worker.
+ private EventHandler dmaap;
+
+ public WorkerImpl(IncomingMessage message, EventHandler dmaap) {
+ this.event = message;
+ this.dmaap = dmaap;
+ }
+
+ @Override
+ public void run() {
+ LOG.debug(String.format("Started working on %s", event.getHeader().getRequestID()));
+
+ dmaap.postStatus(event.toOutgoing(Status.ACCEPTED));
+ // Run the dg in a try catch to handle all exceptions and update the
+ // message at the end
+ try {
+ if (doDG(event)) {
+ dmaap.postStatus(event.toOutgoing(Status.SUCCESS));
+ LOG.debug(String.format("Event %s finished successfully", event.getHeader().getRequestID()));
+ } else {
+ // Should never happen. Exception with message should be thrown instead.
+ LOG.error(String.format(
+ "We somehow returned false from doDG() instead of throwing exception. Incoming event [%s]",
+ event.toJson().toString()));
+ dmaap.postStatus(event.toOutgoing(Status.FAILURE));
+ }
+
+ } catch (Exception e) {
+ // Unknown exception from DG method. Fail and pass the exception
+ // along
+ String msg = "Exception: " + e.getMessage();
+ LOG.warn(String.format("Event %s finished with failure. %s", event.getHeader().getRequestID(), msg));
+ //TODO: should a message be included? there is nothing in the API spec for a msg?
+ //dmaap.postStatus(event.toOutgoing(Status.FAILURE, msg));
+ dmaap.postStatus(event.toOutgoing(Status.FAILURE));
+ }
+
+ LOG.debug("Done working on " + event.getHeader().getRequestID());
+ }
+
+ private boolean doDG(IncomingMessage msg) throws APPCException {
+ return ProviderOperations.topologyDG(msg);
+ }
+}
diff --git a/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/model/Action.java b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/model/Action.java
new file mode 100644
index 000000000..6fc8ca0bc
--- /dev/null
+++ b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/model/Action.java
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2018 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.
+ *
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.listener.demo.model;
+
+public enum Action {
+ Restart("Restart"), Rebuild("Rebuild"), Migrate("Migrate"), Evacuate("Evacuate"), Snapshot("Snapshot"),modifyconfig("ModifyConfig");
+
+ /**
+ * Converts the string to an Action
+ *
+ * @param value
+ * The string to try and convert. Is case insensitive
+ * @return The action matching the string or null if no match was found.
+ */
+ public static Action toAction(String value) {
+ if (value != null) {
+ for (Action e : values()) {
+ if (e.getValue().toUpperCase().equals(value.toUpperCase())) {
+ return e;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ private String value;
+
+ private Action(String valueToUse) {
+ value = valueToUse;
+ }
+
+ public final String getValue() {
+ return value;
+ }
+}
diff --git a/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/model/CommonMessage.java b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/model/CommonMessage.java
new file mode 100644
index 000000000..e0dbbab67
--- /dev/null
+++ b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/model/CommonMessage.java
@@ -0,0 +1,313 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
+ * =============================================================================
+ * 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.onap.appc.listener.demo.model;
+
+import java.io.Serializable;
+import java.util.Collection;
+
+import org.json.JSONObject;
+import org.onap.appc.listener.util.Mapper;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion;
+
+/**
+ * This class holds attributes that are common to DMaaP messages both coming in from DCAE and being sent out by APPC
+ *
+ */
+@JsonSerialize(include = Inclusion.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class CommonMessage implements Serializable {
+ /*
+ * { "CommonHeader": { "TimeStamp": "0000-00-00T00:00:00.000Z", "APIver": "1.01", "OriginatorID": "policy.pdp01",
+ * "RequestID": "b74d13c5-bb26-4b04-992c-4679dfc8280e", "SubrequestID": "1" }, "Action": "RESTART", "Payload": {
+ * "VServerSelfLink":
+ * "http://192.168.1.2:8774/v2/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345",
+ * "VNF_NAME": "test", "VMID": "abc12345-1234-5678-890a-abcdefg12345", "TenantID":
+ * "abcde12345fghijk6789lmnopq123rst", "LOC_ID": "Test", "in-maint": "false", "Identity":
+ * "http://example.com:5000/v2.0", "Prov_status": "ACTIVE", "OAM_IPV4": "192.168.1.2",
+ * "is-closed-loop-disabled": "false", "VM_NAME": "basx0001vm034", "OAM_IPV6": "aaaa::bbbb:cccc:dddd:eeee/64" } }
+ */
+
+ private static final long serialVersionUID = 1L;
+
+ /*
+ * The common header
+ */
+ @JsonProperty("CommonHeader")
+ private CommonHeader header;
+
+ /*
+ * The payload
+ */
+ @JsonProperty("Payload")
+ private Payload payload;
+
+ @JsonIgnore
+ private long startTime = System.currentTimeMillis();
+
+ /*
+ * Getters and Setters
+ */
+
+ public long getStartTime() {
+ return startTime;
+ }
+
+ public void setStartTime(long startTime) {
+ this.startTime = startTime;
+ }
+
+ /**
+ * @return the header
+ */
+ public CommonHeader getHeader() {
+ return header;
+ }
+
+ /**
+ * @param header
+ * the header to set
+ */
+ public void setHeader(CommonHeader header) {
+ this.header = header;
+ }
+
+ /**
+ * @return the payload
+ */
+ public Payload getPayload() {
+ return payload;
+ }
+
+ /**
+ * @param payload
+ * the payload to set
+ */
+ public void setPayload(Payload payload) {
+ this.payload = payload;
+ }
+
+ /**
+ * Convenience method to return a json representation of this object.
+ *
+ * @return The json representation of this object
+ */
+ public JSONObject toJson() {
+ return Mapper.toJsonObject(this);
+ }
+
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ public static class CommonHeader {
+ /*
+ * "CommonHeader": { "TimeStamp": "2016-05-11T13:53:53.146Z", "APIver": "1.01", "OriginatorID": "policy.pdp01",
+ * "RequestID": "b74d13c5-bb26-4b04-992c-4679dfc8280e", "SubrequestID": "1" }
+ */
+
+ /*
+ * The timestamp of the message
+ */
+ @JsonProperty("TimeStamp")
+ private String timeStamp;
+
+ /*
+ * The API version of the message
+ */
+ @JsonProperty("APIver")
+ private String apiVer;
+
+ /*
+ * The Originator ID of the message
+ */
+ @JsonProperty("OriginatorID")
+ private String originatorId;
+
+ /*
+ * The Request Id of the message
+ */
+ @JsonProperty("RequestID")
+ private String requestID;
+
+ /*
+ * The Subrequest Id of the message
+ */
+ @JsonProperty("SubRequestID")
+ private String subRequestId;
+
+ /**
+ * @return the timeStamp
+ */
+ public String getTimeStamp() {
+ return timeStamp;
+ }
+
+ /**
+ * @param timeStamp
+ * the timeStamp to set
+ */
+ public void setTimeStamp(String timeStamp) {
+ this.timeStamp = timeStamp;
+ }
+
+ /**
+ * @return the apiVer
+ */
+ public String getApiVer() {
+ return apiVer;
+ }
+
+ /**
+ * @param apiVer
+ * the apiVer to set
+ */
+ public void setApiVer(String apiVer) {
+ this.apiVer = apiVer;
+ }
+
+ /**
+ * @return the originatorId
+ */
+ public String getOriginatorId() {
+ return originatorId;
+ }
+
+ /**
+ * @param originatorId
+ * the originatorId to set
+ */
+ public void setOriginatorId(String originatorId) {
+ this.originatorId = originatorId;
+ }
+
+ /**
+ * @return the requestID
+ */
+ public String getRequestID() {
+ return requestID;
+ }
+
+ /**
+ * @param requestID
+ * the requestID to set
+ */
+ public void setRequestID(String requestID) {
+ this.requestID = requestID;
+ }
+
+ /**
+ * @return the subRequestId
+ */
+ public String getSubRequestId() {
+ return subRequestId;
+ }
+
+ /**
+ * @param subRequestId
+ * the subRequestId to set
+ */
+ public void setSubRequestId(String subRequestId) {
+ this.subRequestId = subRequestId;
+ }
+ };
+
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ public static class Payload {
+ /*
+ * "Payload": { "VServerSelfLink":
+ * "http://192.168.1.2:8774/v2/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345",
+ * "VNF_NAME": "test", "VMID": "abc12345-1234-5678-890a-abcdefg12345", "TenantID":
+ * "abcde12345fghijk6789lmnopq123rst", "LOC_ID": "Test", "in-maint": "false", "Identity":
+ * "http://example.com:5000/v2.0", "Prov_status": "ACTIVE", "OAM_IPV4": "192.168.1.2",
+ * "is-closed-loop-disabled": "false", "VM_NAME": "test", "OAM_IPV6": "aaaa::bbbb:cccc:dddd:eeee/64" }
+ */
+
+ /*
+ * The TenantID of the message
+ */
+ @JsonProperty("generic-vnf.vnf-id")
+ private String genericVnfId;
+
+ /**
+ * @return the TenantID
+ */
+ public String getGenericVnfId() {
+ return genericVnfId;
+ }
+
+ /**
+ * @param TenantID
+ * the TenantID to set
+ */
+ public void setGenericVnfId(String genericVnfId) {
+ this.genericVnfId = genericVnfId;
+ }
+
+ @JsonProperty("streams")
+ private Streams streams;
+
+ /**
+ * @return the TenantID
+ */
+
+ public String getStreams() {
+ String r = "{\\\"streams\\\": {\\\"active-streams\\\": " + streams.getActiveStreams() +
+ "}}";
+ return r;
+ }
+
+ /**
+ * @param TenantID
+ * the TenantID to set
+ */
+ public void setStreams(Streams streams) {
+ this.streams = streams;
+ }
+
+
+
+
+
+ };
+ @JsonIgnoreProperties(ignoreUnknown = true)
+ public static class Streams {
+
+ @JsonProperty("active-streams")
+ private int activeStreams;
+
+ public int getActiveStreams() {
+ return this.activeStreams;
+ }
+
+ public void setActiveStreams(int activeStreams) {
+ this.activeStreams = activeStreams;
+ }
+
+ };
+
+}
diff --git a/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/model/IncomingMessage.java b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/model/IncomingMessage.java
new file mode 100644
index 000000000..bff1f3bc7
--- /dev/null
+++ b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/model/IncomingMessage.java
@@ -0,0 +1,90 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2018 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.
+ *
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.listener.demo.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion;
+
+/**
+ * This class represents a message coming in from DCAE.
+ *
+ */
+@JsonSerialize(include = Inclusion.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class IncomingMessage extends CommonMessage {
+
+ private static final long serialVersionUID = 1L;
+
+ /*
+ * The action being requested. Its presence signals that it is an incoming message and it is not present on outgoing
+ * messages
+ */
+ //TODO; use enum
+ @JsonProperty("Action")
+ private String action;
+
+
+ public String getRequest() {
+ return action;
+ }
+
+ @JsonIgnore
+ public Action getAction() {
+ return Action.toAction(action);
+ }
+
+ public void setRequest(String request) {
+ this.action = request;
+ }
+
+// @Override
+// public String toString() {
+// String time = getRequestTime() != null ? getRequestTime() : "N/A";
+// // String req = request != null ? request : "N/A";
+// return String.format("[%s - %s]", time, getId());
+// }
+
+// public String toOutgoing(Status status) {
+// return toOutgoing(status);
+// }
+
+ public String toOutgoing(Status status) {
+ OutgoingMessage out = new OutgoingMessage(this);
+ out.setResponse(status);
+ return out.toResponse().toString();
+ }
+
+ /**
+ * Determines if this message should be parsed parsed. Will eventually check that the message is well formed, has
+ * all required fields, and had not exceeded any timing restrictions.
+ *
+ * @return True if the message should be parsed. False otherwise
+ */
+ public boolean isValid() {
+ return true;
+ }
+}
diff --git a/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/model/OutgoingMessage.java b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/model/OutgoingMessage.java
new file mode 100644
index 000000000..100d55bf2
--- /dev/null
+++ b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/model/OutgoingMessage.java
@@ -0,0 +1,202 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
+ * =============================================================================
+ * 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.onap.appc.listener.demo.model;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.security.SecureRandom;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+
+import org.json.JSONObject;
+import org.onap.appc.listener.util.Mapper;
+import org.onap.appc.util.Time;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion;
+
+/**
+ * This class represents a message being sent out to DMaaP by APPC to update listeners on the status of a request
+ *
+ */
+@JsonSerialize(include = Inclusion.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class OutgoingMessage extends CommonMessage {
+
+ public OutgoingMessage() {
+
+ }
+
+ public OutgoingMessage(IncomingMessage msg) {
+ setHeader(msg.getHeader());
+ setPayload(msg.getPayload());
+ // setId(msg.getId());
+ // setOriginalRequest(msg.getRequest());
+ // setRequestClient(msg.getRequestClient());
+ // setRequestTime(msg.getRequestTime());
+ // setVmName(msg.getVmName());
+ // setFromSystem(generateFrom());
+ // setResponse(Status.PENDING);
+ // setPolicyName(msg.getPolicyName());
+ // setPolicyVersion(msg.getPolicyVersion());
+ // setStartTime(msg.getStartTime());
+ }
+
+ private static final long serialVersionUID = -5447940920271469613L;
+ /*
+ * The status of the response
+ */
+ @JsonProperty("Status")
+ private OutStatus status;
+
+ /**
+ * @return the status
+ */
+ public OutStatus getStatus() {
+ return status;
+ }
+
+ /**
+ * @param status the status to set
+ */
+ public void setStatus(OutStatus status) {
+ this.status = status;
+ }
+
+ public void updateResponseTime() {
+ SecureRandom rand = new SecureRandom();
+ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss.SSS");
+ df.setTimeZone(TimeZone.getTimeZone("UTC"));
+ String date = df.format(new Date(Time.utcTime()));
+ //this.responseTime = String.format("%s%03d", date, rand.nextInt(1000));
+ }
+
+ public String generateFrom() {
+ String name;
+ try {
+ InetAddress iAddress = getLocalHost();
+ name = iAddress.getCanonicalHostName();
+ } catch (Exception e) {
+ // Could not get anything from the InetAddress
+ name = "UnknownHost";
+ }
+ return "appc@" + name;
+ }
+
+ public JSONObject toResponse() {
+ updateResponseTime();
+ JSONObject json = Mapper.toJsonObject(this);
+
+ if (!json.has("message")) {
+ // If there is no message, parrot the status (response field)
+ // TODO - Can this be removed for 1602 making message truely optional?
+ //json.put("message", this.getResponse().toString());
+ }
+
+ // Removed duplication of status from message for 1602
+ // json.put("message", String.format("%s: %s", request, json.get("message")));
+
+ return json;
+ }
+
+ // @Override
+ // public String toString() {
+ // return String.format("%s - %s", getId(), getResponse());
+ // }
+
+ public static class OutStatus{
+ @JsonProperty("Code")
+ private String code;
+
+ @JsonProperty("Value")
+ private String value;
+
+ /**
+ * @return the code
+ */
+ public String getCode() {
+ return code;
+ }
+
+ /**
+ * @param code the code to set
+ */
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ /**
+ * @return the value
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * @param value the value to set
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ }
+
+ public void setResponse(Status newStatus) {
+ if(this.status == null){
+ this.status = new OutStatus();
+ }
+ if(newStatus == null) {
+ return;
+ }
+
+ switch (newStatus){
+ case ACCEPTED:
+ this.status.setValue(newStatus.getValue());
+ this.status.setCode("100");
+ break;
+
+ case FAILURE:
+ this.status.setValue(newStatus.getValue());
+ this.status.setCode("500");
+ break;
+
+ case SUCCESS:
+ this.status.setValue(newStatus.getValue());
+ this.status.setCode("400");
+ break;
+ default:
+ break;
+
+ }
+ }
+
+ protected InetAddress getLocalHost() throws UnknownHostException {
+ return InetAddress.getLocalHost();
+ }
+}
diff --git a/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/model/Status.java b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/model/Status.java
new file mode 100644
index 000000000..a4abeac60
--- /dev/null
+++ b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/demo/model/Status.java
@@ -0,0 +1,71 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2018 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.
+ *
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.listener.demo.model;
+
+public enum Status {
+ /*
+ * APP-C acknowledges that it has read the event off of the wire. This is the initial status of an OutgoingEvent
+ */
+ ACCEPTED("ACCEPTED"),
+
+ /*
+ * APP-C has finished processing the event without errors
+ */
+ SUCCESS("SUCCESS"),
+
+ /*
+ * APP-C has finished processing the event with errors
+ */
+ FAILURE("FAILURE");
+
+ /**
+ * Converts the string to an Status
+ *
+ * @param value
+ * The string to try and convert. Is case insensitive
+ * @return The status matching the string or null if no match was found.
+ */
+ public static Status toStatus(String value) {
+ if (value != null) {
+ for (Status e : values()) {
+ if (e.getValue().toUpperCase().equals(value.toUpperCase())) {
+ return e;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ private String value;
+
+ private Status(String valueToUse) {
+ value = valueToUse;
+ }
+
+ public final String getValue() {
+ return value;
+ }
+
+}
diff --git a/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/impl/ControllerImpl.java b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/impl/ControllerImpl.java
new file mode 100644
index 000000000..d1c5d61c2
--- /dev/null
+++ b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/impl/ControllerImpl.java
@@ -0,0 +1,146 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
+ * =============================================================================
+ * 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.onap.appc.listener.impl;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.commons.lang3.concurrent.BasicThreadFactory;
+import org.onap.appc.listener.Controller;
+import org.onap.appc.listener.Listener;
+import org.onap.appc.listener.ListenerProperties;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+
+/**
+ * A common implementation of a controller. This controller should not need to be modified to implement new listeners
+ *
+ */
+public class ControllerImpl implements Controller {
+
+ private final EELFLogger LOG = EELFManager.getInstance().getLogger(ControllerImpl.class);
+
+ private int LISTENER_COUNT = 1;
+
+ private Map<ListenerProperties, Listener> listeners = null;
+
+ private ThreadPoolExecutor executor;
+
+ /**
+ * Creates a Controller with the set of listener properties which will be used to start listener threads.
+ *
+ * @param properties
+ * A non null Set of ListenerProperties
+ */
+ public ControllerImpl(Set<ListenerProperties> properties) {
+ listeners = new HashMap<ListenerProperties, Listener>();
+ for (ListenerProperties props : properties) {
+ if (props.getListenerClass() != null) {
+ listeners.put(props, null);
+ } else {
+ LOG.error(String.format(
+ "The ListenerProperties %s has no Listener class associated with it and will not run.", props));
+ properties.remove(props);
+ }
+ }
+
+ LISTENER_COUNT = properties.size();
+
+ // Only create executor if listeners are configured
+ if (LISTENER_COUNT > 0) {
+ executor = new ThreadPoolExecutor(LISTENER_COUNT, LISTENER_COUNT, 1, TimeUnit.SECONDS,
+ new ArrayBlockingQueue<Runnable>(LISTENER_COUNT));
+
+ // Custom Named thread factory
+ BasicThreadFactory threadFactory = new BasicThreadFactory.Builder().namingPattern("Appc-Listener-%d").build();
+ executor.setThreadFactory(threadFactory);
+ }
+ }
+
+ @Override
+ public void start() {
+ LOG.info("Starting DMaaP Controller.");
+ for (ListenerProperties props : listeners.keySet()) {
+ try {
+ if (props.isDisabled()) {
+ LOG.warn(String.format("The listener %s is disabled and will not be run", props.getPrefix()));
+ } else {
+ Listener l = props.getListenerClass().getConstructor(ListenerProperties.class).newInstance(props);
+ l.setListenerId(props.getPrefix());
+ listeners.put(props, l);
+ executor.execute(l);
+ }
+ } catch (Exception e) {
+ LOG.error(String.format("Exception while starting listener %s.", props), e);
+ }
+ }
+ }
+
+ @Override
+ public void stop(boolean stopNow) {
+ LOG.info("Stopping DMaaP Controller.");
+ Iterator<Listener> itr = listeners.values().iterator();
+ while (itr.hasNext()) {
+ Listener l = itr.next();
+ if (stopNow && l != null) {
+ l.stopNow();
+ } else if(l != null){
+ l.stop();
+ }
+ itr.remove();
+ }
+ // disable new tasks from being submitted
+ if(executor != null) {
+ executor.shutdown();
+ int timeout = 300;
+ try {
+ if (!executor.awaitTermination(timeout, TimeUnit.SECONDS)) {
+ LOG.error("Not all tasks completed execution after " + timeout + " seconds. " +
+ "Attempting to stop all actively executing tasks.");
+ executor.shutdownNow();
+ }
+ if (!executor.awaitTermination(timeout, TimeUnit.SECONDS)) {
+ LOG.error("Could not terminate all tasks after " + (timeout * 2) + " seconds.");
+ }
+ } catch (InterruptedException e) {
+ executor.shutdownNow();
+ Thread.currentThread().interrupt();
+ }
+ }
+ }
+
+ @Override
+ public Map<ListenerProperties, Listener> getListeners() {
+ return listeners;
+ }
+}
diff --git a/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/impl/EventHandlerImpl.java b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/impl/EventHandlerImpl.java
new file mode 100644
index 000000000..117901ca1
--- /dev/null
+++ b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/impl/EventHandlerImpl.java
@@ -0,0 +1,400 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
+ * =============================================================================
+ * 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.onap.appc.listener.impl;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+import org.onap.appc.adapter.factory.MessageService;
+import org.onap.appc.adapter.message.Consumer;
+import org.onap.appc.adapter.message.Producer;
+import org.onap.appc.adapter.messaging.dmaap.http.HttpDmaapConsumerImpl;
+import org.onap.appc.adapter.messaging.dmaap.http.HttpDmaapProducerImpl;
+import org.onap.appc.listener.EventHandler;
+import org.onap.appc.listener.ListenerProperties;
+import org.onap.appc.listener.util.Mapper;
+import org.onap.appc.logging.LoggingConstants;
+import org.slf4j.MDC;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+
+/**
+ * This class is a wrapper for the DMaaP client provided in appc-dmaap-adapter. Its aim is to ensure
+ * that only well formed messages are sent and received on DMaaP.
+ */
+public class EventHandlerImpl implements EventHandler {
+
+ private final EELFLogger LOG = EELFManager.getInstance().getLogger(EventHandlerImpl.class);
+
+ /*
+ * The amount of time in seconds to keep a connection to a topic open while waiting for data
+ */
+ private int READ_TIMEOUT = 60;
+
+ /*
+ * The pool of hosts to query against
+ */
+ private Collection<String> pool;
+
+ /*
+ * The topic to read messages from
+ */
+ private String readTopic;
+
+ /*
+ * The topic to write messages to
+ */
+ private String writeTopic;
+
+ /*
+ * The client (group) name to use for reading messages
+ */
+ private String clientName;
+
+ /*
+ * The id of the client (group) that is reading messages
+ */
+ private String clientId;
+
+ /*
+ * The api public key to use for authentication
+ */
+ private String apiKey;
+
+ /*
+ * The api secret key to use for authentication
+ */
+ private String apiSecret;
+
+ /*
+ * A json object containing filter arguments.
+ */
+ private String filter_json;
+
+
+ /*
+ * Blacklist time for a server with response problem in seconds
+ */
+ private String responseProblemBlacklistTime;
+
+ /*
+ * Blacklist time for a server with server problem in seconds
+ */
+ private String serverProblemBlacklistTime;
+
+ /*
+ * Blacklist time for a server with DNS problem in seconds
+ */
+ private String dnsIssueBlacklistTime;
+
+ /*
+ * Blacklist time for a server with IO Exception problem in seconds
+ */
+ private String ioExceptionBlacklistTime;
+
+ private MessageService messageService;
+
+ private Consumer reader = null;
+ private Producer producer = null;
+
+ public EventHandlerImpl(ListenerProperties props) {
+ pool = new HashSet<>();
+
+ if (props != null) {
+ readTopic = props.getProperty(ListenerProperties.KEYS.TOPIC_READ);
+ clientName = props.getProperty(ListenerProperties.KEYS.CLIENT_NAME, "APP-C");
+ clientId = props.getProperty(ListenerProperties.KEYS.CLIENT_ID, "0");
+ apiKey = props.getProperty(ListenerProperties.KEYS.AUTH_USER_KEY);
+ apiSecret = props.getProperty(ListenerProperties.KEYS.AUTH_SECRET_KEY);
+ responseProblemBlacklistTime = props.getProperty(ListenerProperties.KEYS.PROBLEM_WITH_RESPONSE_BLACKLIST_TIME);
+ serverProblemBlacklistTime = props.getProperty(ListenerProperties.KEYS.PROBLEM_SERVERSIDE_ERROR_BLACKLIST_TIME);
+ dnsIssueBlacklistTime = props.getProperty(ListenerProperties.KEYS.PROBLEM_DNS_BLACKLIST_TIME);
+ ioExceptionBlacklistTime = props.getProperty(ListenerProperties.KEYS.PROBLEM_IO_EXCEPTION_BLACKLIST_TIME);
+
+ filter_json = props.getProperty(ListenerProperties.KEYS.TOPIC_READ_FILTER);
+
+ READ_TIMEOUT = Integer
+ .valueOf(props.getProperty(ListenerProperties.KEYS.TOPIC_READ_TIMEOUT, String.valueOf(READ_TIMEOUT)));
+
+ String hostnames = props.getProperty(ListenerProperties.KEYS.HOSTS);
+ if (hostnames != null && !hostnames.isEmpty()) {
+ for (String name : hostnames.split(",")) {
+ pool.add(name);
+ }
+ }
+
+ String writeTopicStr = props.getProperty(ListenerProperties.KEYS.TOPIC_WRITE);
+ if (writeTopicStr != null) {
+ for (String topic : writeTopicStr.split(",")) {
+ writeTopic = topic;
+ }
+ }
+
+ messageService = MessageService.parse(props.getProperty(ListenerProperties.KEYS.MESSAGE_SERVICE));
+
+ LOG.info(String.format(
+ "Configured to use %s client on host pool [%s]. Reading from [%s] filtered by %s. Writing to [%s]. Authenticated using %s",
+ messageService, hostnames, readTopic, filter_json, writeTopic, apiKey));
+ }
+ }
+
+ @Override
+ public List<String> getIncomingEvents() {
+ return getIncomingEvents(1000);
+ }
+
+ @Override
+ public List<String> getIncomingEvents(int limit) {
+ List<String> out = new ArrayList<>();
+ LOG.info(String.format("Getting up to %d incoming events", limit));
+ // reuse the consumer object instead of creating a new one every time
+ if (reader == null) {
+ LOG.info("Getting Consumer...");
+ reader = getConsumer();
+ }
+ if (reader != null) {
+ List<String> items = reader.fetch(READ_TIMEOUT * 1000, limit);
+ for (String item : items) {
+ out.add(item);
+ }
+ }
+ LOG.info(String.format("Read %d messages from %s as %s/%s.", out.size(), readTopic, clientName, clientId));
+ return out;
+ }
+
+ @Override
+ public <T> List<T> getIncomingEvents(Class<T> cls) {
+ return getIncomingEvents(cls, 1000);
+ }
+
+ @Override
+ public <T> List<T> getIncomingEvents(Class<T> cls, int limit) {
+ List<String> incomingStrings = getIncomingEvents(limit);
+ return Mapper.mapList(incomingStrings, cls);
+ }
+
+ @Override
+ public void postStatus(String event) {
+ postStatus(null, event);
+ }
+
+ @Override
+ public void postStatus(String partition, String event) {
+ LOG.debug(String.format("Posting Message [%s]", event));
+ if (producer == null) {
+ LOG.info("Getting Producer...");
+ producer = getProducer();
+ }
+ producer.post(partition, event);
+ }
+
+ /**
+ * Returns a consumer object for direct access to our Cambria consumer interface
+ *
+ * @return An instance of the consumer interface
+ */
+ protected Consumer getConsumer() {
+ LOG.debug(String.format("Getting Consumer: %s %s/%s/%s", pool, readTopic, clientName, clientId));
+ if (filter_json == null && writeTopic.equals(readTopic)) {
+ LOG.error(
+ "*****We will be writing and reading to the same topic without a filter. This will cause an infinite loop.*****");
+ }
+
+ Consumer out = null;
+ out = new HttpDmaapConsumerImpl(pool, readTopic, clientName, clientId, filter_json, apiKey, apiSecret);
+
+ if (out != null && responseProblemBlacklistTime != null && responseProblemBlacklistTime.length() > 0)
+ {
+ out.setResponseProblemBlacklistTime(responseProblemBlacklistTime);
+ }
+
+ if (out != null && serverProblemBlacklistTime != null && serverProblemBlacklistTime.length() > 0)
+ {
+ out.setServerProblemBlacklistTime(serverProblemBlacklistTime);
+ }
+
+ if (out != null && dnsIssueBlacklistTime != null && dnsIssueBlacklistTime.length() > 0)
+ {
+ out.setDnsIssueBlacklistTime(dnsIssueBlacklistTime);
+ }
+
+ if (out != null && ioExceptionBlacklistTime != null && ioExceptionBlacklistTime.length() > 0)
+ {
+ out.setIOExceptionBlacklistTime(ioExceptionBlacklistTime);
+ }
+ if (out != null) {
+ for (String url : pool) {
+ if (url.contains("3905") || url.contains("https")) {
+ out.useHttps(true);
+ break;
+ }
+ }
+ }
+ return out;
+ }
+
+ /**
+ * Returns a consumer object for direct access to our Cambria producer interface
+ *
+ * @return An instance of the producer interface
+ */
+ protected Producer getProducer() {
+ LOG.debug(String.format("Getting Producer: %s %s", pool, readTopic));
+
+ Producer out = null;
+ out = new HttpDmaapProducerImpl(pool, writeTopic, apiKey, apiSecret);
+ if (out != null && responseProblemBlacklistTime != null && responseProblemBlacklistTime.length() > 0)
+ {
+ out.setResponseProblemBlacklistTime(responseProblemBlacklistTime);
+ }
+
+ if (out != null && serverProblemBlacklistTime != null && serverProblemBlacklistTime.length() > 0)
+ {
+ out.setServerProblemBlacklistTime(serverProblemBlacklistTime);
+ }
+
+ if (out != null && dnsIssueBlacklistTime != null && dnsIssueBlacklistTime.length() > 0)
+ {
+ out.setDnsIssueBlacklistTime(dnsIssueBlacklistTime);
+ }
+
+ if (out != null && ioExceptionBlacklistTime != null && ioExceptionBlacklistTime.length() > 0)
+ {
+ out.setIOExceptionBlacklistTime(ioExceptionBlacklistTime);
+ }
+ if (out != null) {
+ for (String url : pool) {
+ if (url.contains("3905") || url.contains("https")) {
+ out.useHttps(true);
+ break;
+ }
+ }
+ }
+ return out;
+ }
+
+ @Override
+ public void closeClients() {
+ LOG.debug("Closing Consumer and Producer DMaaP clients");
+ if (reader != null) {
+ reader.close();
+ }
+ if (producer != null) {
+ producer.close();
+ }
+ }
+
+ @Override
+ public String getClientId() {
+ return clientId;
+ }
+
+ @Override
+ public void setClientId(String clientId) {
+ this.clientId = clientId;
+ }
+
+ @Override
+ public String getClientName() {
+ return clientName;
+ }
+
+ @Override
+ public void setClientName(String clientName) {
+ this.clientName = clientName;
+ MDC.put(LoggingConstants.MDCKeys.PARTNER_NAME, clientName);
+ }
+
+ @Override
+ public void addToPool(String hostname) {
+ pool.add(hostname);
+ }
+
+ @Override
+ public Collection<String> getPool() {
+ return pool;
+ }
+
+ @Override
+ public void removeFromPool(String hostname) {
+ pool.remove(hostname);
+ }
+
+ @Override
+ public String getReadTopic() {
+ return readTopic;
+ }
+
+ @Override
+ public void setReadTopic(String readTopic) {
+ this.readTopic = readTopic;
+ }
+
+ @Override
+ public String getWriteTopic() {
+ return writeTopic;
+ }
+
+ @Override
+ public void setWriteTopic(String writeTopic) {
+ this.writeTopic = writeTopic;
+ }
+
+ @Override
+ public void setResponseProblemBlacklistTime(String duration){
+ this.responseProblemBlacklistTime = duration;
+ }
+
+ @Override
+ public void setServerProblemBlacklistTime(String duration){
+ this.serverProblemBlacklistTime = duration;
+ }
+
+ @Override
+ public void setDnsIssueBlacklistTime(String duration){
+ this.dnsIssueBlacklistTime = duration;
+ }
+
+ @Override
+ public void setIOExceptionBlacklistTime(String duration){
+ this.ioExceptionBlacklistTime = duration;
+ }
+
+ @Override
+ public void clearCredentials() {
+ apiKey = null;
+ apiSecret = null;
+ }
+
+ @Override
+ public void setCredentials(String key, String secret) {
+ apiKey = key;
+ apiSecret = secret;
+ }
+}
diff --git a/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/util/HttpClientUtil.java b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/util/HttpClientUtil.java
new file mode 100644
index 000000000..2b8e887bf
--- /dev/null
+++ b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/util/HttpClientUtil.java
@@ -0,0 +1,126 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Ericsson. 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.listener.util;
+
+import java.io.IOException;
+import java.net.Socket;
+import java.net.UnknownHostException;
+import java.security.KeyManagementException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import org.apache.http.HttpVersion;
+import org.apache.http.client.HttpClient;
+import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.conn.scheme.PlainSocketFactory;
+import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.scheme.SchemeRegistry;
+import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
+import org.apache.http.params.BasicHttpParams;
+import org.apache.http.params.HttpParams;
+import org.apache.http.params.HttpProtocolParams;
+import org.apache.http.protocol.HTTP;
+import org.onap.appc.exceptions.APPCException;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+@SuppressWarnings("deprecation")
+public class HttpClientUtil {
+
+ private static final EELFLogger log = EELFManager.getInstance().getLogger(HttpClientUtil.class);
+
+ public static HttpClient getHttpClient(String protocol) throws APPCException {
+ HttpClient client;
+ if ("https".equals(protocol)) {
+ try {
+ KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
+ trustStore.load(null, null);
+ MySSLSocketFactory sf = new MySSLSocketFactory(trustStore);
+ sf.setHostnameVerifier(MySSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+
+ HttpParams params = new BasicHttpParams();
+ HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
+ HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
+
+ SchemeRegistry registry = new SchemeRegistry();
+ registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
+ registry.register(new Scheme("https", sf, 443));
+ registry.register(new Scheme("https", sf, 8443));
+ registry.register(new Scheme("http", sf, 8181));
+
+ ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry);
+ client = new DefaultHttpClient(ccm, params);
+ } catch (Exception e) {
+ log.info("Creating Default Http Client with no params " + e.getMessage(), e);
+ client = new DefaultHttpClient();
+ }
+ } else if ("http".equals(protocol)) {
+ client = new DefaultHttpClient();
+ } else {
+ throw new APPCException(
+ "The provider.topology.url property is invalid. The url did not start with http[s]");
+ }
+ return client;
+ }
+
+ private static class MySSLSocketFactory extends SSLSocketFactory {
+ private SSLContext sslContext = SSLContext.getInstance("TLS");
+
+ public MySSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException,
+ KeyManagementException, KeyStoreException, UnrecoverableKeyException {
+ super(truststore);
+
+ TrustManager tm = new X509TrustManager() {
+ @Override
+ public void checkClientTrusted(X509Certificate[] chain, String authType)
+ throws CertificateException {}
+
+ @Override
+ public void checkServerTrusted(X509Certificate[] chain, String authType)
+ throws CertificateException {}
+
+ @Override
+ public X509Certificate[] getAcceptedIssuers() {
+ return null;
+ }
+ };
+
+ sslContext.init(null, new TrustManager[] {tm}, null);
+ }
+
+ @Override
+ public Socket createSocket(Socket socket, String host, int port, boolean autoClose)
+ throws IOException, UnknownHostException {
+ return sslContext.getSocketFactory().createSocket(socket, host, port, autoClose);
+ }
+
+ @Override
+ public Socket createSocket() throws IOException {
+ return sslContext.getSocketFactory().createSocket();
+ }
+ }
+}
diff --git a/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/util/Mapper.java b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/util/Mapper.java
new file mode 100644
index 000000000..b9a6a4cc8
--- /dev/null
+++ b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/java/org/onap/appc/listener/util/Mapper.java
@@ -0,0 +1,136 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
+ * =============================================================================
+ * 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.onap.appc.listener.util;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import org.json.JSONObject;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class Mapper {
+
+ private static final EELFLogger LOG = EELFManager.getInstance().getLogger(Mapper.class);
+
+ private static ObjectMapper mapper = new ObjectMapper();
+
+ /**
+ * @return The object mapper that we are using.
+ */
+ public static ObjectMapper getMapper() {
+ return mapper;
+ }
+
+ /**
+ * Convert a String to a DcaeMessage
+ *
+ * @param data
+ * The json string to try and parse
+ * @return A DcaeMessage from the json string or null if it could not
+ */
+ public static <T> T mapOne(String data, Class<T> cls) {
+ try {
+ return mapper.readValue(data, cls);
+ } catch (Exception e) {
+ LOG.warn(String.format("Could not map [ %s ] to %s", data, cls.getName()), e);
+ return null;
+ }
+ }
+
+ public static <T> List<T> mapList(List<String> data, Class<T> cls) {
+ List<T> out = new ArrayList<T>();
+ for (String s : data) {
+ T tmp = Mapper.mapOne(s, cls);
+ if (tmp != null) {
+ out.add(tmp);
+ }
+ }
+ return out;
+ }
+
+ /**
+ * Convenience method to try and convert objects to json String
+ *
+ * @param obj
+ * The object to try and convert
+ * @return A json string representing the object or null if it could not be converted
+ */
+ public static String toJsonString(Object obj) {
+ String jsonStr;
+ try {
+ if (obj instanceof JSONObject) {
+ jsonStr = obj.toString();
+ }else {
+ jsonStr = mapper.writeValueAsString(obj);
+ }
+ return jsonStr;
+ } catch (Exception e) {
+ LOG.warn(String.format("Could not map %s to JSONObject.", obj), e);
+ return null;
+ }
+ }
+
+ public static JSONObject toJsonObject(Object obj) {
+ String jsonStr;
+ try {
+ if (obj.getClass().equals(String.class)) {
+ jsonStr = (String) obj;
+ } else {
+ jsonStr = mapper.writeValueAsString(obj);
+ }
+ return new JSONObject(jsonStr);
+ } catch (Exception e) {
+ LOG.warn(String.format("Could not map %s to JSONObject.", obj), e);
+ return null;
+ }
+ }
+ public static JsonNode toJsonNodeFromJsonString(String jsonStr) {
+ JsonNode jsonNode = null;
+ if(jsonStr != null) {
+ try {
+ jsonNode = mapper.readTree(jsonStr);
+ } catch (IOException e) {
+ LOG.warn(String.format("Could not map %s to jsonNode.", jsonStr), e);
+ }
+ }
+ return jsonNode;
+ }
+ public static JsonNode toJsonNode(Object obj) {
+ JsonNode jsonNode = null;
+ String jsonStr = toJsonString(obj);
+ if(jsonStr != null) {
+ try {
+ jsonNode = mapper.readTree(jsonStr);
+ } catch (IOException e) {
+ LOG.warn(String.format("Could not map %s to JSONObject.", obj), e);
+ }
+ }
+ return jsonNode;
+ }
+}
diff --git a/services/appc-dmaap-service/appc-event-listener-bundle/src/main/resources/org/onap/appc/default.properties b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/resources/org/onap/appc/default.properties
new file mode 100644
index 000000000..ba4c5239a
--- /dev/null
+++ b/services/appc-dmaap-service/appc-event-listener-bundle/src/main/resources/org/onap/appc/default.properties
@@ -0,0 +1,113 @@
+###
+# ============LICENSE_START=======================================================
+# ONAP : APPC
+# ================================================================================
+# Copyright (C) 2017-2018 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.
+#
+# ============LICENSE_END=========================================================
+###
+
+# ${user.home} usually goes to /root if instantiation uses the appc-docker approach
+
+### ###
+### ###
+###Properties below that are commented out are/need to be provided in appc.properties###
+### ###
+### ###
+
+
+
+
+# Define the name and path of any user-provided configuration (bootstrap) file that can be loaded to supply configuration options
+org.onap.appc.bootstrap.file=appc.properties
+org.onap.appc.bootstrap.path=/opt/onap/appc/data/properties,${user.home},.
+
+
+
+
+
+### ###
+###Closed Loop - properties ###
+### ###
+appc.ClosedLoop.poolMembers=192.168.1.2:3904
+appc.ClosedLoop.topic.read=APPC-TEST2
+appc.ClosedLoop.topic.write=APPC-TEST2
+appc.ClosedLoop.topic.read.filter={"class": "And","filters": [{"class": "Assigned","field": "request"},{"class": "Unassigned","field": "response"}]}
+appc.ClosedLoop.client.name=APPC-TEST-CLIENT-EVT-LST-MAIN
+appc.ClosedLoop.client.name.id=0
+
+# KEY AND SECRET BELOW NEED TO BE MODIFIED TO APPROPRIATE VALUES WHEN THE TOPIC IS API-KEY-BASED AUTH
+#dmaap.client.key=random
+#dmaap.client.secret=random
+
+appc.ClosedLoop.threads.queuesize.min=1
+appc.ClosedLoop.threads.queuesize.max=1000
+appc.ClosedLoop.threads.poolsize.min=1
+appc.ClosedLoop.threads.poolsize.max=2
+appc.ClosedLoop.provider.url=http://localhost:8181/restconf/operations/appc-provider
+appc.ClosedLoop.provider.url.user=ODL_USER
+appc.ClosedLoop.provider.url.pass=ODL_PASS
+
+
+
+
+
+### ###
+###Closed Loop - 1607 properties ###
+### ###
+appc.ClosedLoop1607.poolMembers=192.168.1.2:3904
+appc.ClosedLoop1607.topic.read=MY_DMAAP_TOPIC
+appc.ClosedLoop1607.topic.write=MY_DMAAP_TOPIC
+appc.ClosedLoop1607.topic.read.filter={"class":"Unassigned","field":"Status"}
+appc.ClosedLoop1607.client.name=MY_DMAAP_CLIENT_NAME
+appc.ClosedLoop1607.client.name.id=0
+#dmaap.client.key=random
+#dmaap.client.secret=random
+appc.ClosedLoop1607.threads.queuesize.min=1
+appc.ClosedLoop1607.threads.queuesize.max=1000
+appc.ClosedLoop1607.threads.poolsize.min=1
+appc.ClosedLoop1607.threads.poolsize.max=2
+appc.ClosedLoop.provider.user=ODL_USER
+appc.ClosedLoop.provider.pass=ODL_PASS
+appc.ClosedLoop1607.provider.url=http://localhost:8181/restconf/operations/appc-provider
+
+
+
+
+
+### ###
+### This needs to be changed so that the action can be appended to the end of the URL path ###
+### ###
+appc.LCM.provider.url=http://localhost:8181/restconf/operations/appc-provider
+appc.LCM.poolMembers=127.0.0.1:3001
+appc.LCM.topic.read=DMAAP_TOPIC
+appc.LCM.topic.write=DMAAP_TOPIC
+appc.LCM.client.name=DMAAP_CLIENT_NAME
+appc.LCM.provider.user=ODL_USER
+appc.LCM.provider.pass=ODL_URL
+
+appc.demo.poolMembers=127.0.0.1:3002
+appc.demo.topic.read=APPC-CL
+appc.demo.topic.write=APPC-CL
+appc.demo.client.name=appcDemoEventListener
+appc.demo.threads.queuesize.min=1
+appc.demo.threads.queuesize.max=1000
+appc.demo.threads.poolsize.min=1
+appc.demo.threads.poolsize.max=2
+appc.demo.provider.user=admin
+appc.demo.provider.pass=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U
+appc.demo.provider.url=http://192.168.55.12:8282/restconf/operations/appc-provider