Search in sources :

Example 1 with UiSynthLink

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

the class Topo2Jsonifier method json.

private ObjectNode json(Set<UiSynthLink> memberSet) {
    ArrayNode rollup = arrayNode();
    ObjectNode node = null;
    boolean first = true;
    for (UiSynthLink member : memberSet) {
        UiLink link = member.link();
        if (first) {
            node = json(link);
            first = false;
        }
        rollup.add(json(member.original()));
    }
    if (node != null) {
        node.set("rollup", rollup);
    }
    return node;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) UiSynthLink(org.onosproject.ui.model.topo.UiSynthLink) UiLink(org.onosproject.ui.model.topo.UiLink) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 2 with UiSynthLink

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

the class Topo2Jsonifier method collateSynthLinks.

private ArrayNode collateSynthLinks(List<UiSynthLink> links) {
    Map<UiLinkId, Set<UiSynthLink>> collation = new HashMap<>();
    // first, group together the synthlinks into sets per ID...
    for (UiSynthLink sl : links) {
        UiLinkId id = sl.link().id();
        Set<UiSynthLink> rollup = collation.computeIfAbsent(id, k -> new HashSet<>());
        rollup.add(sl);
    }
    // now add json nodes per set, and return the array of them
    ArrayNode array = arrayNode();
    for (UiLinkId id : collation.keySet()) {
        array.add(json(collation.get(id)));
    }
    return array;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) UiLinkId(org.onosproject.ui.model.topo.UiLinkId) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) UiSynthLink(org.onosproject.ui.model.topo.UiSynthLink) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 3 with UiSynthLink

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

the class Topo2ViewMessageHandler method mkRegionMessage.

private ObjectNode mkRegionMessage(UiTopoLayout currentLayout) {
    UiRegion region = topoSession.getRegion(currentLayout);
    Set<UiRegion> kids = topoSession.getSubRegions(currentLayout);
    List<UiSynthLink> links = topoSession.getLinks(currentLayout);
    return t2json.region(region, kids, links);
}
Also used : UiRegion(org.onosproject.ui.model.topo.UiRegion) UiSynthLink(org.onosproject.ui.model.topo.UiSynthLink)

Example 4 with UiSynthLink

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

the class Traffic2Monitor method doAggregation.

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// -- link aggregation
@Override
protected Set<TrafficLink> doAggregation(Set<TrafficLink> linksWithTraffic) {
    log.debug("Need to aggregate {} links", linksWithTraffic.size());
    // first, retrieve from the shared topology model those synth links that
    // are part of the region currently being viewed by the user...
    Map<UiLinkId, UiSynthLink> synthLinkMap = msgHandler.retrieveRelevantSynthLinks();
    // NOTE: compute Set<TrafficLink> which represents the consolidated links
    Map<UiLinkId, TrafficLink> mappedByUiLinkId = new HashMap<>();
    for (TrafficLink tl : linksWithTraffic) {
        UiLinkId tlid = uiLinkId(tl.key());
        UiSynthLink sl = synthLinkMap.get(tlid);
        if (sl != null) {
            UiLinkId aggrid = sl.link().id();
            TrafficLink aggregated = mappedByUiLinkId.computeIfAbsent(aggrid, TrafficLink::new);
            aggregated.mergeStats(tl);
        }
    }
    Set<TrafficLink> result = new HashSet<>();
    result.addAll(mappedByUiLinkId.values());
    return result;
}
Also used : TrafficLink(org.onosproject.ui.impl.topo.util.TrafficLink) UiLinkId(org.onosproject.ui.model.topo.UiLinkId) HashMap(java.util.HashMap) UiSynthLink(org.onosproject.ui.model.topo.UiSynthLink) HashSet(java.util.HashSet)

Aggregations

UiSynthLink (org.onosproject.ui.model.topo.UiSynthLink)4 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 UiLinkId (org.onosproject.ui.model.topo.UiLinkId)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 Set (java.util.Set)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 TrafficLink (org.onosproject.ui.impl.topo.util.TrafficLink)1 UiLink (org.onosproject.ui.model.topo.UiLink)1 UiRegion (org.onosproject.ui.model.topo.UiRegion)1