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