Refactored Kafka Application to simplify dependencies
1. Fixed a Bug in KafkaProducer. Without this fix the App will not send data in GPB format.
2. Added two new services - KafkaProducerService and KafkaConfigService.
3. Fixed a TODO in the register API to return Kafka server information.
4. Removed the use of LeadershipService and ClusterService, since we are not ready for clustering yet.
Change-Id: If20ef5238bb4629af0c6769129494eb44abf1d3c
diff --git a/apps/kafka-integration/web/src/main/java/org/onosproject/kafkaintegration/rest/EventExporterWebResource.java b/apps/kafka-integration/web/src/main/java/org/onosproject/kafkaintegration/rest/EventExporterWebResource.java
index 0a6e91d..59b9c7e 100644
--- a/apps/kafka-integration/web/src/main/java/org/onosproject/kafkaintegration/rest/EventExporterWebResource.java
+++ b/apps/kafka-integration/web/src/main/java/org/onosproject/kafkaintegration/rest/EventExporterWebResource.java
@@ -18,12 +18,11 @@
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.onosproject.kafkaintegration.api.EventSubscriptionService;
import org.onosproject.kafkaintegration.api.dto.EventSubscriber;
-import org.onosproject.kafkaintegration.api.dto.EventSubscriberGroupId;
+import org.onosproject.kafkaintegration.api.dto.RegistrationResponse;
import org.onosproject.rest.AbstractWebResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.POST;
@@ -62,7 +61,7 @@
*
* @param appName The application trying to register
* @return 200 OK with UUID string which should be used as Kafka Consumer
- * Group Id
+ * Group Id and Kafka Server, port information.
* @onos.rsModel KafkaRegistration
*/
@POST
@@ -73,12 +72,16 @@
EventSubscriptionService service = get(EventSubscriptionService.class);
- EventSubscriberGroupId groupId = service.registerListener(appName);
+ RegistrationResponse response = service.registerListener(appName);
+
+ ObjectNode result = mapper().createObjectNode();
+ result.put("groupId", response.getGroupId().getId().toString());
+ result.put("ipAddress", response.getIpAddress());
+ result.put("port", response.getPort());
log.info("Registered app {}", appName);
- // TODO: Should also return Kafka server information.
- // Will glue this in when we have the config and Kafka modules ready
- return ok(groupId.getId().toString()).build();
+
+ return ok(result.toString()).build();
}
/**