本文整理汇总了Java中vnreal.network.virtual.VirtualNode类的典型用法代码示例。如果您正苦于以下问题:Java VirtualNode类的具体用法?Java VirtualNode怎么用?Java VirtualNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VirtualNode类属于vnreal.network.virtual包,在下文中一共展示了VirtualNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mapEdges
import vnreal.network.virtual.VirtualNode; //导入依赖的package包/类
Collection<ResourceDemandEntry> mapEdges(
SubstrateNetwork sNetwork,
VirtualNetwork vNetwork,
MappingCandidate<VirtualNode, SubstrateNode> candidate,
NodeLinkMapping m,
Collection<ResourceDemandEntry> demandedNodeEnergyResource,
int epsilon) {
Collection<ResourceDemandEntry> out = mapOutEdges(
sNetwork, vNetwork, candidate, m, epsilon);
if (out == null) {
return null;
}
Collection<ResourceDemandEntry> in = mapInEdges(
sNetwork, vNetwork, candidate, m, epsilon);
if (in == null) {
Utils.freeResources(out);
return null;
}
out.addAll(in);
return out;
}
示例2: notifyMsg
import vnreal.network.virtual.VirtualNode; //导入依赖的package包/类
private LinkedList<Message> notifyMsg(int reqId, VirtualNode vNode,
SubstrateNode sNode, VirtualLink vLink) {
Request request = null;
for (Request r : requests) {
if (reqId == r.getRequestId()) {
request = r;
}
}
if (request == null) {
return (new LinkedList<Message>());
}
request.getVirtualNodesToEmbed().remove(vNode);
request.getSubNodesWithoutEmbeddedVirtNodes().remove(sNode);
// link and reversed link are removed in the mapALink method
// request.getVirtualLinksToEmbed().remove(vLink);
// request.getMapping().add(vNode, sNode);
return (new LinkedList<Message>());
}
示例3: analyze
import vnreal.network.virtual.VirtualNode; //导入依赖的package包/类
/**
* This method creates the candidates list
*
* @return true if everything is ok, false if there is one node without a candidate
*/
private boolean analyze(SubstrateNetwork sNet, VirtualNetwork vNet) {
//Walk through any vNode and check the substrate for fitting nodes
for(VirtualNode vn : vNet.getVertices()) {
ArrayList<SubstrateNode> tmpCandidates = findCandidates(sNet, vn, false);
//Check if the list is empty
if(tmpCandidates.isEmpty()) {
tmpCandidates = findCandidates(sNet, vn, true); //Check whether flexibility helps
if(tmpCandidates.isEmpty()) {
System.out.println("Fail(Analyze): "+vn.getName()+":"+MLSUtils.getMLSDemand(vn).toString());
count_abort_analyze++;
return false; //then no candiates for this node
}
}
//Add the list to our global list
candidates.put(vn, tmpCandidates);
}
return true;
}
示例4: generateRandomLabelDemands
import vnreal.network.virtual.VirtualNode; //导入依赖的package包/类
public static void generateRandomLabelDemands(VirtualNetwork network,
int numDemandedLabels, String[] labels, Random rnd) {
for (VirtualNode vn : network.getVertices()) {
LinkedList<String> labelsShuffle = new LinkedList<String>();
for (String s : labels)
labelsShuffle.add(s);
Collections.shuffle(labelsShuffle, rnd);
LinkedList<String> demandedLabels = new LinkedList<String>();
int i = 0;
for (String label : labelsShuffle) {
if (i >= numDemandedLabels)
break;
demandedLabels.add(label);
i++;
}
vn.add(new LabelDemand(vn, demandedLabels));
}
}
示例5: generateVirtualNetwork
import vnreal.network.virtual.VirtualNode; //导入依赖的package包/类
@Override
public VirtualNetwork generateVirtualNetwork(final int level) {
return new Generator<VirtualNetwork, VirtualNode, VirtualLink>() {
@Override
protected VirtualNode createNode() {
return new VirtualNode(level);
}
@Override
protected VirtualNetwork createNetwork() {
return new VirtualNetwork(level);
}
@Override
protected VirtualLink createLink() {
return new VirtualLink(level);
}
}.generateGraph(this.numNodes, this.probability, this.seed);
}
示例6: generateVirtualNetwork
import vnreal.network.virtual.VirtualNode; //导入依赖的package包/类
@Override
public VirtualNetwork generateVirtualNetwork(final int level) {
return new Generator<VirtualNetwork, VirtualNode, VirtualLink>() {
@Override
protected VirtualNode createNode() {
return new VirtualNode(level);
}
@Override
protected VirtualNetwork createNetwork() {
return new VirtualNetwork(level);
}
@Override
protected VirtualLink createLink() {
return new VirtualLink(level);
}
}.generateGraph(this.numNodes, this.alpha, this.beta, this.r, this.seed);
}
示例7: calculate
import vnreal.network.virtual.VirtualNode; //导入依赖的package包/类
@Override
public double calculate(NetworkStack stack) {
double inactiveNodes = 0;
boolean isSolelyForNode;
for (SubstrateNode n : stack.getSubstrate().getVertices()) {
isSolelyForNode = true;
for (AbstractResource res : n)
for(Mapping map : res.getMappings())
if(map.getDemand().getOwner() instanceof VirtualNode){
isSolelyForNode = false;
break;
}
if (isSolelyForNode)
inactiveNodes++;
}
return (inactiveNodes / ((double)stack.getSubstrate().getVertices().size()));
}
示例8: getStressLevel
import vnreal.network.virtual.VirtualNode; //导入依赖的package包/类
public static int getStressLevel(SubstrateNode n) {
int max = 0;
int stress;
for (AbstractResource r : n.get()) {
stress = 0;
if (r instanceof CpuResource) {
for (Mapping f : r.getMappings()) {
if (f.getDemand().getOwner() instanceof VirtualNode)
stress++;
}
} else {
stress = r.getMappings().size();
}
if (stress > max) {
max = stress;
}
}
return max;
}
示例9: findVirtualEntity
import vnreal.network.virtual.VirtualNode; //导入依赖的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;
}
示例10: createCandidateSetWithType
import vnreal.network.virtual.VirtualNode; //导入依赖的package包/类
/**
*
* @param vNet
* @return The set of substrate candidates for each virtual node of vNet
*/
private Map<VirtualNode, List<SubstrateNode>> createCandidateSetWithType(
SubstrateNetwork sNet, VirtualNetwork vNet) {
Map<VirtualNode, List<SubstrateNode>> candidateSet = new LinkedHashMap<VirtualNode, List<SubstrateNode>>();
List<SubstrateNode> substrateSet;
for (Iterator<VirtualNode> itt = vNet.getVertices().iterator(); itt
.hasNext();) {
substrateSet = new LinkedList<SubstrateNode>();
VirtualNode currVnode = itt.next();
if (nodeMapping.containsKey(currVnode)) {
substrateSet.add(nodeMapping.get(currVnode));
} else {
substrateSet.addAll(findFulfillingNodesWithType(sNet, currVnode));
}
candidateSet.put(currVnode, substrateSet);
}
return candidateSet;
}
示例11: createCandidateSet
import vnreal.network.virtual.VirtualNode; //导入依赖的package包/类
/**
*
* @param vNet
* @return The set of substrate candidates for each virtual node of vNet
*/
private Map<VirtualNode, List<SubstrateNode>> createCandidateSet(
SubstrateNetwork sNet, VirtualNetwork vNet) {
Map<VirtualNode, List<SubstrateNode>> candidateSet = new LinkedHashMap<VirtualNode, List<SubstrateNode>>();
List<SubstrateNode> substrateSet;
for (Iterator<VirtualNode> itt = vNet.getVertices().iterator(); itt
.hasNext();) {
substrateSet = new LinkedList<SubstrateNode>();
VirtualNode currVnode = itt.next();
if (nodeMapping.containsKey(currVnode)) {
substrateSet.add(nodeMapping.get(currVnode));
} else {
substrateSet.addAll(findFulfillingNodes(sNet, currVnode));
}
candidateSet.put(currVnode, substrateSet);
}
return candidateSet;
}
示例12: mapNode
import vnreal.network.virtual.VirtualNode; //导入依赖的package包/类
/**
* This Method tries to map the given {@link VirtualNode} on given {@link SubstrateNode}
* @param vn {@link VirtualNode}
* @param sn {@link SubstrateNode}
* @return true if mapping ok, false otherwise
*/
private boolean mapNode(VirtualNode vn, SubstrateNode sn) {
//Check if the Node is still available for mapping
if(!isAvailable(sn))
return false; //Mapping not possible
//Try map it
if(!NodeLinkAssignation.vnm(vn, sn))
return false; //Mapping failed or not possible
//If Mapping is successfull
//System.out.println(vn+":"+MLSUtils.getMLSDemand(vn));
//System.out.println(sn+":"+MLSUtils.getMLSResource(sn));
nodeMapping.put(vn, sn); //Add it to the mappinglist
incrementCounter(sn);
return true;
}
示例13: analyze
import vnreal.network.virtual.VirtualNode; //导入依赖的package包/类
/**
* This method creates the candidates list
*
* @return true if everything is ok, false if there is one node without a candidate
*/
private boolean analyze(VirtualNetwork vNet) {
//Walk through any vNode and check the substrate for fitting nodes
for(VirtualNode vn : vNet.getVertices()) {
ArrayList<SubstrateNode> tmpCandidates = new ArrayList<SubstrateNode>();
for(SubstrateNode sn : sNet.getVertices()) {
if(NodeLinkAssignation.isMappable(vn, sn)) {
tmpCandidates.add(sn);
}
}
//Check if the list is empty
if(tmpCandidates.isEmpty()) {
System.out.println("Fail(Analyze): "+vn.getName()+":"+MLSUtils.getMLSDemand(vn).toString());
count_abort_analyze++;
return false; //then no candiates for this node
}
//Add the list to our global list
candidates.put(vn, tmpCandidates);
}
return true;
}
示例14: mapInEdges
import vnreal.network.virtual.VirtualNode; //导入依赖的package包/类
Collection<ResourceDemandEntry> mapInEdges(
VirtualNetwork g_V, SubstrateNetwork orig_g_P,
MappingCandidate<VirtualNode, SubstrateNode> candidate, NodeLinkMapping m,
int epsilon) {
Collection<ResourceDemandEntry> result = new LinkedList<ResourceDemandEntry>();
for (VirtualLink vl : g_V.getInEdges(candidate.t)) {
VirtualNode opposite = g_V.getOpposite(candidate.t, vl);
SubstrateNode sOpposite = m.getSubstrateNode(opposite);
if (sOpposite != null && sOpposite.getId() != candidate.u.getId()) {
List<SubstrateLink> path = findShortestPath(orig_g_P,
sOpposite, candidate.u, vl.get(), epsilon);
if (path == null) {
Utils.freeResources(result);
return null;
}
result.addAll(Utils.occupyPathResources(vl, path, orig_g_P));
m.add(vl, path);
}
}
return result;
}
示例15: f
import vnreal.network.virtual.VirtualNode; //导入依赖的package包/类
Collection<VirtualNode> f(Set<VirtualNode> vns, VirtualNetwork g) {
Collection<VirtualNode> result = new LinkedList<VirtualNode>();
for (VirtualLink vl : g.getEdges()) {
Pair<VirtualNode> endpoints = g.getEndpoints(vl);
VirtualNode n_i = endpoints.getFirst();
VirtualNode n_j = endpoints.getSecond();
if (Utils.contains(n_j, vns)) {
if (!Utils.contains(n_i, vns)) {
if (!Utils.contains(n_i, result)) {
result.add(n_i);
}
}
} else {
if (Utils.contains(n_i, vns)) {
if (!Utils.contains(n_j, result)) {
result.add(n_j);
}
}
}
}
return result;
}