use of org.onosproject.kafkaintegration.api.dto.EventSubscriberGroupId in project onos by opennetworkinglab.
the class EventSubscriptionManager method validGroupId.
/**
* Checks if the group id is valid for this registered application.
*
* @param groupId GroupId assigned to the subscriber
* @param appName Registered Application name
* @return true if valid groupId and false otherwise
*/
private boolean validGroupId(EventSubscriberGroupId groupId, String appName) {
checkNotNull(groupId);
ApplicationId appId = coreService.getAppId(appName);
EventSubscriberGroupId registeredGroupId = registeredApps.get(appId);
if (registeredGroupId.equals(groupId)) {
return true;
}
return false;
}
use of org.onosproject.kafkaintegration.api.dto.EventSubscriberGroupId 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;
}
use of org.onosproject.kafkaintegration.api.dto.EventSubscriberGroupId in project onos by opennetworkinglab.
the class SubscriberCodec method decode.
@Override
public EventSubscriber decode(ObjectNode json, CodecContext context) {
EventSubscriber.Builder resultBuilder = new DefaultEventSubscriber.Builder();
String appName = json.get(NAME).asText();
resultBuilder.setAppName(appName);
String subscriberGroupId = json.get(GROUP_ID).asText();
resultBuilder.setSubscriberGroupId(new EventSubscriberGroupId(UUID.fromString(subscriberGroupId)));
String eventType = json.get(EVENT_TYPE).asText();
resultBuilder.setEventType(Type.valueOf(eventType));
return resultBuilder.build();
}
Aggregations