From: <sul...@us...> - 2008-09-23 11:10:47
|
Revision: 245 http://gridsim.svn.sourceforge.net/gridsim/?rev=245&view=rev Author: sulistio Date: 2008-09-23 11:10:43 +0000 (Tue, 23 Sep 2008) Log Message: ----------- finish javadoc comments. In addition, modify few things inside this class. Modified Paths: -------------- trunk/source/gridsim/net/fnb/FnbMessage.java trunk/source/gridsim/net/fnb/FnbMessageDropFile.java trunk/source/gridsim/net/fnb/FnbMessageDropGridlet.java trunk/source/gridsim/net/fnb/FnbWhiteList.java trunk/source/gridsim/net/fnb/firstLastPacketsGridlet.java trunk/source/gridsim/net/fnb/source_pktNum.java Modified: trunk/source/gridsim/net/fnb/FnbMessage.java =================================================================== --- trunk/source/gridsim/net/fnb/FnbMessage.java 2008-09-23 11:09:18 UTC (rev 244) +++ trunk/source/gridsim/net/fnb/FnbMessage.java 2008-09-23 11:10:43 UTC (rev 245) @@ -13,14 +13,29 @@ package gridsim.net.fnb; /** - * + * This class provides a template for sending a message due to a packet + * being dropped in the network. * @author Agustin Caminero * @since GridSim Toolkit 4.2 + * @see gridsim.net.fnb.FnbMessageDropGridlet + * @see gridsim.net.fnb.FnbMessageDropFile */ public interface FnbMessage { - public void setEntityID(int i); + /** + * Sets an entity ID that is being dropped in the network. <br> + * NOTE: the type of an entity depends on its subclasses. + * An entity could represents a Gridlet or a File. + * @param id an entity id + * @see gridsim.net.fnb.FnbMessageDropGridlet#setEntityID(int) + * @see gridsim.net.fnb.FnbMessageDropFile#setEntityID(int) + */ + public void setEntityID(int id); + /** + * Gets an entity ID of this class. + * @return an entity ID + */ public int getEntityID(); +} -} Modified: trunk/source/gridsim/net/fnb/FnbMessageDropFile.java =================================================================== --- trunk/source/gridsim/net/fnb/FnbMessageDropFile.java 2008-09-23 11:09:18 UTC (rev 244) +++ trunk/source/gridsim/net/fnb/FnbMessageDropFile.java 2008-09-23 11:10:43 UTC (rev 245) @@ -12,44 +12,66 @@ package gridsim.net.fnb; -import gridsim.net.fnb.*; +import gridsim.net.fnb.FnbMessage; /** - * + * This class contains a file ID and its name, that is currently being + * dropped in the network. + * This class is primarily used by the {@link gridsim.net.fnb.FnbOutput} class. * @author Agustin Caminero * @since GridSim Toolkit 4.2 + * @see gridsim.net.fnb.FnbOutput */ public class FnbMessageDropFile implements FnbMessage { - int fileID; - String filename; + private int fileID_; + private String filename_; - public FnbMessageDropFile(int e, String f) + /** + * A constructor + * @param fileID a file ID + * @param filename a filename + */ + public FnbMessageDropFile(int fileID, String filename) { - fileID = e; - filename = f; + fileID_ = fileID; + filename_ = filename; } - public void setEntityID(int i) + /** + * Sets a file ID that is being dropped in the network. + * @param fileID a file ID + */ + public void setEntityID(int fileID) { - fileID = i; + fileID_ = fileID; } - + /** + * Gets a file ID + * @return a file ID + */ public int getEntityID() { - return fileID; + return fileID_; } - public void setFilename(String f) + /** + * Sets a filename that is being dropped in the network. + * @param filename a filename + */ + public void setFilename(String filename) { - filename = f; + filename_ = filename; } + /** + * Gets a filename + * @return a filename + */ public String getFilename() { - return filename; + return filename_; } - - + } Modified: trunk/source/gridsim/net/fnb/FnbMessageDropGridlet.java =================================================================== --- trunk/source/gridsim/net/fnb/FnbMessageDropGridlet.java 2008-09-23 11:09:18 UTC (rev 244) +++ trunk/source/gridsim/net/fnb/FnbMessageDropGridlet.java 2008-09-23 11:10:43 UTC (rev 245) @@ -12,32 +12,45 @@ package gridsim.net.fnb; -import gridsim.net.fnb.*; +import gridsim.net.fnb.FnbMessage; /** - * + * This class contains a Gridlet ID, that is currently being + * dropped in the network. + * This class is primarily used by the {@link gridsim.net.fnb.FnbOutput} class. * @author Agustin Caminero * @since GridSim Toolkit 4.2 + * @see gridsim.net.fnb.FnbOutput */ public class FnbMessageDropGridlet implements FnbMessage { - int gridletID; + private int gridletID_; - public FnbMessageDropGridlet (int e) + /** + * A constructor + * @param gridletID a gridlet ID + */ + public FnbMessageDropGridlet (int gridletID) { - gridletID = e; + gridletID_ = gridletID; } - public void setEntityID(int i) + /** + * Sets a gridlet ID that is being dropped in the network. + * @param gridletID a gridlet ID + */ + public void setEntityID(int gridletID) { - gridletID = i; + gridletID_ = gridletID; } - + /** + * Gets a gridlet ID + * @return a gridlet ID + */ public int getEntityID() { - return gridletID; + return gridletID_; } - } Modified: trunk/source/gridsim/net/fnb/FnbWhiteList.java =================================================================== --- trunk/source/gridsim/net/fnb/FnbWhiteList.java 2008-09-23 11:09:18 UTC (rev 244) +++ trunk/source/gridsim/net/fnb/FnbWhiteList.java 2008-09-23 11:10:43 UTC (rev 245) @@ -13,108 +13,132 @@ package gridsim.net.fnb; import java.util.*; -import gridsim.*; +import gridsim.GridSim; + /** - * + * This class stores a (white) list of entity IDs, such that their messages + * are guaranteed not to be dropped in the network. * @author Agustin Caminero * @since GridSim Toolkit 4.2 */ -public class FnbWhiteList +public class FnbWhiteList extends ArrayList { - private ArrayList list_; + /** + * Creates a new object of this class. + */ public FnbWhiteList() { - list_ = new ArrayList(); + super(); } + + /** + * Creates a new object of this class with the specified initial capacity. + * @param initialCapacity the initial capacity of the list + */ + public FnbWhiteList(int initialCapacity) + { + super(initialCapacity); + } - - /**Returns true if the given id is in the list. - * @param id the id of an entity - * @return true if the given id is in the list. - * */ + /** + * Returns <tt>true</tt> if the given id is in the white list. + * @param id an entity id + * @return <tt>true</tt> if the given id is in the white list, + * <tt>false</tt> otherwise. + */ public boolean checkList(int id) { - int id_tmp; - for (int i =0; i<list_.size(); i++) + for (int i = 0; i < super.size(); i++) { - id_tmp = ((Integer)list_.get(i)).intValue(); - + id_tmp = ((Integer) super.get(i)).intValue(); if (id == id_tmp) { - //System.out.println("----- checking : " + GridSim.getEntityName(id) + " TRUE"); + //System.out.println("----- checking : " + + // GridSim.getEntityName(id) + " TRUE"); return true; } } - //System.out.println("----- checking : " + GridSim.getEntityName(id) + " FALSE"); + //System.out.println("----- checking : " + GridSim.getEntityName(id) + // + " FALSE"); return false; - } - - + /** + * Adds this entity ID to the white list. + * Note that this method also adds the IDs of {@link gridsim.net.Input} and + * {@link gridsim.net.Output} ports associated with this entity ID. + * @param id an entity ID + * @return <tt>true</tt> if the entity ID has been added to the white list, + * <tt>false</tt> otherwise. + * @see gridsim.net.Input + * @see gridsim.net.Output + */ public boolean addEntityID(Integer id) { - // We must add not only the entity id, but also the ids of the input/output ports. - - if ( (id == null) || (id.intValue() <= 0) ) + if ( (id == null) || (id.intValue() <= 0) ) { return false; - - if (checkList(id.intValue()) == true) + } + + // check if already exist in the list + if (checkList(id.intValue()) == true) { return false; - + } + String name = GridSim.getEntityName(id); - String input = "Input_" + name; String output = "Output_" + name; int input_id = GridSim.getEntityId(input); int output_id = GridSim.getEntityId(output); - list_.add(id); - list_.add(new Integer(input_id)); - list_.add(new Integer(output_id)); + super.add(id); + super.add(new Integer(input_id)); + super.add(new Integer(output_id)); return true; } - - + /** + * Adds this entity ID to the white list. + * Note that this method also adds the IDs of {@link gridsim.net.Input} and + * {@link gridsim.net.Output} ports associated with this entity ID. + * @param id an entity ID + * @return <tt>true</tt> if the entity ID has been added to the white list, + * <tt>false</tt> otherwise. + * @see gridsim.net.Input + * @see gridsim.net.Output + */ public boolean addEntityID(int id) { - return addEntityID(new Integer (id)); + return addEntityID(new Integer(id)); } - /**Removes the given id of the list. - * @param id the id of an entity, to be removed from the list - * @return true if the entity is removed properly, false otherwise*/ - public boolean removeID(int id) - { - int id_tmp; - for (int i =0; i<list_.size(); i++) - { - id_tmp = ((Integer)list_.get(i)).intValue(); + /** + * Removes the given entity id from the white list. + * @param id the entity id to be removed from the white list + * @return <tt>true</tt> if the entity has been removed successfully, + * <tt>false</tt> otherwise. + */ + public boolean removeID(int id) + { + boolean flag = false; + int id_tmp; + for (int i = 0; i < super.size(); i++) + { + id_tmp = ((Integer) super.get(i)).intValue(); + if (id == id_tmp) + { + super.remove(i); + flag = true; + break; + } + } - if (id == id_tmp) - list_.remove(i); + return flag; + } - } - - return false; - - } - - public int size() - { - return list_.size(); - } - - public Integer get(int i) - { - return (Integer) list_.get(i); - } - } Modified: trunk/source/gridsim/net/fnb/firstLastPacketsGridlet.java =================================================================== --- trunk/source/gridsim/net/fnb/firstLastPacketsGridlet.java 2008-09-23 11:09:18 UTC (rev 244) +++ trunk/source/gridsim/net/fnb/firstLastPacketsGridlet.java 2008-09-23 11:10:43 UTC (rev 245) @@ -4,7 +4,7 @@ * of Parallel and Distributed Systems such as Clusters and Grids * Licence: GPL - http://www.gnu.org/copyleft/gpl.html * - * Author: Agustin Caminero + * Author: Agustin Caminero and Anthony Sulistio * Organization: Universidad de Castilla La Mancha (UCLM), Spain. * Copyright (c) 2008, The University of Melbourne, Australia and * Universidad de Castilla La Mancha (UCLM), Spain @@ -13,62 +13,59 @@ package gridsim.net.fnb; /** - * This class is used to keep the number of packets each gridlet is made of. - * This is neccesary when using finite buffers in routers, as when a packet is dropped, - * we have to know which gridlet each dropped packet belonged to. - * + * This class contains relevant information of a dropped + * {@link gridsim.Gridlet} or {@link gridsim.datagrid.File} object. + * Since a gridlet or a file is broken into many packets according to the + * Maximum Transmission Unit (MTU), this class records the first packet ID, + * the last packet ID, and the Gridlet or File ID. + * This class is mainly used by the {@link gridsim.net.fnb.FnbInput} and + * {@link gridsim.net.fnb.FnbOutput} classes. + * <p> * For example, a gridlet with id = 3 is made of 20 packets, e.g. from * packet id 2 to 21. Then, this class stores the following information: - * the first packet number is 2, the last packet number is 21, and - * the gridlet ID is 3. + * the first packet number is 2, the last packet number is 21, + * the ID is 3, and {@link #isFile()} returns <tt>false</tt>. * - * @author Agustin Caminero + * @author Agustin Caminero and Anthony Sulistio * @since GridSim Toolkit 4.2 + * @see gridsim.net.Link#DEFAULT_MTU + * @see gridsim.Gridlet + * @see gridsim.datagrid.File */ public class firstLastPacketsGridlet { - int firstPacket; // the id of the first packet in a gridlet - int lastPacket; // the id of the last packet in a gridlet - int gridletID; // the gridlet/file id + private int firstPacket; // the id of the first packet in a gridlet + private int lastPacket; // the id of the last packet in a gridlet + private int id_; // the gridlet or file id + private boolean isFile; // whether this class contains a gridlet or a file - boolean isFile; - - /**Creates a new object of this class. This is used in the FnbInput and FnbOutput classes. - * @param first id of the first packet - * @param last id of the last packet - * @param gl the gridlet id - * */ - public void firstLastPacketsGridlet(int first, int last, int gl) + /** + * Creates a new object of this class. + * @param firstPacketID the first packet id + * @param lastPacketID the last packet id + */ + public void firstLastPacketsGridlet(int firstPacketID, int lastPacketID) { - firstPacket = first; - lastPacket = last; - gridletID = gl; - isFile = false; + this.firstPacket = firstPacketID; + this.lastPacket = lastPacketID; + this.id_ = -1; + this.isFile = false; } - - - /** Sets the isFile. - * @param f if this is a file or not + /** + * Determines whether this class stores a file ID or a gridlet ID + * @return <tt>true</tt> this class stores a file ID, <tt>false</tt> otherwise * */ - public void setIsFile(boolean f) + public boolean isFile() { - isFile = f; - } - - /** Gets the isFile. - * @return true is this is a file - * */ - public boolean getIsFile() - { return isFile; } /** Gets the id of the first packet. * @return the id of the first packet * */ - public int getFirst() + public int getFirstPacketID() { return firstPacket; } @@ -76,42 +73,54 @@ /** Gets the id of the last packet. * @return the id of the last packet * */ - public int getLast() + public int getLastPacketID() { return lastPacket; - } + } - - /** Gets the gridlet id - * @return the gridlet id - * */ - public int getGridletID() - { - return gridletID; - } - /** Sets the id of the last packet. - * @param last the id of the last packet. + * @param lastID the id of the last packet. * */ - public void setLast(int last) + public void setLastPacketID(int lastID) { - lastPacket = last; + lastPacket = lastID; } /** Sets the id of the first packet. - * @param first the id of the first packet. + * @param firstID the id of the first packet. * */ - public void setFirst(int first) + public void setFirstPacketID(int firstID) { - firstPacket = first; + firstPacket = firstID; } - /** Sets the id of gridlet. - * @param gl the id of the gridlet + /** Sets the gridlet id. + * @param gridletID the gridlet id * */ - public void setGridletID(int gl) + public void setGridletID(int gridletID) { - gridletID = gl; + id_ = gridletID; + isFile = false; } + + /** Sets the file id. + * @param fileID the file id + */ + public void setFileID(int fileID) + { + id_ = fileID; + this.isFile = true; + } + + /** + * Gets a file or gridlet ID.<br> + * NOTE: If {@link #isFile()} denotes <tt>true</tt>, then it is a file ID, + * <tt>false</tt> otherwise + * @return a file or gridlet ID. + */ + public int getID() + { + return id_; + } } Modified: trunk/source/gridsim/net/fnb/source_pktNum.java =================================================================== --- trunk/source/gridsim/net/fnb/source_pktNum.java 2008-09-23 11:09:18 UTC (rev 244) +++ trunk/source/gridsim/net/fnb/source_pktNum.java 2008-09-23 11:10:43 UTC (rev 245) @@ -12,98 +12,109 @@ package gridsim.net.fnb; -/**This class is used in the FnbInput class, to make sure that - * all the packets of a gridlet arrive at the user/resource. +/** + * This class is used by the {@link gridsim.net.fnb.FnbInput} entity, + * to make sure that all Gridlet packets arrive at the destination. * @author Agustin Caminero * @since GridSim Toolkit 4.2 + * @see gridsim.net.fnb.FnbInput */ - public class source_pktNum { - int source; - int numOfPkts; // how many pkts have arrived yet - int glID; // the id of the gridslet this pkt belongs to - boolean ok; // tells if the current gridlet is fine or not + private int source; + private int numOfPkts; // how many pkts have arrived yet + private int glID; // the id of the gridslet this pkt belongs to + private boolean ok; // tells if the current gridlet is fine or not - /**Creates an object of this class. - * @param s the source - * @param g the gridlet this pkt belongs to - * */ - public source_pktNum(int s, int g) + + /** + * Creates an object of this class. + * @param sourceID the source ID + * @param gridletID the gridlet ID that this packet belongs to + */ + public source_pktNum(int sourceID, int gridletID) { - source = s; + source = sourceID; numOfPkts = 0; - glID = g; + glID = gridletID; ok = false; } - /** Gets the source of the gridlet - * @return source of the gridlet */ - public int getSource() + /** + * Gets the source ID of the gridlet + * @return source ID of the gridlet + */ + public int getSourceID() { return source; } - /** Gets the number of packets already received - * @return number of packets already received */ - public int getNumOfPkts() + /** + * Gets the number of packets already received + * @return number of packets already received + */ + public int getNumOfPacket() { return numOfPkts; } - /** Gets the if the gridlet is ok or not, up to now - * @return true if all the packets of a gridlet have already arrived properly. False otherwise */ - public boolean getOk() + /** + * Checks if the gridlet packets have arrived properly or not. + * @return <tt>true</tt> if all the packets of a gridlet have + * arrived properly, <tt>false</tt> otherwise. + */ + public boolean getStatus() { return ok; } - /**Sets the source parameter - * @param s the source of a gridlet - * */ - public void setSource(int s) + /** Sets the source ID + * @param sourceID the source ID of this gridlet + */ + public void setSourceID(int sourceID) { - source = s; + source = sourceID; } - - /**Sets the ok parameter - * @param o the new ok parameter - * */ - public void setOk(boolean o) + /** Sets the status of the incoming gridlet packets. + * @param status <tt>true</tt> if all the packets of a gridlet have + * arrived properly, <tt>false</tt> otherwise. + */ + public void setStatus(boolean status) { - ok = o; + this.ok = status; } - /**Sets the number of packets - * @param n the number of packets of a gridlet - * */ - public void setNumOfPkts(int n) + /** Sets the number of packets + * @param num the number of packets of a gridlet + */ + public void setNumOfPacket(int num) { - numOfPkts = n; + numOfPkts = num; } - /**Sets the gridlet id - * @param g gridlet id - * */ - public void setGlID(int g) + /** Sets the gridlet id + * @param gridletID gridlet id + */ + public void setGridletID(int gridletID) { - glID = g; + glID = gridletID; } /** Gets the gridlet id - * @return gridlet id */ - public int getGlID() + * @return gridlet id + */ + public int getGridletID() { return glID; } - /**Increases the number of received packets - * */ - public void increaseNumOfArrivedPkts() + /** Adds the number of received packets by 1. */ + public void addNumOfArrivedPkts() { - numOfPkts = numOfPkts +1; + numOfPkts++; } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |