Search in sources :

Example 1 with McastRouteUpdate

use of org.onosproject.mcast.api.McastRouteUpdate in project trellis-control by opennetworkinglab.

the class McastHandler method processMcastEventInternal.

private void processMcastEventInternal(McastEvent event) {
    lastMcastChange.set(Instant.now());
    // Current subject is null, for ROUTE_REMOVED events
    final McastRouteUpdate mcastUpdate = event.subject();
    final McastRouteUpdate mcastPrevUpdate = event.prevSubject();
    IpAddress mcastIp = mcastPrevUpdate.route().group();
    Set<ConnectPoint> prevSinks = mcastPrevUpdate.sinks().values().stream().flatMap(Collection::stream).collect(Collectors.toSet());
    Set<ConnectPoint> prevSources = mcastPrevUpdate.sources().values().stream().flatMap(Collection::stream).collect(Collectors.toSet());
    Set<ConnectPoint> sources;
    // Events handling
    if (event.type() == ROUTE_ADDED) {
        processRouteAddedInternal(mcastUpdate.route().group());
    } else if (event.type() == ROUTE_REMOVED) {
        processRouteRemovedInternal(prevSources, mcastIp);
    } else if (event.type() == SOURCES_ADDED) {
        // Current subject and prev just differ for the source connect points
        sources = mcastUpdate.sources().values().stream().flatMap(Collection::stream).collect(Collectors.toSet());
        Set<ConnectPoint> sourcesToBeAdded = Sets.difference(sources, prevSources);
        processSourcesAddedInternal(sourcesToBeAdded, mcastIp, mcastUpdate.sinks());
    } else if (event.type() == SOURCES_REMOVED) {
        // Current subject and prev just differ for the source connect points
        sources = mcastUpdate.sources().values().stream().flatMap(Collection::stream).collect(Collectors.toSet());
        Set<ConnectPoint> sourcesToBeRemoved = Sets.difference(prevSources, sources);
        processSourcesRemovedInternal(sourcesToBeRemoved, sources, mcastIp, mcastUpdate.sinks());
    } else if (event.type() == SINKS_ADDED) {
        processSinksAddedInternal(prevSources, mcastIp, mcastUpdate.sinks(), prevSinks);
    } else if (event.type() == SINKS_REMOVED) {
        processSinksRemovedInternal(prevSources, mcastIp, mcastUpdate.sinks(), mcastPrevUpdate.sinks());
    } else {
        log.warn("Event {} not handled", event);
    }
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) DistributedSet(org.onosproject.store.service.DistributedSet) McastRouteUpdate(org.onosproject.mcast.api.McastRouteUpdate) Collection(java.util.Collection) IpAddress(org.onlab.packet.IpAddress) ConnectPoint(org.onosproject.net.ConnectPoint)

Aggregations

ImmutableSet (com.google.common.collect.ImmutableSet)1 Collection (java.util.Collection)1 Set (java.util.Set)1 IpAddress (org.onlab.packet.IpAddress)1 McastRouteUpdate (org.onosproject.mcast.api.McastRouteUpdate)1 ConnectPoint (org.onosproject.net.ConnectPoint)1 DistributedSet (org.onosproject.store.service.DistributedSet)1