Route extends NetworkElement { public void setPath (double newCarriedTraffic , List<? extends NetworkElement> newPath , List<Double> newOccupationInformation) { netPlan.checkIsModifiable(); Pair<List<Link>,List<Resource>> res = netPlan.checkPathValidityForDemand (newPath, demand); List<Link> newSeqLinks = res.getFirst(); List<Resource> newSeqResources = res.getSecond(); if (newPath.size() != newOccupationInformation.size()) throw new Net2PlanException ("Wrong size of occupation array"); for (Double val : newOccupationInformation) if (val < 0) throw new Net2PlanException ("The occupation of a link/resource cannot be negative"); if (newPath.size() != newOccupationInformation.size()) throw new Net2PlanException ("Wrong size of array"); if (demand.isCoupledInSameLayer()) { final SortedSet<Link> intraLayerUpPropagation = demand.coupledUpperOrSameLayerLink.getIntraLayerUpPropagationIncludingMe(); for (NetworkElement e : newPath) if (e instanceof Link) { final SortedSet<Link> downProp = ((Link) e).getIntraLayerDownPropagationIncludingMe(); if (!Sets.intersection(downProp, intraLayerUpPropagation).isEmpty()) throw new Net2PlanException ("The sequence of links produces a loop in the intra-layer coupling"); } } this.setCarriedTraffic(0 , 0); for (Resource resource : this.getSeqResourcesTraversed()) resource.removeTraversingRoute(this); for (Link link : this.cache_seqLinksRealPath) link.cache_traversingRoutes.remove (this); for (Node node : cache_seqNodesRealPath) node.cache_nodeAssociatedRoutes.remove (this); layer.cache_routesDown.remove(this); layer.cache_routesTravLinkZeroCap.remove(this); this.currentPath = new LinkedList<NetworkElement> (newPath); this.cache_seqLinksRealPath = new LinkedList<Link> (newSeqLinks); boolean isRouteUp = demand.ingressNode.isUp; boolean isRouteTravZeroCapLinks = false; this.cache_seqNodesRealPath = new LinkedList<Node> (); cache_seqNodesRealPath.add (demand.getIngressNode()); for (Link e : cache_seqLinksRealPath) { cache_seqNodesRealPath.add (e.getDestinationNode()); isRouteUp = (isRouteUp && e.isUp && e.destinationNode.isUp); if (e.capacity < Configuration.precisionFactor) isRouteTravZeroCapLinks = true; } if (!isRouteUp) layer.cache_routesDown.add(this); if (isRouteTravZeroCapLinks) layer.cache_routesTravLinkZeroCap.add(this); for (Link link : newSeqLinks) { Integer numPassingTimes = link.cache_traversingRoutes.get (this); if (numPassingTimes == null) numPassingTimes = 1; else numPassingTimes ++; link.cache_traversingRoutes.put (this , numPassingTimes); } for (Node node : cache_seqNodesRealPath) node.cache_nodeAssociatedRoutes.add (this); this.cache_hasLoops = hasLoops(cache_seqNodesRealPath); if (cache_hasLoops) demand.routingCycleType = RoutingCycleType.OPEN_CYCLES; this.updatePropagationAndProcessingDelayInMiliseconds(); setCarriedTraffic (newCarriedTraffic , newOccupationInformation); if (ErrorHandling.isDebugEnabled()) netPlan.checkCachesConsistency(); } Route(NetPlan netPlan , long id , int index , Demand demand , List<? extends NetworkElement> seqLinksAndResourcesTraversed , AttributeMap attributes); Route getBidirectionalPair(); void setBidirectionalPair(Route r); boolean isBidirectional(); Route createBidirectionalOppositePair(); boolean isServiceChain(); SortedSet<Route> getRoutesIAmBackup(); List<Route> getBackupRoutes(); Triple<Double,List<NetworkElement>,List<Double>> getInitialState(); List<NetworkElement> getPath(); List<NetworkElement> getOppositePath(); boolean isBackupRoute(); boolean hasBackupRoutes(); void addBackupRoute(Route backupRoute); void removeBackupRoute(Route backupRoute); double getCarriedTraffic(); double getOccupiedCapacity(NetworkElement ... e); double getCarriedTrafficInNoFailureState(); double getOccupiedCapacityInNoFailureState(NetworkElement ... e); Demand getDemand(); Node getEgressNode(); Node getFirstAvailableNodeAfterFailures(); Node getFirstAvailableNodeBeforeFailures(); Node getIngressNode(); NetworkLayer getLayer(); double getLengthInKm(); int getNumberOfHops(); double getPropagationDelayInMiliseconds(); double getPropagationSpeedInKmPerSecond(); List<Double> getSeqOccupiedCapacitiesIfNotFailing(); boolean isOccupyingDifferentCapacitiesInDifferentLinksInNoFailureState(); List<Resource> getSeqResourcesTraversed(); List<Link> getSeqLinks(); List<Node> getSeqNodes(); List<Node> getSeqIntermediateNodes(); int getNumberOfTimesIsTraversed(NetworkElement e); SortedSet<SharedRiskGroup> getSRGs(); boolean hasLoops(); boolean isDown(); boolean isTraversingZeroCapLinks(); void remove(); void setCarriedTraffic(double newCarriedTraffic , double newOccupiedLinkAndResourcesCapacities); void setCarriedTraffic(double newCarriedTraffic , List<Double> linkAndResourcesOccupationInformation); void setPath(double newCarriedTraffic , List<? extends NetworkElement> newPath , List<Double> newOccupationInformation); void setSeqLinks(List<Link> seqLinks); @Override String toString(); static List<Link> getSeqLinks(List<? extends NetworkElement> seqLinksAndResources); static List<Resource> getSeqResources(List<? extends NetworkElement> seqLinksAndResources);  }
@Test public void testSetPath() { assertEquals (r123a.getCarriedTraffic() , 1.0 , 0.0); assertEquals (r123a.getSeqOccupiedCapacitiesIfNotFailing() , Arrays.asList(1.5, 1.5)); assertEquals (r123a.getSeqLinks() , Arrays.asList(link12, link23)); assertEquals (r123a.getSeqResourcesTraversed() , Arrays.asList()); assertEquals (r123a.getPath() , Arrays.asList(link12 , link23)); r123a.setPath(5 , Arrays.asList(link12 , link23) , Arrays.asList(1.0 , 3.0)); assertEquals (r123a.getCarriedTraffic() , 5.0 , 0.0); assertEquals (r123a.getSeqOccupiedCapacitiesIfNotFailing() , Arrays.asList(1.0, 3.0)); assertEquals (r123a.getSeqLinks() , Arrays.asList(link12, link23)); assertEquals (r123a.getSeqResourcesTraversed() , Arrays.asList()); assertEquals (r123a.getPath() , Arrays.asList(link12 , link23)); this.sc123 = np.addServiceChain(scd123 , 100 , Arrays.asList(100.0 , 1.0 , 200.0) , Arrays.asList(link12 , res2 , link23) , null); assertEquals (sc123.getCarriedTraffic() , 100.0 , 0.0); assertEquals (sc123.getSeqOccupiedCapacitiesIfNotFailing() , Arrays.asList(100.0 , 1.0 , 200.0)); assertEquals (sc123.getSeqLinks() , Arrays.asList(link12, link23)); assertEquals (sc123.getSeqResourcesTraversed() , Arrays.asList(res2)); assertEquals (sc123.getPath() , Arrays.asList(link12 , res2 , link23)); sc123.setPath(5 , Arrays.asList(link12 , res2backup , link23) , Arrays.asList(1.0 , 2.0 , 3.0)); assertEquals (sc123.getCarriedTraffic() , 5.0 , 0.0); assertEquals (sc123.getSeqOccupiedCapacitiesIfNotFailing() , Arrays.asList(1.0, 2.0 , 3.0)); assertEquals (sc123.getSeqLinks() , Arrays.asList(link12, link23)); assertEquals (sc123.getSeqResourcesTraversed() , Arrays.asList(res2backup)); assertEquals (sc123.getPath() , Arrays.asList(link12 , res2backup , link23)); }