VOL-743: Send ONU discover events to Kafka message bus

Change-Id: Ia2d1e3e0ae4f2b5384ae1a9d3c0adf8fbe47c321
diff --git a/api/src/main/java/org/opencord/olt/AccessDeviceEvent.java b/api/src/main/java/org/opencord/olt/AccessDeviceEvent.java
index 9c71084..3c189dd 100644
--- a/api/src/main/java/org/opencord/olt/AccessDeviceEvent.java
+++ b/api/src/main/java/org/opencord/olt/AccessDeviceEvent.java
@@ -18,6 +18,7 @@
 import org.onlab.packet.VlanId;
 import org.onosproject.event.AbstractEvent;
 import org.onosproject.net.DeviceId;
+import org.onosproject.net.Port;
 
 import java.util.Optional;
 
@@ -29,6 +30,8 @@
     private final Optional<VlanId> sVlan;
     private final Optional<VlanId> cVlan;
 
+    private final Optional<Port> port;
+
     public enum Type {
         /**
          * A subscriber was registered and provisioned.
@@ -48,8 +51,17 @@
         /**
          * An access device disconnected.
          */
-        DEVICE_DISCONNECTED
+        DEVICE_DISCONNECTED,
 
+        /**
+         * A new UNI port has been detected.
+         */
+        UNI_ADDED,
+
+        /**
+         * An existing UNI port was removed.
+         */
+        UNI_REMOVED
     }
 
     /**
@@ -69,6 +81,7 @@
         super(type, deviceId);
         this.sVlan = Optional.ofNullable(sVlanId);
         this.cVlan = Optional.ofNullable(cVlanId);
+        this.port = Optional.empty();
     }
 
     /**
@@ -89,9 +102,17 @@
         super(type, deviceId, time);
         this.sVlan = Optional.ofNullable(sVlanId);
         this.cVlan = Optional.ofNullable(cVlanId);
+        this.port = Optional.empty();
 
     }
 
+    public AccessDeviceEvent(Type type, DeviceId deviceId, Port port) {
+        super(type, deviceId);
+        this.sVlan = Optional.empty();
+        this.cVlan = Optional.empty();
+        this.port = Optional.ofNullable(port);
+    }
+
     public Optional<VlanId> sVlanId() {
         return sVlan;
     }
@@ -100,4 +121,8 @@
         return cVlan;
     }
 
+    public Optional<Port> port() {
+        return port;
+    }
+
 }
diff --git a/app/app.xml b/app/app.xml
index ec55db7..5d912fa 100644
--- a/app/app.xml
+++ b/app/app.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
-  ~ Copyright 2016-present Open Networking Foundation
+  ~ Copyright 2018-present Open Networking Foundation
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
@@ -21,4 +21,6 @@
     <description>${project.description}</description>
     <artifact>mvn:${project.groupId}/${project.artifactId}/${project.version}</artifact>
     <artifact>mvn:${project.groupId}/olt-api/${project.version}</artifact>
+    <artifact>mvn:${project.groupId}/olt-kafka/${project.version}</artifact>
+    <artifact>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.kafka-clients/1.1.0_1</artifact>
 </app>
diff --git a/app/features.xml b/app/features.xml
index a19b531..4c1b5f9 100644
--- a/app/features.xml
+++ b/app/features.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <!--
-  ~ Copyright 2016-present Open Networking Foundation
+  ~ Copyright 2018-present Open Networking Foundation
   ~
   ~ Licensed under the Apache License, Version 2.0 (the "License");
   ~ you may not use this file except in compliance with the License.
@@ -20,5 +20,7 @@
         <feature>onos-api</feature>
         <bundle>mvn:${project.groupId}/olt-api/${project.version}</bundle>
         <bundle>mvn:${project.groupId}/${project.artifactId}/${project.version}</bundle>
+        <bundle>mvn:${project.groupId}/olt-kafka/${project.version}</bundle>
+        <bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.kafka-clients/1.1.0_1</bundle>
     </feature>
 </features>
diff --git a/app/pom.xml b/app/pom.xml
index 7c99f45..62ee855 100644
--- a/app/pom.xml
+++ b/app/pom.xml
@@ -37,8 +37,14 @@
         <api.description>
             APIs for interacting with the CORD OLT application.
         </api.description>
+        <onos.app.name>org.opencord.olt</onos.app.name>
+        <onos.app.title>OLT Access Management</onos.app.title>
+        <onos.app.origin>OpenCord</onos.app.origin>
+        <onos.app.category>default</onos.app.category>
+        <onos.app.url>http://opencord.org</onos.app.url>
+        <onos.app.readme>CORD OLT Access management application</onos.app.readme>
 	<api.package>org.onosproject.olt.rest</api.package>
-	<olt.api.version>1.4.0-SNAPSHOT</olt.api.version>
+	<olt.api.version>${project.version}</olt.api.version>
     </properties>
 
     <dependencies>
@@ -49,6 +55,12 @@
         </dependency>
 
         <dependency>
+            <groupId>org.opencord</groupId>
+            <artifactId>olt-kafka</artifactId>
+            <version>${olt.api.version}</version>
+        </dependency>
+
+        <dependency>
             <groupId>org.onosproject</groupId>
             <artifactId>onos-cli</artifactId>
             <version>${onos.version}</version>
diff --git a/app/src/main/java/org/opencord/olt/impl/Olt.java b/app/src/main/java/org/opencord/olt/impl/Olt.java
index 8b71a0a..29f070f 100644
--- a/app/src/main/java/org/opencord/olt/impl/Olt.java
+++ b/app/src/main/java/org/opencord/olt/impl/Olt.java
@@ -182,10 +182,8 @@
 
         oltData.keySet().stream()
                 .flatMap(did -> deviceService.getPorts(did).stream())
-                .filter(p -> !oltData.get(p.element().id()).uplink().equals(p.number()))
-                .filter(p -> p.isEnabled())
-                .forEach(p -> processFilteringObjectives((DeviceId) p.element().id(),
-                                                         p.number(), true));
+                .filter(this::isUni)
+                .forEach(this::initializeUni);
 
         subscribers = storageService.<ConnectPoint, VlanId>consistentMapBuilder()
                 .withName(SUBSCRIBERS)
@@ -285,6 +283,16 @@
         return Maps.newHashMap(oltData);
     }
 
+    private void initializeUni(Port port) {
+        DeviceId deviceId = (DeviceId) port.element().id();
+
+        post(new AccessDeviceEvent(AccessDeviceEvent.Type.UNI_ADDED, deviceId, port));
+
+        if (port.isEnabled()) {
+            processFilteringObjectives(deviceId, port.number(), true);
+        }
+    }
+
     private void unprovisionSubscriber(DeviceId deviceId, PortNumber uplink,
                                        PortNumber subscriberPort, VlanId subscriberVlan,
                                        VlanId deviceVlan, Optional<VlanId> defaultVlan) {
@@ -559,6 +567,10 @@
         flowObjectiveService.filter(devId, igmp);
     }
 
+    private boolean isUni(Port port) {
+        return !oltData.get(port.element().id()).uplink().equals(port.number());
+    }
+
     private class InternalDeviceListener implements DeviceListener {
         @Override
         public void event(DeviceEvent event) {
@@ -570,9 +582,12 @@
                 //TODO: Port handling and bookkeeping should be improved once
                 // olt firmware handles correct behaviour.
                 case PORT_ADDED:
-                    if (!oltData.get(devId).uplink().equals(event.port().number()) &&
-                            event.port().isEnabled()) {
-                        processFilteringObjectives(devId, event.port().number(), true);
+                    if (!oltData.get(devId).uplink().equals(event.port().number())) {
+                        post(new AccessDeviceEvent(AccessDeviceEvent.Type.UNI_ADDED, devId, event.port()));
+
+                        if (event.port().isEnabled()) {
+                            processFilteringObjectives(devId, event.port().number(), true);
+                        }
                     }
                     break;
                 case PORT_REMOVED:
@@ -584,10 +599,14 @@
                                 event.port().number(),
                                 vlan, olt.vlan(), olt.defaultVlan());
                     }
-                    if (!oltData.get(devId).uplink().equals(event.port().number()) &&
-                            event.port().isEnabled()) {
-                        processFilteringObjectives(devId, event.port().number(), false);
+                    if (!oltData.get(devId).uplink().equals(event.port().number())) {
+                        if (event.port().isEnabled()) {
+                            processFilteringObjectives(devId, event.port().number(), false);
+                        }
+
+                        post(new AccessDeviceEvent(AccessDeviceEvent.Type.UNI_REMOVED, devId, event.port()));
                     }
+
                     break;
                 case PORT_UPDATED:
                     if (oltData.get(devId).uplink().equals(event.port().number())) {
@@ -603,9 +622,21 @@
                     post(new AccessDeviceEvent(
                             AccessDeviceEvent.Type.DEVICE_CONNECTED, devId,
                             null, null));
+
+                    // Send UNI_ADDED events for all existing ports
+                    deviceService.getPorts(devId).stream()
+                            .filter(Olt.this::isUni)
+                            .forEach(p -> post(new AccessDeviceEvent(
+                                    AccessDeviceEvent.Type.UNI_ADDED, devId, p)));
+
                     provisionDefaultFlows(devId);
                     break;
                 case DEVICE_REMOVED:
+                    deviceService.getPorts(devId).stream()
+                            .filter(Olt.this::isUni)
+                            .forEach(p -> post(new AccessDeviceEvent(
+                                    AccessDeviceEvent.Type.UNI_REMOVED, devId, p)));
+
                     post(new AccessDeviceEvent(
                             AccessDeviceEvent.Type.DEVICE_DISCONNECTED, devId,
                             null, null));
diff --git a/kafka/pom.xml b/kafka/pom.xml
new file mode 100644
index 0000000..bcc9d56
--- /dev/null
+++ b/kafka/pom.xml
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright 2018-present Open Networking Foundation
+  ~
+  ~ 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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <groupId>org.opencord</groupId>
+        <artifactId>olt</artifactId>
+        <version>1.4.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>olt-kafka</artifactId>
+
+    <packaging>bundle</packaging>
+    <description>Kafka event module for OLT application</description>
+
+      <dependencies>
+        <dependency>
+            <groupId>org.opencord</groupId>
+            <artifactId>olt-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicemix.bundles</groupId>
+            <artifactId>org.apache.servicemix.bundles.kafka-clients</artifactId>
+            <version>1.1.0_1</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.onosproject</groupId>
+                <artifactId>onos-maven-plugin</artifactId>
+                <version>1.11</version>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+                <version>1.21.0</version>
+                <executions>
+                    <execution>
+                        <id>generate-scr-srcdescriptor</id>
+                        <goals>
+                            <goal>scr</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <supportedProjectTypes>
+                        <supportedProjectType>bundle</supportedProjectType>
+                    </supportedProjectTypes>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/kafka/src/main/java/org/opencord/olt/kafka/KafkaIntegration.java b/kafka/src/main/java/org/opencord/olt/kafka/KafkaIntegration.java
new file mode 100644
index 0000000..60be6e6
--- /dev/null
+++ b/kafka/src/main/java/org/opencord/olt/kafka/KafkaIntegration.java
@@ -0,0 +1,258 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.
+ */
+package org.opencord.olt.kafka;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.kafka.clients.producer.KafkaProducer;
+import org.apache.kafka.clients.producer.ProducerRecord;
+import org.apache.kafka.common.serialization.StringSerializer;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.core.CoreService;
+import org.onosproject.net.AnnotationKeys;
+import org.onosproject.net.Port;
+import org.onosproject.net.config.ConfigFactory;
+import org.onosproject.net.config.NetworkConfigEvent;
+import org.onosproject.net.config.NetworkConfigListener;
+import org.onosproject.net.config.NetworkConfigRegistry;
+import org.onosproject.net.config.basics.SubjectFactories;
+import org.opencord.olt.AccessDeviceEvent;
+import org.opencord.olt.AccessDeviceListener;
+import org.opencord.olt.AccessDeviceService;
+import org.slf4j.Logger;
+
+import java.util.Properties;
+import java.util.concurrent.ExecutorService;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static java.util.concurrent.Executors.newSingleThreadExecutor;
+import static org.onlab.util.Tools.groupedThreads;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Sends access device events to an external system.
+ */
+@Component(immediate = true)
+public class KafkaIntegration {
+
+    private final Logger log = getLogger(getClass());
+    private static final Class<OltKafkaConfig>
+            OLT_KAFKA_CONFIG_CLASS = OltKafkaConfig.class;
+
+    private static final String APP_NAME = "org.opencord.olt";
+    private ApplicationId appId;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected CoreService coreService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected NetworkConfigRegistry configRegistry;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected AccessDeviceService accessDeviceService;
+
+    private static StringSerializer stringSerializer = new StringSerializer();
+
+    private KafkaProducer<String, String> kafkaProducer;
+
+    private InternalNetworkConfigListener configListener =
+            new InternalNetworkConfigListener();
+    private InternalAccessDeviceListener listener =
+            new InternalAccessDeviceListener();
+
+    private final ExecutorService executor = newSingleThreadExecutor(
+            groupedThreads(this.getClass().getSimpleName(), "events", log));
+
+    private ConfigFactory<ApplicationId, OltKafkaConfig> kafkaConfigFactory =
+            new ConfigFactory<ApplicationId, OltKafkaConfig>(
+                    SubjectFactories.APP_SUBJECT_FACTORY, OLT_KAFKA_CONFIG_CLASS,
+                    "kafka") {
+                @Override
+                public OltKafkaConfig createConfig() {
+                    return new OltKafkaConfig();
+                }
+            };
+
+    private static final String BOOTSTRAP_SERVERS = "bootstrap.servers";
+    private static final String RETRIES = "retries";
+    private static final String RECONNECT_BACKOFF = "reconnect.backoff.ms";
+    private static final String INFLIGHT_REQUESTS =
+            "max.in.flight.requests.per.connection";
+    private static final String ACKS = "acks";
+    private static final String KEY_SERIALIZER = "key.serializer";
+    private static final String VALUE_SERIALIZER = "value.serializer";
+    private static final String STRING_SERIALIZER =
+            stringSerializer.getClass().getCanonicalName();
+
+    private static final String ONU_TOPIC = "onu.events";
+
+    private static final String STATUS = "status";
+    private static final String SERIAL_NUMBER = "serial_number";
+    private static final String UNI_PORT_ID = "uni_port_id";
+    private static final String OF_DPID = "of_dpid";
+    private static final String ACTIVATED = "activated";
+
+    @Activate
+    public void activate() {
+        appId = coreService.registerApplication(APP_NAME);
+        configRegistry.registerConfigFactory(kafkaConfigFactory);
+        configRegistry.addListener(configListener);
+        accessDeviceService.addListener(listener);
+
+        configure();
+
+        log.info("Started");
+    }
+
+    @Deactivate
+    public void deactivate() {
+        accessDeviceService.removeListener(listener);
+        configRegistry.removeListener(configListener);
+        configRegistry.unregisterConfigFactory(kafkaConfigFactory);
+
+        executor.shutdownNow();
+
+        shutdownKafka();
+        log.info("Stopped");
+    }
+
+    private void configure() {
+        OltKafkaConfig config =
+                configRegistry.getConfig(appId, OLT_KAFKA_CONFIG_CLASS);
+        if (config == null) {
+            log.info("OLT Kafka config not found");
+            return;
+        }
+        configure(config);
+    }
+
+    private void configure(OltKafkaConfig config) {
+        checkNotNull(config);
+
+        Properties properties = new Properties();
+        properties.put(BOOTSTRAP_SERVERS, config.getBootstrapServers());
+        properties.put(RETRIES, config.getRetries());
+        properties.put(RECONNECT_BACKOFF, config.getReconnectBackoff());
+        properties.put(INFLIGHT_REQUESTS, config.getInflightRequests());
+        properties.put(ACKS, config.getAcks());
+        properties.put(KEY_SERIALIZER, STRING_SERIALIZER);
+        properties.put(VALUE_SERIALIZER, STRING_SERIALIZER);
+
+        startKafka(properties);
+    }
+
+    private void unconfigure() {
+        shutdownKafka();
+    }
+
+    private void startKafka(Properties properties) {
+        shutdownKafka();
+
+        // Kafka client doesn't play nice with the default OSGi classloader
+        // This workaround temporarily changes the thread's classloader so that
+        // the Kafka client can load the serializer classes.
+        ClassLoader original = Thread.currentThread().getContextClassLoader();
+        Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+        try {
+            kafkaProducer = new KafkaProducer<>(properties);
+        } finally {
+            Thread.currentThread().setContextClassLoader(original);
+        }
+    }
+
+    private void shutdownKafka() {
+        if (kafkaProducer != null) {
+            kafkaProducer.close();
+            kafkaProducer = null;
+        }
+    }
+
+    private void sendUniAddEvent(AccessDeviceEvent event) {
+        if (kafkaProducer == null) {
+            return;
+        }
+
+        Port port = event.port().get();
+        String serialNumber = port.annotations().value(AnnotationKeys.PORT_NAME);
+
+        ObjectMapper mapper = new ObjectMapper();
+
+        ObjectNode onuNode = mapper.createObjectNode();
+        onuNode.put(STATUS, ACTIVATED);
+        onuNode.put(SERIAL_NUMBER, serialNumber);
+        onuNode.put(UNI_PORT_ID, port.number().toLong());
+        onuNode.put(OF_DPID, port.element().id().toString());
+
+        if (log.isDebugEnabled()) {
+            log.debug("Sending UNI ADD event: {}", onuNode.toString());
+        }
+
+        kafkaProducer.send(new ProducerRecord<>(ONU_TOPIC, onuNode.toString()),
+                (r, e) -> logException(e));
+    }
+
+    private void logException(Exception e) {
+        if (e != null) {
+            log.error("Exception while sending to Kafka", e);
+        }
+    }
+
+    private class InternalNetworkConfigListener implements NetworkConfigListener {
+
+        @Override
+        public void event(NetworkConfigEvent event) {
+            switch (event.type()) {
+            case CONFIG_ADDED:
+            case CONFIG_UPDATED:
+                configure((OltKafkaConfig) event.config().get());
+                break;
+            case CONFIG_REMOVED:
+                unconfigure();
+                break;
+            case CONFIG_REGISTERED:
+            case CONFIG_UNREGISTERED:
+            default:
+                break;
+            }
+        }
+
+        @Override
+        public boolean isRelevant(NetworkConfigEvent event) {
+            return event.configClass().equals(OLT_KAFKA_CONFIG_CLASS);
+        }
+    }
+
+    private class InternalAccessDeviceListener implements AccessDeviceListener {
+
+        @Override
+        public void event(AccessDeviceEvent accessDeviceEvent) {
+            switch (accessDeviceEvent.type()) {
+            case UNI_ADDED:
+                executor.execute(() ->
+                        KafkaIntegration.this.sendUniAddEvent(accessDeviceEvent));
+                break;
+            case UNI_REMOVED:
+            default:
+                break;
+            }
+        }
+    }
+}
diff --git a/kafka/src/main/java/org/opencord/olt/kafka/OltKafkaConfig.java b/kafka/src/main/java/org/opencord/olt/kafka/OltKafkaConfig.java
new file mode 100644
index 0000000..afea805
--- /dev/null
+++ b/kafka/src/main/java/org/opencord/olt/kafka/OltKafkaConfig.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.
+ */
+
+package org.opencord.olt.kafka;
+
+import org.onosproject.core.ApplicationId;
+import org.onosproject.net.config.Config;
+
+/**
+ * Configuration of the Kafka publishing endpoint.
+ */
+public class OltKafkaConfig extends Config<ApplicationId> {
+
+    private static final String BOOTSTRAP_SERVERS = "bootstrapServers";
+    private static final String RETRIES = "retries";
+    private static final String RECONNECT_BACKOFF = "reconnectBackoff";
+    private static final String INFLIGHT_REQUESTS = "inflightRequests";
+    private static final String ACKS = "acks";
+
+    private static final String DEFAULT_RETRIES = "1";
+    private static final String DEFAULT_RECONNECT_BACKOFF = "500";
+    private static final String DEFAULT_INFLIGHT_REQUESTS = "5";
+    private static final String DEFAULT_ACKS = "1";
+
+    @Override
+    public boolean isValid() {
+        return hasOnlyFields(BOOTSTRAP_SERVERS, RETRIES, RECONNECT_BACKOFF,
+                INFLIGHT_REQUESTS, ACKS) && hasFields(BOOTSTRAP_SERVERS);
+    }
+
+    /**
+     * Returns the Kafka bootstrap servers.
+     * <p>
+     * This can be a hostname/IP and port (e.g. 10.1.1.1:9092).
+     * </p>
+     *
+     * @return Kafka bootstrap servers
+     */
+    public String getBootstrapServers() {
+        return object.path(BOOTSTRAP_SERVERS).asText();
+    }
+
+    /**
+     * Returns the number of retries.
+     *
+     * @return retries
+     */
+    public String getRetries() {
+        return get(RETRIES, DEFAULT_RETRIES);
+    }
+
+    /**
+     * Returns the reconnect backoff in milliseconds.
+     *
+     * @return reconnect backoff
+     */
+    public String getReconnectBackoff() {
+        return get(RECONNECT_BACKOFF, DEFAULT_RECONNECT_BACKOFF);
+    }
+
+    /**
+     * Returns the number of inflight requests.
+     *
+     * @return inflight requests
+     */
+    public String getInflightRequests() {
+        return get(INFLIGHT_REQUESTS, DEFAULT_INFLIGHT_REQUESTS);
+    }
+
+    /**
+     * Returns the number of acks.
+     *
+     * @return acks
+     */
+    public String getAcks() {
+        return get(ACKS, DEFAULT_ACKS);
+    }
+}
diff --git a/kafka/src/main/java/org/opencord/olt/kafka/package-info.java b/kafka/src/main/java/org/opencord/olt/kafka/package-info.java
new file mode 100644
index 0000000..7754563
--- /dev/null
+++ b/kafka/src/main/java/org/opencord/olt/kafka/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.
+ */
+
+/**
+ * Kafka event module for OLT application.
+ */
+package org.opencord.olt.kafka;
diff --git a/pom.xml b/pom.xml
index c48b725..9e3ef3e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -34,17 +34,12 @@
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <onos.version>1.13.1</onos.version>
-        <onos.app.name>org.opencord.olt</onos.app.name>
-        <onos.app.title>OLT Access Management</onos.app.title>
-        <onos.app.origin>OpenCord</onos.app.origin>
-        <onos.app.category>default</onos.app.category>
-        <onos.app.url>http://opencord.org</onos.app.url>
-        <onos.app.readme>CORD OLT Access management application</onos.app.readme>
         <cord.config.version>1.4.0-SNAPSHOT</cord.config.version>
     </properties>
 
     <modules>
         <module>api</module>
+        <module>kafka</module>
         <module>app</module>
     </modules>