Route extends NetworkElement { @Override void checkCachesConsistency () { super.checkCachesConsistency (); if (!(layer.routes.contains(this))) throw new RuntimeException(); if (!(demand.cache_routes.contains(this))) throw new RuntimeException(); if (this.bidirectionalPair != null) { if (this.bidirectionalPair.bidirectionalPair != this) throw new RuntimeException ("Bad: this.bidirectionalPair.bidirectionalPair : " + this.bidirectionalPair.bidirectionalPair); if (this.bidirectionalPair.netPlan != this.netPlan) throw new RuntimeException ("Bad"); if (this.demand.bidirectionalPair != this.bidirectionalPair.demand) throw new RuntimeException ("Bad"); if (this.bidirectionalPair.ingressNode != this.egressNode) throw new RuntimeException ("Bad"); if (this.bidirectionalPair.egressNode != this.ingressNode) throw new RuntimeException ("Bad"); if (this.bidirectionalPair.layer != this.layer) throw new RuntimeException ("Bad"); } if (ingressNode.netPlan == null) throw new RuntimeException(); if (egressNode.netPlan == null) throw new RuntimeException(); if (layer.netPlan == null) throw new RuntimeException(); if (initialStatePath == null) throw new RuntimeException(); if (currentLinksAndResourcesOccupationIfNotFailing == null) throw new RuntimeException(); if (currentPath == null) throw new RuntimeException(); if (cache_linkAndResourcesTraversedOccupiedCapIfnotFailMap == null) throw new RuntimeException(); if (backupRoutes == null) throw new RuntimeException(); if (cache_seqLinksRealPath == null) throw new RuntimeException(); if (cache_seqNodesRealPath == null) throw new RuntimeException(); if (cache_routesIAmBackUp == null) throw new RuntimeException(); if (!this.cache_hasLoops != (new TreeSet<> (cache_seqNodesRealPath).size() == cache_seqNodesRealPath.size())) throw new RuntimeException(); netPlan.checkInThisNetPlanAndLayer(currentPath , layer); netPlan.checkInThisNetPlanAndLayer(cache_linkAndResourcesTraversedOccupiedCapIfnotFailMap.keySet() , layer); netPlan.checkInThisNetPlanAndLayer(cache_seqLinksRealPath , layer); netPlan.checkInThisNetPlanAndLayer(cache_seqNodesRealPath , layer); netPlan.checkInThisNetPlanAndLayer(cache_routesIAmBackUp , layer); for (NetworkElement e : currentPath) { if (e == null) throw new RuntimeException(); if (e instanceof Link) { final Link ee = (Link) e; if (!(ee.cache_traversingRoutes.containsKey(this))) throw new RuntimeException(); } if (e instanceof Resource) { final Resource ee = (Resource) e; if (!(ee.cache_traversingRoutesAndOccupiedCapacitiesIfNotFailingRoute.containsKey(this))) throw new RuntimeException(); } } for (Entry<NetworkElement,Double> entry : cache_linkAndResourcesTraversedOccupiedCapIfnotFailMap.entrySet()) { if (entry.getKey() == null) throw new RuntimeException(); if (entry.getValue() == null) throw new RuntimeException(); if (entry.getKey() instanceof Resource) { if (((Resource) entry.getKey()).cache_traversingRoutesAndOccupiedCapacitiesIfNotFailingRoute == null) throw new RuntimeException(); if (Double.compare(((Resource) entry.getKey()).cache_traversingRoutesAndOccupiedCapacitiesIfNotFailingRoute.get(this), entry.getValue()) != 0) throw new RuntimeException(); } else if (entry.getKey() instanceof Link) { if (!(((Link) entry.getKey()).cache_traversingRoutes.containsKey(this))) throw new RuntimeException(); if (!(((Link) entry.getKey()).cache_traversingRoutes.get(this) > 0)) throw new RuntimeException(); } } List<Resource> travResources = new LinkedList<Resource> (); for (NetworkElement el : currentPath) if (el instanceof Resource) travResources.add((Resource) el); for (Resource res : travResources) { if (netPlan.cache_id2ResourceMap.get(res.id) != res) throw new RuntimeException(); if (netPlan.resources.get(res.index) != res) throw new RuntimeException(); if (res.cache_traversingRoutesAndOccupiedCapacitiesIfNotFailingRoute.get(this) == null) throw new RuntimeException(); if (cache_linkAndResourcesTraversedOccupiedCapIfnotFailMap.get(res) == null) throw new RuntimeException(); if (Double.compare(res.cache_traversingRoutesAndOccupiedCapacitiesIfNotFailingRoute.get(this), cache_linkAndResourcesTraversedOccupiedCapIfnotFailMap.get(res)) != 0) throw new RuntimeException(); } for (Link link : cache_seqLinksRealPath) if (!(link.cache_traversingRoutes.containsKey(this))) throw new RuntimeException(); for (Node node : cache_seqNodesRealPath) if (!(node.cache_nodeAssociatedRoutes.contains(this))) throw new RuntimeException(); boolean shouldBeUp = true; for (Link e : cache_seqLinksRealPath) if (!e.isUp) { shouldBeUp = false; break; } boolean travZeroCapLinks = cache_seqLinksRealPath.stream().anyMatch(e->e.capacity<Configuration.precisionFactor); if (shouldBeUp) for (Node n : cache_seqNodesRealPath) if (!n.isUp) { shouldBeUp = false; break; } if (!shouldBeUp != this.isDown()) { System.out.println ("Route : " + this + ", should be up: " + shouldBeUp + ", isDown: " + isDown() + ", carried traffic: " + this.getCarriedTraffic() + ", carried all ok: " + currentCarriedTrafficIfNotFailing); for (Link e : cache_seqLinksRealPath) System.out.println ("Link e: " + e + ", isUp " + e.isUp); for (Node n : cache_seqNodesRealPath) System.out.println ("Node n: " + n + ", isUp " + n.isUp); throw new RuntimeException("Bad."); } if (shouldBeUp) { if (Math.abs(getCarriedTraffic() - currentCarriedTrafficIfNotFailing) > 0.001) throw new RuntimeException(); } else { if (Math.abs(getCarriedTraffic()) > 0.001) throw new RuntimeException(); } if (travZeroCapLinks) if (!(layer.cache_routesTravLinkZeroCap.contains(this))) throw new RuntimeException(); else if (!layer.cache_routesTravLinkZeroCap.contains(this)) throw new RuntimeException(); for (Route r : backupRoutes) if(!(r.cache_routesIAmBackUp.contains(this))) throw new RuntimeException(); for (Route r : cache_routesIAmBackUp) if(!(r.backupRoutes.contains(this))) throw new RuntimeException(); } 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 testCheckCaches() { np.checkCachesConsistency(); }