Resource getCpuBaseResource () { final Set<Resource> cpuResources = n.getResources(RESOURCETYPE_CPU); assert cpuResources.size() < 2; if (cpuResources.isEmpty()) setTotalNumCpus(0); assert n.getResources(RESOURCETYPE_CPU).size() == 1; return n.getResources(RESOURCETYPE_CPU).iterator().next(); } Resource getRamBaseResource ()
Resource getHdBaseResource () { final Set<Resource> hdResources = n.getResources(RESOURCETYPE_HD); assert hdResources.size() < 2; if (hdResources.isEmpty()) setTotalHdGB(0); assert n.getResources(RESOURCETYPE_HD).size() == 1; return n.getResources(RESOURCETYPE_HD).iterator().next(); }
Resource getRamBaseResource () { final Set<Resource> ramResources = n.getResources(RESOURCETYPE_RAM); assert ramResources.size() < 2; if (ramResources.isEmpty()) setTotalRamGB(0); assert n.getResources(RESOURCETYPE_RAM).size() == 1; return n.getResources(RESOURCETYPE_RAM).iterator().next(); } Resource getHdBaseResource ()
/** Returns the number of CPUs available in the node for instantiation of VNFs * @return see above */ public double getTotalNumCpus () { return n.getResources(RESOURCETYPE_CPU).stream().mapToDouble(r->r.getCapacity()).sum (); } /** Sets the number of CPUs available in the node for instantiation of VNFs
/** Returns the total RAM (in GBytes) available in the node for instantiation of VNFs * @return see above */ public double getTotalRamGB () { return n.getResources(RESOURCETYPE_RAM).stream().mapToDouble(r->r.getCapacity()).sum (); } /** Sets the total RAM (in GBytes) available in the node for instantiation of VNFs
/** Sets the total hard disk size (in GBytes) available in the node for instantiation of VNFs * @param totalHdGB see above */ public void setTotalHdGB (double totalHdGB) { final Set<Resource> res = n.getResources(RESOURCETYPE_HD); if (res.size() > 1) throw new Net2PlanException ("Format error"); if (res.isEmpty()) res.add(n.getNetPlan().addResource(RESOURCETYPE_HD, RESOURCETYPE_HD, Optional.of(n), totalHdGB, "GB", new HashMap<> (), 0.0, null)); else res.iterator().next().setCapacity(totalHdGB, new HashMap<> ()); } /** Returns the current number of occupied CPUs by the instantiated VNFs
/** Returns the total hard disk size (in GBytes) available in the node for instantiation of VNFs * @return see above */ public double getTotalHdGB () { return n.getResources(RESOURCETYPE_HD).stream().mapToDouble(r->r.getCapacity()).sum (); } /** Sets the total hard disk size (in GBytes) available in the node for instantiation of VNFs
/** Sets the total RAM (in GBytes) available in the node for instantiation of VNFs * @param totalRamGB see above */ public void setTotalRamGB (double totalRamGB) { final Set<Resource> res = n.getResources(RESOURCETYPE_RAM); if (res.size() > 1) throw new Net2PlanException ("Format error"); if (res.isEmpty()) res.add(n.getNetPlan().addResource(RESOURCETYPE_RAM, RESOURCETYPE_RAM, Optional.of(n), totalRamGB, "GB", new HashMap<> (), 0.0, null)); else res.iterator().next().setCapacity(totalRamGB, new HashMap<> ()); } /** Returns the total hard disk size (in GBytes) available in the node for instantiation of VNFs
/** Returns all the VNF instances in this node, of any type * @return see above */ public SortedSet<WVnfInstance> getAllVnfInstances () { return n.getResources().stream().filter(r->!r.getType().contains(WNetConstants.LISTSEPARATORANDINVALIDNAMECHARACTER)).map(r->new WVnfInstance(r)).collect(Collectors.toCollection(TreeSet::new)); }
/** Sets the number of CPUs available in the node for instantiation of VNFs * @param totalNumCpus see above */ public void setTotalNumCpus (double totalNumCpus) { final Set<Resource> res = n.getResources(RESOURCETYPE_CPU); if (res.size() > 1) throw new Net2PlanException ("Format error"); if (res.isEmpty()) n.getNetPlan().addResource(RESOURCETYPE_CPU, RESOURCETYPE_CPU, Optional.of(n), totalNumCpus, RESOURCETYPE_CPU, new HashMap<> (), 0.0, null); else res.iterator().next().setCapacity(totalNumCpus, new HashMap<> ()); } /** Returns the total RAM (in GBytes) available in the node for instantiation of VNFs
/** Returns all the VNF instances in this node, of the given type * @param type see above * @return see above */ public SortedSet<WVnfInstance> getVnfInstances (String type) { if (type.contains(WNetConstants.LISTSEPARATORANDINVALIDNAMECHARACTER)) throw new Net2PlanException("Names cannot contain the character: " + WNetConstants.LISTSEPARATORANDINVALIDNAMECHARACTER); return n.getResources().stream().filter(r->!r.getType().contains(WNetConstants.LISTSEPARATORANDINVALIDNAMECHARACTER)).map(r->new WVnfInstance(r)).filter(v->v.getType().equals(type)).collect(Collectors.toCollection(TreeSet::new)); }
temp.append("<tr><td>Total link occupation (in / out):</td>"); temp.append("<td>" + String.format("%.2f", inLinkOccup) + " / " + String.format("%.2f", outLinkOccup) + " " + capUnits + "</td></tr>"); for (Resource r : npNode.getResources())
private List<Triple<String,String,String>> getNodeInfoTables (Node n , NetworkLayer layer) { final DecimalFormat df = new DecimalFormat("###.##"); final NetPlan np = n.getNetPlan(); final List<Triple<String,String,String>> res = new ArrayList <> (); final String trafUnits = np.getDemandTrafficUnitsName(layer); res.add(Triple.of("Node index/id" , "Node " + n.getIndex() + " (id " + n.getId() + ")", "node" + n.getId())); res.add(Triple.of("Name" , n.getName().equals("")? "No name" : n.getName(), "")); res.add(Triple.of("Site", (n.getSiteName() != null) ? n.getSiteName() : "undefined","")); res.add(Triple.of("Coordinates (x,y)" , "(" + n.getXYPositionMap().getX() + "," + n.getXYPositionMap().getY() + ")" , "")); res.add(Triple.of("Is up?", "" + n.isUp() , "")); res.add(Triple.of("# Resources" , n.getResources().isEmpty() ? "none" : ""+n.getResources().size() , "")); for (Resource r : n.getResources()) res.add(Triple.of("- " + getResourceName(r) , "" , "resource" + r.getId())); res.add(Triple.of("Information at layer" , getLayerName(layer) , "")); res.add(Triple.of("# output links", "" + n.getOutgoingLinks(layer).size() , "")); res.add(Triple.of("# input links" , "" + n.getIncomingLinks(layer).size() , "")); res.add(Triple.of("Output traffic" , "" + df.format(n.getOutgoingLinks(layer).stream().mapToDouble(e->e.getCarriedTraffic()).sum()) + " " + trafUnits , "")); res.add(Triple.of("Input traffic" , df.format(n.getIncomingLinks(layer).stream().mapToDouble(e->e.getCarriedTraffic()).sum()) + " " + trafUnits , "")); res.add(Triple.of("# SRGs" , n.getSRGs().isEmpty() ? "none" : ""+n.getSRGs().size() , "")); for (SharedRiskGroup srg : n.getSRGs()) res.add(Triple.of("- Sh. risk group index/id" , "" + srg.getIndex() + " (id " + srg.getId() + ")" , "srg" + srg.getId())); return res; } private List<Triple<String,String,String>> getResourceInfoTables (Resource r)
break; // do not add this SC (already full), and no more interm->out paths: all are worse for (Resource intermediateResource : intermediateNode.getResources(intermediateNodeResourceType))
res.add(new AjtColumnInfo<Node>(this , String.class, null , "Site", "The site this node belongs to", (d,val)->d.setSiteName((String) val) , d->d.getSiteName() , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<Node>(this , Collection.class, null , "SRGs", "The SRGs that this node belongs to", null , d->d.getSRGs() , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<Node>(this , Collection.class, null , "Resources", "The resources hosted in this node", null , d->d.getResources() , AGTYPE.SUMCOLLECTIONCOUNT , null)); res.add(new AjtColumnInfo<Node>(this , Collection.class, null , "Out links", "The outgoing links of the node", null , d->d.getOutgoingLinks(layer) , AGTYPE.SUMCOLLECTIONCOUNT , null)); res.add(new AjtColumnInfo<Node>(this , Collection.class, null , "In links", "The incoming links of the node", null , d->d.getIncomingLinks(layer) , AGTYPE.SUMCOLLECTIONCOUNT , null));
Set<Resource> cpuResources = n.getResources("CPU"); if (cpuResources.size() > 1) throw new Net2PlanException ("A node cannot have more than one resource of type CPU, or RAM or HD"); Set<Resource> ramResources = n.getResources("RAM"); if (ramResources.size() > 1) throw new Net2PlanException ("A node cannot have more than one resource of type CPU, or RAM or HD"); Set<Resource> hardDiskResources = n.getResources("HD"); if (hardDiskResources.size() > 1) throw new Net2PlanException ("A node cannot have more than one resource of type CPU, or RAM or HD"); cpu_n.set(index_n, cpuResources.iterator().next().getCapacity()); ram_n.set(index_n, ramResources.iterator().next().getCapacity()); if (nfvRam_f.get(indexNFVType) > ramNode) continue; if (nfvHardDisk_f.get(indexNFVType) > hdNode) continue; netPlan.addResource(nfvType_f.get(indexNFVType), "", Optional.of(n), nfvCap_f.get(indexNFVType), "", n.getResources("CPU", "RAM", "HD").stream().collect(Collectors.toMap(e -> e , e-> 0.0)) , 0, null); final Resource cpu = n.getResources("CPU").iterator().next(); final Resource ram = n.getResources("RAM").iterator().next(); final Resource hd = n.getResources("HD").iterator().next(); for (int indexNFVType = 0 ; indexNFVType < NUMNFVTYPES ; indexNFVType ++) if (n.getResources(type).isEmpty()) continue; final Resource nfv = n.getResources(type).iterator().next(); final int this_ynf = (int) y_nf.get(n.getIndex(), indexNFVType); if (this_ynf == 0) { nfv.remove(); continue; }