use of org.onosproject.kafkaintegration.api.dto.RegistrationResponse in project onos by opennetworkinglab.
the class EventExporterWebResource method registerKafkaListener.
/**
* Registers a listener for ONOS Events.
*
* @param appName The application trying to register
* @return 200 OK with UUID string which should be used as Kafka Consumer
* Group Id and Kafka Server, port information.
* @onos.rsModel KafkaRegistration
*/
@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Path("register")
public Response registerKafkaListener(String appName) {
EventSubscriptionService service = get(EventSubscriptionService.class);
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);
return ok(result.toString()).build();
}
use of org.onosproject.kafkaintegration.api.dto.RegistrationResponse in project onos by opennetworkinglab.
the class EventSubscriptionManager method registerListener.
@Override
public RegistrationResponse registerListener(String appName) {
// TODO: Remove it once ONOS provides a mechanism for external apps
// to register with the core service. See Jira - 4409
ApplicationId externalAppId = coreService.registerApplication(appName);
EventSubscriberGroupId id = registeredApps.computeIfAbsent(externalAppId, (key) -> new EventSubscriberGroupId(UUID.randomUUID()));
RegistrationResponse response = new RegistrationResponse(id, kafkaConfigService.getConfigParams().getIpAddress(), kafkaConfigService.getConfigParams().getPort());
return response;
}
Aggregations