Search in sources :

Example 6 with Highlights

use of org.onosproject.ui.topo.Highlights in project onos by opennetworkinglab.

the class TrafficMonitor method deviceLinkFlows.

// =======================================================================
// === Generate messages in JSON object node format
// NOTE: trafficSummary(StatsType) => Highlights
// has been moved to the superclass
// create highlights for links, showing flows for selected devices.
private Highlights deviceLinkFlows() {
    Highlights highlights = new Highlights();
    if (selectedNodes != null && !selectedNodes.devicesWithHover().isEmpty()) {
        // capture flow counts on bilinks
        TrafficLinkMap linkMap = new TrafficLinkMap();
        for (Device device : selectedNodes.devicesWithHover()) {
            Map<Link, Integer> counts = getLinkFlowCounts(device.id());
            for (Link link : counts.keySet()) {
                TrafficLink tlink = linkMap.add(link);
                tlink.addFlows(counts.get(link));
            }
        }
        // now report on our collated links
        for (TrafficLink tlink : linkMap.biLinks()) {
            highlights.add(tlink.highlight(StatsType.FLOW_COUNT));
        }
    }
    return highlights;
}
Also used : Highlights(org.onosproject.ui.topo.Highlights) TrafficLink(org.onosproject.ui.impl.topo.util.TrafficLink) Device(org.onosproject.net.Device) TrafficLinkMap(org.onosproject.ui.impl.topo.util.TrafficLinkMap) Link(org.onosproject.net.Link) TrafficLink(org.onosproject.ui.impl.topo.util.TrafficLink)

Example 7 with Highlights

use of org.onosproject.ui.topo.Highlights in project onos by opennetworkinglab.

the class TrafficMonitorBase method intentTraffic.

protected Highlights intentTraffic() {
    Highlights highlights = new Highlights();
    if (selectedIntents != null && selectedIntents.single()) {
        Intent current = selectedIntents.current();
        Set<Intent> primary = new HashSet<>();
        primary.add(current);
        log.debug("Highlight traffic for intent: {} ([{}] of {})", current.id(), selectedIntents.index(), selectedIntents.size());
        highlightIntentLinksWithTraffic(highlights, primary);
        highlights.subdueAllElse(Highlights.Amount.MINIMALLY);
    }
    return highlights;
}
Also used : Highlights(org.onosproject.ui.topo.Highlights) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) HostToHostIntent(org.onosproject.net.intent.HostToHostIntent) OpticalPathIntent(org.onosproject.net.intent.OpticalPathIntent) FlowObjectiveIntent(org.onosproject.net.intent.FlowObjectiveIntent) Intent(org.onosproject.net.intent.Intent) PathIntent(org.onosproject.net.intent.PathIntent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) OpticalConnectivityIntent(org.onosproject.net.intent.OpticalConnectivityIntent) HashSet(java.util.HashSet)

Example 8 with Highlights

use of org.onosproject.ui.topo.Highlights in project onos by opennetworkinglab.

the class TrafficMonitorBase method intentGroup.

protected Highlights intentGroup() {
    Highlights highlights = new Highlights();
    if (selectedIntents != null && !selectedIntents.none()) {
        // If 'all' intents are selected, they will all have primary
        // highlighting; otherwise, the specifically selected intent will
        // have primary highlighting, and the remainder will have secondary
        // highlighting.
        Set<Intent> primary;
        Set<Intent> secondary;
        int count = selectedIntents.size();
        Set<Intent> allBut = new HashSet<>(selectedIntents.intents());
        Intent current;
        if (selectedIntents.all()) {
            primary = allBut;
            secondary = Collections.emptySet();
            log.debug("Highlight all intents ({})", count);
        } else {
            current = selectedIntents.current();
            primary = new HashSet<>();
            primary.add(current);
            allBut.remove(current);
            secondary = allBut;
            log.debug("Highlight intent: {} ([{}] of {})", current.id(), selectedIntents.index(), count);
        }
        highlightIntentLinks(highlights, primary, secondary);
    }
    return highlights;
}
Also used : Highlights(org.onosproject.ui.topo.Highlights) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) HostToHostIntent(org.onosproject.net.intent.HostToHostIntent) OpticalPathIntent(org.onosproject.net.intent.OpticalPathIntent) FlowObjectiveIntent(org.onosproject.net.intent.FlowObjectiveIntent) Intent(org.onosproject.net.intent.Intent) PathIntent(org.onosproject.net.intent.PathIntent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) OpticalConnectivityIntent(org.onosproject.net.intent.OpticalConnectivityIntent) HashSet(java.util.HashSet)

Example 9 with Highlights

use of org.onosproject.ui.topo.Highlights in project onos by opennetworkinglab.

the class TrafficMonitorBase method trafficSummary.

// =======================================================================
// === Methods for computing traffic on links
/**
 * Generates a {@link Highlights} object summarizing the traffic on the
 * network, ready to be transmitted back to the client for display on
 * the topology view.
 *
 * @param type the type of statistics to be displayed
 * @return highlights, representing links to be labeled/colored
 */
protected Highlights trafficSummary(TrafficLink.StatsType type) {
    Highlights highlights = new Highlights();
    // TODO: consider whether a map would be better...
    Set<TrafficLink> linksWithTraffic = computeLinksWithTraffic(type);
    Set<TrafficLink> aggregatedLinks = doAggregation(linksWithTraffic);
    for (TrafficLink tlink : aggregatedLinks) {
        highlights.add(tlink.highlight(type));
    }
    return highlights;
}
Also used : Highlights(org.onosproject.ui.topo.Highlights) TrafficLink(org.onosproject.ui.impl.topo.util.TrafficLink)

Example 10 with Highlights

use of org.onosproject.ui.topo.Highlights in project onos by opennetworkinglab.

the class ProtectedIntentMonitor method protectedIntentHighlights.

// =======================================================================
// === Generate messages in JSON object node format
private Highlights protectedIntentHighlights() {
    Highlights highlights = new Highlights();
    TrafficLinkMap linkMap = new TrafficLinkMap();
    IntentService intentService = services.intent();
    if (selectedIntent != null) {
        List<Intent> installables = intentService.getInstallableIntents(selectedIntent.key());
        if (installables != null) {
            ProtectionEndpointIntent ep1 = installables.stream().filter(ProtectionEndpointIntent.class::isInstance).map(ProtectionEndpointIntent.class::cast).findFirst().orElse(null);
            ProtectionEndpointIntent ep2 = installables.stream().filter(ii -> !ii.equals(ep1)).filter(ProtectionEndpointIntent.class::isInstance).map(ProtectionEndpointIntent.class::cast).findFirst().orElse(null);
            if (ep1 == null || ep2 == null) {
                log.warn("Selected Intent {} didn't have 2 protection endpoints", selectedIntent.key());
                stopMonitoring();
                return highlights;
            }
            Set<Link> primary = new LinkedHashSet<>();
            Set<Link> backup = new LinkedHashSet<>();
            Map<Boolean, List<FlowRuleIntent>> transits = installables.stream().filter(FlowRuleIntent.class::isInstance).map(FlowRuleIntent.class::cast).collect(Collectors.groupingBy(this::isPrimary));
            // walk primary
            ConnectPoint primHead = ep1.description().paths().get(0).output().connectPoint();
            ConnectPoint primTail = ep2.description().paths().get(0).output().connectPoint();
            List<FlowRuleIntent> primTransit = transits.getOrDefault(true, ImmutableList.of());
            populateLinks(primary, primHead, primTail, primTransit);
            // walk backup
            ConnectPoint backHead = ep1.description().paths().get(1).output().connectPoint();
            ConnectPoint backTail = ep2.description().paths().get(1).output().connectPoint();
            List<FlowRuleIntent> backTransit = transits.getOrDefault(false, ImmutableList.of());
            populateLinks(backup, backHead, backTail, backTransit);
            // Add packet to optical links
            if (!usingBackup(primary)) {
                primary.addAll(protectedIntentMultiLayer(primHead, primTail));
            }
            backup.addAll(protectedIntentMultiLayer(backHead, backTail));
            boolean isOptical = selectedIntent instanceof OpticalConnectivityIntent;
            // Flavor is swapped so green is primary path.
            if (usingBackup(primary)) {
                // the backup becomes in use so we have a dotted line
                processLinks(linkMap, backup, Flavor.PRIMARY_HIGHLIGHT, isOptical, true, PROTECTED_MOD_BACKUP_SET);
            } else {
                processLinks(linkMap, primary, Flavor.PRIMARY_HIGHLIGHT, isOptical, true, PROTECTED_MOD_PRIMARY_SET);
                processLinks(linkMap, backup, Flavor.SECONDARY_HIGHLIGHT, isOptical, false, PROTECTED_MOD_BACKUP_SET);
            }
            updateHighlights(highlights, primary);
            updateHighlights(highlights, backup);
            colorLinks(highlights, linkMap);
            highlights.subdueAllElse(Highlights.Amount.MINIMALLY);
        } else {
            log.debug("Selected Intent has no installable intents");
        }
    } else {
        log.debug("Selected Intent is null");
    }
    return highlights;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) IntentService(org.onosproject.net.intent.IntentService) Highlights(org.onosproject.ui.topo.Highlights) ProtectionEndpointIntent(org.onosproject.net.intent.ProtectionEndpointIntent) OpticalConnectivityIntent(org.onosproject.net.intent.OpticalConnectivityIntent) Intent(org.onosproject.net.intent.Intent) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) OpticalConnectivityIntent(org.onosproject.net.intent.OpticalConnectivityIntent) ProtectionEndpointIntent(org.onosproject.net.intent.ProtectionEndpointIntent) ConnectPoint(org.onosproject.net.ConnectPoint) TrafficLinkMap(org.onosproject.ui.impl.topo.util.TrafficLinkMap) ImmutableList(com.google.common.collect.ImmutableList) LinkedList(java.util.LinkedList) List(java.util.List) Link(org.onosproject.net.Link) TrafficLink(org.onosproject.ui.impl.topo.util.TrafficLink) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent)

Aggregations

Highlights (org.onosproject.ui.topo.Highlights)19 Link (org.onosproject.net.Link)7 Device (org.onosproject.net.Device)6 DeviceId (org.onosproject.net.DeviceId)5 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)4 Intent (org.onosproject.net.intent.Intent)4 OpticalConnectivityIntent (org.onosproject.net.intent.OpticalConnectivityIntent)4 HashSet (java.util.HashSet)3 List (java.util.List)3 FlowObjectiveIntent (org.onosproject.net.intent.FlowObjectiveIntent)3 HostToHostIntent (org.onosproject.net.intent.HostToHostIntent)3 LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)3 OpticalPathIntent (org.onosproject.net.intent.OpticalPathIntent)3 PathIntent (org.onosproject.net.intent.PathIntent)3 TrafficLink (org.onosproject.ui.impl.topo.util.TrafficLink)3 ImmutableList (com.google.common.collect.ImmutableList)2 Lists (com.google.common.collect.Lists)2 Collection (java.util.Collection)2 Set (java.util.Set)2 TrafficLinkMap (org.onosproject.ui.impl.topo.util.TrafficLinkMap)2