Cleanup unused code in Kafka Application and other cosmetic changes[patchset #2]

1. Deleted classes not being used.
2. There was inconsistent terminology in use w.r.t naming of classes for ex - producer vs publisher.

Change-Id: If78a06bb59261bdfe1854ae8ed3ee2218696d984
diff --git a/apps/kafka-integration/api/src/main/java/org/onosproject/kafkaintegration/api/ExportableEventListener.java b/apps/kafka-integration/api/src/main/java/org/onosproject/kafkaintegration/api/ExportableEventListener.java
deleted file mode 100644
index c778ffc..0000000
--- a/apps/kafka-integration/api/src/main/java/org/onosproject/kafkaintegration/api/ExportableEventListener.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Copyright 2016-present Open Networking Laboratory
- * 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.onosproject.kafkaintegration.api;
-
-import org.onosproject.event.EventListener;
-import org.onosproject.kafkaintegration.api.dto.OnosEvent;
-
-import com.google.common.annotations.Beta;
-
-/**
- * API for listeners to listen for Events generated by the ONOS event listener.
- * At present the only listener will be a Kafka Manager or Module whose sole
- * purpose is to publish the received data to a Kafka message bus.
- *
- */
-@Beta
-public interface ExportableEventListener extends EventListener<OnosEvent> {
-
-}
diff --git a/apps/kafka-integration/api/src/main/java/org/onosproject/kafkaintegration/api/KafkaProducerService.java b/apps/kafka-integration/api/src/main/java/org/onosproject/kafkaintegration/api/KafkaProducerService.java
deleted file mode 100644
index d29cd47..0000000
--- a/apps/kafka-integration/api/src/main/java/org/onosproject/kafkaintegration/api/KafkaProducerService.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * Copyright 2016-present Open Networking Laboratory
- *
- * 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.onosproject.kafkaintegration.api;
-
-import java.util.concurrent.Future;
-
-import org.onosproject.kafkaintegration.api.dto.KafkaServerConfig;
-import org.apache.kafka.clients.producer.ProducerRecord;
-import org.apache.kafka.clients.producer.RecordMetadata;
-/**
- * APIs for controlling the Kafka Producer.
- *
- */
-public interface KafkaProducerService {
-
-    /**
-     * Starts the Kafka Producer.
-     *
-     * @param config the Kafka Server Config
-     */
-    void start(KafkaServerConfig config);
-
-    /**
-     * Stops the Kafka Producer.
-     *
-     */
-    void stop();
-
-    /**
-     * Restarts the Kafka Producer.
-     *
-     * @param config the Kafka Server Config
-     */
-    void restart(KafkaServerConfig config);
-
-    /**
-     * Sends message to Kafka Server.
-     *
-     * @param record a message to be sent
-     * @return metadata for a record that as been acknowledged
-     */
-    public Future<RecordMetadata> send(ProducerRecord<String, byte[]> record);
-}
diff --git a/apps/kafka-integration/api/src/main/java/org/onosproject/kafkaintegration/api/KafkaPublisherService.java b/apps/kafka-integration/api/src/main/java/org/onosproject/kafkaintegration/api/KafkaPublisherService.java
index 052c1e6..6156134 100644
--- a/apps/kafka-integration/api/src/main/java/org/onosproject/kafkaintegration/api/KafkaPublisherService.java
+++ b/apps/kafka-integration/api/src/main/java/org/onosproject/kafkaintegration/api/KafkaPublisherService.java
@@ -13,24 +13,44 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.onosproject.kafkaintegration.api;
 
-import com.google.protobuf.GeneratedMessageV3;
+import java.util.concurrent.Future;
 
-import org.onosproject.kafkaintegration.api.dto.OnosEvent.Type;
-
+import org.onosproject.kafkaintegration.api.dto.KafkaServerConfig;
+import org.apache.kafka.clients.producer.ProducerRecord;
+import org.apache.kafka.clients.producer.RecordMetadata;
 /**
- * API for dispatching ONOS events.
+ * APIs for controlling the Kafka Producer.
+ *
  */
 public interface KafkaPublisherService {
 
     /**
-     * Publish the ONOS Event to all listeners.
+     * Starts the Kafka Producer.
      *
-     * @param eventType the ONOS eventtype
-     * @param message generated Protocol buffer message from ONOS event data
+     * @param config the Kafka Server Config
      */
-    // FIXME reconsider message type, something similar to "OnosEvent"?
-    void publish(Type eventType, GeneratedMessageV3 message);
+    void start(KafkaServerConfig config);
+
+    /**
+     * Stops the Kafka Producer.
+     *
+     */
+    void stop();
+
+    /**
+     * Restarts the Kafka Producer.
+     *
+     * @param config the Kafka Server Config
+     */
+    void restart(KafkaServerConfig config);
+
+    /**
+     * Sends message to Kafka Server.
+     *
+     * @param record a message to be sent
+     * @return metadata for a record that as been acknowledged
+     */
+    public Future<RecordMetadata> send(ProducerRecord<String, byte[]> record);
 }
diff --git a/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/impl/EventSubscriptionManager.java b/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/impl/EventSubscriptionManager.java
index f530a3c..4fee5cb 100644
--- a/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/impl/EventSubscriptionManager.java
+++ b/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/impl/EventSubscriptionManager.java
@@ -16,8 +16,6 @@
 package org.onosproject.kafkaintegration.impl;
 
 import static com.google.common.base.Preconditions.checkNotNull;
-import static org.onosproject.kafkaintegration.api.dto.OnosEvent.Type.DEVICE;
-import static org.onosproject.kafkaintegration.api.dto.OnosEvent.Type.LINK;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -42,7 +40,6 @@
 import org.onosproject.kafkaintegration.api.dto.OnosEvent.Type;
 import org.onosproject.kafkaintegration.errors.InvalidApplicationException;
 import org.onosproject.kafkaintegration.errors.InvalidGroupIdException;
-import org.onosproject.kafkaintegration.listener.OnosEventListener;
 import org.onosproject.net.device.DeviceService;
 import org.onosproject.net.link.LinkService;
 import org.onosproject.store.serializers.KryoNamespaces;
@@ -202,44 +199,6 @@
     }
 
     /**
-     * Applies the specified action on the Listener.
-     *
-     * @param eventType the ONOS Event type registered by the application
-     * @param onosListener ONOS event listener
-     * @param action to be performed on the listener
-     */
-    private void applyListenerAction(Type eventType,
-                                     OnosEventListener onosListener,
-                                     ListenerAction action) {
-        switch (eventType) {
-        case DEVICE:
-            if (action == ListenerAction.START) {
-                onosListener.startListener(DEVICE, deviceService);
-            } else {
-                onosListener.stopListener(DEVICE, deviceService);
-            }
-            break;
-        case LINK:
-            if (action == ListenerAction.START) {
-                onosListener.startListener(LINK, linkService);
-            } else {
-                onosListener.stopListener(LINK, linkService);
-            }
-            break;
-        default:
-            log.error("Cannot {} listener. Unsupported event type {} ",
-                      action.toString(), eventType.toString());
-        }
-    }
-
-    /**
-     * Returns the ONOS event listener corresponding to the ONOS Event type.
-     *
-     * @param eventType ONOS event type
-     * @return ONOS event listener
-     */
-
-    /**
      * Checks if the group id is valid for this registered application.
      *
      * @param groupId GroupId assigned to the subscriber
diff --git a/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/impl/KafkaPublisherManager.java b/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/impl/KafkaPublisherManager.java
deleted file mode 100644
index 9213a6d..0000000
--- a/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/impl/KafkaPublisherManager.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * Copyright 2016-present Open Networking Laboratory
- * 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.onosproject.kafkaintegration.impl;
-
-import org.onosproject.event.AbstractListenerManager;
-import org.onosproject.kafkaintegration.api.ExportableEventListener;
-import org.onosproject.kafkaintegration.api.KafkaPublisherService;
-import org.onosproject.kafkaintegration.api.dto.OnosEvent;
-import org.onosproject.kafkaintegration.api.dto.OnosEvent.Type;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.protobuf.GeneratedMessageV3;
-
-/**
- * Dispatch ONOS Events to all interested Listeners.
- *
- */
-
-public final class KafkaPublisherManager
-        extends AbstractListenerManager<OnosEvent, ExportableEventListener> implements KafkaPublisherService {
-
-    private final Logger log = LoggerFactory.getLogger(getClass());
-
-    // Exists to defeat instantiation
-    private KafkaPublisherManager() {
-    }
-
-    //TODO: If possible, get rid of Singleton implementation.
-    private static class SingletonHolder {
-        private static final KafkaPublisherManager INSTANCE = new KafkaPublisherManager();
-    }
-
-    /**
-     * Returns a static reference to the Listener Factory.
-     *
-     * @return singleton object
-     */
-    public static KafkaPublisherManager getInstance() {
-        return SingletonHolder.INSTANCE;
-    }
-
-    @Override
-    public void publish(Type eventType, GeneratedMessageV3 message) {
-        log.debug("Dispatching ONOS Event {}", eventType);
-        post(new OnosEvent(eventType, message));
-    }
-}
diff --git a/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/impl/KafkaStorageManager.java b/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/impl/KafkaStorageManager.java
index c26a0de..8ea15a2 100644
--- a/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/impl/KafkaStorageManager.java
+++ b/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/impl/KafkaStorageManager.java
@@ -31,6 +31,12 @@
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
 
