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);
}
}
Aggregations