public void put(Demand demand , Link link) { demandLinkMapping.put(demand, link); if (demandSideLayer == null) demandSideLayer = demand.layer; else if (!demandSideLayer.equals(demand.layer)) throw new RuntimeException ("Bad"); if (linkSideLayer == null) linkSideLayer = link.layer; else if (!linkSideLayer.equals(link.layer)) throw new RuntimeException ("Bad"); }
public void put(MulticastDemand demand , SortedSet<Link> links) { multicastDemandLinkMapping.put(demand, links); if (demandSideLayer == null) demandSideLayer = demand.layer; else if (!demandSideLayer.equals(demand.layer)) throw new RuntimeException ("Bad"); if (linkSideLayer == null) linkSideLayer = links.iterator().next().layer; else if (!linkSideLayer.equals(links.iterator().next().layer)) throw new RuntimeException ("Bad"); }
/** * <p>Returns the set of links associated to the SRG (fail, when the SRG is in failure state), but only those belonging to the given layer. </p> * @param layer the layer * @return The set of failing links */ public SortedSet<Link> getLinks(NetworkLayer layer) { SortedSet<Link> res = new TreeSet<Link> (); for (Link e : getLinksAllLayers()) if (e.layer.equals(layer)) res.add (e); return res; }
/** * <p>Returns the set of multicast trees in the given layer affected by the SRG (fail, when the SRG is in failure state)</p> * @param layer Network layer * @return The failing multicast trees belonging to the given layer */ public SortedSet<MulticastTree> getAffectedMulticastTrees (NetworkLayer layer) { SortedSet<MulticastTree> res = new TreeSet<MulticastTree> (); for (Link e : getLinksAllLayers()) for (MulticastTree t : e.cache_traversingTrees) if (t.layer.equals(layer)) res.add (t); for (Node n : getNodes ()) for (MulticastTree t : n.cache_nodeAssociatedulticastTrees) if (t.layer.equals(layer)) res.add (t); return res; }
/** Returns the set of routes 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<Route> getTaggedRoutes (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 Route).map(e->(Route) e).filter(e->e.getLayer().equals(layer)).collect (Collectors.toCollection(TreeSet::new)); } /** Returns the set of SRGs with the given tag.
/** Returns the set of links 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<Link> getTaggedLinks (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 Link).map(e->(Link) e).filter(e->e.getLayer().equals(layer)).collect (Collectors.toCollection(TreeSet::new)); } /** Returns the set of multicast demands in the given layer with the given tag. If no layer is provided, the defaulf layer is assumed.
/** Returns the set of multicast trees 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<MulticastTree> getTaggedMulticastTrees (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 MulticastTree).map(e->(MulticastTree) e).filter(e->e.getLayer().equals(layer)).collect (Collectors.toCollection(TreeSet::new)); } /** Returns the set of layers with the given tag.
/** * <p>Returns the set of multicast trees ending in the node, in the given layer. If no layer is provided, the default layer is assumed.</p> * @param optionalLayerParameter Network layer (optional) * @return The multicast trees, or an empty set if none */ public SortedSet<MulticastTree> getIncomingMulticastTrees (NetworkLayer ... optionalLayerParameter) { checkAttachedToNetPlanObject(); NetworkLayer layer = netPlan.checkInThisNetPlanOptionalLayerParameter(optionalLayerParameter); SortedSet<MulticastTree> res = new TreeSet<MulticastTree> (); for (MulticastDemand e : cache_nodeIncomingMulticastDemands) if (e.layer.equals(layer)) res.addAll (e.cache_multicastTrees); return res; }
/** * <p>Returns the set of links initiated in the node, in the given layer. If no layer is provided, the default layer is assumed.</p> * @param optionalLayerParameter Network layer (optional) * @return The set of outgoing links, or an empty set if none */ public SortedSet<Link> getOutgoingLinks(NetworkLayer ... optionalLayerParameter) { checkAttachedToNetPlanObject(); NetworkLayer layer = netPlan.checkInThisNetPlanOptionalLayerParameter(optionalLayerParameter); SortedSet<Link> res = new TreeSet<Link> (); for (Link e : cache_nodeOutgoingLinks) if (e.layer.equals(layer)) res.add (e); return res; }
/** * <p>Returns the set of multicast tree initiated in the node, in the given layer. If no layer is provided, the default layer is assumed. </p> * @param optionalLayerParameter The layer * @return The multicast trees, or an empty set if none */ public SortedSet<MulticastTree> getOutgoingMulticastTrees (NetworkLayer ... optionalLayerParameter) { checkAttachedToNetPlanObject(); NetworkLayer layer = netPlan.checkInThisNetPlanOptionalLayerParameter(optionalLayerParameter); SortedSet<MulticastTree> res = new TreeSet<MulticastTree> (); for (MulticastDemand e : cache_nodeOutgoingMulticastDemands) if (e.layer.equals(layer)) res.addAll (e.cache_multicastTrees); return res; }
/** * <p>Returns the set of multicast demands ending in the node, in the given layer. If no layer is provided, the default layer is assumed.</p> * @param optionalLayerParameter Network layer (optional) * @return The demands, or an empty set if none */ public SortedSet<MulticastDemand> getIncomingMulticastDemands(NetworkLayer ... optionalLayerParameter) { checkAttachedToNetPlanObject(); NetworkLayer layer = netPlan.checkInThisNetPlanOptionalLayerParameter(optionalLayerParameter); SortedSet<MulticastDemand> res = new TreeSet<MulticastDemand> (); for (MulticastDemand e : cache_nodeIncomingMulticastDemands) if (e.layer.equals(layer)) res.add (e); return res; }
/** Returns the set of multicast 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<MulticastDemand> getTaggedMulticastDemands (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 MulticastDemand).map(e->(MulticastDemand) e).filter(e->e.getLayer().equals(layer)).collect (Collectors.toCollection(TreeSet::new)); } /** Returns the set of multicast trees in the given layer with the given tag. If no layer is provided, the defaulf layer is assumed.
/** * <p>Returns the set of demands ending in the node, in the given layer. If no layer is provided, the default layer is assumed.</p> * @param optionalLayerParameter Network layer (optional) * @return the demands, or an empty set if none */ public SortedSet<Demand> getIncomingDemands(NetworkLayer ... optionalLayerParameter) { checkAttachedToNetPlanObject(); NetworkLayer layer = netPlan.checkInThisNetPlanOptionalLayerParameter(optionalLayerParameter); SortedSet<Demand> res = new TreeSet<Demand> (); for (Demand e : cache_nodeIncomingDemands) if (e.layer.equals(layer)) res.add (e); return res; }
/** * <p>Returns the set of routes ending in the node, in the given layer. If no layer is provided, the default layer is assumed.</p> * @param optionalLayerParameter Network layer * @return The routes, or an empty set if none */ public SortedSet<Route> getIncomingRoutes(NetworkLayer ... optionalLayerParameter) { checkAttachedToNetPlanObject(); NetworkLayer layer = netPlan.checkInThisNetPlanOptionalLayerParameter(optionalLayerParameter); SortedSet<Route> res = new TreeSet<Route> (); for (Demand d : cache_nodeIncomingDemands) if (d.layer.equals(layer)) res.addAll (d.cache_routes); return res; }
/** * <p>Returns the set of demands initiated in the node, in the given layer. If no layer is provided, the default layer is assumed.</p> * @param optionalLayerParameter Network layer (optional) * @return The demands, or an empty set if none */ public SortedSet<Demand> getOutgoingDemands(NetworkLayer ... optionalLayerParameter) { checkAttachedToNetPlanObject(); NetworkLayer layer = netPlan.checkInThisNetPlanOptionalLayerParameter(optionalLayerParameter); SortedSet<Demand> res = new TreeSet<Demand> (); for (Demand e : cache_nodeOutgoingDemands) if (e.layer.equals(layer)) res.add (e); return res; }
/** * <p>Returns the set of multicast demands initiated in the node, in the given layer. If no layer is provided, the default layer is assumed.</p> * @param optionalLayerParameter Network layer (optional) * @return The demands, or an empty set if none */ public SortedSet<MulticastDemand> getOutgoingMulticastDemands(NetworkLayer ... optionalLayerParameter) { checkAttachedToNetPlanObject(); NetworkLayer layer = netPlan.checkInThisNetPlanOptionalLayerParameter(optionalLayerParameter); SortedSet<MulticastDemand> res = new TreeSet<MulticastDemand> (); for (MulticastDemand e : cache_nodeOutgoingMulticastDemands) if (e.layer.equals(layer)) res.add (e); return res; }
/** * <p>Returns the total multicast offered traffic initiated in the node, counting the multicast demands at the given layer. * If no layer is provided, the default layer is assumed.</p> * @param optionalLayerParameter Network layer (optional) * @return The total multicast offered traffic initiated in the node */ public double getIngressOfferedMulticastTraffic (NetworkLayer ... optionalLayerParameter) { checkAttachedToNetPlanObject(); NetworkLayer layer = netPlan.checkInThisNetPlanOptionalLayerParameter(optionalLayerParameter); double accum = 0; for (MulticastDemand d : cache_nodeOutgoingMulticastDemands) if (d.layer.equals (layer)) accum += d.offeredTraffic; return accum; }
/** Returns the total capacity in the links of te given layer entering the node. * If no layer is provided, the default layer is assumed * @param optionalLayerParameter Network layer (optional) * @return see above */ public double getOutgoingLinksCapacity (NetworkLayer ... optionalLayerParameter) { checkAttachedToNetPlanObject(); NetworkLayer layer = netPlan.checkInThisNetPlanOptionalLayerParameter(optionalLayerParameter); double accum = 0; for (Link e : cache_nodeOutgoingLinks) if (e.layer.equals (layer)) accum += e.capacity; return accum; }
/** * <p>Removes all forwarding rules associated to the node for a given layer (that is, of layer links outgoing from the node). If no layer is provided, the default layer is assumed.</p> * @param optionalLayerParameter the layer */ public void removeAllForwardingRules(NetworkLayer ... optionalLayerParameter) { checkAttachedToNetPlanObject(); netPlan.checkIsModifiable(); NetworkLayer layer = netPlan.checkInThisNetPlanOptionalLayerParameter(optionalLayerParameter); for (Link e : cache_nodeOutgoingLinks) if (e.layer.equals (layer)) e.removeAllForwardingRules(); if (ErrorHandling.isDebugEnabled()) netPlan.checkCachesConsistency(); }
@Override public void saveDemandSetToFile(NetPlan netPlan, File file) { for (NetworkLayer layer : netPlan.getNetworkLayers ()) if (!layer.equals(netPlan.getNetworkLayerDefault())) netPlan.removeNetworkLayer (layer); netPlan.removeAllLinks(); netPlan.removeAllUnicastRoutingInformation(); netPlan.removeAllSRGs(); netPlan.saveToFile(file); }