Search in sources :

Example 1 with EventSubscriberGroupId

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;
}
Also used : EventSubscriberGroupId(org.onosproject.kafkaintegration.api.dto.EventSubscriberGroupId) ApplicationId(org.onosproject.core.ApplicationId)

Example 2 with EventSubscriberGroupId

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;
}
Also used : EventSubscriberGroupId(org.onosproject.kafkaintegration.api.dto.EventSubscriberGroupId) ApplicationId(org.onosproject.core.ApplicationId) RegistrationResponse(org.onosproject.kafkaintegration.api.dto.RegistrationResponse)

Example 3 with EventSubscriberGroupId

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();
}
Also used : EventSubscriber(org.onosproject.kafkaintegration.api.dto.EventSubscriber) DefaultEventSubscriber(org.onosproject.kafkaintegration.api.dto.DefaultEventSubscriber) EventSubscriberGroupId(org.onosproject.kafkaintegration.api.dto.EventSubscriberGroupId)

Aggregations

EventSubscriberGroupId (org.onosproject.kafkaintegration.api.dto.EventSubscriberGroupId)3 ApplicationId (org.onosproject.core.ApplicationId)2 DefaultEventSubscriber (org.onosproject.kafkaintegration.api.dto.DefaultEventSubscriber)1 EventSubscriber (org.onosproject.kafkaintegration.api.dto.EventSubscriber)1 RegistrationResponse (org.onosproject.kafkaintegration.api.dto.RegistrationResponse)1