/** * <p>Returns {@code true} if the link is coupled to a demand in the same layer as the demand, false otherwise.</p> * @return see above */ public boolean isCoupledInSameLayer () { if (coupledLowerOrThisLayerDemand != null) if (coupledLowerOrThisLayerDemand.getLayer() == this.layer) return true; return false; }
/** * <p>Returns {@code true} if the link is coupled to a demand in a different layer than the demnad (and thus an *upper* layer) * , false otherwise.</p> * @return see above */ public boolean isCoupledInDifferentLayer () { if (coupledLowerOrThisLayerDemand != null) if (coupledLowerOrThisLayerDemand.getLayer() != this.layer) return true; return false; }
/** Returns the set of demands in the given layer with the given tag. If no layer is provided, the defaulf layer is assumed. * @param tag the tag * @param optionalLayerParameter the layer (optional) * @return the set (or an empty set if there are no elements to return) */ public SortedSet<Demand> getTaggedDemands (String tag , NetworkLayer... optionalLayerParameter) { final NetworkLayer layer = checkInThisNetPlanOptionalLayerParameter(optionalLayerParameter); final SortedSet<NetworkElement> el = cache_taggedElements.get (tag); if (el == null) return new TreeSet<> (); return el.stream ().filter (e->e instanceof Demand).map(e->(Demand) e).filter(e->e.getLayer().equals(layer)).collect (Collectors.toCollection(TreeSet::new)); } /** Returns the set of links in the given layer with the given tag. If no layer is provided, the defaulf layer is assumed.
/** Returns the layers where this node is working: has at least one link, or demand, or multicast demand at the given layer associated to it. * @return see above */ public SortedSet<NetworkLayer> getWorkingLayers () { final SortedSet<NetworkLayer> res = new TreeSet<>(); res.addAll (cache_nodeIncomingLinks.stream().map(e->e.getLayer()).collect(Collectors.toSet())); res.addAll (cache_nodeOutgoingLinks.stream().map(e->e.getLayer()).collect(Collectors.toSet())); res.addAll (cache_nodeIncomingDemands.stream().map(e->e.getLayer()).collect(Collectors.toSet())); res.addAll (cache_nodeOutgoingDemands.stream().map(e->e.getLayer()).collect(Collectors.toSet())); res.addAll (cache_nodeIncomingMulticastDemands.stream().map(e->e.getLayer()).collect(Collectors.toSet())); res.addAll (cache_nodeOutgoingMulticastDemands.stream().map(e->e.getLayer()).collect(Collectors.toSet())); return res; }
/** * Constructor to generate a new {@code LightpathAdd} object. * @param demand Demand * @param lineRateGbps Line rate in Gbps */ public LightpathAdd(Demand demand, double lineRateGbps) { this.demand = demand; this.primaryRSA = null; this.lineRateGbps = lineRateGbps; this.backupRSA = null; this.ingressNode = demand.getIngressNode(); this.egressNode = demand.getEgressNode(); this.layer = demand.getLayer(); }
/** * Constructor to generate a new {@code LightpathAdd} object. * @param demand Demand * @param rsa The lightpath RSA of the primary (no backup) * @param lineRateGbps Line rate in Gbps */ public LightpathAdd(Demand demand, RSA rsa , double lineRateGbps) { this.demand = demand; this.primaryRSA = rsa; this.lineRateGbps = lineRateGbps; this.backupRSA = null; this.ingressNode = demand.getIngressNode(); this.egressNode = demand.getEgressNode(); this.layer = demand.getLayer(); }
/** * Constructor to generate a new {@code LightpathAdd} object. * @param demand Demand the lighptath belongs to * @param primaryRSA the RSA of the primary (create as a Route) * @param backupRSA the RSA of the backup (create as a protection segment) * @param lineRateGbps line rate of the lightpath */ public LightpathAdd(Demand demand, RSA primaryRSA , RSA backupRSA , double lineRateGbps) { this.demand = demand; this.primaryRSA = primaryRSA; this.lineRateGbps = lineRateGbps; this.backupRSA = backupRSA ; this.ingressNode = demand.getIngressNode(); this.egressNode = demand.getEgressNode(); this.layer = demand.getLayer(); }
private TBFToFromCarriedTraffic(Demand demand, boolean onlyThisLayer) { super(demand.getNetPlan()); this.initialElement = demand; this.onlyThisLayer = onlyThisLayer; this.initialFR = null; this.auxLayerInNodes = null; final Set<Link> linksAllLayers = new HashSet<>(); final Set<Demand> demandsAllLayers = new HashSet<>(); final Set<MulticastDemand> mDemandsAllLayers = new HashSet<>(); demandsAllLayers.add(demand); final Pair<SortedSet<Link>, SortedSet<Link>> thisLayerPropagation = demand.getLinksNoDownPropagationPotentiallyCarryingTraffic(); linksAllLayers.addAll(thisLayerPropagation.getFirst()); linksAllLayers.addAll(thisLayerPropagation.getSecond()); if (!onlyThisLayer) updatePropagationDownWards(linksAllLayers, linksAllLayers, demandsAllLayers, mDemandsAllLayers); if (!onlyThisLayer) updatePropagationUpWards(Arrays.asList(demand), null, linksAllLayers, demandsAllLayers, mDemandsAllLayers); final Set<NetworkLayer> layersToKeepAllElements = onlyThisLayer ? Sets.difference(new HashSet<>(netPlan.getNetworkLayers()), Sets.newHashSet(demand.getLayer())) : new HashSet<>(); updateAllButLinksDemandsMDemandsUsingExistingInfo(linksAllLayers, demandsAllLayers, mDemandsAllLayers, layersToKeepAllElements); }
this.layer = demand.getLayer (); this.demand = demand; this.ingressNode = demand.ingressNode;
private void drawDemand(Graphics2D g2d) { final FontMetrics fontMetrics = g2d.getFontMetrics(); final int regularInterlineSpacePixels = fontMetrics.getHeight(); final Demand demand = forwardingRule.getFirst(); final Node demandIngress = demand.getIngressNode(); final Node demandEgress = demand.getEgressNode(); final DrawNode ingressNode = new DrawNode(demandIngress, demand.getLayer(), maxIconSize); final DrawNode egressNode = new DrawNode(demandEgress, demand.getLayer(), maxIconSize); textRow = addIconJump(iconRow); textRow = addLineJump(textRow); textRow = addLineJump(textRow); iconRow = addLineJump(textRow); int topCoordinateLineNodes = maxIconSize + (generalMessage.size() * regularInterlineSpacePixels) + (maxNumberOfTagsPerNodeNorResource * regularInterlineSpacePixels) * iconRow; Point initialDnTopLeftPosition = new Point(maxIconSize, topCoordinateLineNodes); int xSeparationDnCenters = maxIconSize * 3; g2d.setFont(headerFont); g2d.drawString("Demand " + demand.getIndex(), maxIconSize, maxIconSize + (regularInterlineSpacePixels * (textRow))); g2d.setFont(plainFont); DrawNode.addNodeToGraphics(g2d, ingressNode, initialDnTopLeftPosition, fontMetrics, regularInterlineSpacePixels, null); DrawNode.addNodeToGraphics(g2d, egressNode, new Point(initialDnTopLeftPosition.x + xSeparationDnCenters, initialDnTopLeftPosition.y), fontMetrics, regularInterlineSpacePixels, null); drawnNodes.add(ingressNode); drawnNodes.add(egressNode); final DrawLine demandDL = new DrawLine(ingressNode, egressNode, ingressNode.posEast(), egressNode.posWest()); DrawLine.addLineToGraphics(g2d, demandDL, fontMetrics, regularInterlineSpacePixels, lineStroke); }
private List<Triple<String,String,String>> getForwardingRuleInfoTables (Pair<Demand,Link> fr) { final DecimalFormat df = new DecimalFormat("###.##"); final Demand d = fr.getFirst(); final Link e = fr.getSecond(); final NetworkLayer layer = d.getLayer(); final NetPlan np = e.getNetPlan(); final List<Triple<String,String,String>> res = new ArrayList <> (); final String trafUnits = np.getDemandTrafficUnitsName(layer); final String capUnits = np.getLinkCapacityUnitsName(layer); res.add(Triple.of("Demand index/id" , "Demand " + d.getIndex() + " (id " + d.getId() + ")", "demand" + d.getId())); res.add(Triple.of("Link index/id" , "Link " + e.getIndex() + " (id " + e.getId() + ")", "link" + e.getId())); res.add(Triple.of("Splitting factor", "" + df.format(np.getForwardingRuleSplittingFactor(d,e)) , "")); res.add(Triple.of("Carried traffic", "" + df.format(np.getForwardingRuleCarriedTraffic(d,e)) + " " + trafUnits , "")); return res; } private List<Triple<String,String,String>> getRouteInfoTables (Route r)
DrawLine(DrawNode from, DrawNode to, Link e, Point pFrom, Point pTo, double occupiedToShow) { final String capUnits = e.getNetPlan().getLinkCapacityUnitsName(e.getLayer()); this.from = from; this.to = to; this.pFrom = pFrom; this.pTo = pTo; this.labels = new ArrayList<>(); this.urlsLabels = new ArrayList<>(); final DecimalFormat df = new DecimalFormat("###.##"); String length_km = df.format((e.getLengthInKm() == Double.MAX_VALUE) ? Double.POSITIVE_INFINITY : e.getLengthInKm()); String delay_ms = df.format((e.getPropagationDelayInMs() == Double.MAX_VALUE) ? Double.POSITIVE_INFINITY : e.getPropagationDelayInMs()); this.labels.addAll(Arrays.asList( "Link " + e.getIndex() , length_km + " km (" + delay_ms + " ms)" , "Occup: " + String.format("%.1f" , occupiedToShow) + " " + capUnits, "Total: " + String.format("%.1f" , e.getOccupiedCapacity()) + "/" + String.format("%.1f" , e.getCapacity()) + " " + capUnits )); this.urlsLabels.addAll(Arrays.asList("link" + e.getId(), "", "", "")); if (e.getCoupledDemand() != null) { labels.add("Coupled: Demand " + e.getCoupledDemand().getIndex() + ", " + getLayerName(e.getCoupledDemand().getLayer())); urlsLabels.add("demand" + e.getCoupledDemand().getId()); } else if (e.getCoupledMulticastDemand() != null) { labels.add("Coupled: Multicast demand " + e.getCoupledMulticastDemand().getIndex() + ", " + getLayerName(e.getCoupledMulticastDemand().getLayer())); urlsLabels.add("multicastDemand" + e.getCoupledMulticastDemand().getId()); } this.associatedElement = e; }
WServiceChainRequest(Demand sc) { super(sc); this.sc = sc; assert sc.getLayer().getIndex() == 1; assert new WNode (sc.getIngressNode()).isVirtualNode(); assert new WNode (sc.getEgressNode()).isVirtualNode(); }
final Link eNewNp = targetNp.getLinkFromId(e.getId()); if (dNewNp == null || eNewNp == null) return Optional.empty(); if (!dNewNp.getLayer().equals(eNewNp.getLayer ())) return Optional.empty(); nefrNewNp = new NetworkElementOrFr(Pair.of(dNewNp, eNewNp));
final NetworkLayer layer = d.getLayer(); final List<Triple<String,String,String>> res = new ArrayList <> (); final RoutingCycleType cycleType = d.getRoutingCycleType();
if (e.isCoupled()) final NetworkLayer lowerLayer = e.getCoupledDemand() == null? e.getCoupledMulticastDemand().getLayer() : e.getCoupledDemand().getLayer(); res.add(Triple.of("- Lower layer coupled to", getLayerName(lowerLayer) , "")); if (e.getCoupledDemand() == null)
public NetworkLayer getOrEstimateLayer () { if (ne == null && fr == null) return null; if (isFr()) return fr.getFirst().getLayer(); switch (ne.getNeType()) { case DEMAND: return ((Demand) ne).getLayer(); case LAYER: return (NetworkLayer) ne; case LINK: return ((Link) ne).getLayer(); case MULTICAST_DEMAND: return ((MulticastDemand) ne).getLayer(); case MULTICAST_TREE: return ((MulticastTree) ne).getLayer(); case NETWORK: return ((NetPlan) ne).getNetworkLayerDefault(); case NODE: return ne.getNetPlan().getNetworkLayerDefault(); case RESOURCE: return ne.getNetPlan().getNetworkLayerDefault(); case ROUTE: return ((Route) ne).getLayer(); case SRG: return ne.getNetPlan().getNetworkLayerDefault(); default: throw new Net2PlanException (); } } }
final boolean isFRLayerVisibleInTheCanvas = vs.isLayerVisibleInCanvas(pickedFR.getFirst().getLayer()); final Demand pickedDemand = pickedFR.getFirst(); final Link pickedLink = pickedFR.getSecond();
static void drawDownPropagationInterLayerLinks(VisualizationState vs, SortedSet<Link> links, Paint color) { for (Link link : links) { final GUILink gl = vs.getCanvasAssociatedGUILink(link); if (gl == null) continue; if (!link.isCoupled()) continue; final boolean isCoupledToDemand = link.getCoupledDemand() != null; final NetworkLayer upperLayer = link.getLayer(); final NetworkLayer lowerLayer = isCoupledToDemand ? link.getCoupledDemand().getLayer() : link.getCoupledMulticastDemand().getLayer(); if (!vs.isLayerVisibleInCanvas(lowerLayer)) continue; for (GUILink interLayerLink : vs.getCanvasIntraNodeGUILinkSequence(link.getOriginNode(), upperLayer, lowerLayer)) { setCurrentDefaultEdgeStroke(vs, interLayerLink, VisualizationConstants.DEFAULT_INTRANODEGUILINK_EDGESTROKE_PICKED, VisualizationConstants.DEFAULT_INTRANODEGUILINK_EDGESTROKE_PICKED); interLayerLink.setEdgeDrawPaint(color); interLayerLink.setShownSeparated(false); interLayerLink.setHasArrow(true); } for (GUILink interLayerLink : vs.getCanvasIntraNodeGUILinkSequence(link.getDestinationNode(), lowerLayer, upperLayer)) { setCurrentDefaultEdgeStroke(vs, interLayerLink, VisualizationConstants.DEFAULT_INTRANODEGUILINK_EDGESTROKE_PICKED, VisualizationConstants.DEFAULT_INTRANODEGUILINK_EDGESTROKE_PICKED); interLayerLink.setEdgeDrawPaint(color); interLayerLink.setShownSeparated(false); interLayerLink.setHasArrow(true); } } }