+/**
+ * TODO: This code is not being used at the moment.
+ * This will be modified to use Distributed Work Queue.
+ * Please see clustering section of
+ * https://wiki.onosproject.org/display/ONOS/Kafka+Integration
+ */
 @Component(immediate = false)
 public class KafkaStorageManager implements KafkaEventStorageService {
 
diff --git a/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/kafka/EventMonitor.java b/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/kafka/EventListener.java
similarity index 97%
rename from apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/kafka/EventMonitor.java
rename to apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/kafka/EventListener.java
index 4bc0450..13a24c2 100644
--- a/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/kafka/EventMonitor.java
+++ b/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/kafka/EventListener.java
@@ -24,7 +24,7 @@
 import org.apache.kafka.clients.producer.ProducerRecord;
 import org.onosproject.kafkaintegration.api.EventConversionService;
 import org.onosproject.kafkaintegration.api.EventSubscriptionService;
-import org.onosproject.kafkaintegration.api.KafkaProducerService;
+import org.onosproject.kafkaintegration.api.KafkaPublisherService;
 import org.onosproject.kafkaintegration.api.KafkaConfigService;
 import org.onosproject.kafkaintegration.api.dto.OnosEvent;
 import org.onosproject.net.device.DeviceEvent;
@@ -49,7 +49,7 @@
  * Encapsulates the behavior of monitoring various ONOS events.
  * */
 @Component(immediate = true)
-public class EventMonitor {
+public class EventListener {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
@@ -59,7 +59,7 @@
     protected EventConversionService eventConversionService;
 
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
-    protected KafkaProducerService kafkaProducer;
+    protected KafkaPublisherService kafkaProducer;
 
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
     protected DeviceService deviceService;
diff --git a/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/kafka/Producer.java b/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/kafka/EventPublisher.java
similarity index 95%
rename from apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/kafka/Producer.java
rename to apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/kafka/EventPublisher.java
index 4267d87..c471312 100644
--- a/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/kafka/Producer.java
+++ b/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/kafka/EventPublisher.java
@@ -26,7 +26,7 @@
 import org.apache.kafka.clients.producer.KafkaProducer;
 import org.apache.kafka.clients.producer.ProducerRecord;
 import org.apache.kafka.clients.producer.RecordMetadata;
-import org.onosproject.kafkaintegration.api.KafkaProducerService;
+import org.onosproject.kafkaintegration.api.KafkaPublisherService;
 import org.onosproject.kafkaintegration.api.dto.KafkaServerConfig;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -36,7 +36,7 @@
  */
 @Component
 @Service
-public class Producer implements KafkaProducerService {
+public class EventPublisher implements KafkaPublisherService {
     private KafkaProducer<String, byte[]> kafkaProducer = null;
 
     private final Logger log = LoggerFactory.getLogger(getClass());
diff --git a/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/kafka/KafkaConfigManager.java b/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/kafka/KafkaConfigManager.java
index 35a2207..40d1d2d 100644
--- a/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/kafka/KafkaConfigManager.java
+++ b/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/kafka/KafkaConfigManager.java
@@ -30,7 +30,7 @@
 import org.apache.felix.scr.annotations.Service;
 import org.onosproject.cfg.ComponentConfigService;
 import org.onosproject.kafkaintegration.api.KafkaConfigService;
-import org.onosproject.kafkaintegration.api.KafkaProducerService;
+import org.onosproject.kafkaintegration.api.KafkaPublisherService;
 import org.onosproject.kafkaintegration.api.dto.KafkaServerConfig;
 import org.osgi.service.component.ComponentContext;
 import org.slf4j.Logger;
@@ -46,7 +46,7 @@
     protected ComponentConfigService componentConfigService;
 
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
-    protected KafkaProducerService producer;
+    protected KafkaPublisherService producer;
 
     public static final String BOOTSTRAP_SERVERS = "localhost:9092";
     private String kafkaServerIp =
diff --git a/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/listener/OnosEventListener.java b/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/listener/OnosEventListener.java
deleted file mode 100644
index 927c048..0000000
--- a/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/listener/OnosEventListener.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * Copyright 2016-present Open Networking Laboratory
- * 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.onosproject.kafkaintegration.listener;
-
-import org.onosproject.event.ListenerService;
-import org.onosproject.kafkaintegration.api.dto.OnosEvent.Type;
-
-/**
- * APIs for starting and stopping a ONOS Event listener.
- *
- */
-public interface OnosEventListener {
-
-    /**
-     * Start the listener for the specific ONOS event type.
-     *
-     * @param event ONOS event type
-     * @param service ONOS event listener for the specific event type
-     */
-    void startListener(Type event, ListenerService<?, ?> service);
-    /**
-     * Stop the Listener for the specific ONOS event type.
-     *
-     * @param event ONOS event type
-     * @param service ONOS event listener for the specific event type
-     */
-    void stopListener(Type event, ListenerService<?, ?> service);
-
-}
diff --git a/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/listener/package-info.java b/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/listener/package-info.java
deleted file mode 100644
index f6f602f..0000000
--- a/apps/kafka-integration/core/src/main/java/org/onosproject/kafkaintegration/listener/package-info.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * Copyright 2016-present Open Networking Laboratory 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.
- */
-
-/**
- * Listeners for listening to various ONOS events.
- *
- */
-package org.onosproject.kafkaintegration.listener;