void copyFrom (Node origin) { if ((this.id != origin.id) || (this.index != origin.index)) throw new RuntimeException ("Bad"); if ((this.netPlan == null) || (origin.netPlan == null) || (this.netPlan == origin.netPlan)) throw new RuntimeException ("Bad"); this.name = origin.name; this.population = origin.population; this.siteName = origin.siteName; this.mapLayout2NodeXYPositionMap = new TreeMap<> (); for (Entry<String,Point2D> entry : origin.mapLayout2NodeXYPositionMap.entrySet()) this.mapLayout2NodeXYPositionMap.put(entry.getKey(), new UnmodifiablePoint2D(entry.getValue().getX(), entry.getValue().getY())); this.isUp = origin.isUp; this.mapLayer2URLSpecificIcon.clear(); for (NetworkLayer l : origin.mapLayer2URLSpecificIcon.keySet()) this.mapLayer2URLSpecificIcon.put(this.netPlan.getNetworkLayerFromId(l.getId()) , origin.mapLayer2URLSpecificIcon.get(l)); this.cache_nodeIncomingLinks.clear (); for (Link e : origin.cache_nodeIncomingLinks) this.cache_nodeIncomingLinks.add(this.netPlan.getLinkFromId (e.id)); this.cache_nodeOutgoingLinks.clear (); for (Link e : origin.cache_nodeOutgoingLinks) this.cache_nodeOutgoingLinks.add(this.netPlan.getLinkFromId (e.id)); this.cache_nodeIncomingDemands.clear (); for (Demand d : origin.cache_nodeIncomingDemands) this.cache_nodeIncomingDemands.add(this.netPlan.getDemandFromId (d.id)); this.cache_nodeOutgoingDemands.clear (); for (Demand d : origin.cache_nodeOutgoingDemands) this.cache_nodeOutgoingDemands.add(this.netPlan.getDemandFromId (d.id)); this.cache_nodeIncomingMulticastDemands.clear (); for (MulticastDemand d : origin.cache_nodeIncomingMulticastDemands) this.cache_nodeIncomingMulticastDemands.add(this.netPlan.getMulticastDemandFromId(d.id)); this.cache_nodeOutgoingMulticastDemands.clear (); for (MulticastDemand d : origin.cache_nodeOutgoingMulticastDemands) this.cache_nodeOutgoingMulticastDemands.add(this.netPlan.getMulticastDemandFromId(d.id)); this.cache_nodeNonDynamicSRGs.clear (); for (SharedRiskGroup s : origin.cache_nodeNonDynamicSRGs) this.cache_nodeNonDynamicSRGs.add(this.netPlan.getSRGFromId(s.id)); this.cache_nodeResources.clear(); for (Resource r : origin.cache_nodeResources) this.cache_nodeResources.add(this.netPlan.getResourceFromId(r.id)); this.cache_nodeAssociatedRoutes.clear (); for (Route r : origin.cache_nodeAssociatedRoutes) this.cache_nodeAssociatedRoutes.add(this.netPlan.getRouteFromId (r.id)); this.cache_nodeAssociatedulticastTrees.clear (); for (MulticastTree t : origin.cache_nodeAssociatedulticastTrees) this.cache_nodeAssociatedulticastTrees.add(this.netPlan.getMulticastTreeFromId(t.id)); }
private void parseHopByHopRouting(NetPlan netPlan, long layerId) throws XMLStreamException netPlan.setRoutingTypeAllDemands (RoutingType.HOP_BY_HOP_ROUTING , netPlan.getNetworkLayerFromId(layerId) ); final NetworkLayer layer = netPlan.getNetworkLayerFromId(layerId); final int D = netPlan.getNumberOfDemands(layer); final int E = netPlan.getNumberOfLinks(layer); if (endElementName.equals("hopByHopRouting")) NetworkLayer thisLayer = netPlan.getNetworkLayerFromId(layerId); netPlan.setForwardingRules(f_de , null , thisLayer); return;
private void parseSourceRouting(NetPlan netPlan, long layerId) throws XMLStreamException netPlan.setRoutingTypeAllDemands (RoutingType.SOURCE_ROUTING , netPlan.getNetworkLayerFromId(layerId)); this.backupRouteIdsMap.clear(); // in multiple layers, we have to refresh this
private void parseHopByHopRouting(NetPlan netPlan, long layerId) throws XMLStreamException final NetworkLayer layer = netPlan.getNetworkLayerFromId(layerId); final int D = netPlan.getNumberOfDemands(layer); final int E = netPlan.getNumberOfLinks(layer); if (endElementName.equals("hopByHopRouting")) NetworkLayer thisLayer = netPlan.getNetworkLayerFromId(layerId); netPlan.setForwardingRules(f_de , new TreeSet<> (netPlan.getDemandsHopByHopRouted(thisLayer)) , thisLayer); return;
else if (hlType.equals(PREFIXLAYER)) final NetworkLayer layer = np.getNetworkLayerFromId(Long.parseLong(hlInfo)); np.setNetworkLayerDefault(layer); pickManager.pickElements(pickManager.new PickStateInfo(layer, Optional.empty()));
final NetworkLayer e = np.getNetworkLayerFromId(id); np.setNetworkLayerDefault(e); callback.updateVisualizationAfterChanges();
@Override public int compare(Pair<Long, Long> o1, Pair<Long, Long> o2) { NetworkLayer layer = netPlan.getNetworkLayerFromId(layerId); Node node1 = netPlan.getLinkFromId (o1.getSecond()).getOriginNode(); Node node2 = netPlan.getLinkFromId (o2.getSecond()).getOriginNode(); int compareNodes = Long.compare(node1.getId (), node2.getId ()); if (compareNodes != 0) return compareNodes; int compareDemands = o1.getFirst().compareTo(o2.getFirst()); if (compareDemands != 0) return compareDemands; int compareLinks = o1.getSecond().compareTo(o2.getSecond()); return compareLinks; } }
if (newValue.isEmpty()) netPlan.getNetworkLayerFromId(layerId).removeAttribute(key); else netPlan.getNetworkLayerFromId(layerId).setAttribute(key, newValue); break;
NetworkLayer layer = (cli.hasOption("traffic-layer")) ? netPlan.getNetworkLayerFromId(((Number) cli.getParsedOptionValue("traffic-layer")).longValue()) : netPlan.getNetworkLayerDefault();
final NetworkLayer layerNewNp = targetNp.getNetworkLayerFromId(layer.getId()); if (layerNewNp == null) return Optional.empty(); NetworkElementOrFr nefrNewNp = null;
this.layer = layerId.getLong () == -1? initialNetPlan.getNetworkLayerDefault() : initialNetPlan.getNetworkLayerFromId(layerId.getLong ()); this.nodes = initialNetPlan.getNodes (); this.isShortestPathNumHops = shortestPathType.getString ().equalsIgnoreCase("hops");
private void parseMulticastDemand(NetPlan netPlan, long layerId) throws XMLStreamException { final long demandId = getLong ("id"); if (demandId >= netPlan.nextElementId.toLong()) throw new Net2PlanException ("A network element has an id higher than the nextElementId"); final long ingressNodeId = getLong ("ingressNodeId"); Set<Node> newEgressNodes = getNodeSetFromIds(netPlan , getListLong("egressNodeIds")); final double offeredTraffic = getDouble ("offeredTraffic"); final MulticastDemand newDemand = netPlan.addMulticastDemand(demandId , netPlan.getNodeFromId(ingressNodeId), newEgressNodes , offeredTraffic, null , netPlan.getNetworkLayerFromId(layerId)); readAndAddAttributesToEndAndPdForNodes(newDemand, "multicastDemand"); }
final String layerName = np.getNetworkLayerFromId(layerId).getName(); String layerLabel = "Layer " + layerId; if (!layerName.isEmpty()) layerLabel += " (" + layerName + ")"; NetworkLayer layer = np.getNetworkLayerFromId(layerId); for (MulticastDemand demand : getSelectedElements()) if (!demand.isCoupled())
long bidirectionalPairId = -1; try { bidirectionalPairId = getLong ("bidirectionalPairId"); } catch (Exception e) {} Demand newDemand = netPlan.addDemand(demandId , netPlan.getNodeFromId(ingressNodeId), netPlan.getNodeFromId(egressNodeId), offeredTraffic, networkLayer2RoutingType.get(layerId) , null , netPlan.getNetworkLayerFromId(layerId)); newDemand.setIntendedRecoveryType(recoveryType); final Demand bidirPairDemand = bidirectionalPairId == -1? null : netPlan.getDemandFromId(bidirectionalPairId);
long bidirectionalPairId = -1; try { bidirectionalPairId = getLong ("bidirectionalPairId"); } catch (Exception e) {} Demand newDemand = netPlan.addDemand(demandId , netPlan.getNodeFromId(ingressNodeId), netPlan.getNodeFromId(egressNodeId), offeredTraffic, routingType != null? routingType : RoutingType.SOURCE_ROUTING,null , netPlan.getNetworkLayerFromId(layerId)); newDemand.setIntendedRecoveryType(recoveryType); newDemand.setOfferedTrafficPerPeriodGrowthFactor(offeredTrafficGrowthFactorPerPeriodZeroIsNoGrowth);
private void parseLink(NetPlan netPlan, long layerId) throws XMLStreamException { final long linkId = getLong ("id"); if (linkId >= netPlan.nextElementId.toLong()) throw new Net2PlanException ("A network element has an id higher than the nextElementId"); final long originNodeId = getLong ("originNodeId"); final long destinationNodeId = getLong ("destinationNodeId"); final double capacity = getDouble ("capacity"); final double lengthInKm = getDouble ("lengthInKm"); final double propagationSpeedInKmPerSecond = getDouble ("propagationSpeedInKmPerSecond"); long bidirectionalPairId = -1; try { bidirectionalPairId = getLong ("bidirectionalPairId"); } catch (Exception e) {} boolean isUp = true; try { isUp = getBoolean ("isUp"); } catch (Exception e) {} Link newLink = netPlan.addLink(linkId , netPlan.getNodeFromId(originNodeId), netPlan.getNodeFromId(destinationNodeId), capacity, lengthInKm, propagationSpeedInKmPerSecond, null , netPlan.getNetworkLayerFromId(layerId)); newLink.setFailureState(isUp); final Link bidirPairLink = bidirectionalPairId == -1? null : netPlan.getLinkFromId(bidirectionalPairId); if (bidirPairLink != null) { if (bidirPairLink.isBidirectional()) throw new RuntimeException (); bidirPairLink.setBidirectionalPair(newLink); } readAndAddAttributesToEndAndPdForNodes(newLink, "link"); }
NetworkLayer trafficLayer = trafficLayerId.getLong () == -1? initialNetPlan.getNetworkLayerDefault () : initialNetPlan.getNetworkLayerFromId(trafficLayerId.getLong ()); if (trafficLayer == null) throw new Net2PlanException ("Unknown layer id"); final int D = initialNetPlan.getNumberOfDemands(trafficLayer);
NetworkLayer trafficLayer = trafficLayerId.getLong () == -1? initialNetPlan.getNetworkLayerDefault () : initialNetPlan.getNetworkLayerFromId(trafficLayerId.getLong ()); if (trafficLayer == null) throw new Net2PlanException ("Unknown layer id"); final int D = initialNetPlan.getNumberOfDemands(trafficLayer);
private void parseLink(NetPlan netPlan, long layerId) throws XMLStreamException { final long linkId = getLong ("id"); if (linkId >= netPlan.nextElementId.toLong()) throw new Net2PlanException ("A network element has an id higher than the nextElementId"); final long originNodeId = getLong ("originNodeId"); final long destinationNodeId = getLong ("destinationNodeId"); final double capacity = getDouble ("capacity"); final double lengthInKm = getDouble ("lengthInKm"); final double propagationSpeedInKmPerSecond = getDouble ("propagationSpeedInKmPerSecond"); long bidirectionalPairId = -1; try { bidirectionalPairId = getLong ("bidirectionalPairId"); } catch (Exception e) {} boolean isUp = true; try { isUp = getBoolean ("isUp"); } catch (Exception e) {} Link newLink = netPlan.addLink(linkId , netPlan.getNodeFromId(originNodeId), netPlan.getNodeFromId(destinationNodeId), capacity, lengthInKm, propagationSpeedInKmPerSecond, null , netPlan.getNetworkLayerFromId(layerId)); newLink.setFailureState(isUp); newLink.setName(getStringOrDefault("name", "")); newLink.setDescription(getStringOrDefault("description", "")); try { final List<String> rows = StringUtils.readEscapedString_asStringList (getString("monitoredOrForecastedTraffics") , new ArrayList<> ()); final TrafficSeries readTimeSerie = TrafficSeries.createFromStringList(rows); newLink.setMonitoredOrForecastedCarriedTraffic(readTimeSerie); } catch (Exception e) {} final Link bidirPairLink = bidirectionalPairId == -1? null : netPlan.getLinkFromId(bidirectionalPairId); if (bidirPairLink != null) { if (bidirPairLink.isBidirectional()) throw new RuntimeException (); bidirPairLink.setBidirectionalPair(newLink); } readAndAddAttributesToEndAndPdForNodes(newLink, "link"); }
private void parseMulticastDemand(NetPlan netPlan, long layerId) throws XMLStreamException { final long demandId = getLong ("id"); if (demandId >= netPlan.nextElementId.toLong()) throw new Net2PlanException ("A network element has an id higher than the nextElementId"); final long ingressNodeId = getLong ("ingressNodeId"); SortedSet<Node> newEgressNodes = getNodeSetFromIds(netPlan , getListLong("egressNodeIds")); final double offeredTraffic = getDouble ("offeredTraffic"); double maximumAcceptableE2EWorstCaseLatencyInMs = -1; try { maximumAcceptableE2EWorstCaseLatencyInMs = getDouble ("maximumAcceptableE2EWorstCaseLatencyInMs"); } catch (Throwable e) {} double offeredTrafficGrowthFactorPerPeriodZeroIsNoGrowth = 0; try { offeredTrafficGrowthFactorPerPeriodZeroIsNoGrowth = getDouble ("offeredTrafficGrowthFactorPerPeriodZeroIsNoGrowth"); } catch (Throwable e) {} String qosType = ""; try { qosType = getString("qosType"); } catch (Throwable e) {} final MulticastDemand newDemand = netPlan.addMulticastDemand(demandId , netPlan.getNodeFromId(ingressNodeId), newEgressNodes , offeredTraffic, null , netPlan.getNetworkLayerFromId(layerId)); newDemand.setMaximumAcceptableE2EWorstCaseLatencyInMs(maximumAcceptableE2EWorstCaseLatencyInMs); newDemand.setOfferedTrafficPerPeriodGrowthFactor(offeredTrafficGrowthFactorPerPeriodZeroIsNoGrowth); newDemand.setQoSType(qosType); newDemand.setName(getStringOrDefault("name", "")); newDemand.setDescription(getStringOrDefault("description", "")); try { final List<String> rows = StringUtils.readEscapedString_asStringList (getString("monitoredOrForecastedTraffics") , new ArrayList<> ()); final TrafficSeries readTimeSerie = TrafficSeries.createFromStringList(rows); newDemand.setMonitoredOrForecastedOfferedTraffic(readTimeSerie); } catch (Exception e) {} readAndAddAttributesToEndAndPdForNodes(newDemand, "multicastDemand"); }