Commit a48834e3 authored by Manoel Campos's avatar Manoel Campos

Documentation of packages org.cloudbus.cloudsim.network and…

Documentation of packages org.cloudbus.cloudsim.network and org.cloudbus.cloudsim.power.lists improved.
parent 841a9352
...@@ -40,11 +40,16 @@ import org.cloudbus.cloudsim.network.TopologicalNode; ...@@ -40,11 +40,16 @@ import org.cloudbus.cloudsim.network.TopologicalNode;
* A private default constructor would be created to avoid instantiation. * A private default constructor would be created to avoid instantiation.
*/ */
public class NetworkTopology { public class NetworkTopology {
/**
* The BRITE id to use for the next node to be created in the network.
*/
protected static int nextIdx = 0; protected static int nextIdx = 0;
private static boolean networkEnabled = false; private static boolean networkEnabled = false;
/**
* A matrix containing the delay between every pair of nodes in the network.
*/
protected static DelayMatrix_Float delayMatrix = null; protected static DelayMatrix_Float delayMatrix = null;
/** /**
...@@ -52,6 +57,9 @@ public class NetworkTopology { ...@@ -52,6 +57,9 @@ public class NetworkTopology {
*/ */
protected static double[][] bwMatrix = null; protected static double[][] bwMatrix = null;
/**
* The Topological Graph of the network.
*/
protected static TopologicalGraph graph = null; protected static TopologicalGraph graph = null;
/** /**
...@@ -103,7 +111,7 @@ public class NetworkTopology { ...@@ -103,7 +111,7 @@ public class NetworkTopology {
/** /**
* Adds a new link in the network topology. * Adds a new link in the network topology.
* The CloudSim entities that represent the source and destination of the link * The CloudSim entities that represent the source and destination of the link
* will be mapped to the BRITE entity. * will be mapped to BRITE entities.
* *
* @param srcId ID of the CloudSim entity that represents the link's source node * @param srcId ID of the CloudSim entity that represents the link's source node
* @param destId ID of the CloudSim entity that represents the link's destination node * @param destId ID of the CloudSim entity that represents the link's destination node
...@@ -224,7 +232,7 @@ public class NetworkTopology { ...@@ -224,7 +232,7 @@ public class NetworkTopology {
} }
/** /**
* Calculates the delay between two CloudSim nodes. * Calculates the delay between two nodes.
* *
* @param srcID ID of the CloudSim entity that represents the link's source node * @param srcID ID of the CloudSim entity that represents the link's source node
* @param destID ID of the CloudSim entity that represents the link's destination node * @param destID ID of the CloudSim entity that represents the link's destination node
...@@ -248,11 +256,11 @@ public class NetworkTopology { ...@@ -248,11 +256,11 @@ public class NetworkTopology {
} }
/** /**
* This method returns true if network simulation is working. If there were some problem during * Checks if the network simulation is working. If there were some problem during
* creation of network (e.g., during parsing of BRITE file) that does not allow a proper * creation of network (e.g., during parsing of BRITE file) that does not allow a proper
* simulation of the network, this method returns false. * simulation of the network, this method returns false.
* *
* @return $true if network simulation is ok. $false otherwise * @return $true if network simulation is working, $false otherwise
* @pre $none * @pre $none
* @post $none * @post $none
*/ */
......
...@@ -11,7 +11,8 @@ package org.cloudbus.cloudsim.network; ...@@ -11,7 +11,8 @@ package org.cloudbus.cloudsim.network;
import java.util.Iterator; import java.util.Iterator;
/** /**
* This class represents an delay-topology storing every distance between connected nodes * This class represents a delay matrix between every pair or nodes
* inside a network topology, storing every distance between connected nodes.
* *
* @author Thomas Hohnstein * @author Thomas Hohnstein
* @since CloudSim Toolkit 1.0 * @since CloudSim Toolkit 1.0
...@@ -19,27 +20,27 @@ import java.util.Iterator; ...@@ -19,27 +20,27 @@ import java.util.Iterator;
public class DelayMatrix_Float { public class DelayMatrix_Float {
/** /**
* matrix holding delay information between any two nodes * Matrix holding delay information between any two nodes.
*/ */
protected float[][] mDelayMatrix = null; protected float[][] mDelayMatrix = null;
/** /**
* number of nodes in the distance-aware-topology * Number of nodes in the distance-aware-topology.
*/ */
protected int mTotalNodeNum = 0; protected int mTotalNodeNum = 0;
/** /**
* private constructor to ensure that only an correct initialized delay-matrix could be created * Private constructor to ensure that only an correct initialized delay-matrix could be created.
*/ */
@SuppressWarnings("unused") @SuppressWarnings("unused")
private DelayMatrix_Float() { private DelayMatrix_Float() {
}; }
/** /**
* this constructor creates an correct initialized Float-Delay-Matrix * Creates an correctly initialized Float-Delay-Matrix.
* *
* @param graph the topological graph as source-information * @param graph the network topological graph
* @param directed true if an directed matrix should be computed, false otherwise * @param directed indicates if an directed matrix should be computed (true) or not (false)
*/ */
public DelayMatrix_Float(TopologicalGraph graph, boolean directed) { public DelayMatrix_Float(TopologicalGraph graph, boolean directed) {
...@@ -51,9 +52,11 @@ public class DelayMatrix_Float { ...@@ -51,9 +52,11 @@ public class DelayMatrix_Float {
} }
/** /**
* @param srcID the id of the source-node * Gets the delay between two nodes.
* @param destID the id of the destination-node *
* @return the delay-count between the given two nodes * @param srcID the id of the source node
* @param destID the id of the destination node
* @return the delay between the given two nodes
*/ */
public float getDelay(int srcID, int destID) { public float getDelay(int srcID, int destID) {
// check the nodeIDs against internal array-boundarys // check the nodeIDs against internal array-boundarys
...@@ -65,12 +68,12 @@ public class DelayMatrix_Float { ...@@ -65,12 +68,12 @@ public class DelayMatrix_Float {
} }
/** /**
* creates all internal necessary network-distance structures from the given graph for * Creates all internal necessary network-distance structures from the given graph.
* similarity we assume all kommunikation-distances are symmetrical thus leads to an undirected * For similarity, we assume all communication-distances are symmetrical,
* network * thus leading to an undirected network.
* *
* @param graph this graph contains all node and link information * @param graph the network topological graph
* @param directed defines to preinitialize an directed or undirected Delay-Matrix! * @param directed indicates if an directed matrix should be computed (true) or not (false)
*/ */
private void createDelayMatrix(TopologicalGraph graph, boolean directed) { private void createDelayMatrix(TopologicalGraph graph, boolean directed) {
...@@ -95,7 +98,7 @@ public class DelayMatrix_Float { ...@@ -95,7 +98,7 @@ public class DelayMatrix_Float {
mDelayMatrix[edge.getSrcNodeID()][edge.getDestNodeID()] = edge.getLinkDelay(); mDelayMatrix[edge.getSrcNodeID()][edge.getDestNodeID()] = edge.getLinkDelay();
if (!directed) { if (!directed) {
// according to aproximity of symmetry to all kommunication-paths // according to aproximity of symmetry to all communication-paths
mDelayMatrix[edge.getDestNodeID()][edge.getSrcNodeID()] = edge.getLinkDelay(); mDelayMatrix[edge.getDestNodeID()][edge.getSrcNodeID()] = edge.getLinkDelay();
} }
...@@ -103,7 +106,7 @@ public class DelayMatrix_Float { ...@@ -103,7 +106,7 @@ public class DelayMatrix_Float {
} }
/** /**
* just calculates all pairs shortest paths * Calculates the shortest path between all pairs of nodes.
*/ */
private void calculateShortestPath() { private void calculateShortestPath() {
FloydWarshall_Float floyd = new FloydWarshall_Float(); FloydWarshall_Float floyd = new FloydWarshall_Float();
...@@ -112,10 +115,6 @@ public class DelayMatrix_Float { ...@@ -112,10 +115,6 @@ public class DelayMatrix_Float {
mDelayMatrix = floyd.allPairsShortestPaths(mDelayMatrix); mDelayMatrix = floyd.allPairsShortestPaths(mDelayMatrix);
} }
/**
* this method just creates an string-output from the internal structures... eg. printsout the
* delay-matrix...
*/
@Override @Override
public String toString() { public String toString() {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
......
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
package org.cloudbus.cloudsim.network; package org.cloudbus.cloudsim.network;
/** /**
* FloydWarshall algorithm to calculate all pairs delay and predecessor matrix. * FloydWarshall algorithm to calculate the predecessor matrix
* and the delay between all pairs of nodes.
* *
* @author Rahul Simha * @author Rahul Simha
* @author Weishuai Yang * @author Weishuai Yang
...@@ -19,32 +20,30 @@ package org.cloudbus.cloudsim.network; ...@@ -19,32 +20,30 @@ package org.cloudbus.cloudsim.network;
public class FloydWarshall_Float { public class FloydWarshall_Float {
/** /**
* Number of vertices (when initialized) * Number of vertices (nodes).
*/ */
private int numVertices; private int numVertices;
// /**
// * The adjacency matrix (given as input),
// * here I use float rather than double to save memory,
// * since there won't be a lot of spilting for delay,
// * and float is accurate enough.
// */
// private float[][] adjMatrix;
/** /**
* Matrices used in dynamic programming * Matrices used in dynamic programming.
*/ */
private float[][] Dk, Dk_minus_one; private float[][] Dk, Dk_minus_one;
/** /**
* Matrices used in dynamic programming * The predecessor matrix. Matrix used by dynamic programming.
*/ */
private int[][] Pk, Pk_minus_one; private int[][] Pk;
/**
* Matrix used by dynamic programming.
*/
private int[][] Pk_minus_one;
/** /**
* initialization matrix * Initialization the matrix.
* *
* @param numVertices number of nodes * @param numVertices number of nodes
* @todo The class doesn't have a constructor. This should be the constructor.
*/ */
public void initialize(int numVertices) { public void initialize(int numVertices) {
this.numVertices = numVertices; this.numVertices = numVertices;
...@@ -68,10 +67,10 @@ public class FloydWarshall_Float { ...@@ -68,10 +67,10 @@ public class FloydWarshall_Float {
} }
/** /**
* calculates all pairs delay * Calculates the delay between all pairs of nodes.
* *
* @param adjMatrix original delay matrix * @param adjMatrix original delay matrix
* @return all pairs delay matrix * @return the delay matrix
*/ */
public float[][] allPairsShortestPaths(float[][] adjMatrix) { public float[][] allPairsShortestPaths(float[][] adjMatrix) {
// Dk_minus_one = weights when k = -1 // Dk_minus_one = weights when k = -1
...@@ -128,66 +127,11 @@ public class FloydWarshall_Float { ...@@ -128,66 +127,11 @@ public class FloydWarshall_Float {
} }
/** /**
* gets predecessor matrix * Gets predecessor matrix.
* *
* @return predecessor matrix * @return predecessor matrix
*/ */
public int[][] getPK() { public int[][] getPK() {
return Pk; return Pk;
} }
/*
public static void main (String[] argv)
{
// A test case.
*
double[][] adjMatrix = {
{0, 1, 0, 0, 1},
{1, 0, 1, 3, 0},
{0, 1, 0, 2, 0},
{0, 3, 2, 0, 1},
{1, 0, 0, 1, 0},
};
int n = adjMatrix.length;
FloydWarshall fwAlg = new FloydWarshall ();
fwAlg.initialize (n);
adjMatrix=fwAlg.allPairsShortestPaths (adjMatrix);
//debug begin
StringBuffer s0=new StringBuffer("Delay Information before floydwarshall:\n");
for(int i=0;i<n;i++){
s0.append("Node "+i+" to others:");
for(int j=0;j<n;j++){
s0.append(LogFormatter.sprintf(" % 6.1f ", adjMatrix[i][j]));
}
s0.append("\n");
}
Log.printLine(""+s0);
int[][] Pk=fwAlg.getPK();
Log.printLine("Path information");
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
Log.print("From "+i+" to "+j+": ");
int pre=Pk[i][j];
while((pre!=-1)&&(pre!=i)){
Log.print(" <- "+ pre);
pre=Pk[i][pre];
if((pre==-1)||(pre==i))
Log.print(" <- "+ pre);
}
Log.printLine("\n");
}
}
}
*/
} }
...@@ -14,10 +14,13 @@ import java.io.IOException; ...@@ -14,10 +14,13 @@ import java.io.IOException;
import java.util.StringTokenizer; import java.util.StringTokenizer;
/** /**
* This class is just an file-reader for the special brite-format! the brite-file is structured as * A file reader for the special BRITE-format. A BRITE file is structured as
* followed: Node-section: NodeID, xpos, ypos, indegree, outdegree, ASid, type(router/AS) * follows:<br/>
* Edge-section: EdgeID, fromNode, toNode, euclideanLength, linkDelay, linkBandwith, AS_from, AS_to, * <ul>
* <li>Node-section: NodeID, xpos, ypos, indegree, outdegree, ASid, type(router/AS)
* <li>Edge-section: EdgeID, fromNode, toNode, euclideanLength, linkDelay, linkBandwith, AS_from, AS_to,
* type * type
* </ul>
* *
* @author Thomas Hohnstein * @author Thomas Hohnstein
* @since CloudSim Toolkit 1.0 * @since CloudSim Toolkit 1.0
...@@ -32,15 +35,11 @@ public class GraphReaderBrite implements GraphReaderIF { ...@@ -32,15 +35,11 @@ public class GraphReaderBrite implements GraphReaderIF {
private int state = PARSE_NOTHING; private int state = PARSE_NOTHING;
/**
* The network Topological Graph.
*/
private TopologicalGraph graph = null; private TopologicalGraph graph = null;
/**
* this method just reads the file and creates an TopologicalGraph object
*
* @param filename name of the file to read
* @return created TopologicalGraph
* @throws IOException
*/
@Override @Override
public TopologicalGraph readGraphFile(String filename) throws IOException { public TopologicalGraph readGraphFile(String filename) throws IOException {
...@@ -92,8 +91,12 @@ public class GraphReaderBrite implements GraphReaderIF { ...@@ -92,8 +91,12 @@ public class GraphReaderBrite implements GraphReaderIF {
return graph; return graph;
} }
/**
* Parses nodes inside a line from the BRITE file.
*
* @param nodeLine A line read from the file
*/
private void parseNodeString(String nodeLine) { private void parseNodeString(String nodeLine) {
StringTokenizer tokenizer = new StringTokenizer(nodeLine); StringTokenizer tokenizer = new StringTokenizer(nodeLine);
// number of node parameters to parse (counts at linestart) // number of node parameters to parse (counts at linestart)
...@@ -144,8 +147,13 @@ public class GraphReaderBrite implements GraphReaderIF { ...@@ -144,8 +147,13 @@ public class GraphReaderBrite implements GraphReaderIF {
TopologicalNode topoNode = new TopologicalNode(nodeID, nodeLabel, xPos, yPos); TopologicalNode topoNode = new TopologicalNode(nodeID, nodeLabel, xPos, yPos);
graph.addNode(topoNode); graph.addNode(topoNode);
}// parseNodeString-END }
/**
* Parses edges inside a line from the BRITE file.
*
* @param nodeLine A line read from the file
*/
private void parseEdgesString(String nodeLine) { private void parseEdgesString(String nodeLine) {
StringTokenizer tokenizer = new StringTokenizer(nodeLine); StringTokenizer tokenizer = new StringTokenizer(nodeLine);
......
...@@ -11,7 +11,7 @@ package org.cloudbus.cloudsim.network; ...@@ -11,7 +11,7 @@ package org.cloudbus.cloudsim.network;
import java.io.IOException; import java.io.IOException;
/** /**
* This interface abstracts an reader for different graph-file-formats * An interface to abstract a reader for different graph file formats.
* *
* @author Thomas Hohnstein * @author Thomas Hohnstein
* @since CloudSim Toolkit 1.0 * @since CloudSim Toolkit 1.0
...@@ -19,11 +19,11 @@ import java.io.IOException; ...@@ -19,11 +19,11 @@ import java.io.IOException;
public interface GraphReaderIF { public interface GraphReaderIF {
/** /**
* this method just reads the file and creates an TopologicalGraph object * Reads a file and creates an {@link TopologicalGraph} object.
* *
* @param filename name of the file to read * @param filename Name of the file to read
* @return created TopologicalGraph * @return The created TopologicalGraph
* @throws IOException * @throws IOException when the file cannot be accessed
*/ */
TopologicalGraph readGraphFile(String filename) throws IOException; TopologicalGraph readGraphFile(String filename) throws IOException;
......
...@@ -13,21 +13,30 @@ import java.util.LinkedList; ...@@ -13,21 +13,30 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
/** /**
* This class represents an graph containing nodes and edges, used for input with an network-layer * This class represents a graph containing vertices (nodes) and edges (links),
* Graphical-Output Restricions! EdgeColors: GraphicalProperties.getColorEdge NodeColors: * used for input with a network-layer.
* GraphicalProperties.getColorNode * Graphical-Output Restricions! <br/>
* <ul>
* <li>EdgeColors: GraphicalProperties.getColorEdge
* <li>NodeColors: GraphicalProperties.getColorNode
* </ul>
* *
* @author Thomas Hohnstein * @author Thomas Hohnstein
* @since CloudSim Toolkit 1.0 * @since CloudSim Toolkit 1.0
*/ */
public class TopologicalGraph { public class TopologicalGraph {
/**
* The list of links of the network graph.
*/
private List<TopologicalLink> linkList = null; private List<TopologicalLink> linkList = null;
/**
* The list of nodes of the network graph.
*/
private List<TopologicalNode> nodeList = null; private List<TopologicalNode> nodeList = null;
/** /**
* just the constructor to create an empty graph-object * Creates an empty graph-object.
*/ */
public TopologicalGraph() { public TopologicalGraph() {
linkList = new LinkedList<TopologicalLink>(); linkList = new LinkedList<TopologicalLink>();
...@@ -35,7 +44,7 @@ public class TopologicalGraph { ...@@ -35,7 +44,7 @@ public class TopologicalGraph {
} }
/** /**
* adds an link between two topological nodes * Adds an link between two topological nodes.
* *
* @param edge the topological link * @param edge the topological link
*/ */
...@@ -44,7 +53,7 @@ public class TopologicalGraph { ...@@ -44,7 +53,7 @@ public class TopologicalGraph {
} }
/** /**
* adds an Topological Node to this graph * Adds an Topological Node to this graph.
* *
* @param node the topological node to add * @param node the topological node to add
*/ */
...@@ -53,7 +62,7 @@ public class TopologicalGraph { ...@@ -53,7 +62,7 @@ public class TopologicalGraph {
} }
/** /**
* returns the number of nodes contained inside the topological-graph * Gets the number of nodes contained inside the topological-graph.
* *
* @return number of nodes * @return number of nodes
*/ */
...@@ -62,7 +71,7 @@ public class TopologicalGraph { ...@@ -62,7 +71,7 @@ public class TopologicalGraph {
} }
/** /**
* returns the number of links contained inside the topological-graph * Gets the number of links contained inside the topological-graph.
* *
* @return number of links * @return number of links
*/ */
...@@ -71,7 +80,7 @@ public class TopologicalGraph { ...@@ -71,7 +80,7 @@ public class TopologicalGraph {
} }
/** /**
* return an iterator through all network-graph links * Gets an iterator through all network-graph links.
* *
* @return the iterator throug all links * @return the iterator throug all links
*/ */
...@@ -80,7 +89,7 @@ public class TopologicalGraph { ...@@ -80,7 +89,7 @@ public class TopologicalGraph {
} }
/** /**
* returns an iterator through all network-graph nodes * Gets an iterator through all network-graph nodes.
* *
* @return the iterator through all nodes * @return the iterator through all nodes
*/ */
...@@ -88,9 +97,6 @@ public class TopologicalGraph { ...@@ -88,9 +97,6 @@ public class TopologicalGraph {
return nodeList.iterator(); return nodeList.iterator();
} }
/**
* prints out all internal node and link information
*/
@Override @Override
public String toString() { public String toString() {
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
package org.cloudbus.cloudsim.network; package org.cloudbus.cloudsim.network;
/** /**
* This class represents an link (edge) from an graph * This class represents an link (edge) from a network graph.
* *
* @author Thomas Hohnstein * @author Thomas Hohnstein
* @since CloudSim Toolkit 1.0 * @since CloudSim Toolkit 1.0
...@@ -17,24 +17,27 @@ package org.cloudbus.cloudsim.network; ...@@ -17,24 +17,27 @@ package org.cloudbus.cloudsim.network;
public class TopologicalLink { public class TopologicalLink {
/** /**
* id of the link src node-id * The BRITE id of the source node of the link.
*/ */
private int srcNodeID = 0; private int srcNodeID = 0;
/** /**
* id of the link dest node-id * The BRITE id of the destination node of the link.
*/ */
private int destNodeID = 0; private int destNodeID = 0;
/** /**
* representing the link-delay of the connection * The link delay of the connection.
*/ */
private float linkDelay = 0; private float linkDelay = 0;
/**
* The link bandwidth (bw).
*/
private float linkBw = 0; private float linkBw = 0;
/** /**
* creates an new link-object * Creates a new Topological Link.
*/ */
public TopologicalLink(int srcNode, int destNode, float delay, float bw) { public TopologicalLink(int srcNode, int destNode, float delay, float bw) {
// lets initialize all internal attributes // lets initialize all internal attributes
...@@ -45,7 +48,7 @@ public class TopologicalLink { ...@@ -45,7 +48,7 @@ public class TopologicalLink {
} }
/** /**
* returns the node-ID from the SrcNode * Gets the BRITE id of the source node of the link.
* *
* @return nodeID * @return nodeID
*/ */
...@@ -54,7 +57,7 @@ public class TopologicalLink { ...@@ -54,7 +57,7 @@ public class TopologicalLink {
} }
/** /**
* return the node-ID from the DestNode * Gets the BRITE id of the destination node of the link.
* *
* @return nodeID * @return nodeID
*/ */
...@@ -63,16 +66,16 @@ public class TopologicalLink { ...@@ -63,16 +66,16 @@ public class TopologicalLink {
} }
/** /**
* return the link-delay of the defined linke * Gets the delay of the link.
* *
* @return the delay-amount * @return the link delay
*/ */
public float getLinkDelay() { public float getLinkDelay() {
return linkDelay; return linkDelay;
} }
/** /**
* return the link-bw of the defined linke * Gets the bandwidth of the link.
* *
* @return the bw * @return the bw
*/ */
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
package org.cloudbus.cloudsim.network; package org.cloudbus.cloudsim.network;
/** /**
* Just represents an topological network node retrieves its information from an * Represents an topological network node that retrieves its information from a
* topological-generated file (eg. topology-generator) * topological-generated file (eg. topology-generator)
* *
* @author Thomas Hohnstein * @author Thomas Hohnstein
...@@ -17,88 +17,96 @@ package org.cloudbus.cloudsim.network; ...@@ -17,88 +17,96 @@ package org.cloudbus.cloudsim.network;
*/ */
public class TopologicalNode { public class TopologicalNode {
/** /**
* its the nodes-ID inside this network * The BRITE id of the node inside the network.
*/ */
private int nodeID = 0; private int nodeID = 0;
/** /**
* describes the nodes-name inside the network * The name of the node inside the network.
*/ */
private String nodeName = null; private String nodeName = null;
/** /**
* representing the x an y world-coordinates * Represents the x world-coordinate.
*/ */
private int worldX = 0; private int worldX = 0;
private int worldY = 0; /**
* Represents the y world-coordinate.
*/
private int worldY = 0;
/** /**
* constructs an new node * Constructs an new node.
*/ * @param nodeID The BRITE id of the node inside the network
public TopologicalNode(int nodeID) { */
// lets initialize all private class attributes public TopologicalNode(int nodeID) {
this.nodeID = nodeID; this.nodeID = nodeID;
nodeName = String.valueOf(nodeID); nodeName = String.valueOf(nodeID);
} }
/** /**
* constructs an new node including world-coordinates * Constructs an new node including world-coordinates.
*/ * @param nodeID The BRITE id of the node inside the network
public TopologicalNode(int nodeID, int x, int y) { * @param x x world-coordinate
// lets initialize all private class attributes * @param y y world-coordinate
this.nodeID = nodeID; */
nodeName = String.valueOf(nodeID); public TopologicalNode(int nodeID, int x, int y) {
worldX = x; this.nodeID = nodeID;
worldY = y; nodeName = String.valueOf(nodeID);
} worldX = x;
worldY = y;
}
/** /**
* constructs an new node including world-coordinates and the nodeName * Constructs an new node including world-coordinates and the nodeName.
*/ * @param nodeID The BRITE id of the node inside the network
public TopologicalNode(int nodeID, String nodeName, int x, int y) { * @param nodeName The name of the node inside the network
// lets initialize all private class attributes * @param x x world-coordinate
this.nodeID = nodeID; * @param y y world-coordinate
this.nodeName = nodeName; */
worldX = x; public TopologicalNode(int nodeID, String nodeName, int x, int y) {
worldY = y; this.nodeID = nodeID;
} this.nodeName = nodeName;
worldX = x;
worldY = y;
}
/** /**
* delivers the nodes id * Gets the node BRITE id.
* *
* @return just the nodeID * @return the nodeID
*/ */
public int getNodeID() { public int getNodeID() {
return nodeID; return nodeID;
} }
/** /**
* delivers the name of the node * Gets the name of the node
* *
* @return name of the node * @return name of the node
*/ */
public String getNodeLabel() { public String getNodeLabel() {
return nodeName; return nodeName;
} }
/** /**
* returns the x coordinate of this network-node * Gets the x world coordinate of this network-node.
* *
* @return the x coordinate * @return the x world coordinate
*/ */
public int getCoordinateX() { public int getCoordinateX() {
return worldX; return worldX;
} }
/** /**
* returns the y coordinate of this network-node * Gets the y world coordinate of this network-node
* *
* @return the y coordinate * @return the y world coordinate
*/ */
public int getCoordinateY() { public int getCoordinateY() {
return worldY; return worldY;
} }
} }
...@@ -31,13 +31,20 @@ import org.cloudbus.cloudsim.lists.VmList; ...@@ -31,13 +31,20 @@ import org.cloudbus.cloudsim.lists.VmList;
* *
* @author Anton Beloglazov * @author Anton Beloglazov
* @since CloudSim Toolkit 2.0 * @since CloudSim Toolkit 2.0
* @todo It is a list, so it would be better inside the org.cloudbus.cloudsim.lists package.
* This class in fact doesn't use a list or PowerVm, but a list of Vm.
* The used methods are just of the Vm class, thus doesn't have
* a reason to create another class. This classes don't either stores lists of VM,
* they only perform operations on lists given by parameter.
* So, the method of this class would be moved to the VmList class
* and the class erased.
*/ */
public class PowerVmList extends VmList { public class PowerVmList extends VmList {
/** /**
* Sort by cpu utilization. * Sort a given list of VMs by cpu utilization.
* *
* @param vmList the vm list * @param vmList the vm list to be sorted
*/ */
public static <T extends Vm> void sortByCpuUtilization(List<T> vmList) { public static <T extends Vm> void sortByCpuUtilization(List<T> vmList) {
Collections.sort(vmList, new Comparator<T>() { Collections.sort(vmList, new Comparator<T>() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment