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