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;
* A private default constructor would be created to avoid instantiation.
*/
public class NetworkTopology {
/**
* The BRITE id to use for the next node to be created in the network.
*/
protected static int nextIdx = 0;
private static boolean networkEnabled = false;
/**
* A matrix containing the delay between every pair of nodes in the network.
*/
protected static DelayMatrix_Float delayMatrix = null;
/**
......@@ -52,6 +57,9 @@ public class NetworkTopology {
*/
protected static double[][] bwMatrix = null;
/**
* The Topological Graph of the network.
*/
protected static TopologicalGraph graph = null;
/**
......@@ -103,7 +111,7 @@ public class NetworkTopology {
/**
* Adds a new link in the network topology.
* 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 destId ID of the CloudSim entity that represents the link's destination node
......@@ -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 destID ID of the CloudSim entity that represents the link's destination node
......@@ -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
* 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
* @post $none
*/
......
......@@ -11,7 +11,8 @@ package org.cloudbus.cloudsim.network;
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
* @since CloudSim Toolkit 1.0
......@@ -19,27 +20,27 @@ import java.util.Iterator;
public class DelayMatrix_Float {
/**
* matrix holding delay information between any two nodes
* Matrix holding delay information between any two nodes.
*/
protected float[][] mDelayMatrix = null;
/**
* number of nodes in the distance-aware-topology
* Number of nodes in the distance-aware-topology.
*/
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")
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 directed true if an directed matrix should be computed, false otherwise
* @param graph the network topological graph
* @param directed indicates if an directed matrix should be computed (true) or not (false)
*/
public DelayMatrix_Float(TopologicalGraph graph, boolean directed) {
......@@ -51,9 +52,11 @@ public class DelayMatrix_Float {
}
/**
* @param srcID the id of the source-node
* @param destID the id of the destination-node
* @return the delay-count between the given two nodes
* Gets the delay between 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) {
// check the nodeIDs against internal array-boundarys
......@@ -65,12 +68,12 @@ public class DelayMatrix_Float {
}
/**
* creates all internal necessary network-distance structures from the given graph for
* similarity we assume all kommunikation-distances are symmetrical thus leads to an undirected
* network
* Creates all internal necessary network-distance structures from the given graph.
* For similarity, we assume all communication-distances are symmetrical,
* thus leading to an undirected network.
*
* @param graph this graph contains all node and link information
* @param directed defines to preinitialize an directed or undirected Delay-Matrix!
* @param graph the network topological graph
* @param directed indicates if an directed matrix should be computed (true) or not (false)
*/
private void createDelayMatrix(TopologicalGraph graph, boolean directed) {
......@@ -95,7 +98,7 @@ public class DelayMatrix_Float {
mDelayMatrix[edge.getSrcNodeID()][edge.getDestNodeID()] = edge.getLinkDelay();
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();
}
......@@ -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() {
FloydWarshall_Float floyd = new FloydWarshall_Float();
......@@ -112,10 +115,6 @@ public class DelayMatrix_Float {
mDelayMatrix = floyd.allPairsShortestPaths(mDelayMatrix);
}
/**
* this method just creates an string-output from the internal structures... eg. printsout the
* delay-matrix...
*/
@Override
public String toString() {
StringBuffer buffer = new StringBuffer();
......
......@@ -9,7 +9,8 @@
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 Weishuai Yang
......@@ -19,32 +20,30 @@ package org.cloudbus.cloudsim.network;
public class FloydWarshall_Float {
/**
* Number of vertices (when initialized)
* Number of vertices (nodes).
*/
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;
/**
* 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
* @todo The class doesn't have a constructor. This should be the constructor.
*/
public void initialize(int numVertices) {
this.numVertices = numVertices;
......@@ -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
* @return all pairs delay matrix
* @return the delay matrix
*/
public float[][] allPairsShortestPaths(float[][] adjMatrix) {
// Dk_minus_one = weights when k = -1
......@@ -128,66 +127,11 @@ public class FloydWarshall_Float {
}
/**
* gets predecessor matrix
* Gets predecessor matrix.
*
* @return predecessor matrix
*/
public int[][] getPK() {
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;
import java.util.StringTokenizer;
/**
* This class is just an file-reader for the special brite-format! the brite-file is structured as
* followed: Node-section: NodeID, xpos, ypos, indegree, outdegree, ASid, type(router/AS)
* Edge-section: EdgeID, fromNode, toNode, euclideanLength, linkDelay, linkBandwith, AS_from, AS_to,
* A file reader for the special BRITE-format. A BRITE file is structured as
* follows:<br/>
* <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
* </ul>
*
* @author Thomas Hohnstein
* @since CloudSim Toolkit 1.0
......@@ -32,15 +35,11 @@ public class GraphReaderBrite implements GraphReaderIF {
private int state = PARSE_NOTHING;
/**
* The network Topological Graph.
*/
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
public TopologicalGraph readGraphFile(String filename) throws IOException {
......@@ -92,8 +91,12 @@ public class GraphReaderBrite implements GraphReaderIF {
return graph;
}
/**
* Parses nodes inside a line from the BRITE file.
*
* @param nodeLine A line read from the file
*/
private void parseNodeString(String nodeLine) {
StringTokenizer tokenizer = new StringTokenizer(nodeLine);
// number of node parameters to parse (counts at linestart)
......@@ -144,8 +147,13 @@ public class GraphReaderBrite implements GraphReaderIF {
TopologicalNode topoNode = new TopologicalNode(nodeID, nodeLabel, xPos, yPos);
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) {
StringTokenizer tokenizer = new StringTokenizer(nodeLine);
......
......@@ -11,7 +11,7 @@ package org.cloudbus.cloudsim.network;
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
* @since CloudSim Toolkit 1.0
......@@ -19,11 +19,11 @@ import java.io.IOException;
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
* @return created TopologicalGraph
* @throws IOException
* @param filename Name of the file to read
* @return The created TopologicalGraph
* @throws IOException when the file cannot be accessed
*/
TopologicalGraph readGraphFile(String filename) throws IOException;
......
......@@ -13,21 +13,30 @@ import java.util.LinkedList;
import java.util.List;
/**
* This class represents an graph containing nodes and edges, used for input with an network-layer
* Graphical-Output Restricions! EdgeColors: GraphicalProperties.getColorEdge NodeColors:
* GraphicalProperties.getColorNode
* This class represents a graph containing vertices (nodes) and edges (links),
* used for input with a network-layer.
* Graphical-Output Restricions! <br/>
* <ul>
* <li>EdgeColors: GraphicalProperties.getColorEdge
* <li>NodeColors: GraphicalProperties.getColorNode
* </ul>
*
* @author Thomas Hohnstein
* @since CloudSim Toolkit 1.0
*/
public class TopologicalGraph {
/**
* The list of links of the network graph.
*/
private List<TopologicalLink> linkList = null;
/**
* The list of nodes of the network graph.
*/
private List<TopologicalNode> nodeList = null;
/**
* just the constructor to create an empty graph-object
* Creates an empty graph-object.
*/
public TopologicalGraph() {
linkList = new LinkedList<TopologicalLink>();
......@@ -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
*/
......@@ -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
*/
......@@ -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
*/
......@@ -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
*/
......@@ -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
*/
......@@ -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
*/
......@@ -88,9 +97,6 @@ public class TopologicalGraph {
return nodeList.iterator();
}
/**
* prints out all internal node and link information
*/
@Override
public String toString() {
StringBuffer buffer = new StringBuffer();
......
......@@ -9,7 +9,7 @@
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
* @since CloudSim Toolkit 1.0
......@@ -17,24 +17,27 @@ package org.cloudbus.cloudsim.network;
public class TopologicalLink {
/**
* id of the link src node-id
* The BRITE id of the source node of the link.
*/
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;
/**
* representing the link-delay of the connection
* The link delay of the connection.
*/
private float linkDelay = 0;
/**
* The link bandwidth (bw).
*/
private float linkBw = 0;
/**
* creates an new link-object
* Creates a new Topological Link.
*/
public TopologicalLink(int srcNode, int destNode, float delay, float bw) {
// lets initialize all internal attributes
......@@ -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
*/
......@@ -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
*/
......@@ -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() {
return linkDelay;
}
/**
* return the link-bw of the defined linke
* Gets the bandwidth of the link.
*
* @return the bw
*/
......
......@@ -9,7 +9,7 @@
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)
*
* @author Thomas Hohnstein
......@@ -17,88 +17,96 @@ package org.cloudbus.cloudsim.network;
*/
public class TopologicalNode {
/**
* its the nodes-ID inside this network
*/
private int nodeID = 0;
/**
* The BRITE id of the node inside the network.
*/
private int nodeID = 0;
/**
* describes the nodes-name inside the network
*/
private String nodeName = null;
/**
* The name of the node inside the network.
*/
private String nodeName = null;
/**
* representing the x an y world-coordinates
*/
private int worldX = 0;
/**
* Represents the x world-coordinate.
*/
private int worldX = 0;
private int worldY = 0;
/**
* Represents the y world-coordinate.
*/
private int worldY = 0;
/**
* constructs an new node
*/
public TopologicalNode(int nodeID) {
// lets initialize all private class attributes
this.nodeID = nodeID;
nodeName = String.valueOf(nodeID);
}
/**
* Constructs an new node.
* @param nodeID The BRITE id of the node inside the network
*/
public TopologicalNode(int nodeID) {
this.nodeID = nodeID;
nodeName = String.valueOf(nodeID);
}
/**
* constructs an new node including world-coordinates
*/
public TopologicalNode(int nodeID, int x, int y) {
// lets initialize all private class attributes
this.nodeID = nodeID;
nodeName = String.valueOf(nodeID);
worldX = x;
worldY = y;
}
/**
* Constructs an new node including world-coordinates.
* @param nodeID The BRITE id of the node inside the network
* @param x x world-coordinate
* @param y y world-coordinate
*/
public TopologicalNode(int nodeID, int x, int y) {
this.nodeID = nodeID;
nodeName = String.valueOf(nodeID);
worldX = x;
worldY = y;
}
/**
* constructs an new node including world-coordinates and the nodeName
*/
public TopologicalNode(int nodeID, String nodeName, int x, int y) {
// lets initialize all private class attributes
this.nodeID = nodeID;
this.nodeName = nodeName;
worldX = x;
worldY = y;
}
/**
* Constructs an new node including world-coordinates and the nodeName.
* @param nodeID The BRITE id of the node inside the network
* @param nodeName The name of the node inside the network
* @param x x world-coordinate
* @param y y world-coordinate
*/
public TopologicalNode(int nodeID, String nodeName, int x, int y) {
this.nodeID = nodeID;
this.nodeName = nodeName;
worldX = x;
worldY = y;
}
/**
* delivers the nodes id
*
* @return just the nodeID
*/
public int getNodeID() {
return nodeID;
}
/**
* Gets the node BRITE id.
*
* @return the nodeID
*/
public int getNodeID() {
return nodeID;
}
/**
* delivers the name of the node
*
* @return name of the node
*/
public String getNodeLabel() {
return nodeName;
}
/**
* Gets the name of the node
*
* @return name of the node
*/
public String getNodeLabel() {
return nodeName;
}
/**
* returns the x coordinate of this network-node
*
* @return the x coordinate
*/
public int getCoordinateX() {
return worldX;
}
/**
* Gets the x world coordinate of this network-node.
*
* @return the x world coordinate
*/
public int getCoordinateX() {
return worldX;
}
/**
* returns the y coordinate of this network-node
*
* @return the y coordinate
*/
public int getCoordinateY() {
return worldY;
}
/**
* Gets the y world coordinate of this network-node
*
* @return the y world coordinate
*/
public int getCoordinateY() {
return worldY;
}
}
......@@ -31,13 +31,20 @@ import org.cloudbus.cloudsim.lists.VmList;
*
* @author Anton Beloglazov
* @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 {
/**
* 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) {
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