use of org.onosproject.ui.impl.topo.util.TrafficLinkMap in project onos by opennetworkinglab.
the class TrafficMonitorBase method createTrafficLinks.
protected void createTrafficLinks(Highlights highlights, TrafficLinkMap linkMap, Set<Intent> intents, LinkHighlight.Flavor flavor, boolean showTraffic) {
for (Intent intent : intents) {
List<Intent> installables = services.intent().getInstallableIntents(intent.key());
Iterable<Link> links = null;
if (installables != null) {
for (Intent installable : installables) {
if (installable instanceof PathIntent) {
links = ((PathIntent) installable).path().links();
} else if (installable instanceof FlowRuleIntent) {
Collection<Link> l = new ArrayList<>();
l.addAll(linkResources(installable));
// Add cross connect links
if (intent instanceof OpticalConnectivityIntent) {
OpticalConnectivityIntent ocIntent = (OpticalConnectivityIntent) intent;
LinkService linkService = services.link();
DeviceService deviceService = services.device();
l.addAll(linkService.getDeviceIngressLinks(ocIntent.getSrc().deviceId()).stream().filter(i -> deviceService.getDevice(i.src().deviceId()).type() == Device.Type.SWITCH).collect(Collectors.toList()));
l.addAll(linkService.getDeviceEgressLinks(ocIntent.getDst().deviceId()).stream().filter(e -> deviceService.getDevice(e.dst().deviceId()).type() == Device.Type.SWITCH).collect(Collectors.toList()));
}
links = l;
} else if (installable instanceof FlowObjectiveIntent) {
links = linkResources(installable);
} else if (installable instanceof LinkCollectionIntent) {
links = ((LinkCollectionIntent) installable).links();
} else if (installable instanceof OpticalPathIntent) {
links = ((OpticalPathIntent) installable).path().links();
}
if (links == null) {
links = Lists.newArrayList();
}
links = addEdgeLinksIfNeeded(intent, Lists.newArrayList(links));
boolean isOptical = intent instanceof OpticalConnectivityIntent;
processLinks(linkMap, links, flavor, isOptical, showTraffic);
updateHighlights(highlights, links);
}
}
}
}
use of org.onosproject.ui.impl.topo.util.TrafficLinkMap in project onos by opennetworkinglab.
the class TrafficMonitorBase method computeLinksWithTraffic.
/**
* Generates a set of "traffic links" encapsulating information about the
* traffic on each link (that is deemed to have traffic).
*
* @param type the type of statistics to be displayed
* @return the set of links with traffic
*/
protected Set<TrafficLink> computeLinksWithTraffic(TrafficLink.StatsType type) {
TrafficLinkMap linkMap = new TrafficLinkMap();
compileLinks(linkMap);
addEdgeLinks(linkMap);
Set<TrafficLink> linksWithTraffic = new HashSet<>();
for (TrafficLink tlink : linkMap.biLinks()) {
if (type == TrafficLink.StatsType.FLOW_STATS) {
attachFlowLoad(tlink);
} else if (type == TrafficLink.StatsType.PORT_STATS) {
attachPortLoad(tlink, BYTES);
} else if (type == TrafficLink.StatsType.PORT_PACKET_STATS) {
attachPortLoad(tlink, PACKETS);
}
// we only want to report on links deemed to have traffic
if (tlink.hasTraffic()) {
linksWithTraffic.add(tlink);
}
}
return linksWithTraffic;
}
use of org.onosproject.ui.impl.topo.util.TrafficLinkMap in project onos by opennetworkinglab.
the class TrafficMonitorBase method highlightIntentLinksWithTraffic.
private void highlightIntentLinksWithTraffic(Highlights highlights, Set<Intent> primary) {
TrafficLinkMap linkMap = new TrafficLinkMap();
createTrafficLinks(highlights, linkMap, primary, LinkHighlight.Flavor.PRIMARY_HIGHLIGHT, true);
colorLinks(highlights, linkMap);
}
use of org.onosproject.ui.impl.topo.util.TrafficLinkMap in project onos by opennetworkinglab.
the class TrafficMonitorBase method highlightIntentLinks.
protected void highlightIntentLinks(Highlights highlights, Set<Intent> primary, Set<Intent> secondary) {
TrafficLinkMap linkMap = new TrafficLinkMap();
// NOTE: highlight secondary first, then primary, so that links shared
// by intents are colored correctly ("last man wins")
createTrafficLinks(highlights, linkMap, secondary, LinkHighlight.Flavor.SECONDARY_HIGHLIGHT, false);
createTrafficLinks(highlights, linkMap, primary, LinkHighlight.Flavor.PRIMARY_HIGHLIGHT, false);
colorLinks(highlights, linkMap);
}
use of org.onosproject.ui.impl.topo.util.TrafficLinkMap 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;
}
Aggregations