Search in sources :

Example 1 with McastRouteData

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

the class McastHandler method initInternal.

private void initInternal() {
    srManager.multicastRouteService.getRoutes().forEach(mcastRoute -> {
        lastMcastChange.set(Instant.now());
        log.debug("Init group {}", mcastRoute.group());
        if (!mcastUtils.isLeader(mcastRoute.group())) {
            log.debug("Skip {} due to lack of leadership", mcastRoute.group());
            return;
        }
        McastRouteData mcastRouteData = srManager.multicastRouteService.routeData(mcastRoute);
        // For each source process the mcast tree
        srManager.multicastRouteService.sources(mcastRoute).forEach(source -> {
            McastPathStoreKey pathStoreKey = new McastPathStoreKey(mcastRoute.group(), source);
            Collection<? extends List<Link>> storedPaths = Versioned.valueOrElse(mcastPathStore.get(pathStoreKey), Lists.newArrayList());
            Map<ConnectPoint, List<ConnectPoint>> mcastPaths = buildMcastPaths(storedPaths, mcastRoute.group(), source);
            // Get all the sinks and process them
            Set<ConnectPoint> sinks = processSinksToBeAdded(source, mcastRoute.group(), mcastRouteData.sinks());
            // Filter out all the working sinks, we do not want to move them
            // TODO we need a better way to distinguish flows coming from different sources
            sinks = sinks.stream().filter(sink -> !mcastPaths.containsKey(sink) || !isSinkForSource(mcastRoute.group(), sink, source)).collect(Collectors.toSet());
            if (sinks.isEmpty()) {
                log.debug("Skip {} for source {} nothing to do", mcastRoute.group(), source);
                return;
            }
            Map<ConnectPoint, List<Path>> mcasTree = mcastUtils.computeSinkMcastTree(mcastRoute.group(), source.deviceId(), sinks);
            mcasTree.forEach((sink, paths) -> processSinkAddedInternal(source, sink, mcastRoute.group(), null));
        });
    });
}
Also used : McastRouteData(org.onosproject.mcast.api.McastRouteData) List(java.util.List) ConnectPoint(org.onosproject.net.ConnectPoint) Link(org.onosproject.net.Link)

Aggregations

List (java.util.List)1 McastRouteData (org.onosproject.mcast.api.McastRouteData)1 ConnectPoint (org.onosproject.net.ConnectPoint)1 Link (org.onosproject.net.Link)1