本文整理汇总了Java中vnreal.network.NetworkEntity类的典型用法代码示例。如果您正苦于以下问题:Java NetworkEntity类的具体用法?Java NetworkEntity怎么用?Java NetworkEntity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NetworkEntity类属于vnreal.network包,在下文中一共展示了NetworkEntity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMappedVirtualEntities
import vnreal.network.NetworkEntity; //导入依赖的package包/类
@SuppressWarnings("unchecked")
static LinkedList<NetworkEntity<AbstractDemand>> getMappedVirtualEntities(Collection<? extends NetworkEntity<AbstractResource>> entities) {
LinkedList<NetworkEntity<AbstractDemand>> result = new LinkedList<NetworkEntity<AbstractDemand>>();
for (NetworkEntity<AbstractResource> e : entities) {
for (AbstractResource res : e.get()) {
for (Mapping m : res.getMappings()) {
if (m.getDemand().getOwner() != null) {
NetworkEntity<AbstractDemand> owner = (NetworkEntity<AbstractDemand>) m.getDemand().getOwner();
if (!result.contains(owner)) {
result.add(owner);
}
}
}
}
}
return result;
}
示例2: main
import vnreal.network.NetworkEntity; //导入依赖的package包/类
public static void main(String[] args) {
FreeSlotsResource r = new FreeSlotsResource("net", 2, null);
FreeSlotsDemand d1 = new FreeSlotsDemand("net", "FW1", null, new LinkedList<NetworkEntity<AbstractResource>>());
FreeSlotsDemand d2 = new FreeSlotsDemand("net", "FW2", null, new LinkedList<NetworkEntity<AbstractResource>>());
FreeSlotsDemand d3 = new FreeSlotsDemand("net", "FW3", null, new LinkedList<NetworkEntity<AbstractResource>>());
FreeSlotsDemand d4 = new FreeSlotsDemand("net", "FW4", null, new LinkedList<NetworkEntity<AbstractResource>>());
System.out.println(d1.occupy(r));
System.out.println(r);
System.out.println(d2.occupy(r));
System.out.println(r);
System.out.println(d3.occupy(r));
System.out.println(r);
System.out.println(d4.occupy(r));
System.out.println(r);
}
示例3: getCopy
import vnreal.network.NetworkEntity; //导入依赖的package包/类
@Override
public AbstractResource getCopy(
NetworkEntity<? extends AbstractConstraint> owner, boolean setOccupied) {
PhysicalProvidedSecurity clone;
if(owner.getClass().getSimpleName().contains("Node"))
clone = new PhysicalProvidedSecurity((Node<? extends AbstractConstraint>)owner, this.getName());
else if(owner.getClass().getSimpleName().contains("Link"))
clone = new PhysicalProvidedSecurity((Link<? extends AbstractConstraint>)owner, this.getName());
else
throw new Error("The class: "+owner.getClass()+" is invalid for "+this.getClass().getSimpleName());
clone.level = level;
return clone;
}
示例4: assign
import vnreal.network.NetworkEntity; //导入依赖的package包/类
public static void assign(NetworkEntity<AbstractResource> sl, UpdateEntry e) {
for (AbstractResource r : sl) {
if (r.accepts(e.demand) && r.fulfills(e.demand) && e.demand.occupy(r)) {
return;
}
// if (r instanceof CpuResource) {
// CpuResource re = ((CpuResource) r);
// re.setOccupiedCycles(re.getOccupiedCycles() + e.cpu);
// }
// if (r instanceof BandwidthResource) {
// BandwidthResource re = ((BandwidthResource) r);
// re.setOccupiedBandwidth(re.getOccupiedBandwidth() + e.bw);
// }
}
}
示例5: findVirtualEntity
import vnreal.network.NetworkEntity; //导入依赖的package包/类
/**
* This method returns the requested virtual Cluster/Link demand Resource defined by the class
* @param sname Name of the Link/Node
* @return NetworkEntity<AbstractDemand>
*/
public static NetworkEntity<AbstractDemand> findVirtualEntity(String vname,
VirtualNetwork vNet) {
for (VirtualNode sn : vNet.getVertices()) {
if (sn.getName().equals(vname)) {
return sn;
}
}
for (VirtualLink sl : vNet.getEdges()) {
if (sl.getName().equals(vname)) {
return sl;
}
}
return null;
}
示例6: fulfills
import vnreal.network.NetworkEntity; //导入依赖的package包/类
/**
*
* @param demands
* set of demands
* @param e
* Network Entity (Node or link)
* @return boolean value indicating if the set of demands can be fulfilled
* by the network entity e.
*/
public static boolean fulfills(
Collection<? extends AbstractDemand> demands,
NetworkEntity<? extends AbstractResource> e) {
if (demands != null) {
for (AbstractDemand dem : demands) {
boolean found = false;
for (AbstractResource res : e) {
if (res.accepts(dem) && res.fulfills(dem)) {
found = true;
break;
}
}
if (!found) {
return false;
}
}
}
return true;
}
示例7: getStressLevel
import vnreal.network.NetworkEntity; //导入依赖的package包/类
public static int getStressLevel(NetworkEntity<? extends AbstractResource> e) {
List<NetworkEntity<?>> vEntities = new LinkedList<NetworkEntity<?>>();
for (AbstractResource r : e.get()) {
for (vnreal.mapping.Mapping m : r.getMappings()) {
AbstractDemand d = m.getDemand();
if (!(d instanceof HiddenHopEnergyDemand)) {
NetworkEntity<?> owner = d.getOwner();
if (!vEntities.contains(owner)) {
vEntities.add(owner);
}
}
}
}
return vEntities.size();
}
示例8: getSubstrateEntityForId
import vnreal.network.NetworkEntity; //导入依赖的package包/类
public static NetworkEntity<? extends AbstractResource> getSubstrateEntityForId(long id, SubstrateNetwork sNet) {
for (SubstrateNode sn : sNet.getVertices()) {
if (sn.getId() == id) {
return sn;
}
}
for(SubstrateLink sl : sNet.getEdges()) {
if (sl.getId() == id) {
return sl;
}
}
throw new AssertionError("No Substrate node found with id " + id + ".");
}
示例9: calculate
import vnreal.network.NetworkEntity; //导入依赖的package包/类
@Override
public double calculate(NetworkStack stack) {
SubstrateNetwork sNet = stack.getSubstrate();
LinkedList<NetworkEntity<AbstractDemand>> vNodes = getMappedVirtualEntities(sNet.getVertices());
LinkedList<NetworkEntity<AbstractDemand>> vLinks = getMappedVirtualEntities(sNet.getEdges());
return calculateVnetRevenue(vNodes, vLinks);
}
示例10: getCopy
import vnreal.network.NetworkEntity; //导入依赖的package包/类
@Override
public AbstractResource getCopy(
NetworkEntity<? extends AbstractConstraint> owner, boolean setOccupied) {
StaticEnergyResource clone = new StaticEnergyResource(
(Node<? extends AbstractConstraint>) owner, consumption, this.getName());
clone.usedBy = usedBy;
return clone;
}
示例11: getCopy
import vnreal.network.NetworkEntity; //导入依赖的package包/类
@Override
public AbstractResource getCopy(
NetworkEntity<? extends AbstractConstraint> owner, boolean setOccupied) {
IdResource clone = new IdResource(
(Node<? extends AbstractConstraint>) owner, sNetwork, this.getName());
clone.id = id;
return clone;
}
示例12: getCopy
import vnreal.network.NetworkEntity; //导入依赖的package包/类
@Override
public AbstractResource getCopy(
NetworkEntity<? extends AbstractConstraint> owner, boolean setOccupied) {
CommonResource clone = new CommonResource((NetworkEntity<? extends AbstractConstraint>) owner, this.getName());
clone.capacity = capacity;
if (setOccupied)
clone.occupiedCapacity = occupiedCapacity;
return clone;
}
示例13: getCopy
import vnreal.network.NetworkEntity; //导入依赖的package包/类
@Override
public AbstractResource getCopy(
NetworkEntity<? extends AbstractConstraint> owner, boolean setOccupied) {
FreeSlotsResource clone = new FreeSlotsResource(this.label, this.slots, (Node<? extends AbstractConstraint>) owner, this.getName());
return clone;
}
示例14: getCopy
import vnreal.network.NetworkEntity; //导入依赖的package包/类
@Override
public AbstractResource getCopy(
NetworkEntity<? extends AbstractConstraint> owner, boolean setOccupied) {
PowerResource clone = new PowerResource(
(Node<? extends AbstractConstraint>) owner, this.getName());
clone.usedBy = usedBy;
return clone;
}
示例15: getCopy
import vnreal.network.NetworkEntity; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public AbstractResource getCopy(
NetworkEntity<? extends AbstractConstraint> owner, boolean setOccupied) {
if(owner.getClass().getSimpleName().contains("Node"))
return new NullResource((Node<? extends AbstractResource>)owner, this.getName());
else if(owner.getClass().getSimpleName().contains("Link"))
return new NullResource((Link<? extends AbstractResource>)owner, this.getName());
throw new Error("The class: "+owner.getClass()+" is invalid for NullResource");
}